<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Codeulate.</title>
	
	<link>http://codeulate.com</link>
	<description />
	<lastBuildDate>Tue, 02 Mar 2010 21:16:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Codeulate" /><feedburner:info uri="codeulate" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Installing fuzzyfinder_textmate: Textmate’s Cmd+T in Vim</title>
		<link>http://feedproxy.google.com/~r/Codeulate/~3/o_U_tOkP33A/</link>
		<comments>http://codeulate.com/2010/02/installing-fuzzyfinder_textmate-textmates-cmdt-in-vim/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 00:37:11 +0000</pubDate>
		<dc:creator>Ben Orenstein</dc:creator>
				<category><![CDATA[general]]></category>

		<guid isPermaLink="false">http://codeulate.com/?p=80</guid>
		<description><![CDATA[When Jamis Buck switched from TextMate to vim, he found he missed one bit of functionality above all others: TextMate&#8217;s file finder, Cmd+T.
Being a capable programmer, he &#8220;took an evening&#8221; and wrote up a Ruby library to replicate this functionality.  Then he extended vim with a plugin called fuzzyfinder_textmate that called out to this Ruby [...]]]></description>
			<content:encoded><![CDATA[<p>When <a href="http://twitter.com/Jamis">Jamis Buck</a> <a href="http://weblog.jamisbuck.org/2008/10/10/coming-home-to-vim">switched from TextMate to vim</a>, he found he missed one bit of functionality above all others: TextMate&#8217;s file finder, Cmd+T.</p>
<p>Being a capable programmer, he &#8220;took an evening&#8221; and wrote up a Ruby library to replicate this functionality.  Then he extended vim with a plugin called fuzzyfinder_textmate that called out to this Ruby library.</p>
<p>The results were terrific, and fuzzyfinder_textmate is my go-to solution for opening files in vim.  I almost never type &#8220;:e &#8230;&#8221; anymore.  I&#8217;ve yet to see anything faster at grabbing a file buried somewhere in a directory tree. This plugin is <em>particularly </em>useful for me when working on Rails projects, where vim&#8217;s &#8216;current directory&#8217; is Rails.root, and everything I want to open is down at least one level.  If you&#8217;re not familiar with the plugin, here&#8217;s a <a href="http://s3.amazonaws.com/buckblog/videos/fuzzyfinder_textmate.mov">silent-movie-style screencast</a> Jamis put together when he released it.</p>
<p>Sadly, this terrific plugin has a bit of a problem: it&#8217;s a pain in the ass to install.</p>
<p>Jamis&#8217; fuzzyfinder_textmate relies on a second plugin, called fuzzyfinder.vim.  The author of this plugin makes frequent changes, which usually end up breaking fuzzyfinder_textmate.  This got to be too much for Jamis, and he officially <a href="http://weblog.jamisbuck.org/2009/1/28/the-future-of-fuzzyfinder-textmate">dropped the project</a> a year ago.  Today, the latest versions of these plugins won&#8217;t work together.</p>
<p>However, thanks to several contributors and github&#8217;s forking, you can get this big mish-mash of libraries and plugins to work&#8230;provided you install exactly the right versions of each.  It&#8217;s a trifle annoying, but fortunately I&#8217;ve done the homework for you.  Follow the steps below and enjoy my <em>favorite</em> bit of vim functionality.<br />
<strong><br />
Installing fuzzyfinder_textmate:</strong></p>
<ol>
<li>Make sure you&#8217;re using vim 7.2 (the latest, as of this writing).  It&#8217;s possible earlier versions work as well, but I can&#8217;t confirm these steps will apply.</li>
<li>Make sure the vim you installed was compiled with ruby support.  Check this by running <em>vim &#8211;version | grep ruby</em> at the command line.  A result of <em><strong>+</strong>ruby</em> means you&#8217;re good, <em><strong>-</strong>ruby</em> means you DON&#8217;T have ruby support.  Debian/Ubuntu users can get a ruby-capable vim by running <em>sudo apt-get install vim-ruby</em>.  Another test to make sure you&#8217;ve got ruby support: type <em>:ruby</em> in vim.  <em>Argument required</em> is good.  <em>Not an editor command: ruby</em> is bad.</li>
<li>Install Jamis&#8217; fuzzy_file_finder Ruby library <a href="http://github.com/jamis/fuzzy_file_finder">from here</a>.  This is installable as a gem, but I strongly recommend simply <em>git clone</em>ing this repo, creating a ruby directory in your .vim folder, and placing the lib/fuzzy_file_finder.rb inside there.   This keeps this dependency in your .vim directory (rather than on a system gem you&#8217;ll forget about when you change servers), and enables keeping your vim configuration in a git repository (HIGHLY recommended).</li>
<li> Install <a href="http://www.vim.org/scripts/download_script.php?src_id=10718">vim-fuzzyfinder version 2.22.3</a>.  IMPORTANT: you MUST use this exact version.  Other versions (particularly anything NEWER than this one) will NOT work.  After installing, confirm it works by running <em>:FuzzyFinderFile</em> in vim.  You should get a pop up box with a list of files.  If you do you&#8217;re almost there.</li>
<li> Install fuzzyfinder_textmate, but use <a href="http://github.com/sethbc/fuzzyfinder_textmate">sethbc&#8217;s fork from github</a>.  Don&#8217;t use the version from Jamis&#8217; repo as it will NOT work with the version of fuzzyfinder.vim we installed.  <em>git clone </em>again, and simply put fuzzyfinder_textmate.vim in your .vim/plugin folder. To test that everything worked, run <em>:FuzzyFinderTextMate</em> in vim.  If you get a popup box, you&#8217;re done!</li>
</ol>
<p>If you&#8217;re having trouble, the most common culprit is that you&#8217;ve mucked up the versions.  This collection of files is quite finicky, and if you&#8217;re using the wrong version of any one things fall apart quickly.  After that, double-check you&#8217;ve got Ruby support.</p>
<p>If you&#8217;re still having trouble, do a <em>git clone</em> of <a href="http://github.com/r00k/dotfiles">my dotfiles</a>.  My setup is confirmed working, so you can diff your copies of the library/plugins against mine.  Any differences mean you&#8217;ve got the wrong version.</p>
<p>If you still have issues, leave a note in the comments and I&#8217;ll try to get you sorted out.</p>
<p>Finally, if you found this post useful, I&#8217;d urge you to check out my screencast: <a href="http://www.codeulatescreencasts.com/products/vim-for-rails-developers">Vim for Rails Developers</a>.  In it, I&#8217;ll teach you the best plugins, external tools, and editing tricks for writing Rails code at top-speed.  If you write Rails code in vim, it&#8217;s sure to save you time.</p>
<img src="http://feeds.feedburner.com/~r/Codeulate/~4/o_U_tOkP33A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codeulate.com/2010/02/installing-fuzzyfinder_textmate-textmates-cmdt-in-vim/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
<enclosure url="http://s3.amazonaws.com/buckblog/videos/fuzzyfinder_textmate.mov" length="604727" type="video/quicktime" />
		<feedburner:origLink>http://codeulate.com/2010/02/installing-fuzzyfinder_textmate-textmates-cmdt-in-vim/</feedburner:origLink></item>
		<item>
		<title>New In factory_girl: Callbacks</title>
		<link>http://feedproxy.google.com/~r/Codeulate/~3/SFDYrPBF-Nw/</link>
		<comments>http://codeulate.com/2009/11/factory_girl-callbacks/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 23:59:45 +0000</pubDate>
		<dc:creator>Ben Orenstein</dc:creator>
				<category><![CDATA[general]]></category>

		<guid isPermaLink="false">http://codeulate.com/?p=64</guid>
		<description><![CDATA[Thoughtbot&#8217;s factory_girl has recently gotten a terrific new feature: callbacks.
They look like this:

Factory&#40;:user&#41; do &#124;u&#124;
&#160;
  u.after_create &#123; &#124;user_instance&#124; do_something_to&#40;user_instance&#41; &#125;
&#160;
end

Now, when you use Factory(:user) in your tests, the do_something_to method will be called after the user is saved in the database.  Also notice that you&#8217;ll be passed the instance of the user as block [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.thoughtbot.com">Thoughtbot</a>&#8217;s <a href="http://github.com/thoughtbot/factory_girl">factory_girl</a> has <a href="http://github.com/thoughtbot/factory_girl/commit/6e35bf92071f4b34763e6d0d12ebef8f7eab4d4b">recently gotten</a> a terrific new feature: callbacks.</p>
<p>They look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">Factory<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:user</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>u<span style="color:#006600; font-weight:bold;">|</span>
&nbsp;
  u.<span style="color:#9900CC;">after_create</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>user_instance<span style="color:#006600; font-weight:bold;">|</span> do_something_to<span style="color:#006600; font-weight:bold;">&#40;</span>user_instance<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Now, when you use <em>Factory(:user)</em> in your tests, the <em>do_something_to </em>method will be called after the user is saved in the database.  Also notice that you&#8217;ll be passed the instance of the user as block parameter.</p>
<p>There are two other callbacks now available: <em>after_build</em> and <em>after_stub</em>.  Their callbacks fire pretty much where you&#8217;d expect them to.</p>
<p>You can mix and match these callbacks on the same factory.  Multiple definitions of the same callback will be executed in the order you provide them:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">Factory<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:user</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>u<span style="color:#006600; font-weight:bold;">|</span>
&nbsp;
  u.<span style="color:#9900CC;">after_build</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>user_instance<span style="color:#006600; font-weight:bold;">|</span> do_something_to<span style="color:#006600; font-weight:bold;">&#40;</span>user_instance<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
  u.<span style="color:#9900CC;">after_create</span> <span style="color:#006600; font-weight:bold;">&#123;</span> do_this_after_create <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
  u.<span style="color:#9900CC;">after_create</span> <span style="color:#006600; font-weight:bold;">&#123;</span> then_do_this <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>I&#8217;m excited about this addition because of how much more flexibility this gives factory_girl.  There are some kludgy parts of my <em>factories.rb</em> files that will be more elegantly accomplished with these tools.</p>
<p>Accepting these little lambdas to be run later feels very lispy, something I take as a great sign.</p>
<p>For more usage details, check out the &#8216;callbacks&#8217; section of the <a href="http://github.com/thoughtbot/factory_girl/blob/master/README.rdoc">README</a>.</p>
<p>And, if you&#8217;d like to read more about using Ruby&#8217;s blocks this way, Greg Brown has an <a href="http://blog.rubybestpractices.com/posts/gregory/009-beautiful-blocks.html">excellent article on the topic</a> (excerpted from his <a href="http://www.amazon.com/gp/product/0596523009?ie=UTF8&amp;tag=codeulate-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0596523009">also-excellent book</a>).</p>
<img src="http://feeds.feedburner.com/~r/Codeulate/~4/SFDYrPBF-Nw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codeulate.com/2009/11/factory_girl-callbacks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://codeulate.com/2009/11/factory_girl-callbacks/</feedburner:origLink></item>
		<item>
		<title>Making Github’s Code Readable</title>
		<link>http://feedproxy.google.com/~r/Codeulate/~3/jeQddnEM5VA/</link>
		<comments>http://codeulate.com/2009/11/making-githubs-code-readable/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 15:45:15 +0000</pubDate>
		<dc:creator>Ben Orenstein</dc:creator>
				<category><![CDATA[general]]></category>

		<guid isPermaLink="false">http://codeulate.com/?p=46</guid>
		<description><![CDATA[I love Github.  We recently decided to become paid customers at work, and I&#8217;m tickled.
I also can&#8217;t stand reading code on the site.
Why?  Frankly, the text is plain old ugly:

Those italicized comments look like faintly-etched glass.  And the bolded bits look clumsy as well (check out the &#8216;m&#8217; on &#8216;module&#8217;)!
What&#8217;s with the ugly?  Let&#8217;s ask [...]]]></description>
			<content:encoded><![CDATA[<p>I love Github.  We recently decided to become paid customers at work, and I&#8217;m tickled.</p>
<p>I also<em> </em>can&#8217;t stand reading code on the site.</p>
<p>Why?  Frankly, the text is plain old ugly:</p>
<p><img class="alignnone size-full wp-image-51" title="before" src="http://codeulate.com/wp-content/uploads/2009/10/before1.png" alt="before" width="614" height="621" /></p>
<p>Those italicized comments look like faintly-etched glass.  And the bolded bits look clumsy as well (check out the &#8216;m&#8217; on &#8216;module&#8217;)!</p>
<p>What&#8217;s with the ugly?  Let&#8217;s ask Firebug:</p>
<p><img class="alignnone size-full wp-image-52" title="firebug" src="http://codeulate.com/wp-content/uploads/2009/10/firebug.png" alt="firebug" width="504" height="98" /></p>
<p>&#8216;Bitstream Vera Sans Mono&#8217;?  Never heard of it.  Haven&#8217;t got it installed.  If you&#8217;re on Windows or OS X, <a href="http://en.wikipedia.org/wiki/Bitstream_Vera">you probably don&#8217;t either</a>.</p>
<p>Okay, so I haven&#8217;t got Bitstream, so it looks like we&#8217;re falling back t&#8211;oh my GOD it&#8217;s COURIER.</p>
<p>Yes, <a href="http://en.wikipedia.org/wiki/Courier_%28typeface%29">Courier</a>.  Invented in the 1950s.  For typewriters.  I think I last used this font while editing <a href="http://www.jefflewis.net/archive/programming/gorilla.bas">GORILLA.BAS</a> to mess with the speed and gravity.  No one should be using Courier anymore (<a href="http://www.empirecontact.com/readability/Courier_font.html">unless you&#8217;re writing a screenplay</a>).</p>
<p>Fortunately, there are two easy ways to fix this.  The first, you and I can do.  The second will have to be done by the Github guys.</p>
<p>What we can do: <strong>install Bitstream Vera Sans Mono.</strong></p>
<p><a href="http://www.dafont.com/bitstream-vera-mono.font">Download it here.</a></p>
<p>Installation is OS-specific, but I bet you can <a href="http://www.lmgtfy.com/?q=&quot;install+font&quot;+linux+OR+os+x+OR+windows">figure it out</a>.</p>
<p>Here&#8217;s how things look after the install:</p>
<p><img class="alignnone size-full wp-image-53" title="after" src="http://codeulate.com/wp-content/uploads/2009/10/after.png" alt="after" width="599" height="731" /></p>
<p>Sweet mystery of life at last I&#8217;ve found you!  This is about&#8230;a billion times more readable.</p>
<p>Now, the experience of not having their first-choice font shouldn&#8217;t have been so painful.  If you&#8217;re going to lead with a talented but fragile rookie, make sure you have a dependable second-string something something sports analogy.</p>
<p>Anyway, the Github guys <strong>should change &#8216;Courier&#8217; to &#8216;Courier New&#8217; in their stylesheet. </strong><a href="http://en.wikipedia.org/wiki/Courier_%28typeface%29#Courier_New">Courier New</a> is an updated and refreshed grand-child of Courier, and it&#8217;s far more readable, especially when bolded or italicized.  Plus it&#8217;s just as widely installed as Courier.</p>
<p>Little change on our side.  Little change on their side.  Code looks beautiful; everyone&#8217;s happy.</p>
<p>Github &#8212; no longer a butterface.</p>
<img src="http://feeds.feedburner.com/~r/Codeulate/~4/jeQddnEM5VA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codeulate.com/2009/11/making-githubs-code-readable/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://codeulate.com/2009/11/making-githubs-code-readable/</feedburner:origLink></item>
		<item>
		<title>Making OpenID Usable</title>
		<link>http://feedproxy.google.com/~r/Codeulate/~3/GoBcIiak6CA/</link>
		<comments>http://codeulate.com/2009/09/27/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 20:05:57 +0000</pubDate>
		<dc:creator>Ben Orenstein</dc:creator>
				<category><![CDATA[general]]></category>

		<guid isPermaLink="false">http://codeulate.com/?p=27</guid>
		<description><![CDATA[During the Rails Rumble &#8216;09, OpenID came up a lot in the #railsrumble IRC
channel.  A lot people had implemented OpenID in their app, and there was
some surprising grumbling from judges who didn&#8217;t like it.
The grumbling surprised me at first: I like OpenID.  But I think I&#8217;ve figured
out why these judges didn&#8217;t: it&#8217;s easy to do [...]]]></description>
			<content:encoded><![CDATA[<p>During the <a href="http://r09.railsrumble.com/">Rails Rumble &#8216;09</a>, <a href="http://openid.net/">OpenID </a>came up a lot in the #railsrumble IRC<br />
channel.  A lot people had implemented OpenID in their app, and there was<br />
some surprising grumbling from judges who didn&#8217;t like it.</p>
<p>The grumbling surprised me at first: I like OpenID.  But I think I&#8217;ve figured<br />
out why these judges didn&#8217;t: it&#8217;s easy to do a crappy login page.</p>
<p>Here&#8217;s an example of a really unfriendly OpenID login page:<br />
<a href="http://www.livejournal.com/openid/"><img class="alignnone" title="LJ OpenID" src="http://codeulate.com/images/lj_open_id.png" alt="" width="477" height="64" /></a></p>
<p>Yikes.</p>
<p>That blank white text box is like an iron door between me and this site.  I am a<br />
nerd AND an OpenID proponent, but I do not have my provider&#8217;s URL memorized.<br />
Even if I did, it&#8217;s a drag to type: &#8220;https://www.google.com/accounts/o8/id&#8221;</p>
<p>(Incidentally, Googlers: can we get https://openid.google.com for this?  C&#8217;mon,<br />
that&#8217;s kinda cool, no?)</p>
<p>So, please don&#8217;t ever make me go look up my OpenID provider URL.  Particularly<br />
if I&#8217;m using someone as large as Google for a provider.</p>
<p>Okay, cleanse your palatte and let&#8217;s check out an example of an EXCELLENT OpenID login page:<br />
<a href="http://stackoverflow.com/users/login"><img class="alignnone" title="SO OpenID" src="http://codeulate.com/images/so_open_id.png" alt="" width="554" height="265" /></a></p>
<p>Kudos to you, SO team.  This page kicks ass.</p>
<p>Stack Overflow gives me exactly what I want on an OpenID login page: a huge button with Google&#8217;s logo on it.<br />
Not only that, but they&#8217;ve shrunk the buttons for the less popular providers. I love that sort of touch in software.</p>
<p>If you&#8217;re going to support OpenID, please read the organization&#8217;s <a href="http://wiki.openid.net/Details-of-UX-Best-Practices-for-RPs">Best UX<br />
Practices</a>.  Or maybe <a href="http://developer.yahoo.com/openid/bestpractices.html">Yahoo&#8217;s OpenID Usability Research</a>.</p>
<p>Then just go copy StackOverflow&#8217;s page.</p>
<p>I think we should shoot to have all OpenID login pages look like siblings: possessing a thread of sameness despite their differences.</p>
<img src="http://feeds.feedburner.com/~r/Codeulate/~4/GoBcIiak6CA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codeulate.com/2009/09/27/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://codeulate.com/2009/09/27/</feedburner:origLink></item>
		<item>
		<title>Ruby Best Practices: A Review</title>
		<link>http://feedproxy.google.com/~r/Codeulate/~3/Wmut9HqvV6w/</link>
		<comments>http://codeulate.com/2009/07/ruby-best-practices-a-review/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 19:19:03 +0000</pubDate>
		<dc:creator>Ben Orenstein</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://codeulate.com/?p=26</guid>
		<description><![CDATA[One of my favorite simple pleasures is reading a technical or instructional book where the level of complexity perfectly matches my expertise.  I&#8217;ve been enjoying this exact experience while reading Greg Brown&#8217;s new book, Ruby Best Practices.
I have been programming professionally for over three years, with the last five months doing full time Ruby on [...]]]></description>
			<content:encoded><![CDATA[<p>One of my favorite simple pleasures is reading a technical or instructional book where the level of complexity perfectly matches my expertise.  I&#8217;ve been enjoying this exact experience while reading <a href="http://rubylearning.com/blog/2009/06/21/interview-author-gregory-brown/">Greg Brown</a>&#8217;s new book, <a href="http://www.amazon.com/gp/product/0596523009?ie=UTF8&amp;tag=codeulate-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0596523009">Ruby Best Practices</a>.</p>
<p>I have been programming professionally for over three years, with the last five months doing full time <a href="http://rubyonrails.org/">Ruby on Rails</a> development.  I would label myself an intermediate Ruby user: comfortable with the basics, but with limited exposure to its more advanced topics.  Lately, I have been reading more and more open source Ruby projects, and have been looking for ways to contribute back to our teriffic community.</p>
<p>Given my experience and goals, <a href="http://www.amazon.com/gp/product/0596523009?ie=UTF8&amp;tag=codeulate-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0596523009">Ruby Best Practices</a> was a perfect read.  The book is a collection of general strategies for solving problems in Ruby, with a focus on real-world code examples. Its author is an experienced Ruby developer who also happens to be an excellent writer.</p>
<p>Ruby Best Practices has a number of notable strengths. First, Brown is highly pragmatic. When discussing closures, he writes &#8220;I could show some abstract examples or academically exciting functionality such as Proc#curry, but instead, I decided that I wanted to show you something I use fairly frequently.&#8221;  This attitude has lead to a book that is full of ideas you can actually use.  It feels like the experienced guy down the hall showing you all his best stuff.</p>
<p>Secondly, RBP&#8217;s examples are almost uniformly excellent.  As contributor or creator of several popular Ruby projects (<a href="http://github.com/sandal/prawn/tree/master">Prawn </a>and <a href="http://github.com/ruport/ruport/tree/master">Ruport</a>) Brown has no lack of real-word code examples to choose from, and he does so with skill.  In addition, he&#8217;s not shy about trimming down the examples to leave behind just the most relevant code elements.  These two factors combine to produce code listings which are indicative of real open-source programs while remaining quite comprehensible.  Not only are Brown&#8217;s examples excellent, but they are plentiful.  Nearly every new idea he introduces is demonstrated through a case study of real (or plausibly real) code.  Working through this book will definitely sharpen your code-reading skills.</p>
<p>Beyond simply being clear, Brown&#8217;s writing is also fun to read.  His enthusiasm for the subject matter is obvious: &#8220;I could stop here and move on to the next topic, but similar to when we looked into the belly of lazy.rb earlier in this chapter, I can&#8217;t resist walking through and explaining some cool code.&#8221;  This sort enthusiasm continues throughout, and leads to a technical book that I&#8217;m tempted to call a page-turner. Making my way through the book really excited me to read and work on open-source projects.</p>
<p>If you&#8217;re still on the fence, take a read through the sample chapter, <a href="http://cdn.oreilly.com/books/9780596523008/Mastering_the_Dynamic_Toolkit.xml.pdf">Mastering the Dynamic Toolkit</a>.  Or, if you&#8217;d prefer a quicker read, check out <a href="http://blog.rubybestpractices.com/posts/gregory/005-code-reading-stdlib.html">this post</a> on <a href="http://rubybestpractices.com/">the book&#8217;s blog</a> to get a feel for Brown&#8217;s writing style.  If you like what you see, don&#8217;t hesitate to <a href="http://www.amazon.com/gp/product/0596523009?ie=UTF8&amp;tag=codeulate-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=0596523009">pick up a copy</a> of this excellent book.</p>
<p><strong>Chapter Titles:</strong><br />
1.  Driving Code Through Tests<br />
2.  Designing Beautiful APIs<br />
3.  <a href="http://cdn.oreilly.com/books/9780596523008/Mastering_the_Dynamic_Toolkit.xml.pdf">Mastering the Dynamic Toolkit</a><br />
4.  Text Processing and File Management<br />
5.  Functional Programming Techniques<br />
6.  When Things Go Wrong<br />
7.  Reducing Cultural Barriers<br />
8.  Skillful Project Maintenance<br />
A.  Writing Backwards Compatible Code<br />
B.  Leveraging Ruby&#8217;s Standard Library<br />
C.  Ruby Worst Practices</p>
<img src="http://feeds.feedburner.com/~r/Codeulate/~4/Wmut9HqvV6w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codeulate.com/2009/07/ruby-best-practices-a-review/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		<feedburner:origLink>http://codeulate.com/2009/07/ruby-best-practices-a-review/</feedburner:origLink></item>
		<item>
		<title>Good and Not So Good Rails Code</title>
		<link>http://feedproxy.google.com/~r/Codeulate/~3/Ao2iG_1_pUM/</link>
		<comments>http://codeulate.com/2009/06/good-and-not-so-good-rails-code/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 15:02:19 +0000</pubDate>
		<dc:creator>Ben Orenstein</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://codeulate.com/?p=25</guid>
		<description><![CDATA[I&#8217;ve found I learn best by example.  If you do too, these examples of good and not so good Rails code might be useful.
This post is targeted at newer Rails programmers.  If you&#8217;ve moved beyond the beginner stages you might not find much here for you.
Onward!
Let&#8217;s start with some code that&#8217;s not so [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve found I learn best by example.  If you do too, these examples of good and not so good Rails code might be useful.</p>
<p>This post is targeted at newer Rails programmers.  If you&#8217;ve moved beyond the beginner stages you might not find much here for you.</p>
<p>Onward!</p>
<p>Let&#8217;s start with some code that&#8217;s not so good.</p>
<hr /><strong>Not so good:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># app/controllers/book_controller.rb</span>
<span style="color:#9966CC; font-weight:bold;">def</span> new
  <span style="color:#0066ff; font-weight:bold;">@book</span> = Book.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:id</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  ...
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> create
  <span style="color:#0066ff; font-weight:bold;">@book</span> = Book.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:id</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  ...
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> edit
  <span style="color:#0066ff; font-weight:bold;">@book</span> = Book.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:id</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  ...
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p><strong>Why it&#8217;s not so good:</strong></p>
<p>This controller contains repeated code.  ALWAYS BE WARY OF THIS!  Pay particular attention when you&#8217;re doing the <em>exact</em> same thing in multiple places.  This type of code should almost always be refactored. In Rails, this duplication can be removed using a <a href="http://api.rubyonrails.org/classes/ActionController/Filters/ClassMethods.html#M000548">before_filter</a>.</p>
<p><strong>Better code:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># app/controllers/books_controller.rb</span>
before_filter <span style="color:#ff3333; font-weight:bold;">:find_book</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> new
  ...
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> create
  ...
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> edit
  ...
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
protected
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> find_book
  <span style="color:#0066ff; font-weight:bold;">@book</span> = Book.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:id</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p><strong>Why it&#8217;s better:</strong></p>
<p>The repeated code has been pulled out into a method (find_book).  Now, changes to the way we find books will be easy to make in this controller.  Notice also that we made it protected.  We only need to use this method in this controller, and a gentleman&#8217;s objects share as little as possible.</p>
<hr /><strong>Not so good code:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Return an array of titles</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> all_titles<span style="color:#006600; font-weight:bold;">&#40;</span>books<span style="color:#006600; font-weight:bold;">&#41;</span>
  book_titles = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
  books.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>book<span style="color:#006600; font-weight:bold;">|</span>
    book_titles <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> book.<span style="color:#9900CC;">name</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  book_titles
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p><strong>Why it&#8217;s not so good:</strong></p>
<p>Local variables can make complicated code more clear, but the variable in this method isn&#8217;t pulling its weight.  It&#8217;s just a box around the stuff we&#8217;re really interested in.</p>
<p><strong>Good code:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Return an array of titles</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> all_titles<span style="color:#006600; font-weight:bold;">&#40;</span>books<span style="color:#006600; font-weight:bold;">&#41;</span>
  books.<span style="color:#9900CC;">inject</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>book_titles, book<span style="color:#006600; font-weight:bold;">|</span> book_titles <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> book.<span style="color:#9900CC;">name</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p><strong>Why it&#8217;s better:</strong></p>
<p>It is a single, clear line, where each token pulls its weight.  Experienced Ruby users will find this version clearer, despite its greater density.</p>
<p>It is possible you find this version less clear.  A few months ago, I would have felt the same.  Back then, inject felt a little scary: I&#8217;d only bumped into it other peoples&#8217; code, and never written a fresh one myself.  However, after a bit of experience, I find it the perfect tool in the certain situations.  Think of using it particularly when you want to build up a collection (like an Array or Hash) from some other collection.</p>
<p>If you&#8217;d like to improve your skills with inject:<br />
1.  Check out <a href="http://blog.jayfields.com/2008/03/ruby-inject.html">Jay Field&#8217;s inject post</a> (good)<br />
2.  Read its <a href="http://www.ruby-doc.org/core/classes/Enumerable.html#M003171">documentation</a> and experiment in <a href="http://en.wikipedia.org/wiki/Interactive_Ruby_Shell">irb</a> (better)</p>
<p><strong>Update after posting:</strong><br />
Several commenters have (rightly) pointed out that this code is better written thusly:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Return an array of titles</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">def</span> all_titles<span style="color:#006600; font-weight:bold;">&#40;</span>books<span style="color:#006600; font-weight:bold;">&#41;</span>
  books.<span style="color:#9900CC;">map</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&amp;</span>:name<span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Quite right guys.  Inject is still great in the right spots though, and it&#8217;s well worth your time to learn it.</p>
<hr /><strong>Not so good code:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"># app/views/books/index.html.erb
&nbsp;
<span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">for</span> book <span style="color:#9966CC; font-weight:bold;">in</span> <span style="color:#0066ff; font-weight:bold;">@books</span> <span style="color:#006600; font-weight:bold;">%&gt;</span>
  <span style="color:#006600; font-weight:bold;">&lt;%</span>= render <span style="color:#ff3333; font-weight:bold;">:partial</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'shared/book'</span>, <span style="color:#ff3333; font-weight:bold;">:locals</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:book</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> book <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#006600; font-weight:bold;">&lt;%</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p><strong>Why it&#8217;s not so good:</strong></p>
<p>You&#8217;re calling a partial on a collection of objects, passing each one in through a variable.  This idiom appears in Rails so frequently that a better syntax was created for it.</p>
<p><strong>Good code:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"># app/views/books/index.html.erb
&nbsp;
<span style="color:#006600; font-weight:bold;">&lt;%</span>= render <span style="color:#ff3333; font-weight:bold;">:partial</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'book'</span>, <span style="color:#ff3333; font-weight:bold;">:collection</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0066ff; font-weight:bold;">@books</span> <span style="color:#006600; font-weight:bold;">%&gt;</span></pre></div></div>

<p>Rails will render the partial once per item in @books.  Each item will be available in the variable &#8216;book&#8217; (this is the name of the partial, NOT the singularization of your collection&#8217;s name).</p>
<p><strong>Why it&#8217;s good:</strong></p>
<p>We&#8217;re being efficient by leveraging functionality that Rails already provides for us. This version makes its intention clearer: &#8220;I&#8217;m rendering a collection.&#8221;  The goal of the first version is less obvious, and takes longer to parse.</p>
<p>Similar to your &#8216;repeated code&#8217; alarm, you should have a &#8216;roughly a million programmers must have written these exact lines in the past&#8217; alarm.  When that one goes off, check the Rails API and browse some plugins.  Rails is great about providing you efficient ways to perform common tasks.</p>
<img src="http://feeds.feedburner.com/~r/Codeulate/~4/Ao2iG_1_pUM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codeulate.com/2009/06/good-and-not-so-good-rails-code/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://codeulate.com/2009/06/good-and-not-so-good-rails-code/</feedburner:origLink></item>
		<item>
		<title>Obama’s New Robots.txt</title>
		<link>http://feedproxy.google.com/~r/Codeulate/~3/dyDGLRv3mYk/</link>
		<comments>http://codeulate.com/2009/01/obamas-change-the-geek-version/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 19:12:38 +0000</pubDate>
		<dc:creator>Ben Orenstein</dc:creator>
				<category><![CDATA[general]]></category>

		<guid isPermaLink="false">http://codeulate.com/?p=24</guid>
		<description><![CDATA[Change is afoot&#8230;
Within a few moments of President Obama being sworn in, a new whitehouse.gov was revealed.  The new site looks great, and promises greater transparency about the actions of our President and government.
Along those lines, check out its robots.txt file, in entirety:
User-agent: *
Disallow: /includes/
Compare this to the robot.txt from Bush&#8217;s era, and I think [...]]]></description>
			<content:encoded><![CDATA[<p>Change is afoot&#8230;</p>
<p>Within a few moments of President Obama being sworn in, a new <a href="http://www.whitehouse.gov">whitehouse.gov</a> was revealed.  The new site looks great, and promises greater transparency about the actions of our President and government.</p>
<p>Along those lines, check out <a href="http://www.whitehouse.gov/robots.txt">its robots.txt file</a>, in entirety:</p>
<blockquote><p>User-agent: *<br />
Disallow: /includes/</p></blockquote>
<p><strong>Compare this to <a href="http://www.codeulate.com/misc/old-robots.txt">the robot.txt from Bush&#8217;s era</a></strong>, and I think you&#8217;ve got a lovely little microcosm; one that points to a hopeful, and open future.</p>
<img src="http://feeds.feedburner.com/~r/Codeulate/~4/dyDGLRv3mYk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codeulate.com/2009/01/obamas-change-the-geek-version/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		<feedburner:origLink>http://codeulate.com/2009/01/obamas-change-the-geek-version/</feedburner:origLink></item>
		<item>
		<title>How Unit Testing Could Have Saved Lives</title>
		<link>http://feedproxy.google.com/~r/Codeulate/~3/sjkJV37u380/</link>
		<comments>http://codeulate.com/2009/01/how-unit-testing-could-have-saved-lives/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 19:35:07 +0000</pubDate>
		<dc:creator>Ben Orenstein</dc:creator>
				<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://codeulate.com/?p=23</guid>
		<description><![CDATA[A recent article in The Independent describes a fascinating study.  Researchers found that forcing surgeons in a London hospital to implement a single new procedure caused the death rate after surgery to fall 47 percent.  Complications likewise fell by 36 percent.
These are enormous numbers:
Donald Berwick, the president of the US Institute for Healthcare Improvement, said [...]]]></description>
			<content:encoded><![CDATA[<p>A recent article in <a href="http://www.independent.co.uk/life-style/health-and-wellbeing/health-news/right-patient-right-limb-two-questions-that-have-almost-halved-death-rate-at-one-hospital-1366705.html">The Independent</a> describes a <a href="http://content.nejm.org/cgi/content/full/NEJMsa0810119">fascinating study</a>.  Researchers found that forcing surgeons in a London hospital to implement a single new procedure caused <strong>the death rate after surgery to fall 47 percent</strong>.  Complications likewise fell by 36 percent.</p>
<p>These are enormous numbers:</p>
<blockquote><p>Donald Berwick, the president of the US Institute for Healthcare Improvement, said of the innovation: &#8220;I cannot recall a clinical care innovation in the past 30 years that has shown results of [this] magnitude.&#8221;</p></blockquote>
<p>The change?  <strong>The surgeons were required to run through a simple checklist before and after every procedure.</strong></p>
<p>Now, <a href="http://www.who.int/patientsafety/safesurgery/tools_resources/SSSL_Checklist_finalJun08.pdf">this checklist</a> [pdf] is not lengthy.  In fact, it&#8217;s less than twenty questions.  Even more strikingly, <strong>the questions are not complicated</strong>: before administering anesthesia, has the patient confirmed his identity?  Does the patient have any known allergies?  Have we confirmed that this is the <em>right</em> foot?  I&#8217;d wager that the most common reaction of people seeing this checklist is &#8220;you mean these things weren&#8217;t being asked <em>already</em>?&#8221;</p>
<p>The thing is, these questions <em>were</em> already being asked.  The difference is that<strong> they weren&#8217;t being asked in systematic way</strong>.  Members of a surgical team assume that these obvious things have been checked <em>because</em> they&#8217;re so obvious.  &#8220;Of <em>course</em> this is the right patient.&#8221;  &#8220;Of <em>course </em>we asked if he&#8217;s allergic to the anesthetic.&#8221;  &#8220;Of <em>course</em> we marked the right limb for amputation.&#8221;</p>
<p>The problem is, these things are sometimes done incorrectly, or missed entirely.  Not often, not usually; just sometimes.  Forcing doctors and nurses to use the checklist caught these &#8220;sometimes&#8221; problems, and dramatically improved patient safety in the process.</p>
<p>From this study, we can draw the following conclusions:</p>
<ol>
<li>Even obvious errors are easy to commit, and once committed, can have terrible consequences.</li>
<li>Those who overlook these problems can be highly-trained and intelligent people.  It appears that you cannot out-train or out-brain our human tendency to err from time to time.</li>
<li>Instituting a rigorous system to check for errors lowers their occurrence dramatically, compared to existing processes that check for them informally.</li>
</ol>
<p>Laid out this way, these statements are probably starting to look familiar, because <strong>they are exactly like the arguments for using unit tests in programming</strong>.  As a software developer, I look at this list and think <em>we knew this stuff already</em>!  We knew it, and we came up with a way of mitigating the problems caused by our own flawed humanity.</p>
<p><strong>The errors that this checklist catches are the kind that kill people</strong>.  Thousands of people, every year.  If we, as an industry, had somehow conveyed the efficacy of systemic testing with the medical field, this checklist might have been implemented sooner, and lives could have been saved.</p>
<p>The fact that ideas like this don&#8217;t flow across fields is not surprising.  Industry-specific myopia reflects our human tendency to form into groups and <a href="http://query.nytimes.com/gst/fullpage.html?res=9C05E6D8113BF933A15757C0A9629C8B63&amp;sec=health&amp;spon=&amp;pagewanted=print">distrust outsiders</a>.  Despite this, I do believe it&#8217;s worth struggling against.  Perhaps the field of architecture could provide useful insights into the construction of software (<a href="http://www.codinghorror.com/blog/archives/001003.html">perhaps it already has</a>).  Maybe the next big idea in architecture will be inpsired <a href="http://blog.futurelab.net/2007/08/chemistry_as_architecture.html">by chemistry</a>, or <a href="http://zeta.math.utsa.edu/~yxk833/pinker.html">biology</a>.  Maybe the next time I open my editor I should think &#8220;<a href="http://en.wikipedia.org/wiki/Primum_non_nocere">first, do no harm</a>.&#8221;</p>
<p>It certainly couldn&#8217;t hurt.</p>
<img src="http://feeds.feedburner.com/~r/Codeulate/~4/sjkJV37u380" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codeulate.com/2009/01/how-unit-testing-could-have-saved-lives/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://codeulate.com/2009/01/how-unit-testing-could-have-saved-lives/</feedburner:origLink></item>
		<item>
		<title>Damn Useful: When You Forget to type Sudo</title>
		<link>http://feedproxy.google.com/~r/Codeulate/~3/qecywWsv1Gs/</link>
		<comments>http://codeulate.com/2008/12/damn-useful-1-you-forgot-to-type-sudo/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 16:12:20 +0000</pubDate>
		<dc:creator>Ben Orenstein</dc:creator>
				<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://codeulate.com/?p=22</guid>
		<description><![CDATA[
(This post is part of a series.  To read more tips and to learn about the philosophy behind these posts, check out the parent post.)
You know you&#8217;ve done this way too many times:
ben@lispclub ~ $ apt-get install blahblahblah
E: Could not open lock file /var/lib/dpkg/lock &#8211; open (13 Permission denied)
E: Unable to lock the administration directory [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://imgs.xkcd.com/comics/sandwich.png" width="360" align="middle" height="299" hspace="105" /></p>
<h2>(This post is part of a series.  To read more tips and to learn about the philosophy behind these posts, check out the <a href="http://codeulate.com/?p=21">parent post</a>.)</h2>
<p>You know you&#8217;ve done this way too many times:</p>
<p>ben@lispclub ~ $<strong> apt-get install blahblahblah<br />
</strong>E: Could not open lock file /var/lib/dpkg/lock &#8211; open (13 Permission denied)<br />
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?</p>
<p>Bah.</p>
<h2><strong>You forgot to type sudo first</strong>.</h2>
<p>So what do you do?  Hit up arrow, swing back to the beginning of the line, type sudo&#8211;ARGGH&#8230;THE WASTED SECONDS!</p>
<h2><strong>Do this instead: </strong><strong>sudo !!</strong></h2>
<p>In bash, !! means &#8220;repeat the last command I entered.&#8221;  Bash substitutes your apt-get command after the sudo, and you finally get to install blahblahblah 0.0.13.  Note that this isn&#8217;t specific to sudo.  If you do an ls, and then wish you&#8217;d grepped the results for foo, type !! | grep foo.</p>
<h2><strong>How to remember it: </strong></h2>
<p>Imagine an angry father yelling for his son.  &#8220;Sudo!!&#8221;  Sudo runs down from his room, sees the command  he was supposed to be in front of, and executes it immediately.</p>
<img src="http://feeds.feedburner.com/~r/Codeulate/~4/qecywWsv1Gs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codeulate.com/2008/12/damn-useful-1-you-forgot-to-type-sudo/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		<feedburner:origLink>http://codeulate.com/2008/12/damn-useful-1-you-forgot-to-type-sudo/</feedburner:origLink></item>
		<item>
		<title>Damn Useful Tips</title>
		<link>http://feedproxy.google.com/~r/Codeulate/~3/YxL89LWFzaI/</link>
		<comments>http://codeulate.com/2008/12/damn-useful-tips/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 16:11:57 +0000</pubDate>
		<dc:creator>Ben Orenstein</dc:creator>
				<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://codeulate.com/?p=21</guid>
		<description><![CDATA[   This post is the first in a series called Damn Useful.  The posts will be a number of tips on the tools we use most frequently as programmers, particularly the shell and editor.  Because of my own preferences, I&#8217;ll focus on bash, vim, and unix tools like grep, screen, and others.
Here are [...]]]></description>
			<content:encoded><![CDATA[<p>   This post is the first in a series called Damn Useful.  The posts will be a number of tips on the tools we use most frequently as programmers, particularly the shell and editor.  Because of my own preferences, I&#8217;ll focus on bash, vim, and unix tools like grep, screen, and others.</p>
<p>Here are some guidelines on what to expect:</p>
<p>1. <strong>One tip per post.</strong></p>
<p>I&#8217;m a sucker for productivity tips.  I&#8217;ve read dozens of articles with titles like &#8220;25 _____ Tips for Fun and Profit!&#8221;  I usually take away at most one useful tidbit from these articles.  A lot of good stuff gets lost in the tidal wave of new information.  This posts in this series will be short: one tip each.  I&#8217;ll focus on just one idea and move on.</p>
<p>2. <strong>I&#8217;ll provide mnemonics or imagery to aid recall.</strong></p>
<p>Can you name the nine planets in our solar system?  How about the order of arithmetic operations?</p>
<p>If you can, I bet you access a mnemonic you&#8217;ve learned for this purpose.  I use My Video Eye May Just Show Us Nine Planets, and Please Excuse My Dear Aunt Sally for these two.<strong><br />
</strong><br />
I&#8217;m never, EVER going to forget the names of the planets.  That mnemonic is in my brain for good.  I want the things you learn through this series to be the same way.  As such, I&#8217;ll try hard to come up with memorable mnemonics for them.  Sometimes mnemonics don&#8217;t make sense, and I&#8217;ll instead provide an image to think about that will hopefully stick in your mind.</p>
<p>3. <strong>The tips will involve tools programmers tend to use daily.</strong><br />
<strong><br />
</strong>The value of a tip is proportional the number of times a day you can use it.  These tips will probably only be worth a few seconds each on their own, so I want to be sure there&#8217;s a big fat multiplier next to each one.  I&#8217;ll be focusing on the heavy hitters in the programming world.</p>
<p><strong>The Posts:</strong></p>
<p><a href="http://codeulate.com/?p=22&amp;"><strong>When You Forget to type Sudo</strong></a></p>
<img src="http://feeds.feedburner.com/~r/Codeulate/~4/YxL89LWFzaI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://codeulate.com/2008/12/damn-useful-tips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://codeulate.com/2008/12/damn-useful-tips/</feedburner:origLink></item>
	</channel>
</rss>
