<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alex Taylor</title>
    <description>The latest articles on DEV Community by Alex Taylor (@mctaylorpants).</description>
    <link>https://dev.to/mctaylorpants</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F31200%2Fe98f8abd-cba5-45d0-9562-3a76859cc4cc.jpg</url>
      <title>DEV Community: Alex Taylor</title>
      <link>https://dev.to/mctaylorpants</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mctaylorpants"/>
    <language>en</language>
    <item>
      <title>A Weird and Wonderful Trip through Ruby’s Standard Library</title>
      <dc:creator>Alex Taylor</dc:creator>
      <pubDate>Sat, 15 Dec 2018 07:12:08 +0000</pubDate>
      <link>https://dev.to/mctaylorpants/a-weird-and-wonderful-trip-through-rubys-standard-library-2ko1</link>
      <guid>https://dev.to/mctaylorpants/a-weird-and-wonderful-trip-through-rubys-standard-library-2ko1</guid>
      <description>&lt;p&gt;&lt;em&gt;&lt;a href="https://medium.com/@mctaylorpants/a-weird-and-wonderful-trip-through-rubys-standard-library-762ddcf7a908" rel="noopener noreferrer"&gt;Originally posted on Medium&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fhokc6yihnholomf4jirr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fhokc6yihnholomf4jirr.png" alt="keep ruby's standard library weird"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You've probably heard the news by now - &lt;a href="http://engineering.appfolio.com/appfolio-engineering/2018/11/26/bundler-is-built-into-ruby-260preview3" rel="noopener noreferrer"&gt;Bundler is getting merged into Ruby core&lt;/a&gt;! It's great to see that projects like Bundler, which have become so central to the Ruby experience, are becoming part of Ruby in a deep way.&lt;/p&gt;

&lt;p&gt;It also got me thinking: what else is in there? I use Ruby primarily for writing web applications, but Ruby's rich history as a scripting language means that there's lots of functionality I don't use every day, and probably lots that I don't even know existed.&lt;/p&gt;

&lt;p&gt;So, I decided to find out. I spent some time looking through the &lt;a href="https://ruby-doc.org/stdlib-2.5.3/" rel="noopener noreferrer"&gt;standard library documentation&lt;/a&gt;, keeping my eyes peeled for things I didn't recognize. I found some pretty weird and wonderful things, and I wanted to share some of my favourites.&lt;/p&gt;

&lt;p&gt;Ready for some contrived examples? Let's go!&lt;/p&gt;

&lt;h1&gt;
  
  
  Shellwords
&lt;/h1&gt;

&lt;p&gt;First up: the Shellwords module. It provides a few nice methods which make it easier to build and parse shell commands from within Ruby.&lt;/p&gt;

&lt;p&gt;For example: let's say you have a filename with an apostrophe in it, and you want to use cat to get the contents of the file. (I did say these were contrived, didn't I? 😉)&lt;/p&gt;

&lt;p&gt;You could do something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="vg"&gt;$&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;filename&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Alex's Notes.txt"&lt;/span&gt;
&lt;span class="vg"&gt;$&amp;gt;&lt;/span&gt; &lt;span class="sb"&gt;`cat &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But bash doesn't like unescaped single quotes, so you end up with an error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sh: -c: line 0: unexpected EOF while looking for matching `''
sh: -c: line 1: syntax error: unexpected end of file
=&amp;gt; ""
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Never fear! #shellescape is here!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="vg"&gt;$&amp;gt;&lt;/span&gt; &lt;span class="sb"&gt;`cat &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;filename&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;shellescape&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sb"&gt;`&lt;/span&gt;
&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"Apostrophes in a filename? 🤔"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hurray, your problem is solved! Although you might want to have a chat with whoever put that apostrophe there in the first place...&lt;/p&gt;

&lt;h1&gt;
  
  
  English: for when you want less $$
&lt;/h1&gt;

&lt;p&gt;Pop quiz: what does &lt;code&gt;$$&lt;/code&gt; return?&lt;/p&gt;

&lt;p&gt;If your answer is "why, the current process ID, of course!", then I suppose you can skip this section.&lt;/p&gt;

&lt;p&gt;For the rest of us, Ruby's &lt;code&gt;$$&lt;/code&gt; is an homage to Perl, and returns the ID of the current system process. But it's not the most developer-friendly of names, so Ruby's English module provides some helpful aliases: &lt;code&gt;$PROCESS_ID&lt;/code&gt; and &lt;code&gt;$PID&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This is a pretty small thing, but I think it's a perfect example of Matz's original goal with Ruby, which was to create a language that's understood by humans first and computers second.&lt;/p&gt;

&lt;p&gt;English provides a handful of these aliases. Another useful one is &lt;code&gt;$CHILD_STATUS&lt;/code&gt;, which will return the exit code of the last shell command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="vg"&gt;$&amp;gt;&lt;/span&gt; &lt;span class="sb"&gt;`exit 42`&lt;/span&gt;
&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;

&lt;span class="vg"&gt;$&amp;gt;&lt;/span&gt; &lt;span class="vg"&gt;$CHILD_STATUS&lt;/span&gt;   &lt;span class="c1"&gt;# or $? for the purists&lt;/span&gt;
&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="c1"&gt;#&amp;lt;Process::Status: pid 25566 exit 42&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Prime
&lt;/h1&gt;

&lt;p&gt;If you require the Prime module, Ruby can tell you if a number is prime:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="vg"&gt;$&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;prime?&lt;/span&gt;
&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ok, cool.&lt;/p&gt;

&lt;p&gt;But did you know that Ruby has not one, not two, but two-and-a-half* implementations for determining the primality of a number?&lt;/p&gt;

&lt;p&gt;First up, there's &lt;code&gt;TrialDivision&lt;/code&gt;, a brute-force approach which divides the number in question by other smaller numbers until it has a definitive answer.&lt;/p&gt;

&lt;p&gt;There's also &lt;code&gt;EratosthenesSieve&lt;/code&gt;, which as you can probably tell from the name, was invented over 2,000 years ago by a Greek mathematician. Go figure!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="vg"&gt;$&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;Prime&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;EratosthenesGenerator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;take&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;19&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;23&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;29&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="vg"&gt;$&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;Prime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;take&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;   &lt;span class="c1"&gt;# uses Eratosthenes under the hood, by default&lt;/span&gt;
&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;19&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;23&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;29&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*Last, and probably least - this is why there's only two and a half, after all - we have &lt;code&gt;Generator23&lt;/code&gt;. This is a special one, because it doesn't actually generate prime numbers, but rather numbers which are not divisible by 2 or 3. This is a clever optimization invented by Mathematicians to make validating a prime more memory-efficient. As such, this generator is used by &lt;code&gt;#prime?&lt;/code&gt;, along with some additional computations, to check primality.&lt;/p&gt;

&lt;h1&gt;
  
  
  Abbrev
&lt;/h1&gt;

&lt;p&gt;This is probably the weirdest and most wonderful module I found in my spelunking. According to the docs, &lt;code&gt;Abbrev&lt;/code&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Calculates the set of unique abbreviations for a given set of strings.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Interesting... let's see it in action:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="vg"&gt;$&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;require&lt;/span&gt; &lt;span class="s1"&gt;'abbrev'&lt;/span&gt;
&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&gt;

&lt;span class="vg"&gt;$&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ruby&lt;/span&gt; &lt;span class="n"&gt;rules&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;abbrev&lt;/span&gt;
&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="s2"&gt;"ruby"&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"ruby"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="s2"&gt;"rub"&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"ruby"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="s2"&gt;"rules"&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"rules"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="s2"&gt;"rule"&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"rules"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="s2"&gt;"rul"&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;"rules"&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Give &lt;code&gt;Abbrev&lt;/code&gt; an array of strings, and it will give you a hash where those words become the values, and each key is a way of unambiguously referring to that word. In the example above, since both words start with "ru", we have to get more specific if we want to refer to one or the other.&lt;/p&gt;

&lt;p&gt;This module is arguably limited in its use cases, but it's elegant and wonderful nonetheless. I just love that data structure: taking advantage of a hash's unique keys and having it point back to the original word? 👌👌&lt;/p&gt;

&lt;p&gt;The only uses of &lt;code&gt;Abbrev&lt;/code&gt; I can find are in &lt;a href="https://docs.ruby-lang.org/en/2.1.0/RDoc/RI/Driver.html#method-i-expand_class" rel="noopener noreferrer"&gt;RDoc&lt;/a&gt;, and &lt;a href="https://github.com/ruby/ruby/blob/trunk/tool/redmine-backporter.rb#L578" rel="noopener noreferrer"&gt;a miscellaneous script in Ruby core&lt;/a&gt;, but I imagine one could put it to good use in things that need command-line autocompletion.&lt;/p&gt;

&lt;p&gt;Or, you could use it to write your very own Unambiguous Nickname Generator!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="vg"&gt;$&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sx"&gt;%w(Alex Amy Ayla Amanda)&lt;/span&gt;
&lt;span class="vg"&gt;$&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;names&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;abbrev&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;select&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Alex"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Ale"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Amy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Ayla"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Ayl"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Amanda"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Amand"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Aman"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Ama"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From now on, call me Ale. 🍻&lt;/p&gt;

&lt;h1&gt;
  
  
  Last, but not least...
&lt;/h1&gt;

&lt;p&gt;Chances are you've made an HTTP request from your Ruby program at some point. You probably used &lt;code&gt;Net::HTTP&lt;/code&gt; (or maybe another gem that uses it under the hood).&lt;/p&gt;

&lt;p&gt;But let me ask you this - have you ever checked your e-mail with Ruby?&lt;/p&gt;

&lt;p&gt;🥁 🥁 🥁&lt;/p&gt;

&lt;p&gt;Introducing &lt;code&gt;Net::POP3&lt;/code&gt;!&lt;/p&gt;

&lt;p&gt;That's right, you can check your e-mail without ever leaving IRB:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="vg"&gt;$&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;inbox&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Net&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;POP3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'pop.gmail.com'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="c1"&gt;#&amp;lt;Net::POP3 pop.gmail.com: open=false&amp;gt;&lt;/span&gt;

&lt;span class="vg"&gt;$&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;inbox&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'your-email-here@gmail.com'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'supersecret'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="c1"&gt;#&amp;lt;Net::POP3 pop.gmail.com: open=true&amp;gt;&lt;/span&gt;

&lt;span class="vg"&gt;$&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;inbox&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;each_mail&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;grep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/Subject/&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="no"&gt;Subject&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;Hello&lt;/span&gt; &lt;span class="no"&gt;IRB&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;

&lt;span class="vg"&gt;$&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;finish&lt;/span&gt;
&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"+OK Farewell."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1z981ve69x30b7wq3w47.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1z981ve69x30b7wq3w47.png" alt="i ❤ ruby"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;What a ride! I hope I've opened your mind to some new possibilities with the language you know and love. I certainly learned a ton, and digging into these weird, dusty corners of Ruby just makes me love it even more. ❤️&lt;/p&gt;

&lt;p&gt;Have you found any other fun Ruby modules, or can you think of another use for &lt;code&gt;Abbrev&lt;/code&gt;? Let me know!&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>scripting</category>
      <category>fun</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Tips for Finding Focus</title>
      <dc:creator>Alex Taylor</dc:creator>
      <pubDate>Sat, 23 Sep 2017 18:56:36 +0000</pubDate>
      <link>https://dev.to/mctaylorpants/tips-for-finding-focus</link>
      <guid>https://dev.to/mctaylorpants/tips-for-finding-focus</guid>
      <description>&lt;p&gt;&lt;a href="https://medium.com/@mctaylorpants/tips-for-finding-focus-129ed165bf79" rel="noopener noreferrer"&gt;&lt;em&gt;Originally published on Medium.&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Focusing on a single task is quickly becoming a lost art. The temptation to always be multi-tasking, keeping up with notifications and e-mail, can make you feel “busy even though you might not be getting a lot done.&lt;/p&gt;

&lt;p&gt;Programming is one of those tasks that does not lend itself well to multi-taskingâ€Š–â€Šat least for me, anyway. It’s hard to effectively solve a problem in 4–5 minute chunks between meetings and conversations.&lt;/p&gt;

&lt;p&gt;What follows is nothing new, simply a couple of techniques I’ve come across over the last couple of years that have really helped me find the focus that’s so important when working as a developer. I hope these tips will help you find focus in your life, too!&lt;/p&gt;

&lt;h3&gt;
  
  
  Schedule your Focus Time
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2AfdVseIvg-e1Yf-Rj1WwFZw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2AfdVseIvg-e1Yf-Rj1WwFZw.png" alt="FOCUS TIME - a developer's best friend."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At Unbounce, we’ve designated every Tuesday and Thursday afternoon to focus time. Since this is a department-wide calendar event, the idea is that meetings should be booked outside of this time when possible. It doesn’t always work exactly as planned, but it’s a great strategy to protect time on a company-wide level.&lt;br&gt;
Some of us have gone one step further and created a “Do not book event on our public calendars. This serves as another reminder for those who are scheduling meetings with me that I’d prefer to keep that time free for myself.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do Pomodoro ðŸ…
&lt;/h3&gt;

&lt;p&gt;If you haven’t heard of the &lt;a href="https://en.wikipedia.org/wiki/Pomodoro_Technique" rel="noopener noreferrer"&gt;Pomodoro Technique&lt;/a&gt;, I’m here to tell you that it’s the snake oil that will change your life! ... or not. It may not work for everybody, but I’ve found it to be the perfect framework for finding focus throughout the day.&lt;/p&gt;

&lt;p&gt;A typical Pomodoro sequence goes like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Focus on a predetermined task for 25 minutes, with no distractions;&lt;/li&gt;
&lt;li&gt;Take a short (3–5 minute) break;&lt;/li&gt;
&lt;li&gt;Repeat. Take a longer break (15–30 minute) after four Pomodoros.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don’t have to follow this religiously. I tend to stick to the 25-minute focus time, but I’m not as regimented with the duration of my breaks. I also don’t try to do Pomodoro on days when I have a lot of meetings, since it quickly becomes an exercise in frustration. It’s best for a morning or an afternoon that’s yours to schedule as you choose.&lt;/p&gt;

&lt;p&gt;The key to the Pomodoro technique comes in the separation of focus from interrupts. For that 25 minutes of focus, you do not check e-mail. You do not check Slack. Put your headphones on and turn on some music. Politely tell people who walk up to you with a question that you’ll be with them shortly.&lt;/p&gt;

&lt;p&gt;Before each Pomodoro session, have a plan in mind of what you want to accomplish in the next 25 minutes. You don’t necessarily need to write it down or anythingâ€Š–â€Šjust know what you want to accomplish so that you can completely dedicate your time and energy to that task.&lt;/p&gt;

&lt;p&gt;Of course, there are apps to help you time these sessions! I like &lt;a href="http://tomighty.org/" rel="noopener noreferrer"&gt;Tomighty&lt;/a&gt;. It’s nice and simple.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do Not Disturb. 24/7.
&lt;/h3&gt;

&lt;p&gt;It’s probably obvious that when you want to find focus, you should enable Do Not Disturb mode on your computer. I started doing this when I began practicing Pomodoro. However, I quickly realized that I didn’t need to keep toggling my notificationsâ€Š–â€ŠI could just leave them off all the time.&lt;/p&gt;

&lt;p&gt;When you practice Pomodoro, you create specific times where you’ll be available for Slack chats, responding to e-mails, etc. Since you’ve made a habit of this, why bother turning on your notifications? Once you’re in the habit of checking the feeds you need to check, you no longer need pop-ups informing you the moment something happensâ€Š–â€Šexcept maybe if your app goes down!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(Hot tip for macOS users: you can Option-click the notification menu bar icon to automatically toggle DND mode.)&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Don’t always be available
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2AhOq6ecjr1Hl-VTLkyOu7fw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F1600%2F1%2AhOq6ecjr1Hl-VTLkyOu7fw.png" alt="Your answer in 25 minutes or it's free."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The introduction of Slack, or another chat app, into the workplace also usually comes with the implicit expectation that you will reply to people’s messages immediately, or at least faster than an e-mail. This can be a problem if you’re trying to partition your time.&lt;/p&gt;

&lt;p&gt;I’ve started using my Slack status to set the expectation that I won’t always respond immediately. This is a small thing, but I think it’s a respectful way to set up some boundaries around your availability throughout the day. Plus, 25 minutes is a pretty reasonable amount of time for a reply in my opinion, unless of course it’s an emergency.&lt;/p&gt;

&lt;h3&gt;
  
  
  Be Disciplined
&lt;/h3&gt;

&lt;p&gt;None of this will work if you start making exceptions to your focus rules. It can be tempting at first to take a quick peek at Slack while your tests are running, for example, but once you start establishing a rhythm I think you’ll notice a difference in your productivity. Right now it feels so satisfying when I click “start on my Pomodoro timer and throw on my headphonesâ€Š–â€Šhere comes focus!&lt;/p&gt;

&lt;p&gt;How do you find focus throughout the day? I’d love to hear other ideas!&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>pomodorotechnique</category>
      <category>focus</category>
    </item>
  </channel>
</rss>
