<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>tbaggery</title>
 <link href="http://tbaggery.com/atom.xml" rel="self"/>
 <link href="http://tbaggery.com/"/>
 <updated>2010-03-04T15:25:48-08:00</updated>
 <id>http://tbaggery.com/</id>
 <author>
   <name>Tim Pope</name>
   <uri>http://tpo.pe/</uri>
 </author>

 
 <entry>
   <title>Smack a Ho.st</title>
   <link href="http://tbaggery.com/2010/03/04/smack-a-ho-st.html"/>
   <updated>2010-03-04T00:00:00-08:00</updated>
   <id>http://tbaggery.com/2010/03/04/smack-a-ho-st</id>
   <content type="html">&lt;p&gt;Tired of having no choice but to add aliases for localhost to &lt;code&gt;/etc/hosts&lt;/code&gt; every time you work on a site that uses subdomains? Me too. That&amp;#8217;s why I grabbed smackaho.st and made it a localhost wildcard, pointing &lt;code&gt;*.smackaho.st&lt;/code&gt; at &lt;code&gt;127.0.0.1&lt;/code&gt;. If you&amp;#8217;re a Rails developer, try visiting &lt;a href='http://dontmakeme.smackaho.st:3000/'&gt;http://dontmakeme.smackaho.st:3000/&lt;/a&gt;.&lt;/p&gt;
   &lt;!-- #hashrocket --&gt;
   </content>

 </entry>
 
 <entry>
   <title>Episode IV: A New Pope</title>
   <link href="http://tbaggery.com/2010/02/28/episode-iv-a-new-pope.html"/>
   <updated>2010-02-28T00:00:00-08:00</updated>
   <id>http://tbaggery.com/2010/02/28/episode-iv-a-new-pope</id>
   <content type="html">&lt;p&gt;I&amp;#8217;ve moved my blog to Jekyll. I think this is the post where I&amp;#8217;m supposed to apologize for falling off the blog wagon and promise to post more in the future, though truth be told I have few regrets and make no promises. My aged Drupal install had gotten to the point where I felt actively discouraged from posting. Now that I&amp;#8217;ve rectified that, I&amp;#8217;ve at least enabled myself to post in the future if I have any flashes of inspiration. Still, I promise nothing. I only migrated the handful of posts that seemed less than completely obsolete.&lt;/p&gt;

&lt;p&gt;My migration process produced two noteworthy artifacts: &lt;a href='http://github.com/tpope/vim-liquid'&gt;Vim syntax highlighting for Liquid&lt;/a&gt; and &lt;a href='http://github.com/tpope/vim-markdown'&gt;the same for Markdown&lt;/a&gt;. There are existing implementations of both of these, but they had limitations I could not accept (most notably, I couldn&amp;#8217;t combine them). The Liquid set has some Jekyll specific goodies like YAML front matter highlighting and support for Pygments &lt;code&gt;highlight&lt;/code&gt; blocks. You need to explicitly specify which types of &lt;code&gt;highlight&lt;/code&gt; blocks you want highlighted and map between the Pygments type and Vim type in your &lt;code&gt;vimrc&lt;/code&gt;:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='vim'&gt;&lt;span class='k'&gt;let&lt;/span&gt; g:liquid_highlight_types&lt;span class='p'&gt;=&lt;/span&gt;[&lt;span class='s2'&gt;&amp;quot;html&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;&lt;span class='s2'&gt;&amp;quot;erb=eruby&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;&lt;span class='s2'&gt;&amp;quot;html+erb=eruby.html&amp;quot;&lt;/span&gt;]
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
   &lt;!-- #hashrocket --&gt;
   </content>

 </entry>
 
 <entry>
   <title>A Note About Git Commit Messages</title>
   <link href="http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html"/>
   <updated>2008-04-19T00:00:00-07:00</updated>
   <id>http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages</id>
   <content type="html">&lt;p&gt;I want to take a moment to elaborate on what makes a well formed commit message. I think the best practices for commit message formatting is one of the little details that makes Git great. Understandably, some of the first commits to rails.git have messages of the really-long-line variety, and I want to expand on why this is a poor practice.&lt;/p&gt;

&lt;p&gt;Here&amp;#8217;s a model Git commit message:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Short (50 chars or less) summary of changes

More detailed explanatory text, if necessary.  Wrap it to about 72
characters or so.  In some contexts, the first line is treated as the
subject of an email and the rest of the text as the body.  The blank
line separating the summary from the body is critical (unless you omit
the body entirely); tools like rebase can get confused if you run the
two together.

Write your commit message in the present tense: &amp;quot;Fix bug&amp;quot; and not &amp;quot;Fixed
bug.&amp;quot;  This convention matches up with commit messages generated by
commands like git merge and git revert.

Further paragraphs come after blank lines.

- Bullet points are okay, too

- Typically a hyphen or asterisk is used for the bullet, preceded by a
  single space, with blank lines in between, but conventions vary here

- Use a hanging indent&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Let&amp;#8217;s start with a few of the reasons why wrapping your commit messages to 72 columns is a good thing.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git log&lt;/code&gt; doesn&amp;#8217;t do any special special wrapping of the commit messages. With the default pager of &lt;code&gt;less -S&lt;/code&gt;, this means your paragraphs flow far off the edge of the screen, making them difficult to read. On an 80 column terminal, if we subtract 4 columns for the indent on the left and 4 more for symmetry on the right, we&amp;#8217;re left with 72 columns.&lt;/li&gt;

&lt;li&gt;&lt;code&gt;git format-patch --stdout&lt;/code&gt; converts a series of commits to a series of emails, using the messages for the message body. Good email netiquette dictates we wrap our plain text emails such that there&amp;#8217;s room for a few levels of nested reply indicators without overflow in an 80 column terminal. (The current rails.git workflow doesn&amp;#8217;t include email, but who knows what the future will bring.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Vim users can meet this requirement by installing my &lt;a href='http://github.com/tpope/vim-git'&gt;vim-git runtime files&lt;/a&gt;, or by simply setting the following option in your git commit message file:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;:set textwidth=72&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;For Textmate, you can adjust the &amp;#8220;Wrap Column&amp;#8221; option under the view menu, then use &lt;code&gt;^Q&lt;/code&gt; to rewrap paragraphs (be sure there&amp;#8217;s a blank line afterwards to avoid mixing in the comments). Here&amp;#8217;s a shell command to add 72 to the menu so you don&amp;#8217;t have to drag to select each time:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ defaults write com.macromates.textmate OakWrapColumns &amp;#39;( 40, 72, 78 )&amp;#39;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;More important than the mechanics of formatting the body is the practice of having a subject line. As the example indicates, you should shoot for about 50 characters (though this isn&amp;#8217;t a hard maximum) and always, always follow it with a blank line. This first line should be a concise summary of the changes introduced by the commit; if there are any technical details that cannot be expressed in these strict size constraints, put them in the body instead. The subject line is used all over Git, oftentimes in truncated form if too long of a message was used. The following are just a handful of examples of where it ends up:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;git log --pretty=oneline&lt;/code&gt; shows a terse history mapping containing the commit id and the summary&lt;/li&gt;

&lt;li&gt;&lt;code&gt;git rebase --interactive&lt;/code&gt; provides the summary for each commit in the editor it invokes&lt;/li&gt;

&lt;li&gt;if the config option &lt;code&gt;merge.summary&lt;/code&gt; is set, the summaries from all merged commits will make their way into the merge commit message&lt;/li&gt;

&lt;li&gt;&lt;code&gt;git shortlog&lt;/code&gt; uses summary lines in the changelog-like output it produces&lt;/li&gt;

&lt;li&gt;&lt;code&gt;git format-patch&lt;/code&gt;, &lt;code&gt;git send-email&lt;/code&gt;, and related tools use it as the subject for emails&lt;/li&gt;

&lt;li&gt;reflogs, a local history accessible with &lt;code&gt;git reflog&lt;/code&gt; intended to help you recover from stupid mistakes, get a copy of the summary&lt;/li&gt;

&lt;li&gt;&lt;code&gt;gitk&lt;/code&gt; has a column for the summary&lt;/li&gt;

&lt;li&gt;GitHub uses the summary in various places in their user interface&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The subject/body distinction may seem unimportant but it&amp;#8217;s one of many subtle factors that makes Git history so much more pleasant to work with than Subversion.&lt;/p&gt;
   &lt;!-- #hashrocket --&gt;
   </content>

 </entry>
 
 <entry>
   <title>Easy Ruby Examples</title>
   <link href="http://tbaggery.com/2007/05/03/easy-ruby-examples.html"/>
   <updated>2007-05-03T00:00:00-07:00</updated>
   <id>http://tbaggery.com/2007/05/03/easy-ruby-examples</id>
   <content type="html">&lt;p&gt;Today I devised a little script to generate Ruby examples showing code and output.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;% rubydemo &amp;#39;[1,2,3].inject {|m,o|m+o}&amp;#39;
[1,2,3].inject {|m,o|m+o} #=&amp;gt; 6
% rubydemo 1/0
1/0 #=&amp;gt; #&amp;lt;ZeroDivisionError: divided by 0&amp;gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Here&amp;#8217;s the script I used for generation. (It could have been one line if I didn&amp;#8217;t care so much about exception formatting.)&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='c1'&gt;#!/usr/bin/env ruby&lt;/span&gt;
&lt;span class='nb'&gt;print&lt;/span&gt; &lt;span class='no'&gt;ARGV&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;join&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='s2'&gt;&amp;quot; &amp;quot;&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt; &lt;span class='o'&gt;+&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot; #=&amp;gt; &amp;quot;&lt;/span&gt;
&lt;span class='k'&gt;begin&lt;/span&gt;
  &lt;span class='nb'&gt;p&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nb'&gt;eval&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='no'&gt;ARGV&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;join&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='s2'&gt;&amp;quot; &amp;quot;&lt;/span&gt;&lt;span class='p'&gt;),&lt;/span&gt;&lt;span class='nb'&gt;binding&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;&lt;span class='s2'&gt;&amp;quot;(demo)&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;))&lt;/span&gt;
&lt;span class='k'&gt;rescue&lt;/span&gt; &lt;span class='no'&gt;Exception&lt;/span&gt; &lt;span class='o'&gt;=&amp;gt;&lt;/span&gt; &lt;span class='n'&gt;e&lt;/span&gt;
  &lt;span class='nb'&gt;puts&lt;/span&gt; &lt;span class='s2'&gt;&amp;quot;#&amp;lt;&lt;/span&gt;&lt;span class='si'&gt;#{&lt;/span&gt;&lt;span class='n'&gt;e&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;class&lt;/span&gt;&lt;span class='si'&gt;}&lt;/span&gt;&lt;span class='s2'&gt;: &lt;/span&gt;&lt;span class='si'&gt;#{&lt;/span&gt;&lt;span class='n'&gt;e&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;message&lt;/span&gt;&lt;span class='o'&gt;[/.&lt;/span&gt;&lt;span class='n'&gt;*&lt;/span&gt;&lt;span class='o'&gt;/]&lt;/span&gt;&lt;span class='si'&gt;}&lt;/span&gt;&lt;span class='s2'&gt;&amp;gt;&amp;quot;&lt;/span&gt;
&lt;span class='k'&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;The real killer app, though, is using it in conjunction with IRC. Here&amp;#8217;s the alias I used in Irssi.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;/alias rd exec -nosh - -out rubydemo $*&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now I need merely do &lt;code&gt;/rd 2+2&lt;/code&gt; to get a beautifully formatted &lt;code&gt;2+2 #=&amp;gt;
4&lt;/code&gt; in any conversation.&lt;/p&gt;
   &lt;!-- #hashrocket --&gt;
   </content>

 </entry>
 
 <entry>
   <title>Auto-loading Ruby Code</title>
   <link href="http://tbaggery.com/2007/02/11/auto-loading-ruby-code.html"/>
   <updated>2007-02-11T00:00:00-08:00</updated>
   <id>http://tbaggery.com/2007/02/11/auto-loading-ruby-code</id>
   <content type="html">&lt;p&gt;An incredibly useful technique when using Ruby is to auto-load at start-up a custom library written for exactly that purpose. This is easy to accomplish with a couple of environment variables, but I see very little discussion on the subject. Thus, I&amp;#8217;ve written a nice summary of how to go about setting this up.&lt;/p&gt;

&lt;p&gt;The secret to running code at start-up is &lt;code&gt;RUBYOPT&lt;/code&gt;. You&amp;#8217;ve probably seen this environment variable before if you&amp;#8217;ve used RubyGems. It is recommended to set this to a value of &lt;code&gt;rubygems&lt;/code&gt;. This is equivalent to always calling ruby as &lt;code&gt;ruby -rubygems&lt;/code&gt;. The &lt;code&gt;-r&lt;/code&gt; option requires a library, so this option essentially does a &lt;code&gt;require &amp;#39;ubygems&amp;#39;&lt;/code&gt; each time Ruby is started. (The odd name of &lt;code&gt;ubygems&lt;/code&gt; was picked to look nice next to &lt;code&gt;-r&lt;/code&gt;.)&lt;/p&gt;

&lt;p&gt;We&amp;#8217;re going to be doing something similar, but with our own library. I&amp;#8217;ve traditionally put this file in &lt;code&gt;~/.ruby/lib/tpope.rb&lt;/code&gt;, but I will be using the more user-agnostic &lt;code&gt;mine.rb&lt;/code&gt; for the purposes of this example.&lt;/p&gt;

&lt;p&gt;The first thing we need to do is find the right place to set this environment variable, along with setting &lt;code&gt;RUBYLIB&lt;/code&gt; to a path that holds our file. If you are using a bourne compatible shell, like bash, add this to your shell&amp;#8217;s rc file (&lt;code&gt;~/.bashrc&lt;/code&gt; for bash):&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='bash'&gt;&lt;span class='k'&gt;if&lt;/span&gt; &lt;span class='o'&gt;[&lt;/span&gt; -f &lt;span class='s2'&gt;&amp;quot;$HOME/.ruby/lib/mine.rb&amp;quot;&lt;/span&gt; &lt;span class='o'&gt;]&lt;/span&gt;; &lt;span class='k'&gt;then&lt;/span&gt;
&lt;span class='k'&gt;  &lt;/span&gt;&lt;span class='nv'&gt;RUBYLIB&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s2'&gt;&amp;quot;$HOME/.ruby/lib&amp;quot;&lt;/span&gt;
  &lt;span class='nv'&gt;RUBYOPT&lt;/span&gt;&lt;span class='o'&gt;=&lt;/span&gt;&lt;span class='s2'&gt;&amp;quot;rmine&amp;quot;&lt;/span&gt;
  &lt;span class='nb'&gt;export &lt;/span&gt;RUBYLIB RUBYOPT
&lt;span class='k'&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;For C shells, add the following to &lt;code&gt;~/.cshrc&lt;/code&gt;:&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='csh'&gt;&lt;span class='k'&gt;if&lt;/span&gt; &lt;span class='o'&gt;(&lt;/span&gt; -f &lt;span class='s2'&gt;&amp;quot;$HOME/.ruby/lib/mine.rb&amp;quot;&lt;/span&gt; &lt;span class='o'&gt;)&lt;/span&gt; &lt;span class='k'&gt;then&lt;/span&gt;
&lt;span class='k'&gt;  &lt;/span&gt;&lt;span class='nb'&gt;setenv &lt;/span&gt;RUBYLIB &lt;span class='s2'&gt;&amp;quot;$HOME/.ruby/lib&amp;quot;&lt;/span&gt;
  &lt;span class='nb'&gt;setenv &lt;/span&gt;RUBYOPT &lt;span class='s2'&gt;&amp;quot;rmine&amp;quot;&lt;/span&gt;
&lt;span class='k'&gt;endif&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;If you are running under a GUI environment, you will want to make this variables known to the top level GUI as well. Both Windows and Mac OS X have interfaces to set environment variables. Some desktop environments running under X11 provide such an interface as well, or you can just add similar lines to &lt;code&gt;~/.xsession&lt;/code&gt; or &lt;code&gt;~/.xinitrc&lt;/code&gt;, depending on your setup.&lt;/p&gt;

&lt;p&gt;So now that we have this configured, what can we add to this new file? Plenty of things. Let&amp;#8217;s start by enhancing the &lt;code&gt;$LOAD_PATH&lt;/code&gt; (also known as &lt;code&gt;$:&lt;/code&gt;). My strategy here is to pop the current working directory off the end, add a few more directories, then restore it.&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='n'&gt;old_current&lt;/span&gt; &lt;span class='o'&gt;=&lt;/span&gt; &lt;span class='vg'&gt;$LOAD_PATH&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;pop&lt;/span&gt; &lt;span class='k'&gt;if&lt;/span&gt; &lt;span class='vg'&gt;$LOAD_PATH&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;last&lt;/span&gt; &lt;span class='o'&gt;==&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;.&amp;#39;&lt;/span&gt;
&lt;span class='sx'&gt;%w(.ruby/lib ruby/lib .ruby ruby)&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;each&lt;/span&gt; &lt;span class='k'&gt;do&lt;/span&gt; &lt;span class='o'&gt;|&lt;/span&gt;&lt;span class='n'&gt;dir&lt;/span&gt;&lt;span class='o'&gt;|&lt;/span&gt;
  &lt;span class='vg'&gt;$LOAD_PATH&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;unshift&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='no'&gt;File&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;expand_path&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='s2'&gt;&amp;quot;~/&lt;/span&gt;&lt;span class='si'&gt;#{&lt;/span&gt;&lt;span class='n'&gt;dir&lt;/span&gt;&lt;span class='si'&gt;}&lt;/span&gt;&lt;span class='s2'&gt;&amp;quot;&lt;/span&gt;&lt;span class='p'&gt;))&lt;/span&gt;
&lt;span class='k'&gt;end&lt;/span&gt;
&lt;span class='no'&gt;Dir&lt;/span&gt;&lt;span class='o'&gt;[&lt;/span&gt;&lt;span class='no'&gt;File&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;expand_path&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='s1'&gt;&amp;#39;~/ruby/*/lib&amp;#39;&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt;&lt;span class='o'&gt;].&lt;/span&gt;&lt;span class='n'&gt;each&lt;/span&gt; &lt;span class='k'&gt;do&lt;/span&gt; &lt;span class='o'&gt;|&lt;/span&gt;&lt;span class='n'&gt;dir&lt;/span&gt;&lt;span class='o'&gt;|&lt;/span&gt;
  &lt;span class='vg'&gt;$LOAD_PATH&lt;/span&gt; &lt;span class='o'&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class='n'&gt;dir&lt;/span&gt;
&lt;span class='k'&gt;end&lt;/span&gt;
&lt;span class='vg'&gt;$LOAD_PATH&lt;/span&gt; &lt;span class='o'&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class='n'&gt;old_current&lt;/span&gt; &lt;span class='k'&gt;if&lt;/span&gt; &lt;span class='n'&gt;old_current&lt;/span&gt;
&lt;span class='vg'&gt;$LOAD_PATH&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;uniq!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;I add a wide variety of directories here, feel free to adjust as you see fit. Note the addition of every directory matching &lt;code&gt;~/ruby/*/lib&lt;/code&gt;, which makes it easy to install new libraries in &lt;code&gt;~/ruby&lt;/code&gt;. This is something that would be tricky to do just by adjusting &lt;code&gt;RUBYLIB&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Next, let&amp;#8217;s load RubyGems. We can do this in such a way that it won&amp;#8217;t fail on systems where it&amp;#8217;s not installed.&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='k'&gt;begin&lt;/span&gt;
  &lt;span class='nb'&gt;require&lt;/span&gt; &lt;span class='s1'&gt;&amp;#39;rubygems&amp;#39;&lt;/span&gt;
&lt;span class='k'&gt;rescue&lt;/span&gt; &lt;span class='no'&gt;LoadError&lt;/span&gt;
&lt;span class='k'&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;What else? How about always keeping good old &lt;code&gt;Symbol#to_proc&lt;/code&gt; handy.&lt;/p&gt;
&lt;div class='highlight'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='k'&gt;class&lt;/span&gt; &lt;span class='nc'&gt;Symbol&lt;/span&gt;
  &lt;span class='k'&gt;def&lt;/span&gt; &lt;span class='nf'&gt;to_proc&lt;/span&gt;
    &lt;span class='no'&gt;Proc&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;new&lt;/span&gt; &lt;span class='p'&gt;{&lt;/span&gt; &lt;span class='o'&gt;|*&lt;/span&gt;&lt;span class='n'&gt;args&lt;/span&gt;&lt;span class='o'&gt;|&lt;/span&gt; &lt;span class='n'&gt;args&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;shift&lt;/span&gt;&lt;span class='o'&gt;.&lt;/span&gt;&lt;span class='n'&gt;__send__&lt;/span&gt;&lt;span class='p'&gt;(&lt;/span&gt;&lt;span class='nb'&gt;self&lt;/span&gt;&lt;span class='p'&gt;,&lt;/span&gt;&lt;span class='o'&gt;*&lt;/span&gt;&lt;span class='n'&gt;args&lt;/span&gt;&lt;span class='p'&gt;)&lt;/span&gt; &lt;span class='p'&gt;}&lt;/span&gt;
  &lt;span class='k'&gt;end&lt;/span&gt;
&lt;span class='k'&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;One thing to be careful about is not letting your code grow dependent on this auto-loaded library. For example, if you add the above snippet and start doing &lt;code&gt;pets.each(&amp;amp;:feed)&lt;/code&gt; all over the place, your code will break for other people without your library. I still define &lt;code&gt;Symbol#to_proc&lt;/code&gt; because it&amp;#8217;s handy for debug statements and quick scripts and it&amp;#8217;s easy enough to avoid using where it&amp;#8217;s important. But I avoid something more invasive like &lt;code&gt;require &amp;#39;active_support&amp;#39;&lt;/code&gt; because it&amp;#8217;s harder to keep track of everything it provides. Use your own best judgement.&lt;/p&gt;
   &lt;!-- #hashrocket --&gt;
   </content>

 </entry>
 
 
</feed>
