<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>ones zeros majors and minors</title>
 <link href="http://ozmm.org/atom.xml" rel="self"/>
 <link href="http://ozmm.org/"/>
 <updated>2012-06-26T19:31:33-07:00</updated>
 <id>http://ozmm.org/</id>
 <author>
   <name>Chris Wanstrath</name>
   <email>chris@ozmm.org</email>
 </author>

 
 <entry>
   <title>I Love Labels</title>
   <link href="http://ozmm.org/posts/i_love_labels.html"/>
   <updated>2010-08-11T00:00:00-07:00</updated>
   <id>http://ozmm.org//posts/i_love_labels</id>
   <content type="html">&lt;p&gt;I really love when checkbox labels are done properly.&lt;/p&gt;

&lt;p&gt;To see what I mean click on this checkbox's text label (&quot;Click Me!&quot;):&lt;/p&gt;

&lt;p&gt;&lt;input type=&quot;checkbox&quot;&gt; Click Me!&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;input type=&quot;checkbox&quot;&amp;gt; Click Me!
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Nothing happened, right? Right.&lt;/p&gt;

&lt;p&gt;Now click on this checkbox's text label:&lt;/p&gt;

&lt;p&gt;&lt;label&gt;&lt;input type=&quot;checkbox&quot;&gt; Click Me!&lt;/label&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;label&amp;gt;&amp;lt;input type=&quot;checkbox&quot;&amp;gt; Click Me!&amp;lt;/label&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Yep, awesome. Here's another way to do it (in case your &lt;code&gt;&amp;lt;label&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt; tags are far apart):&lt;/p&gt;

&lt;p&gt;&lt;input type=&quot;checkbox&quot; id=&quot;ckbx&quot;&gt; &lt;label for=&quot;ckbx&quot;&gt;Click Me!&lt;/label&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;input type=&quot;checkbox&quot; id=&quot;ckbx&quot;&amp;gt; &amp;lt;label for=ckbx&quot;&amp;gt;Click Me!&amp;lt;/label&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
</content>
 </entry>
 
 <entry>
   <title>do it like rake</title>
   <link href="http://ozmm.org/posts/do_it_like_rake.html"/>
   <updated>2010-07-22T00:00:00-07:00</updated>
   <id>http://ozmm.org//posts/do_it_like_rake</id>
   <content type="html">&lt;p&gt;If you must require RubyGems in your Ruby library, do it like &lt;a href=&quot;http://github.com/jimweirich/rake/blob/0df4b81b/bin/rake#L25-30&quot;&gt;Rake&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;k&quot;&gt;begin&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;rake&amp;#39;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;rescue&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;LoadError&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;rubygems&amp;#39;&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&amp;#39;rake&amp;#39;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Everyone wins.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Managing Expectations</title>
   <link href="http://ozmm.org/posts/managing_expectations.html"/>
   <updated>2010-07-21T00:00:00-07:00</updated>
   <id>http://ozmm.org//posts/managing_expectations</id>
   <content type="html">&lt;p&gt;If you look on Cultured Code's &lt;a href=&quot;http://culturedcode.com/status&quot;&gt;Arrivals&lt;/a&gt; page, you'll see something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://culturedcode.com/status&quot;&gt;&lt;img src=&quot;http://img.skitch.com/20100722-kj1sch8merei1j5ncw2dn6iue6.png&quot; alt=&quot;Things' Arrivals Board&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a very tempting thing for small companies to do. You want your customers to know that you're working on something they want.&lt;/p&gt;

&lt;p&gt;But ultimately, it's a bad idea. When Cloud Sync launches, I'll think, &quot;Finally.&quot; If I didn't &lt;em&gt;know&lt;/em&gt; they were working on it, I'd think, &quot;Oh, Cloud Sync! Finally! Sweet!&quot;&lt;/p&gt;

&lt;p&gt;That is, when it's released my thoughts will focus on how long it's been on their Arrivals board. I won't think about all the awesome stuff they released in the meantime, some of which may have been more valuable than Cloud Sync.&lt;/p&gt;

&lt;p&gt;Under promise, over deliver.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Slightly Obtrusive JavaScript</title>
   <link href="http://ozmm.org/posts/slightly_obtrusive_javascript.html"/>
   <updated>2010-05-31T00:00:00-07:00</updated>
   <id>http://ozmm.org//posts/slightly_obtrusive_javascript</id>
   <content type="html">&lt;p&gt;There are good things and bad things about &quot;Unobtrustive JavaScript.&quot;
One bad thing: it's hard to tell what JavaScript is touching an
element.&lt;/p&gt;

&lt;p&gt;Idea: Only ever use classes and ids prefix with &lt;code&gt;js-&lt;/code&gt; when touching
the DOM with JavaScript.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;a href=&quot;#prices class=&quot;js-open-tab&quot;&amp;gt;Prices&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now we know to look for any JavaScript touching &lt;code&gt;.js-open-tab&lt;/code&gt;, which
should only be a simple search away.&lt;/p&gt;

&lt;p&gt;And hey, now JavaScript and CSS won't share selectors. Since we're
separating our content and presentation, we might as well separate our
behavior all the way too.&lt;/p&gt;

&lt;p&gt;We could also use &lt;a href=&quot;http://firequery.binaryage.com/&quot;&gt;FireQuery&lt;/a&gt;, though it only works with one JavaScript
library in one browser, and not with &lt;code&gt;$.fn.live()&lt;/code&gt;. Though I do love
it.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Higher Order Mustache</title>
   <link href="http://ozmm.org/posts/higher_order_mustache.html"/>
   <updated>2010-04-27T00:00:00-07:00</updated>
   <id>http://ozmm.org//posts/higher_order_mustache</id>
   <content type="html">&lt;p&gt;On the GitHub East Coast tour a few weeks ago Tom Preston-Werner and I were trying to figure out a solution to what I saw as the Final Mustache Problem: caching.&lt;/p&gt;

&lt;p&gt;In ERB you might do this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;% cache &quot;user:#{current_user.id}&quot; do %&amp;gt;
  Some expensive stuff.
&amp;lt;% end %&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;At GitHub we do a fair amount of HTML caching this way. Without this feature, we couldn't start porting the site to Mustache. Solving this problem would probably let us implement syntax highlighting and other similar concepts in Mustache, too.&lt;/p&gt;

&lt;p&gt;Here's what we got: Higher Order Sections.&lt;/p&gt;

&lt;script src=&quot;http://gist.github.com/381731.js?file=gistfile1.txt&quot;&gt;&lt;/script&gt;


&lt;p&gt;&lt;noscript&gt;&lt;pre&gt;
  Some expensive stuff.
&lt;/pre&gt;&lt;/noscript&gt;&lt;/p&gt;

&lt;p&gt;How? If the value of &lt;code&gt;cache_by_user_id&lt;/code&gt; is a lambda or function, Mustache will pass the unrendered block of text to it. The block can then do whatever it wants and its return value replaces the block.&lt;/p&gt;

&lt;p&gt;Here's how we might do caching in Ruby:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MyView&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Mustache&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;cache_by_user_id&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;lambda&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;cache_key&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&amp;quot;user:&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;current_user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&amp;quot;&lt;/span&gt;

      &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;vg&quot;&gt;$cache&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cache_key&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;rendered&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;render&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;text&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;vg&quot;&gt;$cache&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cache_key&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rendered&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;rendered&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;The &lt;code&gt;lambda&lt;/code&gt; is passed the raw template text. If we find something in the cache, we return that and it replaces the block. If we don't find anything in the cache we render the block, store it in the cache, then return it.&lt;/p&gt;

&lt;h3&gt;Examples&lt;/h3&gt;

&lt;p&gt;I opened sourced the &lt;a href=&quot;http://github.com/defunkt/mustache-syntax-highlighter&quot;&gt;mustache-syntax-highlighter&lt;/a&gt; recently, and also created &lt;a href=&quot;http://gist.github.com/381430&quot;&gt;a Gist&lt;/a&gt; of a Markdown helper we're using. Both are Higher Order Sections in action.&lt;/p&gt;

&lt;p&gt;Bonus: both &lt;a href=&quot;http://github.com/defunkt/mustache&quot;&gt;mustache.rb&lt;/a&gt; and &lt;a href=&quot;http://github.com/janl/mustache.js&quot;&gt;mustache.js&lt;/a&gt; already support this feature.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>JavaScript Style</title>
   <link href="http://ozmm.org/posts/javascript_style.html"/>
   <updated>2010-04-01T00:00:00-07:00</updated>
   <id>http://ozmm.org//posts/javascript_style</id>
   <content type="html">&lt;p&gt;I know that when you write Ruby or Python, you use under_scored method
names and CamelCase class names. But JavaScript isn't Ruby or Python.&lt;/p&gt;

&lt;p&gt;Consider:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In browsers, all methods are camelCase.&lt;/li&gt;
&lt;li&gt;In node.js's standard library, all methods are camelCase.&lt;/li&gt;
&lt;li&gt;In commonjs, all methods are camelCase.&lt;/li&gt;
&lt;li&gt;In jQuery, all methods are camelCase.&lt;/li&gt;
&lt;li&gt;In MooTools, all methods are camelCase.&lt;/li&gt;
&lt;li&gt;In Prototype, all method are camelCase.&lt;/li&gt;
&lt;li&gt;In YUI, all method are camelCase.&lt;/li&gt;
&lt;li&gt;In JavaScript: The Good Parts, all methods are camelCase.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;I'm not saying you must write JavaScript a certain way. Do what makes
you the most comfortable, write code that is fun to write. But if
you're trying to figure out what everyone else is doing, they're doing
camelCase.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Mustache 0.9.0</title>
   <link href="http://ozmm.org/posts/mustache_0_9_0.html"/>
   <updated>2010-03-26T00:00:00-07:00</updated>
   <id>http://ozmm.org//posts/mustache_0_9_0</id>
   <content type="html">&lt;p&gt;I'm very happy to announce Mustache 0.9.0, probably the most major
release so far. Sinatra 1.0, new parser, bugfixes, and more!&lt;/p&gt;

&lt;p&gt;Grab it:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;gem install mustache
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Or check &lt;a href=&quot;http://defunkt.github.com/mustache/&quot;&gt;http://defunkt.github.com/mustache/&lt;/a&gt; for other
implementations.&lt;/p&gt;

&lt;h3&gt;Sinatra 1.0&lt;/h3&gt;

&lt;p&gt;The release of Sinatra 1.0 changed the way templates are rendered. As
such, previous versions of Mustache use an old API and won't work with
it.&lt;/p&gt;

&lt;p&gt;If you're upgrading from Mustache 0.7.0 or lower please note that the
settings have changed very slightly. &lt;a href=&quot;http://gist.github.com/345490&quot;&gt;This diff&lt;/a&gt; is an example of
one app I upgraded to Sinatra 1.0 + Mustache 0.9 -- pretty painless,
and the settings all have better names (finally).&lt;/p&gt;

&lt;p&gt;Anyway, Mustache 0.9.0 works great with Sinatra 1.0 and even provides
some big improvements:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Caching&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first time a Mustache template is rendered it is compiled into
pure Ruby and cached, even if there's no associated view
class. Subsequent calls use the cached version which completely
bypasses the parsing and generating stages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Overriding Content in Layouts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Previously there was no easy way to change the layout from a view
class. Take this &lt;code&gt;layout.mustache&lt;/code&gt;:&lt;/p&gt;

&lt;script src=&quot;http://gist.github.com/345524.js?file=gistfile1.txt&quot;&gt;&lt;/script&gt;


&lt;p&gt;And these views:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Layout&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Mustache&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;title&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&amp;quot;layout&amp;quot;&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Index&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Layout&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;title&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&amp;quot;index&amp;quot;&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;You'd expect it to work, and you'd hope it would work, but it would
not. Now it does. Just make sure your views inherit from your layout
and everything will be dandy.&lt;/p&gt;

&lt;h3&gt;Syntax Errors&lt;/h3&gt;

&lt;p&gt;More syntax errors are caught and the error messages are much more
helpful thanks to the new parser (more on that below).&lt;/p&gt;

&lt;p&gt;For example, here's a broken template:&lt;/p&gt;

&lt;script src=&quot;http://gist.github.com/345524.js?file=gistfile2.txt&quot;&gt;&lt;/script&gt;


&lt;p&gt;And here's what we get trying to tokenize it:&lt;/p&gt;

&lt;script src=&quot;http://gist.github.com/345524.js?file=gistfile3.txt&quot;&gt;&lt;/script&gt;


&lt;p&gt;Or take this broken template:&lt;/p&gt;

&lt;script src=&quot;http://gist.github.com/345524.js?file=gistfile4.txt&quot;&gt;&lt;/script&gt;


&lt;p&gt;Again, helpful output:&lt;/p&gt;

&lt;script src=&quot;http://gist.github.com/345524.js?file=gistfile5.txt&quot;&gt;&lt;/script&gt;


&lt;p&gt;Tag names are a bit more strict as they more closely resemble allowed
Ruby method names, with a few exceptions. If you have a big problem
with this please &lt;a href=&quot;http://github.com/defunkt/mustache/issues&quot;&gt;file an issue&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;New Parser&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://judofyr.net/&quot;&gt;Magnus Holm&lt;/a&gt; has once again torn Mustache's
parser apart and rebuilt it into something beautiful. This time it's
an entirely new scanner and generator.&lt;/p&gt;

&lt;p&gt;Mustache used to loop through a template looking for regular
expressions and building up a compiled Ruby string along the way. As a
result we had some obscure bugs in nested sections and whatnot. The
new parser uses Ruby's &lt;code&gt;StringScanner&lt;/code&gt; to intelligently build an array
of tokens from a string template.&lt;/p&gt;

&lt;p&gt;Using the &lt;code&gt;mustache&lt;/code&gt; command line utility we can see exactly what
&lt;code&gt;Mustache::Parser&lt;/code&gt; returns for a given template:&lt;/p&gt;

&lt;script src=&quot;http://gist.github.com/345524.js?file=gistfile6.txt&quot;&gt;&lt;/script&gt;


&lt;p&gt;Pretty neat. Internally this token stream is handed to
&lt;code&gt;Mustache::Generator&lt;/code&gt; who compiles it into a Ruby string:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ mustache -c hi.mustache
&quot;#{if v = ctx[:greet?]
    if v == true
      &quot;Hello #{CGI.escapeHTML(ctx[:name].to_s)}!&quot;
    else
      v = [v] unless v.is_a?(Array) # shortcut when passed non-array
      v.map { |h|
        ctx.push(h)
        r = &quot;Hello #{CGI.escapeHTML(ctx[:name].to_s)}!&quot;
        ctx.pop
        r }.join
    end
  end}&quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This compiled string is the actual code run in your app to produce
HTML output. Fun to look at but mostly useless unless you're familiar
with Mustache's internals.&lt;/p&gt;

&lt;h3&gt;Bugfixes&lt;/h3&gt;

&lt;p&gt;Recursive partials, nested sections with names matching outer
sections, and other bugs are now fixed. Many bugs were fixed by the
new parser.&lt;/p&gt;

&lt;h3&gt;Speedup&lt;/h3&gt;

&lt;p&gt;When we started to allow Ruby objects to server as section contexts,
the implementation slowed down Mustache dramatically. That's been
fixed and things are (when compiled and cached) once again speedy.&lt;/p&gt;

&lt;h3&gt;Mustache 1.0&lt;/h3&gt;

&lt;p&gt;This release would be 1.0 but there's no Rails integration. That's
next on the list - see you then.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>ARGF</title>
   <link href="http://ozmm.org/posts/argf.html"/>
   <updated>2010-03-13T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/argf</id>
   <content type="html">&lt;p&gt;Today Ruby gave me a birthday present: &lt;code&gt;ARGF&lt;/code&gt;. If you write a lot of
shell scripts you're gonna love it.&lt;/p&gt;

&lt;p&gt;To demonstrate we'll write &lt;code&gt;rcat&lt;/code&gt;, a dumbed down version of &lt;code&gt;cat&lt;/code&gt;(1),
in Ruby. But first let's examine some of &lt;code&gt;cat&lt;/code&gt;'s basic functionality
using &lt;code&gt;one.txt&lt;/code&gt; and &lt;code&gt;two.txt&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ echo 'File one!' &amp;gt; one.txt
$ echo 'File two :(' &amp;gt; two.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Printing a single file:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ cat one.txt
File one!
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Printing multiple files:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ cat one.txt two.txt
File one!
File two :(
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Mixing files and streams:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ cat - two.txt &amp;lt; one.txt
File one!
File two :(
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Okay. And &lt;code&gt;rcat&lt;/code&gt;?&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ rcat one.txt
File one!

$ rcat one.txt two.txt
File one!
File two :(

$ rcat - two.txt &amp;lt; one.txt
File one!
File two :(
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Great! So, how's &lt;code&gt;rcat&lt;/code&gt; work?&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ rcat rcat
#!/usr/bin/env ruby
puts ARGF.read
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Gorgeous. From the docs:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;The global constant &lt;code&gt;ARGF&lt;/code&gt; (also accessible as &lt;code&gt;$&amp;lt;&lt;/code&gt;) provides an
IO-like stream which allows access to all files mentioned on the
command line (or STDIN if no files are mentioned). &lt;code&gt;ARGF&lt;/code&gt; provides
the methods &lt;code&gt;#path&lt;/code&gt; and &lt;code&gt;#filename&lt;/code&gt; to access the name of the file
currently being read.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;I've just &lt;a href=&quot;http://github.com/defunkt/mustache/commit/c6cf8419aa&quot;&gt;rewritten&lt;/a&gt; &lt;code&gt;mustache&lt;/code&gt;(1) to use ARGF. Less code, more
functionality - what else could you want for your birthday? Thanks
Ruby!&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>gem man fork</title>
   <link href="http://ozmm.org/posts/gem_man_fork.html"/>
   <updated>2010-03-11T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/gem_man_fork</id>
   <content type="html">&lt;p&gt;Want to install &lt;a href=&quot;http://defunkt.github.com/gem-man/&quot;&gt;&lt;code&gt;gem-man(1)&lt;/code&gt;&lt;/a&gt; and forget about it? You can. Add
this to your &lt;code&gt;~/.bash_profile&lt;/code&gt; or whatever after installing 0.2.0:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;alias man='gem man -s'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ man 5 mustache
$ man fork
$ man grep
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And, of course:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ man gem-man
&lt;/code&gt;&lt;/pre&gt;
</content>
 </entry>
 
 <entry>
   <title>man what</title>
   <link href="http://ozmm.org/posts/man_what.html"/>
   <updated>2010-03-08T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/man_what</id>
   <content type="html">&lt;p&gt;Everyone loves having instant access to documentation. This is one of
the things &lt;a href=&quot;http://cheat.errtheblog.com/&quot;&gt;Cheat&lt;/a&gt; does really well: just type &lt;code&gt;cheat git&lt;/code&gt; and
you've got a git cheat sheet in your terminal. Or in your editor,
whatever. It's cool stuff.&lt;/p&gt;

&lt;p&gt;Well, man pages do the same thing. For instance, I've installed
node.js via homebrew which means I can type &lt;code&gt;man node&lt;/code&gt; at any time to
see the docs to the entire node.js standard library. Seriously. Thanks
mxcl and ryah.&lt;/p&gt;

&lt;p&gt;In Emacs I can hit &lt;code&gt;M-x man&lt;/code&gt; to pull up any man page. Vim has &lt;a href=&quot;http://www.vim.org/scripts/script.php?script_id=489&quot;&gt;a
plugin&lt;/a&gt; and so does &lt;a href=&quot;http://jasonrudolph.com/blog/2008/03/14/manning-up-textmate-meets-man-pages/&quot;&gt;TextMate&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you're using a tool that came with your OS, you can bet there's a
man page for it. Unicorn has a great one, so does ack. And if you've
installed cmatrix, which I hope you have, it has one too.&lt;/p&gt;

&lt;p&gt;It's the way Unix documents things, and it's already really easy for
you to access. man pages are worth understanding.&lt;/p&gt;

&lt;h3&gt;What's a man page?&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Man_page&quot;&gt;Wikipedia&lt;/a&gt; says:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;Man pages (short for manual pages) are the extensive documentation
  that comes preinstalled with almost all substantial Unix and
  Unix-like operating systems. The Unix command used to display them
  is man. Each page is a self-contained document.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;You can see one by going to your terminal and typing:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ man grep
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Or, naturally, &lt;code&gt;man man&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;On some systems like Debian, every program is required to come with a
man page. I don't know if the same is true for OS X, but all the
Mac-specific commands I've used have man pages. For example:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ man pbcopy
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Same for &lt;code&gt;launchctl&lt;/code&gt;, &lt;code&gt;say&lt;/code&gt;, and more.&lt;/p&gt;

&lt;p&gt;Man pages are a great way to learn about a piece of software. Try &lt;code&gt;man
grep&lt;/code&gt; or check out &lt;code&gt;man strftime&lt;/code&gt;. Yes, C functions have man pages
too.&lt;/p&gt;

&lt;h3&gt;What do the sections mean?&lt;/h3&gt;

&lt;p&gt;man pages are broken into sections:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;General commands&lt;/li&gt;
&lt;li&gt;System calls&lt;/li&gt;
&lt;li&gt;C library functions&lt;/li&gt;
&lt;li&gt;Special files (usually devices, those found in /dev) and drivers&lt;/li&gt;
&lt;li&gt;File formats and conventions&lt;/li&gt;
&lt;li&gt;Games and screensavers&lt;/li&gt;
&lt;li&gt;Miscellanea&lt;/li&gt;
&lt;li&gt;System administration commands and daemons&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;This means we can have &lt;code&gt;markdown(1)&lt;/code&gt; and &lt;code&gt;markdown(5)&lt;/code&gt;, two man pages
with the same name that live in different sections. One is a man page
describing a command, typing &lt;code&gt;markdown&lt;/code&gt; in your shell, and one is a
man page describing the Markdown file format. Like what you'd read on
&lt;a href=&quot;http://daringfireball.net/projects/markdown/&quot;&gt;Gruber's Markdown page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can specify which you'd like to view like so:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ man 1 markdown
$ man 5 markdown
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;How do you find man pages?&lt;/h3&gt;

&lt;p&gt;You can use &lt;code&gt;apropos&lt;/code&gt; on many systems to search for man pages matching
a string:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ apropos ruby
macruby(1), ruby(1)      - Interpreted object-oriented scripting language
cap(1)                   - Ruby on Rails web applications deployment utility
gem(1)                   - RubyGems program
irb(1), erb(1), ri(1), rdoc(1), testrb(1) - Ruby helper programs
mongrel_rails(1)         - Fast HTTP library and server for Ruby
rake(1)                  - Ruby Make
ruby(1)                  - Interpreted object-oriented scripting
language
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;There are also at least five iPhone apps dedicated to man pages, all
of which cost money:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://img.skitch.com/20100309-ryw5trss5dgqfr7q5gbyush5aj.png&quot; alt=&quot;iPhone Man Pages&quot; /&gt;&lt;/p&gt;

&lt;p&gt;If you're using Ruby, you can discover man pages that RubyGems you've
installed contain by installing &lt;code&gt;gem-man&lt;/code&gt; and using &lt;code&gt;--all&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ gem install gem-man
$ gem man --all
These gems have man pages:

ronn 0.4.1
unicorn 0.97.0
unicorn 0.96.0
gem-man 0.1.3
mustache 0.6.0
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And then:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ gem man 1 mustache
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Sweet. There's also Richard Crowley's &lt;a href=&quot;http://github.com/rcrowley/home/commit/45eea3e25fbe19156a2c7597818f3980d16dd853&quot;&gt;alias man&lt;/a&gt; trick.&lt;/p&gt;

&lt;h3&gt;How do you write man pages?&lt;/h3&gt;

&lt;p&gt;man pages are written in a funky macro language as part of a
typesetting system called roff, which dates back to around 1973. That
is, according to &lt;code&gt;man roff&lt;/code&gt;. Anyway, it's nasty - you can look at
&lt;a href=&quot;http://github.com/defunkt/mustache/blob/30146e8d25/man/mustache.1&quot;&gt;mustache.1&lt;/a&gt; for an example. You don't wanna write it by hand.&lt;/p&gt;

&lt;p&gt;It's much easier to let a computer generate this markup for us, just
like how we let Markdown generate HTML. As far as I know there are two
excellent tools you can use to author man pages.&lt;/p&gt;

&lt;h3&gt;AsciiDoc&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://www.kernel.org/pub/software/scm/git-core/docs/&quot;&gt;Git&lt;/a&gt; and &lt;a href=&quot;http://unicorn.bogomips.org/unicorn_1.html&quot;&gt;Unicorn&lt;/a&gt; use &lt;a href=&quot;http://www.methods.co.nz/asciidoc/&quot;&gt;AsciiDoc&lt;/a&gt;. The &lt;a href=&quot;http://www.modrails.com/documentation/Users%20guide.html&quot;&gt;Passenger&lt;/a&gt;
guys do, too. It can generate both HTML and man pages from quite
readable text files.&lt;/p&gt;

&lt;p&gt;In fact, check this out: I grabbed ParseTree's spartan yet extremely
readable &lt;a href=&quot;http://github.com/seattlerb/parsetree/blob/a6e868b954/README.txt&quot;&gt;README.txt&lt;/a&gt; and ran it through &lt;code&gt;asciidoc&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://img.skitch.com/20100309-p4sxt2wjpxsbt4t5m77m8ihpsi.png&quot; alt=&quot;ParseTree
 README&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Tasty.&lt;/p&gt;

&lt;p&gt;You can grab AsciiDoc with:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ brew install asciidoc
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;or by any of the methods documented on their &lt;a href=&quot;http://www.methods.co.nz/asciidoc/INSTALL.html&quot;&gt;Installation page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It, naturally, has a man page: &lt;a href=&quot;http://www.methods.co.nz/asciidoc/manpage.html&quot;&gt;man asciidoc&lt;/a&gt; once you've got it
installed.&lt;/p&gt;

&lt;h3&gt;ronn&lt;/h3&gt;

&lt;p&gt;Personally, I like to use Ryan Tomayko's &lt;a href=&quot;http://rtomayko.github.com/ronn/&quot;&gt;ronn&lt;/a&gt;. If you have
RubyGems:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ gem install ronn
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now run it on any README.markdown. I'll try it on Resque's:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ ronn -b5 README.markdown
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src=&quot;http://img.skitch.com/20100309-dktmupdbyc5iqyxyn6t3sar6ye.png&quot; alt=&quot;Resque
 README&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Gorgeous.&lt;/p&gt;

&lt;p&gt;It looks even better when passed something in the Markdown derived
&lt;a href=&quot;http://rtomayko.github.com/ronn/ronn.5.html&quot;&gt;ronn(5)&lt;/a&gt; format:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://defunkt.github.com/mustache/mustache.1.html&quot;&gt;&lt;img src=&quot;http://img.skitch.com/20100309-d97sww5ef337yt4ngxgxwr1i7s.png&quot; alt=&quot;Mustache
docs&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here are some I've published:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://defunkt.github.com/mustache/mustache.1.html&quot;&gt;mustache(1)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://defunkt.github.com/mustache/mustache.5.html&quot;&gt;mustache(5)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://defunkt.github.com/hub/hub.1.html&quot;&gt;hub(1)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://defunkt.github.com/gem-man/&quot;&gt;gem-man(1)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://defunkt.github.com/gist/&quot;&gt;gist(1)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Others&lt;/h3&gt;

&lt;p&gt;Perl has &lt;a href=&quot;http://perldoc.perl.org/perlpod.html&quot;&gt;Pod&lt;/a&gt; - I can &lt;code&gt;man Apache2::Const&lt;/code&gt; and see a different
yet familiar face, presumably a man page generated by &lt;code&gt;pod2man&lt;/code&gt;, which
is neat.&lt;/p&gt;

&lt;p&gt;Ruby also has &lt;a href=&quot;http://github.com/michaeledgar/rtfm&quot;&gt;rtfm&lt;/a&gt;, a gem for building man pages in
Ruby.&lt;/p&gt;

&lt;p&gt;Then there's &lt;a href=&quot;http://www.stack.nl/~dimitri/doxygen/&quot;&gt;Doxygen&lt;/a&gt;, and probably many more.&lt;/p&gt;

&lt;h3&gt;How do you publish man pages?&lt;/h3&gt;

&lt;p&gt;For generating them, I use &lt;a href=&quot;http://github.com/defunkt/hub/blob/master/Rakefile#L26-34&quot;&gt;these rake tasks&lt;/a&gt;. You might also want to
look at Richard Crowley's &lt;a href=&quot;http://github.com/rcrowley/manskeleton&quot;&gt;manskeleton&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For HTML I like to use &lt;a href=&quot;http://pages.github.com/&quot;&gt;GitHub Pages&lt;/a&gt;. It's pretty easy to write a
&lt;a href=&quot;http://github.com/defunkt/hub/blob/72c047d305/Rakefile#L111-123&quot;&gt;Rake task&lt;/a&gt; or something that generates a man page's HTML and
publishes it to your &lt;code&gt;gh-pages&lt;/code&gt; branch. I pretty much do it in all my
projects - I'm sure many others do the same.&lt;/p&gt;

&lt;p&gt;Many packaging systems support files in &lt;code&gt;man/file.section&lt;/code&gt; or
&lt;code&gt;man/manSECTION/file.SECTION&lt;/code&gt; format. For example, &lt;a href=&quot;http://github.com/rcrowley/manskeleton/tree/a76bfb23a5/man/man1/&quot;&gt;manskeleton's man
pages&lt;/a&gt; or &lt;a href=&quot;http://github.com/defunkt/mustache/tree/60fa264c54/man&quot;&gt;mustache's&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;When you install a Debian or homebrew package, any man pages get
installed automatically. This means if you package man pages users
will magically get them, and everyone wins.&lt;/p&gt;

&lt;p&gt;So let's do that.&lt;/p&gt;

&lt;h3&gt;Manuals of Interest&lt;/h3&gt;

&lt;p&gt;Finally, some manuals of interest:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;man fork&lt;/li&gt;
&lt;li&gt;man bash&lt;/li&gt;
&lt;li&gt;man zsh&lt;/li&gt;
&lt;li&gt;man curl&lt;/li&gt;
&lt;li&gt;man httpd&lt;/li&gt;
&lt;li&gt;man 5 crontab&lt;/li&gt;
&lt;li&gt;man netcat&lt;/li&gt;
&lt;li&gt;man gist&lt;/li&gt;
&lt;li&gt;man hub&lt;/li&gt;
&lt;li&gt;man git-rebase&lt;/li&gt;
&lt;li&gt;gem man 7 ronn&lt;/li&gt;
&lt;li&gt;gem man unicorn&lt;/li&gt;
&lt;/ul&gt;

</content>
 </entry>
 
 <entry>
   <title>coffee-mode</title>
   <link href="http://ozmm.org/posts/coffee_mode.html"/>
   <updated>2010-03-07T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/coffee_mode</id>
   <content type="html">&lt;p&gt;I've fallen in love with &lt;a href=&quot;http://jashkenas.github.com/coffee-script/&quot;&gt;CoffeeScript&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It's the best parts of my three favorite languages (JavaScript, Ruby,
and Python) rolled into one. It runs on node.js, compiles to
surprisingly readable JavaScript, has great documentation, and is
written in itself.&lt;/p&gt;

&lt;p&gt;Yes, CoffeeScript is written in CoffeeScript. Check the &lt;a href=&quot;http://github.com/jashkenas/coffee-script/tree/master/src/&quot;&gt;source
code&lt;/a&gt; or the beautiful &lt;a href=&quot;http://jashkenas.github.com/coffee-script/documentation/docs/grammar.html&quot;&gt;internals documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can use it on the server with node.js (or, presumably, any
CommonJS compatible process), or you can use it in the browser.&lt;/p&gt;

&lt;p&gt;Deployment? When you bundle your JavaScript, compile your CoffeeScript
and include it. In development mode use something like
&lt;a href=&quot;http://github.com/mattly/rack-coffee&quot;&gt;rack-coffee&lt;/a&gt; to have your CoffeeScript automatically compiled and
served to the browser - no work on your part.&lt;/p&gt;

&lt;p&gt;There's a &lt;a href=&quot;http://github.com/jashkenas/coffee-script/blob/master/extras/coffee.vim&quot;&gt;Vim plugin&lt;/a&gt;, a &lt;a href=&quot;http://github.com/jashkenas/coffee-script/tree/master/extras/CoffeeScript.tmbundle/&quot;&gt;TextMate bundle&lt;/a&gt;, and, now, an
&lt;a href=&quot;http://github.com/defunkt/coffee-mode&quot;&gt;Emacs mode&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Say hello to &lt;code&gt;coffee-mode&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;coffee-mode: An Emacs major mode for CoffeeScript.&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;http://img.skitch.com/20100308-fcr622c95ibey4m474d5m1m1qt.png&quot; alt=&quot;Screenshot&quot; /&gt;&lt;/p&gt;

&lt;p&gt;It does all the things you want it to.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Syntax Highlighting&lt;/li&gt;
&lt;li&gt;imenu support (for ⇧⌘T in &lt;a href=&quot;http://github.com/defunkt/textmate.el&quot;&gt;textmate.el&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;customize-group&lt;/code&gt; support&lt;/li&gt;
&lt;li&gt;Comment support (&lt;code&gt;alt-;&lt;/code&gt; and ⌘; for me)&lt;/li&gt;
&lt;li&gt;Indentation using &lt;code&gt;tab-width&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&quot;Smart&quot; indentation (e.g. hitting &lt;code&gt;RET&lt;/code&gt; after a &lt;code&gt;-&amp;gt;&lt;/code&gt; will indent you
properly)&lt;/li&gt;
&lt;li&gt;Menu Bar with links to the documentation for CoffeeScript and node.js.&lt;/li&gt;
&lt;li&gt;Compiles CoffeeScript&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;A Note on Compilation&lt;/h3&gt;

&lt;p&gt;If you're using Aquamacs, ⌘r should compile the current &lt;code&gt;coffee-mode&lt;/code&gt;
buffer and open the resulting JavaScript in a new buffer using
&lt;code&gt;js2-mode&lt;/code&gt;. You can customize the mode used to open JavaScript by
overriding &lt;code&gt;coffee-js-mode&lt;/code&gt; and you can override the key combo by
adding this to the &lt;code&gt;coffee-mode-hook&lt;/code&gt; like so:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;scheme&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;defun&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;coffee-custom&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
  &lt;span class=&quot;s&quot;&gt;&amp;quot;coffee-mode-hook&amp;quot;&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;;; Emacs key binding&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;define-key&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;coffee-mode-map&lt;/span&gt; &lt;span class=&quot;err&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;meta&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;&amp;#39;coffee-compile-buffer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;

&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;add-hook&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;&amp;#39;coffee-mode-hook&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;lambda &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;coffee-custom&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Make sure you have CoffeeScript 0.5.4 or higher, or change your
&lt;code&gt;coffee-command&lt;/code&gt; and &lt;code&gt;coffee-args-compile&lt;/code&gt; variables to whatever you
know works.&lt;/p&gt;

&lt;p&gt;Why is this worth pointing out? Because it means you can hit a single
key and see the compiled JavaScript in your editor, which is just
great:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://img.skitch.com/20100308-cre5adxgq9x35icju1kqtggg9e.png&quot; alt=&quot;Compiled Output&quot; /&gt;&lt;/p&gt;

&lt;h3&gt;Installation&lt;/h3&gt;

&lt;p&gt;In your shell:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ cd ~/.emacs.d/vendor
$ git clone git://github.com/defunkt/coffee-mode.git
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In your emacs config:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;scheme&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;add-to-list&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;&amp;#39;load-path&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&amp;quot;~/.emacs.d/vendor/coffee-mode&amp;quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;&amp;#39;coffee-mode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;If &lt;code&gt;coffee-mode&lt;/code&gt; is not enabled automatically for any files ending in
&quot;.coffee&quot; or named &quot;Cakefile&quot;, add this to your emacs config as well:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;scheme&quot;&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;add-to-list&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;&amp;#39;auto-mode-alist&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;\\.coffee$&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;coffee-mode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;add-to-list&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;&amp;#39;auto-mode-alist&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;#39;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&amp;quot;Cakefile&amp;quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;coffee-mode&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Bugs &lt;a href=&quot;http://github.com/defunkt/coffee-mode/issues&quot;&gt;http://github.com/defunkt/coffee-mode/issues&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Source &lt;a href=&quot;http://github.com/defunkt/coffee-mode&quot;&gt;http://github.com/defunkt/coffee-mode&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enjoy.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Code Bloggin' at Gist</title>
   <link href="http://ozmm.org/posts/code_bloggin__at_gist.html"/>
   <updated>2010-03-01T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/code_bloggin__at_gist</id>
   <content type="html">&lt;p&gt;&lt;a href=&quot;http://gist.github.com/defunkt&quot;&gt;http://gist.github.com/defunkt&lt;/a&gt;, in case you missed it.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>gist(1)</title>
   <link href="http://ozmm.org/posts/gist_1.html"/>
   <updated>2010-02-28T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/gist_1</id>
   <content type="html">&lt;p&gt;I just updated the &lt;a href=&quot;http://github.com/defunkt/gist&quot;&gt;command line gist script&lt;/a&gt; with a few patches,
cleaner code, a RubyGem, and a man page. The updated version should
hit &lt;a href=&quot;http://github.com/mxcl/homebrew&quot;&gt;homebrew&lt;/a&gt; soon, too.&lt;/p&gt;

&lt;p&gt;In a nutshell:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ gem install gist
$ gist -h
$ gist -m
$ gist script.py
$ echo &quot;puts :hi&quot; | gist -t rb
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Enjoy.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Load Paths</title>
   <link href="http://ozmm.org/posts/python_and_ruby_load_paths.html"/>
   <updated>2010-02-19T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/python_and_ruby_load_paths</id>
   <content type="html">&lt;p&gt;If your &lt;code&gt;import&lt;/code&gt; is failing in Python or your &lt;code&gt;require&lt;/code&gt; can't locate a
Ruby file, here is how to find the load path in each language:&lt;/p&gt;

&lt;p&gt;Python:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ python
&amp;gt;&amp;gt;&amp;gt; import sys
&amp;gt;&amp;gt;&amp;gt; sys.path
['', '/usr/lib/python2.5', '/usr/lib/python2. ...]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Ruby:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ irb
&amp;gt;&amp;gt; $LOAD_PATH
=&amp;gt; [&quot;/usr/local/lib/site_ruby/1.8&quot;, &quot;/usr/local ...]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;These should help you debug load errors, especially if you're new to
either language.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>hub + zsh</title>
   <link href="http://ozmm.org/posts/hub___zsh.html"/>
   <updated>2010-02-17T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/hub___zsh</id>
   <content type="html">&lt;p&gt;&lt;a href=&quot;http://github.com/defunkt/hub&quot;&gt;hub&lt;/a&gt; never seemed to play nicely with git's autocompletion in
zshell. Until now.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ resque git:(master) git log v0.2.0
v0.1.0  [v0.2.0]  v1.0.0  v1.1.0  v1.2.0  v1.2.1  v1.2.2  v1.2.3
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;How? After &lt;a href=&quot;http://defunkt.github.com/hub/&quot;&gt;installing hub&lt;/a&gt; just run this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ hub alias -s zsh &amp;gt;&amp;gt; ~/.zshrc
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Of course, you can always use &lt;code&gt;hub&lt;/code&gt; without aliasing it to &lt;code&gt;git&lt;/code&gt;. But
what fun is that?&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Pystache 0.2.0</title>
   <link href="http://ozmm.org/posts/pystache_0_2_0.html"/>
   <updated>2010-02-15T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/pystache_0_2_0</id>
   <content type="html">&lt;p&gt;I just pushed &lt;a href=&quot;http://pypi.python.org/pypi/pystache/0.2.0&quot;&gt;Pystache 0.2.0&lt;/a&gt; to Pypi.&lt;/p&gt;

&lt;p&gt;Check the &lt;a href=&quot;http://github.com/defunkt/pystache/compare/v0.1.0...v0.2.0&quot;&gt;compare view&lt;/a&gt; for changes.&lt;/p&gt;

&lt;p&gt;I hope to have a language agnostic &quot;Mustache Guide&quot; ready in the next
few weeks. Keep an eye out!&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>hub updater</title>
   <link href="http://ozmm.org/posts/hub_updater.html"/>
   <updated>2010-02-13T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/hub_updater</id>
   <content type="html">&lt;p&gt;&lt;a href=&quot;http://github.com/defunkt/hub/blob/v0.3.1/HISTORY.md&quot;&gt;Hub 0.3.1&lt;/a&gt;
is out. Grab it with &lt;code&gt;hub-update&lt;/code&gt;:&lt;/p&gt;

&lt;script
src=&quot;http://gist.github.com/303368.js?file=hub-update&quot;&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;pre&gt;#!/bin/sh
# Updates hub!
HUBPATH=~/bin/hub

curl -s http://defunkt.github.com/hub/standalone &gt; $HUBPATH
hub version&lt;/pre&gt;&lt;/noscript&gt;

</content>
 </entry>
 
 <entry>
   <title>Haml + Mustache</title>
   <link href="http://ozmm.org/posts/haml___mustache.html"/>
   <updated>2010-02-12T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/haml___mustache</id>
   <content type="html">&lt;p&gt;Haml and Mustache are friends, not enemies.&lt;/p&gt;

&lt;p&gt;See for yourself.&lt;/p&gt;

&lt;h3&gt;example.yml&lt;/h3&gt;

&lt;script src=&quot;http://gist.github.com/303039.js?file=example.yml&quot;&gt;&lt;/script&gt;


&lt;p&gt;&lt;noscript&gt;&lt;pre&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;---
users:
  - { user: chris }
  - { user: bob }
  - { user: jones }
---
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;/pre&gt;&lt;/noscript&gt;&lt;/p&gt;

&lt;h3&gt;example.haml.mustache&lt;/h3&gt;

&lt;script src=&quot;http://gist.github.com/303039.js?file=example.haml.mustache&quot;&gt;&lt;/script&gt;


&lt;p&gt;&lt;noscript&gt;&lt;pre&gt;&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#content
  .left.column
    %h2 Welcome to our site!
  .right.column
    #users

        %p 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;/pre&gt;&lt;/noscript&gt;&lt;/p&gt;

&lt;p&gt;This is nothing new. We've covered the &lt;code&gt;mustache&lt;/code&gt; command line utility
&lt;a href=&quot;http://ozmm.org/posts/static_sites_with_mustache.html&quot;&gt;before&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;What's new is using Mustache to generate Haml, then generating HTML
from that Haml:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ cat example.yml example.haml.mustache | mustache | haml -s
&amp;lt;div id='content'&amp;gt;
  &amp;lt;div class='left column'&amp;gt;
    &amp;lt;h2&amp;gt;Welcome to our site!&amp;lt;/h2&amp;gt;
  &amp;lt;/div&amp;gt;
  &amp;lt;div class='right column'&amp;gt;
    &amp;lt;div id='users'&amp;gt;
      &amp;lt;p&amp;gt;chris&amp;lt;/p&amp;gt;
      &amp;lt;p&amp;gt;bob&amp;lt;/p&amp;gt;
      &amp;lt;p&amp;gt;jones&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;a href=&quot;http://gist.github.com/303039&quot;&gt;Hamstache&lt;/a&gt;.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Resque 1.4.0</title>
   <link href="http://ozmm.org/posts/resque_1_4_0.html"/>
   <updated>2010-02-11T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/resque_1_4_0</id>
   <content type="html">&lt;p&gt;From the &lt;a href=&quot;http://github.com/defunkt/resque/blob/v1.4.0/HISTORY.md&quot;&gt;HISTORY&lt;/a&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fallback when unable to bind QUIT and USR1 for Windows and JRuby.&lt;/li&gt;
&lt;li&gt;Fallback when no &lt;code&gt;Kernel.fork&lt;/code&gt; is provided (for IronRuby).&lt;/li&gt;
&lt;li&gt;Web: Rounded corners in Firefox&lt;/li&gt;
&lt;li&gt;Cut down system calls in &lt;code&gt;Worker#prune_dead_workers&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Enable switching DB in a Redis server from config&lt;/li&gt;
&lt;li&gt;Support USR2 and CONT to stop and start job processing.&lt;/li&gt;
&lt;li&gt;Web: Add example failing job&lt;/li&gt;
&lt;li&gt;Bugfix: &lt;code&gt;Worker#unregister_worker&lt;/code&gt; shouldn't call &lt;code&gt;done_working&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Bugfix: Example god config now restarts Resque properly.&lt;/li&gt;
&lt;li&gt;Multiple failure backends now permitted.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Check the &lt;a href=&quot;http://github.com/defunkt/resque/compare/v1.3.1...v1.4.0&quot;&gt;compare view&lt;/a&gt;, too.&lt;/p&gt;

&lt;p&gt;Upgrade:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ gem install resque
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Find Resque on &lt;a href=&quot;http://gemcutter.org/gems/resque&quot;&gt;Gemcutter&lt;/a&gt; and &lt;a href=&quot;http://github.com/defunkt/resque&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Gem Popularity</title>
   <link href="http://ozmm.org/posts/gem_popularity.html"/>
   <updated>2010-02-11T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/gem_popularity</id>
   <content type="html">&lt;p&gt;Ever wonder how popular a RubyGem is? &lt;a href=&quot;http://gemcutter.org/&quot;&gt;Gemcutter&lt;/a&gt; has the answer.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://gemcutter.org/gems/rails&quot;&gt;Rails&lt;/a&gt;: 323,229 downloads&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://gemcutter.org/gems/rspec&quot;&gt;rspec&lt;/a&gt;: 82,260 downloads&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://gemcutter.org/gems/god&quot;&gt;god&lt;/a&gt;: 13,577 downloads&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://gemcutter.org/gems/shoulda&quot;&gt;shoulda&lt;/a&gt;: 12,726 downloads&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://gemcutter.org/gems/mustache&quot;&gt;mustache&lt;/a&gt;: 2,690 downloads&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://gemcutter.org/gems/machinist&quot;&gt;machinist&lt;/a&gt;: 4,730 downloads&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://gemcutter.org/gems/delayed_job&quot;&gt;delayed_job&lt;/a&gt;: 5,787 downloads&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://gemcutter.org/gems/memcache-client&quot;&gt;memcache-client&lt;/a&gt;: 31,851 downloads&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://gemcutter.org/gems/rdiscount&quot;&gt;rdiscount&lt;/a&gt;: 8,441 downloads&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://gemcutter.org/gems/rack&quot;&gt;rack&lt;/a&gt;: 326,053 downloads&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://gemcutter.org/gems/sinatra&quot;&gt;sinatra&lt;/a&gt;: 33,722 downloads&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://gemcutter.org/gems/thin&quot;&gt;thin&lt;/a&gt;: 22,707 downloads&lt;/li&gt;
&lt;/ul&gt;

</content>
 </entry>
 
 <entry>
   <title>Jumpcut</title>
   <link href="http://ozmm.org/posts/jumpcut.html"/>
   <updated>2010-01-27T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/jumpcut</id>
   <content type="html">&lt;p&gt;I can't really imagine what life was like before &lt;a href=&quot;http://jumpcut.sourceforge.net/&quot;&gt;Jumpcut&lt;/a&gt;. If
you're not using clipboard history, try it - it's basically one key
command that will change the way you work.&lt;/p&gt;

&lt;p&gt;Even better: &lt;a href=&quot;http://www.obdev.at/products/launchbar/index.html&quot;&gt;Launchbar&lt;/a&gt; has a clipboard manager, too (which I
currently use).&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Hotkey Bookmarks</title>
   <link href="http://ozmm.org/posts/hotkey_bookmarks.html"/>
   <updated>2010-01-27T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/hotkey_bookmarks</id>
   <content type="html">&lt;p&gt;Since switching to Chrome the thing I've missed most is the ⌘# hotkeys
for bookmarks.&lt;/p&gt;

&lt;p&gt;In Safari you can hit &amp;#8984;1 to open the first bookmark in your bookmark
bar, &amp;#8984;2 to open the second, etc. This means you can keep your bookmark
bar closed and jump to any site whose number you know pretty
quickly. No clicking or extra UI required!&lt;/p&gt;

&lt;p&gt;In Chrome, &amp;#8984;N quickly switches you to the corresponding tab in the
active window. &lt;a href=&quot;http://twitter.com/pjhyett&quot;&gt;Some people&lt;/a&gt; love this. That's great, and they're
not wrong - it's a cool feature. What's wrong is having to pick
sides.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.shadowlab.org/Software/spark.php&quot;&gt;Spark&lt;/a&gt; is a great piece of OS X software which lets you bind key
combinations to anything - Applications, AppleScript, etc.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.shadowlab.org/Software/spark.php&quot;&gt;&lt;img src=&quot;http://img.skitch.com/20100127-bd8eii7tnasfcfw8qx7rgqktfm.png&quot; alt=&quot;Spark&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I've bound F1, F2, F3, and F4 to AppleScripts which open the sites I
want.&lt;/p&gt;

&lt;p&gt;Here's an example:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;do shell script &quot;open https://mail.google.com/a/ozmm.org/&quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;&lt;img src=&quot;http://img.skitch.com/20100127-k5q2a3i7tp38q248wjyfehdqp1.png&quot; alt=&quot;Spark&quot; /&gt;&lt;/p&gt;

&lt;p&gt;No more relying on the browser of the month for this
functionality. Sweetness.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Chrome Error Pages</title>
   <link href="http://ozmm.org/posts/chrome_error_pages.html"/>
   <updated>2009-12-18T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/chrome_error_pages</id>
   <content type="html">&lt;p&gt;Why so many different styles?&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://skitch.com/defunkt/nc8es&quot;&gt;&lt;img src=&quot;http://img.skitch.com/20091218-j4r9jicjp2eikkqc5xbrdagqd5.png&quot; alt=&quot;No Connection&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://skitch.com/defunkt/nc8e3&quot;&gt;&lt;img src=&quot;http://img.skitch.com/20091218-8idhex1jtrj1i7m9pxdesgmt5w.png&quot; alt=&quot;404&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://skitch.com/defunkt/nc8e5&quot;&gt;&lt;img src=&quot;http://img.skitch.com/20091218-e2wx4wmky3c4f1yg3auqpshdbq.png&quot; alt=&quot;SSL Error&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://skitch.com/defunkt/nc8ew&quot;&gt;&lt;img src=&quot;http://img.skitch.com/20091218-er6w856xsx9ynerrkwcadxjh3.png&quot; alt=&quot;Internal Error&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>2009 Open Source Top Ten</title>
   <link href="http://ozmm.org/posts/2009_open_source_top_ten.html"/>
   <updated>2009-12-17T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/2009_open_source_top_ten</id>
   <content type="html">&lt;p&gt;This was an amazing year for open source software. In alphabetical
order, here are my favorite releases of 2009.&lt;/p&gt;

&lt;h3&gt;&lt;a href=&quot;http://bert-rpc.org/&quot;&gt;BERT&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Beyond playing a massive role in &lt;a href=&quot;http://github.com/blog/530-how-we-made-github-fast&quot;&gt;making GitHub fast&lt;/a&gt;, BERT
is a textbook example of how to do open source correctly. Three
well documented and tested libraries double as reference
implementations for those who would implement the spec in other
languages.&lt;/p&gt;

&lt;h3&gt;&lt;a href=&quot;http://rentzsch.github.com/clicktoflash/&quot;&gt;ClickToFlash&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;In only a few months it became the canonical example of distributed
version control gone right: a simple Safari plugin posted on
GitHub got dozens of contributors and was kept surprisingly sane and
useful under the guidance of one &lt;a href=&quot;http://rentzsch.com/&quot;&gt;Rentzsch&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;&lt;a href=&quot;http://gemcutter.org/&quot;&gt;Gemcutter&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Ruby's gem ecosystem had been in a funk for a while. &lt;a href=&quot;http://twitter.com/qrush&quot;&gt;qrush&lt;/a&gt;
cured it. Packed with useful features, Gemcutter actually makes it fun
to publish gems again.&lt;/p&gt;

&lt;h3&gt;&lt;a href=&quot;http://github.com/mxcl/homebrew&quot;&gt;homebrew&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;It seems so obvious in retrospect: a packaging system with packages
stored in git, so anyone can easily add (or maintain) a package with
the same tools they use to develop software. With almost 200
contributors and nearly 400 packages as of writing, it has certainly
proven the viability of this idea. It also helps that it's simple to
use and works great - no longer do we dread installing or updating
software on our Macs. Now it's fun.&lt;/p&gt;

&lt;h3&gt;&lt;a href=&quot;http://unicorn.bogomips.org/&quot;&gt;Unicorn&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;The long awaited silver bullet: a Ruby web-app server that relies on
proven Unix technologies to do the hard stuff and do it well. It
doesn't hurt that the author is extremely responsive and a great
maintainer, either.&lt;/p&gt;

&lt;h3&gt;&lt;a href=&quot;http://pushmodule.slact.net/&quot;&gt;nginx http push module&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Like Unicorn, it leaves the heavy lifting of a hard problem to a
proven champion: nginx's famous concurrency. The idea is so simple
it's beautiful but, more importantly, the module asks an important and
inevitable question: what if persistent connections to the browser
were so easy that anyone with a commodity VPS could implement sites
with them?&lt;/p&gt;

&lt;p&gt;What does a Web with cheap persistent connections look like? We're
going to find out soon.&lt;/p&gt;

&lt;h3&gt;&lt;a href=&quot;http://nodejs.org/&quot;&gt;node.js&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;node is what we were all waiting for: fast, simple, server side
JavaScript. &lt;a href=&quot;http://four.livejournal.com/&quot;&gt;Ryan Dahl&lt;/a&gt; has shown us what V8 can really do. While the
year of Desktop Linux may never arrive, 2010 will certainly be the
Year of JavaScript thanks in no small part to node.&lt;/p&gt;

&lt;h3&gt;&lt;a href=&quot;http://code.google.com/p/redis/&quot;&gt;Redis&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;Redis has set the standard for open source databases: simple,
sensible, and well commented default configuration file; fantastic
&lt;a href=&quot;http://code.google.com/p/redis/wiki/index?tm=6&quot;&gt;documentation&lt;/a&gt;; cheat-sheet style &lt;a href=&quot;http://code.google.com/p/redis/wiki/CommandReference&quot;&gt;command
reference&lt;/a&gt;; extremely useful command line
utility; easy &lt;a href=&quot;http://code.google.com/p/redis/wiki/QuickStart&quot;&gt;installation&lt;/a&gt;; great
&lt;a href=&quot;http://code.google.com/p/redis/wiki/Benchmarks&quot;&gt;performance&lt;/a&gt;; and a very attentive
&lt;a href=&quot;http://twitter.com/antirez&quot;&gt;maintainer&lt;/a&gt;. Bonus points for being easy to explain and
easy to use.&lt;/p&gt;

&lt;h3&gt;&lt;a href=&quot;http://documentcloud.github.com/underscore/&quot;&gt;Underscore.js&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;The missing link, the &quot;tie to go along with jQuery's tux.&quot; Even
better: it's DOM free and can be used on the server side. The
&lt;code&gt;noConflict&lt;/code&gt; pattern jQuery pioneered is put to great use here and
something I'd love to see more of in the future. Underscore is a good
idea well executed.&lt;/p&gt;

&lt;h3&gt;&lt;a href=&quot;http://github.com/brianmario/yajl-ruby&quot;&gt;yajl-ruby&lt;/a&gt;&lt;/h3&gt;

&lt;p&gt;JSON is the serialization format of the web. yajl-ruby makes it fast
and, more importantly, streams it: yajl-ruby works great with
EventMachine and even includes example code so you can quickly get
started. Almost every Ruby project I touch uses JSON, and in all of
them I now use yajl-ruby.&lt;/p&gt;

&lt;p&gt;Thanks to the authors for sharing their creations with us. Now go out
there and build something with them!&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>return early</title>
   <link href="http://ozmm.org/posts/return_early.html"/>
   <updated>2009-12-15T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/return_early</id>
   <content type="html">&lt;p&gt;I often see code like this:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;logger&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;unless&lt;/span&gt; &lt;span class=&quot;vi&quot;&gt;@logger&lt;/span&gt;
    &lt;span class=&quot;vi&quot;&gt;@logger&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Logger&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;STDOUT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;vi&quot;&gt;@logger&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;level&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Logger&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;WARN&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;vi&quot;&gt;@logger&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;What you really want to do is return the instance variable if it's
already set. So why not do that?&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;logger&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;vi&quot;&gt;@logger&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;defined?&lt;/span&gt; &lt;span class=&quot;vi&quot;&gt;@logger&lt;/span&gt;
  &lt;span class=&quot;vi&quot;&gt;@logger&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Logger&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;STDOUT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;vi&quot;&gt;@logger&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;level&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Logger&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;WARN&lt;/span&gt;
  &lt;span class=&quot;vi&quot;&gt;@logger&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Or you could &lt;a href=&quot;http://ozmm.org/posts/z_cache_bang.html&quot;&gt;cache bang&lt;/a&gt; it.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Cache Bang</title>
   <link href="http://ozmm.org/posts/z_cache_bang.html"/>
   <updated>2009-12-14T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/z_cache_bang</id>
   <content type="html">&lt;p&gt;My favorite caching idiom:&lt;/p&gt;

&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;rankings&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;# return cached data or call `rankings!`&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;cache&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:rankings!&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;rankings!&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;# compute expensive rankings&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Smoke 'em if you got 'em.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>URLs in Ruby</title>
   <link href="http://ozmm.org/posts/urls_in_ruby.html"/>
   <updated>2009-12-14T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/urls_in_ruby</id>
   <content type="html">&lt;p&gt;Last year I showed you how to turn &lt;a href=&quot;http://ozmm.org/posts/java_in_ruby.html&quot;&gt;Ruby into Java&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This year I want to show you how to write URLs in Ruby. Let's have
them return their body, shall we?&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; http://github.com/defunkt.json
=&amp;gt; #&amp;lt;URLDSL::Request http://github.com/defunkt.json/&amp;gt;
&amp;gt;&amp;gt; puts http://github.com/defunkt.json
[{&quot;repository&quot;:{&quot;url&quot;:&quot;http://github.com/defunkt/repl&quot;,
... etc ...
=&amp;gt; nil
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Yes, amazing.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; puts http://github.com/api/v2/yaml/repos/show/schacon/grit
---
repository:
  :url: http://github.com/schacon/grit
  :description: Grit is a Ruby library for extracting information
                from a git repository in an object oriented manner
                - this fork tries to intergrate as much pure-ruby
                functionality as possible
  :homepage: http://grit.rubyforge.org/
  :fork: true
  :open_issues: 0
  :private: false
  :name: grit
  :owner: schacon
  :watchers: 81
  :forks: 11
=&amp;gt; nil
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Obligatory Twitter URL:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt; require 'json'
=&amp;gt; true
&amp;gt;&amp;gt; url = http://twitter.com/statuses/show/6592721580.json
=&amp;gt; #&amp;lt;URLDSL::Request http://twitter.com/statuses/show/6592721580.json/&amp;gt;
&amp;gt;&amp;gt; JSON.parse(url.to_s)['text']
=&amp;gt; &quot;He nose the truth.&quot;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That's about as far as we can take it, but that's far enough.&lt;/p&gt;

&lt;p&gt;The code: &lt;a href=&quot;http://gist.github.com/255948&quot;&gt;gist 255948&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enjoy.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>repl</title>
   <link href="http://ozmm.org/posts/repl.html"/>
   <updated>2009-12-12T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/repl</id>
   <content type="html">&lt;p&gt;I've been playing with &lt;a href=&quot;http://code.google.com/p/redis/wiki/QuickStart&quot;&gt;redis-cli&lt;/a&gt; a lot this year and at one point
thought, &quot;This would be great as a simple little shell.&quot;&lt;/p&gt;

&lt;p&gt;So, &lt;a href=&quot;http://github.com/defunkt/repl&quot;&gt;repl&lt;/a&gt;. It turns any basic, non-interactive program into an
interactive one.&lt;/p&gt;

&lt;p&gt;In other words, this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ redis-cli set name chris
OK
$ redis-cli get name
chris
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Becomes this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ repl redis-cli
&amp;gt;&amp;gt; set name chris
OK
&amp;gt;&amp;gt; get name
chris
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you have &lt;a href=&quot;http://utopia.knoware.nl/~hlub/rlwrap/&quot;&gt;rlwrap&lt;/a&gt; installed you even get the full benefits of
readline: history, reverse searches, etc.&lt;/p&gt;

&lt;p&gt;What's more, the contents of any file in &lt;code&gt;~/.repl&lt;/code&gt; matching the name
of the command you're running will be used as a completion list. See
the &lt;a href=&quot;http://github.com/defunkt/repl-completion&quot;&gt;repl-completion&lt;/a&gt; project (still in its infancy) for more info.&lt;/p&gt;

&lt;p&gt;Check out the &lt;a href=&quot;http://github.com/defunkt/repl#readme&quot;&gt;README&lt;/a&gt;, &lt;a href=&quot;http://defunkt.github.com/repl/&quot;&gt;manual&lt;/a&gt;, or just install it as a gem:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ gem install repl -s http://gemcutter.org/
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Enjoy.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>CakePHP on GitHub</title>
   <link href="http://ozmm.org/posts/cakephp_on_github.html"/>
   <updated>2009-12-10T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/cakephp_on_github</id>
   <content type="html">&lt;p&gt;&lt;a href=&quot;http://github.com/cakephp&quot;&gt;CakePHP&lt;/a&gt; is now on GitHub. This tickles me because I created
and published my first open source project on Sourceforge, &lt;a href=&quot;http://sourceforge.net/projects/spyc/&quot;&gt;Spyc&lt;/a&gt;
in an attempt to &lt;a href=&quot;http://groups.google.com/group/cake-php/browse_thread/thread/9611c4c52ad84d1a/f4fbfbb232cd47ee&quot;&gt;get it included&lt;/a&gt; in CakePHP.&lt;/p&gt;

&lt;p&gt;Spyc got me my &lt;a href=&quot;http://www.gamespot.com/&quot;&gt;first big job&lt;/a&gt;, which got me my &lt;a href=&quot;http://www.chow.com/&quot;&gt;first Rails
job&lt;/a&gt;, which is where I met &lt;a href=&quot;http://pjhyett.com/&quot;&gt;PJ Hyett&lt;/a&gt;, an eventual GitHub
co-founder.&lt;/p&gt;

&lt;p&gt;So, thanks CakePHP. And welcome.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>:nth-child</title>
   <link href="http://ozmm.org/posts/nth_child.html"/>
   <updated>2009-11-30T00:00:00-08:00</updated>
   <id>http://ozmm.org//posts/nth_child</id>
   <content type="html">&lt;p&gt;For my new &lt;a href=&quot;http://defunkt.github.com/projects.html&quot;&gt;projects&lt;/a&gt; page, I wanted the background color of each
box to change into one of six pre-selected colors on hover. I also
wanted an arbitrary number of boxes, so the colors needed to repeat.&lt;/p&gt;

&lt;p&gt;I could easily do this using a template language by giving each &lt;code&gt;li&lt;/code&gt; a
unique class then styling thoses classes, but that's lame. Instead I
used CSS3's &lt;code&gt;:nth-child&lt;/code&gt;, which works in current versions of Chrome,
Safari, and Firefox.&lt;/p&gt;

&lt;p&gt;The CSS for the first two boxes is as follows:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;.row &amp;gt; a:nth-child(6n+1):hover {
  background-color: #FFFF00;
}

.row &amp;gt; a:nth-child(6n+2):hover {
  background-color: #FF0000;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;6n+1&lt;/code&gt; means &quot;the first instance and every sixth instance
thereafter.&quot; So &lt;code&gt;6n+2&lt;/code&gt; is the second &lt;code&gt;a&lt;/code&gt; which is a child of &lt;code&gt;.row&lt;/code&gt;
and every sixth &lt;code&gt;a&lt;/code&gt; after that.&lt;/p&gt;

&lt;p&gt;In this manner we also define &lt;code&gt;6n+3&lt;/code&gt; through &lt;code&gt;6n+6&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If there were only four boxes, I'd have &lt;code&gt;4n+1&lt;/code&gt; through &lt;code&gt;4n+4&lt;/code&gt;. In
fact, to achieve the step-like effect with the boxes I style every
first and third box differently using &lt;code&gt;4n+1&lt;/code&gt; and &lt;code&gt;4n+3&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;.row &amp;gt; a:nth-child(4n+1) {
  margin-top: 40px;
}

.row &amp;gt; a:nth-child(4n+3) {
  margin-top: 0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Finally, I give the first &lt;code&gt;a&lt;/code&gt; some extra padding:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;.row &amp;gt; a:first-child {
  padding-left: 20px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Which I could have written as:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;.row &amp;gt; a:nth-child(1) {
  padding-left: 20px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;For more (somewhat obtuse) information, see Sitepoint's
&lt;a href=&quot;http://reference.sitepoint.com/css/understandingnthchildexpressions&quot;&gt;Understanding :nth-child Pseudo-class Expressions&lt;/a&gt; documentation.&lt;/p&gt;
</content>
 </entry>
 
 
</feed>
