<?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:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:yt="http://gdata.youtube.com/schemas/2007" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
   <channel>
      <title>Mocra Employee Blogs</title>
      <description>Recent Mocra Employee blog posts</description>
      <link>http://pipes.yahoo.com/pipes/pipe.info?_id=d4690b685bcb2764cfe3dcca4edfb93c</link>
      <atom:link rel="next" href="http://pipes.yahoo.com/pipes/pipe.run?_id=d4690b685bcb2764cfe3dcca4edfb93c&amp;_render=rss&amp;page=2" />
      <pubDate>Fri, 10 Feb 2012 15:08:31 +0000</pubDate>
      <generator>http://pipes.yahoo.com/pipes/</generator>
      <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/mocra" /><feedburner:info uri="mocra" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><geo:lat>-27.472505</geo:lat><geo:long>153.002579</geo:long><item>
         <title>Trialing RedCar instead of TextMate – replacing my aliases</title>
         <link>http://feedproxy.google.com/~r/mocra/~3/ck3sBnGtJr8/</link>
         <description>I&amp;#8217;m interested to trial RedCar in my life, instead of TextMate. So I need RedCar to appear on my screen whenever I think &amp;#8220;give me an editor&amp;#8221;. I&amp;#8217;ve had m bound to TextMate for years. I also have it set to my $EDITOR variable, so it is launched by git commands, etc. To change the [...]


Related posts:&lt;ol&gt;&lt;li&gt;&lt;a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2010/08/01/packaging-textmate-bundles-in-os-x-dmgs/' title='Permanent Link: Packaging TextMate bundles in OS X DMGs'&gt;Packaging TextMate bundles in OS X DMGs&lt;/a&gt; &lt;small&gt;Last week Engine Yard released a CLI for their Engine...&lt;/small&gt;&lt;/li&gt;&lt;li&gt;&lt;a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2010/06/01/validate-and-save-your-ruby-in-textmate-with-secret-rubinus-superpowers/' title='Permanent Link: Validate and Save your Ruby in TextMate &amp;#8211; with secret Rubinus superpowers'&gt;Validate and Save your Ruby in TextMate &amp;#8211; with secret Rubinus superpowers&lt;/a&gt; &lt;small&gt;In some TextMate bundles, if you save a file it...&lt;/small&gt;&lt;/li&gt;&lt;/ol&gt;</description>
         <guid isPermaLink="false">http://drnicwilliams.com/?p=803</guid>
         <pubDate>Tue, 26 Apr 2011 18:31:38 +0000</pubDate>
         <content:encoded><![CDATA[<p>I&#8217;m interested to trial <a rel="nofollow" target="_blank" href="http://redcareditor.com/">RedCar</a> in my life, instead of TextMate. So I need RedCar<br />
to appear on my screen whenever I think &#8220;give me an editor&#8221;.</p>
<p>I&#8217;ve had <code>m</code> bound to TextMate for years. I also have it set to my <code>$EDITOR</code> variable, so it is launched by git commands, etc.</p>
<p>To change the default to RedCar, and to allow me to toggle between RedCar and TextMate, AND to allow me to use Edge RedCar (from source instead from a RubyGem).</p>
<p></p> 
<p>This file comes from my <a rel="nofollow" target="_blank" href="https://github.com/drnic/.dotfiles/blob/master/editor.sh">editor.sh</a> file which is loaded into all shell terminals.</p>
<p>I can change to TextMate with:</p>
<pre><code>use_textmate
</code></pre>
<p>Back to RedCar (via gem) or RedCar (from source):</p>
<pre><code>use_redcar_gem
use_redcar_dev
</code></pre>


<p>Related posts:<ol><li><a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2010/08/01/packaging-textmate-bundles-in-os-x-dmgs/' title='Permanent Link: Packaging TextMate bundles in OS X DMGs'>Packaging TextMate bundles in OS X DMGs</a> <small>Last week Engine Yard released a CLI for their Engine...</small></li><li><a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2010/06/01/validate-and-save-your-ruby-in-textmate-with-secret-rubinus-superpowers/' title='Permanent Link: Validate and Save your Ruby in TextMate &#8211; with secret Rubinus superpowers'>Validate and Save your Ruby in TextMate &#8211; with secret Rubinus superpowers</a> <small>In some TextMate bundles, if you save a file it...</small></li></ol></p><img src="http://feeds.feedburner.com/~r/mocra/~4/ck3sBnGtJr8" height="1" width="1"/>]]></content:encoded>
         <category>Mocra</category>
      <feedburner:origLink>http://drnicwilliams.com/2011/04/27/replacing-aliases-to-use-redcar-or-textmate/</feedburner:origLink></item>
      <item>
         <title>Packaging TextMate bundles in OS X DMGs</title>
         <link>http://feedproxy.google.com/~r/mocra/~3/CMx4NaLoe5I/</link>
         <description>Last week Engine Yard released a CLI for their Engine Yard AppCloud. Delights such as: ey deploy ey rebuild ey logs ey ssh They simultaneously released a TextMate bundle to deploy, rebuild, view logs, etc using Ctrl+Alt+Cmd+E. Like all TextMate bundles, you can install it in one of two ways: via git (see the README), [...]


Related posts:&lt;ol&gt;&lt;li&gt;&lt;a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2011/04/27/replacing-aliases-to-use-redcar-or-textmate/' title='Permanent Link: Trialing RedCar instead of TextMate &amp;#8211; replacing my aliases'&gt;Trialing RedCar instead of TextMate &amp;#8211; replacing my aliases&lt;/a&gt; &lt;small&gt;I&amp;#8217;m interested to trial RedCar in my life, instead of...&lt;/small&gt;&lt;/li&gt;&lt;li&gt;&lt;a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2010/06/01/validate-and-save-your-ruby-in-textmate-with-secret-rubinus-superpowers/' title='Permanent Link: Validate and Save your Ruby in TextMate &amp;#8211; with secret Rubinus superpowers'&gt;Validate and Save your Ruby in TextMate &amp;#8211; with secret Rubinus superpowers&lt;/a&gt; &lt;small&gt;In some TextMate bundles, if you save a file it...&lt;/small&gt;&lt;/li&gt;&lt;li&gt;&lt;a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2008/10/09/textmate-easter-egg-find-bundle-commands-by-key-combo/' title='Permanent Link: TextMate easter egg: find bundle commands by key combo'&gt;TextMate easter egg: find bundle commands by key combo&lt;/a&gt; &lt;small&gt;I&amp;#8217;ve dreamed of the ability to ask TextMate &amp;#8220;what frigging...&lt;/small&gt;&lt;/li&gt;&lt;/ol&gt;</description>
         <guid isPermaLink="false">http://drnicwilliams.com/?p=765</guid>
         <pubDate>Sat, 31 Jul 2010 21:11:22 +0000</pubDate>
         <content:encoded><![CDATA[<p>Last week Engine Yard released a <a rel="nofollow" target="_blank" href="http://www.engineyard.com/products/appcloud/features/cli">CLI</a> for their Engine Yard AppCloud. Delights such as:</p>
<pre><code>ey deploy
ey rebuild
ey logs
ey ssh
</code></pre>
<p><a rel="nofollow" target="_blank" href="http://www.engineyard.com/docs/Engine_Yard.tmbundle.dmg"><img src="http://img.skitch.com/20100731-gqkw2eb9666qc415akcggjuet1.png" alt="Engine Yard.tmbundle" style="float:right;" width="281" height="153"/></a></p>
<p>They simultaneously released a TextMate bundle to deploy, rebuild, view logs, etc using Ctrl+Alt+Cmd+E. Like all TextMate bundles, you can install it in one of two ways: via git (see the <a rel="nofollow" target="_blank" href="http://github.com/engineyard/engineyard.tmbundle">README</a>), or via a beautiful DMG. <a rel="nofollow" target="_blank" href="http://www.engineyard.com/docs/Engine_Yard.tmbundle.dmg">Download it here!</a></p>
<p>Yes indeed, TextMate bundles can now be packaged up and distributed via DMGs using ChocTop!</p>
<p><a rel="nofollow" target="_blank" href="http://drnicwilliams.com/wp-content/uploads/tmbundles/ruby-on-rails"><img src="http://img.skitch.com/20100731-n6hc948m7bd1qbwykwn1wxyhc1.png" alt="Ruby on Rails.tmbundle" width="380" height="246"/></a></p>
<p>For example, the <a rel="nofollow" target="_blank" href="http://drnicwilliams.com/wp-content/uploads/tmbundles/ruby-on-rails">Ruby on Rails.tmbundle</a> using a simple purple theme.</p>
<h2 id="first_the_engine_yard_tmbundle">First, the Engine Yard tmbundle</h2>
<p>To use the Engine Yard tmbundle, you first need to install and use the CLI once. Instructions at the bottom of the <a rel="nofollow" target="_blank" href="http://www.engineyard.com/products/appcloud/features/cli">information page</a>.</p>
<h2 id="how_to_package_a_textmate_bundle_into_a_dmg">How to package a TextMate bundle into a DMG</h2>
<p><a rel="nofollow" target="_blank" href="http://drnic.github.com/choctop">ChocTop</a> is a packaging and distribution tool originally designed only for Cocoa applications, but can now package any assets, URL links, or even the whole project folder itself. This makes it ideal for packaging TextMate bundles which have no compiled/built output to distribute (like a Cocoa application), rather the project folder itself is the distributed item (the <code>Engine Yard.tmbundle</code> folder in this case).</p>
<h2 id="getting_started">Getting started</h2>
<p>Everything is added into your TextMate bundle project. For example, with the EngineYard bundle:</p>
<pre><code>gem install choctop
cd Library/Application&#92; Support/TextMate/Bundles/Engine&#92; Yard.tmbundle
install_choctop . --tmbundle
</code></pre>
<p>If your tmbundle already has a Rakefile, then don&#8217;t overwrite it. Instead, inside the Rakefile, add the ChocTop configuration:</p>
<pre><code>require "choctop"

ChocTop::Configuration.new do |s|
  s.add_root :position =&gt; [290, 200], :exclude =&gt; %w[appcast build .bundle .git]
  s.add_link 'http://github.com/engineyard/engineyard.tmbundle', 'GitHub', :position =&gt; [520, 200]
  s.defaults :textmate
end
</code></pre>
<p>For TextMate bundles the DMG magic is from the <code>s.add_root</code> line. The resulting DMG will include the entire project as a folder/bundle. For example, you&#8217;ll want to exclude <code>appcast</code>, <code>build</code>, <code>.bundle</code> (if you&#8217;re using Bundler), and <code>.git</code> folders.</p>
<p>The <code>s.defaults :textmate</code> provides a generic background and volume icon for a TextMate bundle DMG. See below for customising the background and volume icons. The <code>:position</code> coordinates above are for the generic background.</p>
<h2 id="building_your_dmg">Building your DMG</h2>
<p>To build your DMG and then view it in Finder:</p>
<pre><code>rake dmg
open appcast/build/*.dmg
# or together
rake dmg[automount]
</code></pre>
<p>You can now share the DMG file. See below for how to upload it to a server.</p>
<h2 id="versioning">Versioning</h2>
<p>In future, it would be great to use Sparkle&#8217;s auto-update mechanism (as seen in nearly every Cocoa application). ChocTop will automatically generate the required XML feed; TextMate nor the bundle has a way to ask Sparkle to poll for it nor update itself, yet.</p>
<p>But, you can start versioning your DMGs today:</p>
<pre><code>$ rake version:current
0.0.0
$ rake version:bump:major
$ rake version:current
1.0.0
$ rake dmg
</code></pre>
<p>The DMG will now have a version number.</p>
<h2 id="uploading_new_dmg_versions">Uploading new DMG versions</h2>
<p>The original ChocTop was designed for Cocoa applications and included Sparkle support so your Cocoa applications automatically updated themselves when you built and uploaded a new version. I haven&#8217;t got a solution for this for TextMate bundles yet; but it seems like a good idea for the future.</p>
<p>Nonetheless, ChocTop still includes a <code>rake upload</code> task to ship new versions of your DMG to a server somewhere.</p>
<p>In your Rakefile, add the following config lines to the ChocTop block:</p>
<pre><code>s.base_url   = 'http://some.host.com/upload/folder'
s.remote_dir = '/path/to/upload/folder'
s.host       = 'some.host.com'
s.user       = 'remote-user'
</code></pre>
<p>The <code>s.base_url</code> is the URL from where the DMG file will be found by users. Later, when I figure out how to do auto-updating of the TextMate bundles, it will also use this URL. This URL is also used to determine the host for uploading the file.</p>
<p>The <code>s.remote_dir</code> is a path on the target server that maps to the <code>base_url</code>. This folder must already exist; rsync cannot create it as far as I can tell. So <code>ssh</code> into the machine and <code>mkdir -p /path/to/upload/folder</code></p>
<p>The latter two are optional: <code>s.host</code> is derived from <code>s.base_url</code> and <code>s.user</code> defaults to your current local user.</p>
<p>To upload the latest DMG, run:</p>
<pre><code>rake upload
</code></pre>
<p>You can now share the URL <code>http://some.host.com/upload/folder</code> for people to download the DMG. A small PHP script redirects from the folder path to the DMG filename.</p>
<h2 id="customising">Customising</h2>
<p>ChocTop allows you to customise nearly everything.</p>
<p>The <code>s.defaults :textmate</code> line is similar to the following configuration:</p>
<pre><code>s.background_file = "...choctop/assets/textmate_background.jpg"
s.volume_icon     = "...choctop/assets/textmate_volume.icns"
s.icon_size       = 104
s.icon_text_size  = 12
</code></pre>
<p>For TextMate bundles, perhaps put customised assets into a <code>Support/dmg</code> folder.</p>
<p>A background image should include blank space for the large YourBundle.tmbundle icon and webloc URL file to your GitHub project (or other target URLs). There are no size constraints on the background image. Design something beautiful.</p>
<p>The volume icon is an <code>icns</code> file. You create this using OS X&#8217;s Icon Composer application. Start with a transparent <code>png</code> file and drop it into the box with the corresponding size.</p>
<p>For the Engine Yard tmbundle, the following configuration is used:</p>
<pre><code>s.background_file = 'Support/dmg/engineyard.tmbundle.dmg.png'
s.volume_icon     = 'Support/dmg/engineyard.dmg.icns'
</code></pre>
<h2 id="additional_files">Additional files</h2>
<p>If there are other files you explicitly want bundled in the DMG, say a pretty README.html or a folder of documentation, then you can specify them:</p>
<pre><code>s.add_file 'README.html', :position =&gt; [50, 100]
s.add_file 'docs', :position =&gt; [100, 100], :name =&gt; 'Documentation'
</code></pre>
<h2 id="summary">Summary</h2>
<p>ChocTop is pretty cool for bundling any set of files into a custom DMG, especially Cocoa applications and now TextMate bundles.</p>
<p>Hopefully one day we can have Sparkle auto-updates for TextMate bundles too.</p>


<p>Related posts:<ol><li><a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2011/04/27/replacing-aliases-to-use-redcar-or-textmate/' title='Permanent Link: Trialing RedCar instead of TextMate &#8211; replacing my aliases'>Trialing RedCar instead of TextMate &#8211; replacing my aliases</a> <small>I&#8217;m interested to trial RedCar in my life, instead of...</small></li><li><a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2010/06/01/validate-and-save-your-ruby-in-textmate-with-secret-rubinus-superpowers/' title='Permanent Link: Validate and Save your Ruby in TextMate &#8211; with secret Rubinus superpowers'>Validate and Save your Ruby in TextMate &#8211; with secret Rubinus superpowers</a> <small>In some TextMate bundles, if you save a file it...</small></li><li><a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2008/10/09/textmate-easter-egg-find-bundle-commands-by-key-combo/' title='Permanent Link: TextMate easter egg: find bundle commands by key combo'>TextMate easter egg: find bundle commands by key combo</a> <small>I&#8217;ve dreamed of the ability to ask TextMate &#8220;what frigging...</small></li></ol></p><img src="http://feeds.feedburner.com/~r/mocra/~4/CMx4NaLoe5I" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://drnicwilliams.com/2010/08/01/packaging-textmate-bundles-in-os-x-dmgs/</feedburner:origLink></item>
      <item>
         <title>Validate and Save your Ruby in TextMate – with secret Rubinus superpowers</title>
         <link>http://feedproxy.google.com/~r/mocra/~3/CvqJDt_QLd4/</link>
         <description>In some TextMate bundles, if you save a file it will also validate the file and show any syntax errors in a tooltip. This is awesome. (e.g. JavaScript and CoffeeScript) So I added the same thing to my Ruby.tmbundle. Install this, save a dodgy Ruby file and you&amp;#8217;ll now see something like: Rubinius superpowers Do [...]


Related posts:&lt;ol&gt;&lt;li&gt;&lt;a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2011/04/27/replacing-aliases-to-use-redcar-or-textmate/' title='Permanent Link: Trialing RedCar instead of TextMate &amp;#8211; replacing my aliases'&gt;Trialing RedCar instead of TextMate &amp;#8211; replacing my aliases&lt;/a&gt; &lt;small&gt;I&amp;#8217;m interested to trial RedCar in my life, instead of...&lt;/small&gt;&lt;/li&gt;&lt;li&gt;&lt;a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2010/08/01/packaging-textmate-bundles-in-os-x-dmgs/' title='Permanent Link: Packaging TextMate bundles in OS X DMGs'&gt;Packaging TextMate bundles in OS X DMGs&lt;/a&gt; &lt;small&gt;Last week Engine Yard released a CLI for their Engine...&lt;/small&gt;&lt;/li&gt;&lt;li&gt;&lt;a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2008/12/11/future-proofing-your-ruby-code/' title='Permanent Link: Future proofing your Ruby code. Ruby 1.9.1 is coming.'&gt;Future proofing your Ruby code. Ruby 1.9.1 is coming.&lt;/a&gt; &lt;small&gt; Bugger. I&amp;#8217;m a Ruby monogamist. I use the Ruby...&lt;/small&gt;&lt;/li&gt;&lt;/ol&gt;</description>
         <guid isPermaLink="false">http://drnicwilliams.com/?p=751</guid>
         <pubDate>Tue, 01 Jun 2010 12:54:18 +0000</pubDate>
         <content:encoded><![CDATA[<p>In some TextMate bundles, if you save a file it will also validate the file and show any syntax errors in a tooltip. This is awesome. (e.g. <a rel="nofollow" target="_blank" href="http://github.com/subtleGradient/javascript-tools.tmbundle">JavaScript</a> and <a rel="nofollow" target="_blank" href="http://github.com/jashkenas/coffee-script-tmbundle">CoffeeScript</a>)</p>
<p>So I added the same thing to my <a rel="nofollow" target="_blank" href="http://github.com/drnic/ruby-tmbundle">Ruby.tmbundle</a>. Install this, save a dodgy Ruby file and you&#8217;ll now see something like:</p>
<p><img src="http://img.skitch.com/20100601-eiw1ugr2ma8xwxbecjfbbpfgpk.jpg" style="width:90%;" alt="Validate and Save - No Rubinius"/></p>
<h3 id="rubinius_superpowers">Rubinius superpowers</h3>
<p>Do you think the following syntax error tooltip is more useful?</p>
<p><img src="http://img.skitch.com/20100601-r66y9yr8nb14br4esi436prn1p.jpg" style="width:90%;" alt="Validate and Save - Rubinius installed"/></p>
<p>Yes it lovely, and the new Ruby.tmbundle will automatically do this if it can find <code>rbx</code> in your TextMate&#8217;s <code>$PATH</code>. Yeah yeah.</p>
<p>If you have <a rel="nofollow" target="_blank" href="http://github.com/mxcl/homebrew">Homebrew</a> installed:</p>
<pre><code>brew install rubinius
</code></pre>
<p>Then in TextMate, add your homebrew <code>bin</code> folder to the $PATH.</p>
<ul>
<li>Go to TextMate&#8217;s Preferences (Cmd+,)</li>
<li>Go to &#8220;Advanced&#8221;, then &#8220;Shell Variables&#8221;</li>
<li>Edit the <code>PATH</code> variable, and add &#8220;:/path/to/homebrew/bin&#8221;</li>
</ul>
<p>For example, if you have homebrew installed in <code>~/.homebrew</code> then you might add <code>:/Users/drnic/.homebrew/bin</code></p>
<p>. My complete <code>$PATH</code> in TextMate is:</p>
<pre>/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin:/usr/local/bin/:/Users/drnic/.homebrew/bin</pre>
<p>Save a dodgy Ruby file and see the beautifully helpful syntax message.</p>
<h3 id="install_rubytmbundle">Install Ruby.tmbundle</h3>
<p>To install via Git:</p>
<pre><code>mkdir -p ~/Library/Application&#92; Support/TextMate/Bundles
cd ~/Library/Application&#92; Support/TextMate/Bundles
git clone git://github.com/drnic/ruby-tmbundle.git "Ruby.tmbundle"
osascript -e 'tell app "TextMate" to reload bundles'
</code></pre>


<p>Related posts:<ol><li><a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2011/04/27/replacing-aliases-to-use-redcar-or-textmate/' title='Permanent Link: Trialing RedCar instead of TextMate &#8211; replacing my aliases'>Trialing RedCar instead of TextMate &#8211; replacing my aliases</a> <small>I&#8217;m interested to trial RedCar in my life, instead of...</small></li><li><a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2010/08/01/packaging-textmate-bundles-in-os-x-dmgs/' title='Permanent Link: Packaging TextMate bundles in OS X DMGs'>Packaging TextMate bundles in OS X DMGs</a> <small>Last week Engine Yard released a CLI for their Engine...</small></li><li><a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2008/12/11/future-proofing-your-ruby-code/' title='Permanent Link: Future proofing your Ruby code. Ruby 1.9.1 is coming.'>Future proofing your Ruby code. Ruby 1.9.1 is coming.</a> <small> Bugger. I&#8217;m a Ruby monogamist. I use the Ruby...</small></li></ol></p><img src="http://feeds.feedburner.com/~r/mocra/~4/CvqJDt_QLd4" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://drnicwilliams.com/2010/06/01/validate-and-save-your-ruby-in-textmate-with-secret-rubinus-superpowers/</feedburner:origLink></item>
      <item>
         <title>Showcase of CoffeeScript – 2.5 mins for your next Dev Group meeting</title>
         <link>http://feedproxy.google.com/~r/mocra/~3/GmkckOci5RQ/</link>
         <description>If you are giving an &amp;#8220;Introduction to CoffeeScript&amp;#8221; talk at your local developer group in the future, I have a 2:30min video you might find exciting to show. CoffeeScript is so cool that I thought it really needed to be put to music. Hard rock music. AC/DC. I finished my session at NordicRuby with this [...]


Related posts:&lt;ol&gt;&lt;li&gt;&lt;a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2010/03/15/using-coffeescript-in-rails-and-even-on-heroku/' title='Permanent Link: Using CoffeeScript in Rails and even on Heroku'&gt;Using CoffeeScript in Rails and even on Heroku&lt;/a&gt; &lt;small&gt;I&amp;#8217;m pretty excited about CoffeeScript as a clean-syntax replacement for...&lt;/small&gt;&lt;/li&gt;&lt;/ol&gt;</description>
         <guid isPermaLink="false">http://drnicwilliams.com/?p=733</guid>
         <pubDate>Fri, 28 May 2010 12:20:08 +0000</pubDate>
         <content:encoded><![CDATA[<p>
<embed src="http://s3.amazonaws.com/screencasts.drnicwilliams/Summary%20of%20CoffeeScript%20-%20streaming.mov" width="320" height="195" pluginspage="http://www.apple.com/quicktime/download/"></iframe></p> 
<p>If you are giving an &#8220;Introduction to CoffeeScript&#8221; talk at your local developer group in the future, I have a 2:30min video you might find exciting to show. <a rel="nofollow" target="_blank" href="http://coffeescript.org/">CoffeeScript</a> is so cool that I thought it really needed to be put to music. Hard rock music. AC/DC.</p>
<p>I finished my session at <a rel="nofollow" target="_blank" href="http://nordicruby.com">NordicRuby</a> with this video and I think it helped get lots of people excited about CoffeeScript.</p>
<p>Because of it&#8217;s heavy dependence of the backing song &#8211; the screencast is boring without it &#8211; I&#8217;m kind of screwed as to how to distribute it to other presenters. The licensing rules of including music and it&#8217;s 600Mb size are prohibitive.</p>
<p>What the hell. I&#8217;ve included an inline sample above; and the links to the 600Mb version is below. All self-promotional &#8220;Dr Nic made this shiny video&#8221; bits have been removed. Go for gold. Share the CoffeeScript excitement.</p>
<h3 id="nordicruby">NordicRuby</h3>
<p><a rel="nofollow" target="_blank" href="http://nordicruby.com">NordicRuby</a> finished 5 days ago, but many of the attendees and speakers are only finally winding down. Executed with the style, excitement and pizazz of Unspace&#8217;s RubyFringe and FutureRuby conferences, I had a brilliant time in Gothenburg. If NordicRuby&#8217;s organiser&#8217;s <a rel="nofollow" target="_blank" href="http://elabs.se/">Elabs</a> host the event again in 2011 I highly recommend attending. Carefully selected and sequenced speakers from around the world, 30 minute talks with 30 minute breaks over two days, an hour of lightning talks each day, and parties every night. Phew.</p>
<p>To CJ and Lilly, the organisers, the other speakers and all the attendees, thanks for an awesome experience in Sweden. Looking forward to coming back next year.</p>
<h3 id="why_coffeescript">Why CoffeeScript?</h3>
<p>JavaScript has a wonderful feature or two: it&#8217;s everywhere and it&#8217;s getting really fast. Unfortunately, its syntax was heavily influenced by Java/C++ and other popular goliaths of the time. But the JavaScript runtime is sweet. JavaScript syntax, not so sweet. </p>
<p>Like .NET and it&#8217;s selection of languages, the JVM and it&#8217;s growing smorgasbord of languages, I think the JavaScript runtime could benefit from more experimentation with alternate languages and/or syntaxes. Objective-J was one attempt. CoffeeScript is another.</p>
<p>Of the two, I like CoffeeScript. A lot.</p>
<h3 id="demonstrating_coffeescript_at_dev_meetups">Demonstrating CoffeeScript at Dev meetups</h3>
<p>The video flies through core ideas pretty quickly, so I ran through syntax examples on a slide first, and then said &#8220;You know, I think this would go better to music,&#8221; and played the video.</p>
<p><img src="http://img.skitch.com/20100528-cf2ts4uqmn91dy8h7m7hj26iwy.png" width="500px"></p>
<h3 id="download_and_demo">Download and Demo</h3>
<p>The purpose of offering the 600Mb video version is for the growing number of people doing CoffeeScript talks at their local software dev groups. The music in it is not licensed, not mine, but sounds awesome.</p>
<p>Please play the video with speakers. AC/DC on mute is a cruel act. Also watching the text jump around without the music is probably weird to watch. AC/DC and CoffeeScript. Perfect match, I think.</p>
<p><a rel="nofollow" target="_blank" href="http://s3.amazonaws.com/screencasts.drnicwilliams/Summary%20of%20CoffeeScript%20-%20Dr%20Nic%20-%20Mocra.mov?torrent"><img src="http://s3.amazonaws.com/screencasts.drnicwilliams/Summary%20of%20CoffeeScript%20cover.png" width="500px"></a></p>
<p>Formats: <a rel="nofollow" target="_blank" href="http://s3.amazonaws.com/screencasts.drnicwilliams/Summary%20of%20CoffeeScript%20-%20Dr%20Nic%20-%20Mocra.mov?torrent">Torrent</a> | <a rel="nofollow" target="_blank" href="http://s3.amazonaws.com/screencasts.drnicwilliams/Summary%20of%20CoffeeScript%20-%20Dr%20Nic%20-%20Mocra.mov">Download</a> (600Mb)</p>
<h3 id="tack_s_mycket">Tack så mycket</h3>
<p>Swedish for &#8220;Thank you very much,&#8221; pronounced like &#8220;tuck sa-meekeh&#8221; or thereabouts.</p>
<p>If you use the video at all, I&#8217;d really appreciate it if you left a comment below! </p>


<p>Related posts:<ol><li><a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2010/03/15/using-coffeescript-in-rails-and-even-on-heroku/' title='Permanent Link: Using CoffeeScript in Rails and even on Heroku'>Using CoffeeScript in Rails and even on Heroku</a> <small>I&#8217;m pretty excited about CoffeeScript as a clean-syntax replacement for...</small></li></ol></p><img src="http://feeds.feedburner.com/~r/mocra/~4/GmkckOci5RQ" height="1" width="1"/>]]></content:encoded>
         <enclosure length="2832999" type="video/quicktime" url="http://s3.amazonaws.com/screencasts.drnicwilliams/Summary%20of%20CoffeeScript%20-%20streaming.mov" />
         <enclosure length="599670164" type="video/quicktime" url="http://s3.amazonaws.com/screencasts.drnicwilliams/Summary%20of%20CoffeeScript%20-%20Dr%20Nic%20-%20Mocra.mov" />
      <feedburner:origLink>http://drnicwilliams.com/2010/05/28/showcase-of-coffeescript-2-5-mins-for-your-next-dev-group-meeting/</feedburner:origLink></item>
      <item>
         <title>How to make a good home-made Open Source</title>
         <link>http://feedproxy.google.com/~r/mocra/~3/7k69LmQPCf0/</link>
         <description>Want to be the funniest person at the next hacker&amp;#8217;s picnic? Point at a bottle of red ketchup with its lid next to it on the table and pronounce &amp;#8220;Hey look, Open Source.&amp;#8221; Be ready with follow-ups like &amp;#8220;Can you pass me the Haml?&amp;#8221; If you&amp;#8217;ve used Ruby on Rails, Apache, Emacs, or Linux then [...]


Related posts:&lt;ol&gt;&lt;li&gt;&lt;a rel="nofollow" target="_blank" href='http://drnicwilliams.com/' title='Permanent Link: Home'&gt;Home&lt;/a&gt; &lt;small&gt;...&lt;/small&gt;&lt;/li&gt;&lt;li&gt;&lt;a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2009/07/13/futureruby-talk-living-with-1000-open-source-projects/' title='Permanent Link: FutureRuby talk: Living With 1000 Open Source Projects'&gt;FutureRuby talk: Living With 1000 Open Source Projects&lt;/a&gt; &lt;small&gt;The FutureRuby conference has been (and still is, as of...&lt;/small&gt;&lt;/li&gt;&lt;/ol&gt;</description>
         <guid isPermaLink="false">http://drnicwilliams.com/?p=725</guid>
         <pubDate>Fri, 09 Apr 2010 13:38:12 +0000</pubDate>
         <content:encoded><![CDATA[<p><img src="http://img.skitch.com/20100409-nek2u3tdff55dn2w2sreys4314.png" style="float:right;"></p>
<p>Want to be the funniest person at the next hacker&#8217;s picnic? Point at a bottle of red ketchup with its lid next to it on the table and pronounce &#8220;Hey look, Open Source.&#8221;</p>
<p>Be ready with follow-ups like &#8220;Can you pass me the Haml?&#8221; </p>
<p>If you&#8217;ve used Ruby on Rails, Apache, Emacs, or Linux then you would have been impressed by the awesome quality of these free bits of software which are so important to us. They are free, they are important, and they are awesome.</p>
<p>Paying money for poor commercial software makes awesome, important free software appear even more awesome and important.</p>
<p>The facts seem gloomy. You are a humble developer. Awesome, important free software is a Herculean achievement.</p>
<p>Conclusion? You implicitly believe you will never write awesome, important free software.</p>
<p>But &#8220;never&#8221; is an awfully long time. And is the only goal &#8220;awesome, important free software&#8221;?</p>
<h3 id="reasons_to_write">Reasons to write?</h3>
<p>Personally, I don&#8217;t think I&#8217;ve ever created an open source project that is either important or awesome. I think my motivations for open source &#8212; my own projects or stuff added to other&#8217;s projects &#8212; is either: </p>
<p>&#8220;Wouldn&#8217;t it be cool if you could do XYZ?&#8221; or &#8220;Seriously. Why can&#8217;t I do XYZ?&#8221;</p>
<p>I was either amused or annoyed. <a rel="nofollow" target="_blank" href="http://magicmodels.rubyforge.org/">Dr Nic&#8217;s Magic Models</a> was a joke. <a rel="nofollow" target="_blank" href="http://drnic.github.com/choctop/">ChocTop</a> was vented frustration.</p>
<p>Perhaps there are different reasons. I find the following examples inspiring.</p>
<p>I think the late Why the Lucky Stiff created <a rel="nofollow" target="_blank" href="http://camping.rubyforge.org/files/README.html">entertaining</a> free software.</p>
<p><a rel="nofollow" target="_blank" href="http://toolmantim.com/thoughts">Tim Lucas</a> created <a rel="nofollow" target="_blank" href="http://railscampteev5.toolmantim.com/">artistic</a> free software (&#8216;View Source&#8217; to see the header comment)</p>
<p><a rel="nofollow" target="_blank" href="http://chneukirchen.org/">Christian Neukirchen</a> created <a rel="nofollow" target="_blank" href="http://rack.rubyforge.org/">liberating</a> free software.</p>
<p><a rel="nofollow" target="_blank" href="http://blog.zenspider.com/">Ryan Davis</a> created free <a rel="nofollow" target="_blank" href="http://seattlerb.rubyforge.org/hoe/">tools</a>.</p>
<p><a rel="nofollow" target="_blank" href="http://ozmm.org/">Chris Wanstrath</a> <a rel="nofollow" target="_blank" href="http://hellorip.com/about.html">ports</a> free software.</p>
<p>Is there a muse that you can choose?</p>
<p>What other reasons are there for writing examples? Perhaps leave comments below and I&#8217;ll add them to the list above.</p>
<h3 id="who_me">Who? Me?</h3>
<p>And &#8220;awesome&#8221; sounds awfully challenging to aim for. Surely, &#8220;Awesome&#8221; is just one end of a scale with &#8220;Worthless&#8221; at the other end. &#8220;Moderately Good&#8221;, &#8220;Average&#8221;, &#8220;Below Average&#8221;, and &#8220;Where are the test cases?!&#8221; are in the middle.</p>
<p>Have you ever visited a friend who you find putting on the finishing touches to a 6&#8217; by 4&#8217; canvas painting of their entire family from their last Christmas dinner together, and they say &#8220;want to help?&#8221; Unlikely. Fortunately open source software &#8220;paintings&#8221; are a free-for-all.</p>
<p>You can write Libraries, Adaptors, Applications, Frameworks, Tools, Extensions and Services.</p>
<p>You don&#8217;t even need to create new free software. Fix something that someone else broke. Add a feature that was missing. Write documentation after you eventually figured out what to do.</p>
<h3 id="mid_year8217s_resolution">Mid-Year&#8217;s Resolution</h3>
<p>It&#8217;s now April. If you&#8217;re still looking for a 2010 New Year&#8217;s Resolution, borrow this one: &#8220;Write some open source software.&#8221;</p>
<p>If you&#8217;re going to RailsConf, perhaps come along to my tutorial <a rel="nofollow" target="_blank" href="http://en.oreilly.com/rails2010/public/schedule/detail/14174">The 8 Steps to Contributing to OSS</a> or let&#8217;s catch up in the corridors. It&#8217;s going to be a great RailsConf!</p>
<p><a rel="nofollow" target="_blank" href="http://en.oreilly.com/rails2010/public/schedule/detail/14174"><img src="http://img.skitch.com/20100409-tjw5twwex9n4hnsffbpkyyj59k.jpg" alt="rails2010_header_bg" width="100%"/></a></p>


<p>Related posts:<ol><li><a rel="nofollow" target="_blank" href='http://drnicwilliams.com/' title='Permanent Link: Home'>Home</a> <small>...</small></li><li><a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2009/07/13/futureruby-talk-living-with-1000-open-source-projects/' title='Permanent Link: FutureRuby talk: Living With 1000 Open Source Projects'>FutureRuby talk: Living With 1000 Open Source Projects</a> <small>The FutureRuby conference has been (and still is, as of...</small></li></ol></p><img src="http://feeds.feedburner.com/~r/mocra/~4/7k69LmQPCf0" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://drnicwilliams.com/2010/04/09/how-to-make-a-good-home-made-open-source/</feedburner:origLink></item>
      <item>
         <title>Using CoffeeScript in Rails and even on Heroku</title>
         <link>http://feedproxy.google.com/~r/mocra/~3/72Tz2lb-rjg/</link>
         <description>I&amp;#8217;m pretty excited about CoffeeScript as a clean-syntax replacement for pure JavaScript. What is CoffeeScript? Imagine all the syntactical delights of Ruby and Haml for your JavaScript. You write in a nice language, but get normal JavaScript at runtime. All whilst having full access to 3rd-party JavaScript libraries (jQuery, PrototypeJS), debugging support (it becomes pure, [...]


Related posts:&lt;ol&gt;&lt;li&gt;&lt;a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2010/06/01/validate-and-save-your-ruby-in-textmate-with-secret-rubinus-superpowers/' title='Permanent Link: Validate and Save your Ruby in TextMate &amp;#8211; with secret Rubinus superpowers'&gt;Validate and Save your Ruby in TextMate &amp;#8211; with secret Rubinus superpowers&lt;/a&gt; &lt;small&gt;In some TextMate bundles, if you save a file it...&lt;/small&gt;&lt;/li&gt;&lt;li&gt;&lt;a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2010/05/28/showcase-of-coffeescript-2-5-mins-for-your-next-dev-group-meeting/' title='Permanent Link: Showcase of CoffeeScript &amp;#8211; 2.5 mins for your next Dev Group meeting'&gt;Showcase of CoffeeScript &amp;#8211; 2.5 mins for your next Dev Group meeting&lt;/a&gt; &lt;small&gt; If you are giving an &amp;#8220;Introduction to CoffeeScript&amp;#8221; talk...&lt;/small&gt;&lt;/li&gt;&lt;li&gt;&lt;a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2009/11/12/dead-simple-javascript-unit-testing-in-rails/' title='Permanent Link: Dead simple JavaScript Unit Testing in Rails'&gt;Dead simple JavaScript Unit Testing in Rails&lt;/a&gt; &lt;small&gt; Formats: Video/Screencast (410 Mb, torrent) | Video only (vimeo)...&lt;/small&gt;&lt;/li&gt;&lt;/ol&gt;</description>
         <guid isPermaLink="false">http://drnicwilliams.com/?p=713</guid>
         <pubDate>Mon, 15 Mar 2010 12:46:52 +0000</pubDate>
         <content:encoded><![CDATA[<p>I&#8217;m pretty excited about <a rel="nofollow" target="_blank" href="http://jashkenas.github.com/coffee-script/">CoffeeScript</a> as a clean-syntax replacement for pure JavaScript. </p>
<h3 id="what_is_coffeescript">What is CoffeeScript?</h3>
<p><img src="http://img.skitch.com/20100315-mq3h882gd6742tixy78mnbc5jt.png" width="550px"></p>
<p>Imagine all the syntactical delights of Ruby and Haml for your JavaScript. You write in a nice language, but get normal JavaScript at runtime. All whilst having full access to 3rd-party JavaScript libraries (jQuery, PrototypeJS), debugging support (it becomes pure, readable JavaScript), existing support from test suites (it&#8217;s normal JavaScript) and growing support from various text editors (<a rel="nofollow" target="_blank" href="http://github.com/jashkenas/coffee-script-tmbundle">TextMate</a>, <a rel="nofollow" target="_blank" href="http://github.com/jashkenas/coffee-script/blob/master/extras/coffee.vim">Vim</a>, <a rel="nofollow" target="_blank" href="http://github.com/defunkt/coffee-mode">Emacs</a>).</p>
<p>What simple delights?</p>
<p>No trailing semi-colons. No <code>{ some_code() }</code> function/closure brackets. String interpolation. Multi-line strings. Explicit <code>class</code> syntax. Array slicing. An existential ? operator.</p>
<p>Scroll down the <a rel="nofollow" target="_blank" href="http://jashkenas.github.com/coffee-script/">home page</a> for awesome example after example.</p>
<p>These aren&#8217;t library extensions. This is clean, purposeful syntax.</p>
<p>You can play with the joyful syntax of CoffeeScript on the website. After reading the basic examples on the <a rel="nofollow" target="_blank" href="http://jashkenas.github.com/coffee-script/">CoffeeScript home page</a>, press &#8220;TRY COFFEESCRIPT&#8221; in the header menu.</p>
<p>As you play with the syntax, the equivalent JavaScript is printed on the right hand side (see image above).</p>
<p>How nice is that syntax? Very.</p>
<h3 id="installing_coffeescript">Installing CoffeeScript</h3>
<ol>
<li>Install NodeJS</li>
<li>Install CoffeeScript</li>
</ol>
<p>For NodeJS (<a rel="nofollow" target="_blank" href="http://nodejs.org/#download">get latest release URL</a>; using 0.1.31 as 0.1.32 doesn&#8217;t unpack for me):</p>
<pre><code>cd /usr/local/src
wget http://nodejs.org/dist/node-v0.1.31.tar.gz
tar xfv node-v0.1.31.tar.gz
cd node-v0.1.31
./configure
make
sudo make install
</code></pre>
<p>For CoffeeScript (<a rel="nofollow" target="_blank" href="http://jashkenas.github.com/coffee-script/#installation">get latest release URL</a>):</p>
<pre><code>cd /usr/local/src
wget http://github.com/jashkenas/coffee-script/tarball/0.5.5
tar xfv jashkenas-coffee-script-bcf7b3f.tar.gz
cd jashkenas-coffee-script-bcf7b3f
sudo bin/cake install
</code></pre>
<p>Now test that everything is in place:</p>
<pre><code>$ coffee --version
CoffeeScript version 0.5.5
$ coffee -e "sys: require 'sys'; sys.puts 'hello world&#92;n'"
hello world
</code></pre>
<p>Phew!</p>
<p>Note, in the command-line/on the server, you are using the NodeJS JavaScript environment. It supports the <a rel="nofollow" target="_blank" href="http://commonjs.org/">CommonJS</a> API for loading modules (normal JavaScript: <code>var sys = require('sys')</code>).</p>
<h3 id="um_but_how_do_i_use_it_in_my_web_app">Um, but how do I use it in my web app?</h3>
<p>Your application source code will have <code>*.coffee</code> files containing your sexy, short CoffeeScript. But at runtime, the browser needs the generated JavaScript.</p>
<p>I&#8217;ve been using the Jonas Nicklas&#8217; <a rel="nofollow" target="_blank" href="http://github.com/jnicklas/bistro_car">bistro_car</a> gem:</p>
<pre><code>gem install bistro_car
mkdir -p app/scripts
</code></pre>
<p>In your Rails <code>config/environment.rb</code> file, add:</p>
<pre><code>config.gem 'bistro_car'
</code></pre>
<p>And in your layouts, such as <code>app/views/layouts/application.html.erb</code> add to the <code>&lt;head&gt;</code> or the bottom:</p>
<pre><code>&lt;%= coffee_script_bundle %&gt;
</code></pre>
<p>Now you&#8217;re good to go. Add your CoffeeScript files in <code>app/scripts/*.coffee</code> and they will be automatically available as JavaScript.</p>
<h3 id="warning_check_your_version_of_coffeescript">WARNING: Check your version of CoffeeScript</h3>
<p>Check that this hasn&#8217;t happened:</p>
<pre><code>$ coffee --version
CoffeeScript version 0.3.2
$ which coffee
/usr/bin/coffee
</code></pre>
<p>Arrgh, we should be using <code>/usr/local/bin/coffee</code>. <code>bistro_car</code> currently installs the old rubygem-based version of coffee-script; and you might be unlucky to have your $PATH find the wrong one first.</p>
<p>Either delete it (<code>sudo rm /usr/bin/coffee</code> and restart your shell) or make sure <code>/usr/local/bin</code> is earlier in your <code>$PATH</code> than <code>/usr/bin</code>, where RubyGems installed the old, unnecessary version of <code>coffee</code> command.</p>
<h3 id="let8217s_drink_the_coffeescript">Let&#8217;s drink the CoffeeScript</h3>
<p>Create a file <code>app/scripts/application.coffee</code> with contents:</p>
<pre><code>powers: [1,2,3,4].map (i) -&gt; i * i
alert powers
</code></pre>
<p>Load up a view in a browser and see <code>[1,4,9,16]</code>. You win! Throw in some jQuery/PrototypeJS/whatever. Beautiful.</p>
<p>View the source of the page, navigate to <code>public/javascripts/bundle/default.js</code> and you&#8217;ll see the generated source:</p>
<pre class="sh_javascript"><code>(function(){
  var powers;
  powers = [1, 2, 3, 4].map(function(i) {
    return i * i;
  });
  alert(powers);
})();
</code></pre>
<h3 id="the_problem_heroku_doesn8217t_have_coffeescript_installed">The problem: Heroku doesn&#8217;t have CoffeeScript installed</h3>
<p>Heroku is a great place to host apps. Though it doesn&#8217;t have CoffeeScript installed so it cannot dynamically convert the <code>*.coffee</code> files into JavaScript.</p>
<p>If you want to use Heroku I guess we need to perform the conversion locally and deploy it.</p>
<p>But. In development and integration testing I want bistro_car&#8217;s dynamically generated <code>default.js</code>. In production, I need a cached version.</p>
<p>In <code>application.html.haml</code> I use (I can&#8217;t keep pretending I use erb):</p>
<pre class="sh_ruby"><code>- if Rails.env.production?
  = javascript_include_tag "coffeescripts"
- else
  = coffee_script_bundle
</code></pre>
<p>Now we&#8217;re just left with the hassle of automatically generating <code>public/javascripts/coffeescripts.js</code>.</p>
<p>First, a rake task. Second, a git pre-commit hook.</p>
<p>Create <code>lib/tasks/bistro_car.rake</code>:</p>
<pre class="sh_ruby"><code>desc "Generate the cached bundle/default.js file from app/scripts/*.coffee files"
task :bistro_car =&gt; :environment do
  path = "public/javascripts/coffeescripts.js"
  puts "Building *.coffee -&gt; #{path}"
  File.open(path, "w") { |file| file &lt;&lt; BistroCar::Bundle.new('default').to_javascript }
end

file "public/javascripts/coffeescripts.js" =&gt; Dir[File.join(Rails.root, 'app/scripts/*.coffee')] do |t|
  Rake::Task["bistro_car"].invoke
end
</code></pre>
<p>Now you can create <code>coffeescripts.js</code> and add it to the repo with:</p>
<pre><code>rake public/javascripts/coffeescripts.js
git add public/javascripts/coffeescripts.js
git commit -m "Initial bundled coffeescripts file"
</code></pre>
<p>Now create <code>.git/hooks/pre-commit</code>:</p>
<pre class="sh_sh"><code>#!/bin/sh

exec rake public/javascripts/coffeescripts.js
</code></pre>
<p>And make it executable (and <code>git commit</code> will invoke it automatically):</p>
<pre><code>chmod +x .git/hooks/pre-commit
</code></pre>
<p>Phew.</p>
<p>Now, whenever you change a *.coffee script and you are about to commit it, the cached-production-only <code>coffeescripts.js</code> is automatically updated and included in the same commit.</p>
<p>Seems like a clean hack.</p>
<h3 id="summary">Summary</h3>
<p>Why not make a library to do this? Well I&#8217;m hoping there is a better, cleaner way. Perhaps <code>bistro_car</code> can include a rails generator to package these bits and pieces itself, if my approach happens to be the best way.</p>
<p>Nonetheless, let history record that CoffeeScript is very cool though in the world of Heroku living with it is non-trivial at the moment.</p>


<p>Related posts:<ol><li><a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2010/06/01/validate-and-save-your-ruby-in-textmate-with-secret-rubinus-superpowers/' title='Permanent Link: Validate and Save your Ruby in TextMate &#8211; with secret Rubinus superpowers'>Validate and Save your Ruby in TextMate &#8211; with secret Rubinus superpowers</a> <small>In some TextMate bundles, if you save a file it...</small></li><li><a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2010/05/28/showcase-of-coffeescript-2-5-mins-for-your-next-dev-group-meeting/' title='Permanent Link: Showcase of CoffeeScript &#8211; 2.5 mins for your next Dev Group meeting'>Showcase of CoffeeScript &#8211; 2.5 mins for your next Dev Group meeting</a> <small> If you are giving an &#8220;Introduction to CoffeeScript&#8221; talk...</small></li><li><a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2009/11/12/dead-simple-javascript-unit-testing-in-rails/' title='Permanent Link: Dead simple JavaScript Unit Testing in Rails'>Dead simple JavaScript Unit Testing in Rails</a> <small> Formats: Video/Screencast (410 Mb, torrent) | Video only (vimeo)...</small></li></ol></p><img src="http://feeds.feedburner.com/~r/mocra/~4/72Tz2lb-rjg" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://drnicwilliams.com/2010/03/15/using-coffeescript-in-rails-and-even-on-heroku/</feedburner:origLink></item>
      <item>
         <title>Customized Google Forms</title>
         <link>http://feedproxy.google.com/~r/mocra/~3/KSJsfZr2wcY/</link>
         <description>Google Forms are a great, free way to collect information from anyone, stored directly into a Google Spreadsheet, and then have Google notify you each time a form is submitted (optionally). The downside is that you can only use one of their pre-packaged themes. You can&amp;#8217;t have your company logo and corporate &amp;#8220;look&amp;#8221;. Pooey to [...]


Related posts:&lt;ol&gt;&lt;li&gt;&lt;a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2009/03/30/closing-in-on-the-dream-one-click-to-deploy-rails-apps/' title='Permanent Link: Closing in on The Dream: &amp;#8220;one-click-to-deploy Rails apps&amp;#8221;'&gt;Closing in on The Dream: &amp;#8220;one-click-to-deploy Rails apps&amp;#8221;&lt;/a&gt; &lt;small&gt; Got a simple app you want to build? Allocate...&lt;/small&gt;&lt;/li&gt;&lt;/ol&gt;</description>
         <guid isPermaLink="false">http://drnicwilliams.com/?p=688</guid>
         <pubDate>Thu, 25 Feb 2010 11:30:24 +0000</pubDate>
         <content:encoded><![CDATA[<p><img src="http://img.skitch.com/20100225-rm11rdpj6qib6ukbwdi87ewd76.preview.jpg" alt="Google Form Customized" style="float:right;width:200px;"/></p>
<p>Google Forms are a great, free way to collect information from anyone, stored directly into a Google Spreadsheet, and then have Google notify you each time a form is submitted (optionally). The downside is that you can only use one of their pre-packaged themes. You can&#8217;t have your company logo and corporate &#8220;look&#8221;.</p>
<p>Pooey to Google, we say. So we wrote <a rel="nofollow" target="_blank" href="http://github.com/mocra/custom_google_forms">custom_google_forms</a>.</p>
<p>Want to truly customized Google Forms? Fork this repository, customize the CSS, DOM and images, and deploy to Heroku. You can then host/customize any number of Google Forms.</p>
<p>For example, here is an original <a rel="nofollow" target="_blank" href="http://spreadsheets.google.com/a/mocra.com/viewform?formkey=dFo0LXQyYmlEV2dXcVJ6WjRweW9vRnc6MA">bare Google Form</a> and here is a <a rel="nofollow" target="_blank" href="http://forms.mocra.com/railsdev">fully customized version</a>, including form validation and thank you page.</p>
<p>It&#8217;s fully a dynamic, thin layer on top of Google Forms. If you change your Google Form, your custom form application automatically changes.</p>
<h2 id="how_to_use_google_forms">How to use Google Forms?</h2>
<p>Perhaps read <a rel="nofollow" target="_blank" href="http://docs.google.com/support/bin/answer.py?hl=en&amp;answer=87809">this docco</a>? Essentially if you can access Google Spreadsheets, you can create a Google Form (which automatically creates and updates a Google Spreadsheet based on the fields and form submissions).</p>
<h2 id="fork_and_customize">Fork and Customize</h2>
<p>It&#8217;s really simple to play with and customize Google Forms. Clone the <a rel="nofollow" target="_blank" href="http://github.com/mocra/custom_google_forms">GitHub project</a> and fire up the Rails server:</p>
<pre><code>gem install github
cd ~/Sites
gh clone mocra/custom-google-forms yourdomain-google-forms
cd yourdomain-google-forms
script/server
</code></pre>
<p>Go to <a rel="nofollow" target="_blank" href="http://localhost:3000/google_forms/new">http://localhost:3000/google_forms/new</a> and add a Google Form:</p>
<p><img src="http://img.skitch.com/20100225-msfc5a8gk5rnm5pm7qdy9fd6x6.jpg" alt="My Google Forms - New" style="width:100%;"/></p>
<p>The &#8220;Slug&#8221; is the URL path people will follow. That is, a slug &#8220;railsdev&#8221; maps to <a rel="nofollow" target="_blank" href="http://forms.mocra.com/railsdev">http://forms.mocra.com/railsdev</a>.</p>
<p>The &#8220;Form Key&#8221; field takes either the <a rel="nofollow" target="_blank" href="http://spreadsheets.google.com/a/mocra.com/viewform?hl=en&amp;formkey=dFo0LXQyYmlEV2dXcVJ6WjRweW9vRnc6MA">Form URL</a> or just the formkey parameter (e.g. dFo0LXQyYmlEV2dXcVJ6WjRweW9vRnc6MA) from when you view the live form.</p>
<p>Press &#8220;Create&#8221; and follow the slug url to view your Google Form through your own customized style.</p>
<p>Well, initially you&#8217;ll see the Mocra style. Let&#8217;s fix that.</p>
<h1 id="default_theme">Default Theme</h1>
<p>First, fork the github repository so that you can push your style changes to your own repo.</p>
<pre><code>gh fork
mate public/stylesheets/style.css
</code></pre>
<p>Now, edit <a rel="nofollow" target="_blank" href="http://github.com/mocra/custom_google_forms/blob/master/public/stylesheets/style.css">public/stylesheets/style.css</a> to your tastes.</p>
<p>Please don&#8217;t reuse our style. Aside from you looking a bit silly having the :mocra logo at the top, it would be weird if your forms looked like our forms. I guess you might as well have used the default Google Form themes?</p>
<h1 id="heroku_deployment">Heroku Deployment</h1>
<p>Let&#8217;s not get fancy, let&#8217;s just deploy your fork to Heroku. It&#8217;s free. It&#8217;s simple. You&#8217;ll be done in two minutes.</p>
<p>To get your copy of the application deployed to <a rel="nofollow" target="_blank" href="http://heroku.com">heroku</a>:</p>
<pre><code>gem install heroku
heroku create yourdomain-google-forms
git push heroku master
heroku rake db:migrate
</code></pre>
<p>Two optional environment variables:</p>
<pre><code>heroku config:add GOOGLE_ANALYTICS='YOURCODE'
</code></pre>
<p>If specified, Google Analytics will be included on all pages (including the custom Google Forms page).</p>
<pre><code>heroku config:add EXPECTED_DOMAIN='some.yourdomain.com'
</code></pre>
<p>If specified, &#8216;yourdomain-google-forms.heroku.com/someform&#8217; automatically redirects to &#8216;some.domain.com/someform&#8217;. </p>
<p>For example, for http://forms.mocra.com we used:</p>
<pre><code>heroku config:add GOOGLE_ANALYTICS='UA-5370510-4'
heroku config:add EXPECTED_DOMAIN='forms.mocra.com'
</code></pre>
<h1 id="getting_started">Getting Started</h1>
<p>Once deployed, go to the /google_forms/new URL and add your first form. Once it is validated and added, you can start using it using the links shown.</p>
<h1 id="summary">Summary</h1>
<p>Yay for free, customized Google Forms! Yay for free Heroku hosting!</p>
<p>Bonus: you can configure your Google Forms/Spreadsheet to notify you when new forms are submitted. That&#8217;s handy.</p>
<p>Thanks to Odin Dutton, our resident designer at Mocra, who did a great job applying our new theme to the Google Forms DOM structure. It&#8217;s wonderful having him on the team!</p>


<p>Related posts:<ol><li><a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2009/03/30/closing-in-on-the-dream-one-click-to-deploy-rails-apps/' title='Permanent Link: Closing in on The Dream: &#8220;one-click-to-deploy Rails apps&#8221;'>Closing in on The Dream: &#8220;one-click-to-deploy Rails apps&#8221;</a> <small> Got a simple app you want to build? Allocate...</small></li></ol></p><img src="http://feeds.feedburner.com/~r/mocra/~4/KSJsfZr2wcY" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://drnicwilliams.com/2010/02/25/customized-google-forms/</feedburner:origLink></item>
      <item>
         <title>Making a pretty Firefox Beta application icon</title>
         <link>http://feedproxy.google.com/~r/mocra/~3/Ha9nNxI24Pk/</link>
         <description>Here&amp;#8217;s the problem: I install OS X Firefox 3.6b2 along side Firefox 3.5. They are both in my dock. Their icons are the same. Um, which is which? How about a sexy Firefox Beta icon to separate what&amp;#8217;s-what in the dock, Quicksilver, Spotlight etc? This post shows how to create a &amp;#8220;beta Firefox&amp;#8221; icon, install [...]


Related posts:&lt;ol&gt;&lt;li&gt;&lt;a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2009/04/06/easy-scheduling-by-location-tasks-and-people-a-case-study-of-a-client-application-from-mocra/' title='Permanent Link: Easy scheduling by location, tasks and people &amp;#8211; a case study of a client application from Mocra'&gt;Easy scheduling by location, tasks and people &amp;#8211; a case study of a client application from Mocra&lt;/a&gt; &lt;small&gt; UPDATE: Orchestrate was reported in TechCrunch Several years ago...&lt;/small&gt;&lt;/li&gt;&lt;/ol&gt;</description>
         <guid isPermaLink="false">http://drnicwilliams.com/?p=661</guid>
         <pubDate>Sun, 15 Nov 2009 22:41:25 +0000</pubDate>
         <content:encoded><![CDATA[<p><img src="http://img.skitch.com/20091113-xhgyhxk8eiuanrs1au27k1pnmd.png" style="float:right;"></p>
<p>Here&#8217;s the problem: I install OS X Firefox 3.6b2 along side Firefox 3.5. They are both in my dock. Their icons are the same. Um, which is which?</p>
<p>How about a sexy Firefox Beta icon to separate what&#8217;s-what in the dock, Quicksilver, Spotlight etc?</p>
<p>This post shows how to create a &#8220;beta Firefox&#8221; icon, install it into the Firefox 3.6b2 OS X application, and live long and prosperously.</p>
<h2 id="installing_firefox_36b2_along_side_firefox_35">Installing Firefox 3.6b2 along side Firefox 3.5</h2>
<p>I think these are the instructions for having two Firefoxes:</p>
<p>Download the Beta DMG. Open it. <strong>Don&#8217;t just drag</strong> the Firefox icon into the provided Application symlink folder.</p>
<p><a rel="nofollow" target="_blank" href="http://www.mozilla.com/en-US/firefox/all-beta.html"><img src="http://img.skitch.com/20091113-ka45x4rutq43ifnwbdfnkyiksj.jpg" alt="firefox beta"/></a></p>
<p>Create in your Applications folder, create &#8220;beta&#8221; folder for all things beta (your you could rename the Firefox beta application or whatever). From the DMG window, drag the Firefox application icon into your &#8220;beta&#8221; folder.</p>
<p>To run it, close down Firefox if it&#8217;s running, and launch the new one. Done.</p>
<h2 id="creating_new_application_icons">Creating new Application icons</h2>
<p><a rel="nofollow" target="_blank" href="http://mocra.com/projects/iconmerge/">iConMerge</a> is a nice OS X tool to create composite application icons and install them. It is freeware from <a rel="nofollow" target="_blank" href="http://mocra.com/">Mocra</a>.</p>
<p><a rel="nofollow" target="_blank" href="http://mocra.com/project_downloads/iconmerge/iConMerge.dmg"><img src="http://img.skitch.com/20091113-nqy7gqe6n7rwqj6wpua8cibsf8.png"></a></p>
<p>You drag images or existing Applications into the two left slots and it automatically creates a composite icon. Press the <code>&lt;--&gt;</code> arrow to switch them.</p>
<p>See the project home page for instructions.</p>
<p>The &#8220;beta&#8221; sub-icon I used is below. Download it OR try dragging it directly from the browser into iConMerge.</p>
<p><img src="http://img.skitch.com/20091113-87ucaiauf1jy764i4qrmmh5utd.png" style="width:80px;"></p>
<h2 id="applying_new_icon_to_firefox_beta">Applying new icon to Firefox Beta</h2>
<p><img src="http://img.skitch.com/20091113-xhgyhxk8eiuanrs1au27k1pnmd.png" style="float:right;"></p>
<p>Click &#8220;Export&#8221; and select the Firefox beta Application. Done.</p>
<p>When you restart Firefox beta, you&#8217;ll see it&#8217;s Dock icon has changed. </p>
<p>Right click on the Dock icon, select &#8220;Keep in Dock&#8221; and them drag the icon next to your existing Firefox 3.5 application. Two Firefoxes, two different icons, happy times.</p>


<p>Related posts:<ol><li><a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2009/04/06/easy-scheduling-by-location-tasks-and-people-a-case-study-of-a-client-application-from-mocra/' title='Permanent Link: Easy scheduling by location, tasks and people &#8211; a case study of a client application from Mocra'>Easy scheduling by location, tasks and people &#8211; a case study of a client application from Mocra</a> <small> UPDATE: Orchestrate was reported in TechCrunch Several years ago...</small></li></ol></p><img src="http://feeds.feedburner.com/~r/mocra/~4/Ha9nNxI24Pk" height="1" width="1"/>]]></content:encoded>
         <category>Mocra</category>
      <feedburner:origLink>http://drnicwilliams.com/2009/11/16/making-a-pretty-firefox-beta-application-icon/</feedburner:origLink></item>
      <item>
         <title>Dead simple JavaScript Unit Testing in Rails</title>
         <link>http://feedproxy.google.com/~r/mocra/~3/AcWfRFR3xmA/</link>
         <description>Formats: Video/Screencast (410 Mb, torrent) &amp;#124; Video only (vimeo) Start downloading the torrent now, read this article 37 times and the video might be ready to watch. Writing tests are great for helping you design and think out your code, and the bonus is you end up with a test suite to aide in fighting [...]


Related posts:&lt;ol&gt;&lt;li&gt;&lt;a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2010/03/15/using-coffeescript-in-rails-and-even-on-heroku/' title='Permanent Link: Using CoffeeScript in Rails and even on Heroku'&gt;Using CoffeeScript in Rails and even on Heroku&lt;/a&gt; &lt;small&gt;I&amp;#8217;m pretty excited about CoffeeScript as a clean-syntax replacement for...&lt;/small&gt;&lt;/li&gt;&lt;li&gt;&lt;a rel="nofollow" target="_blank" href='http://drnicwilliams.com/presentations/' title='Permanent Link: Presentations'&gt;Presentations&lt;/a&gt; &lt;small&gt; RailsConf 2010: Contributing to Open Source Not sure how...&lt;/small&gt;&lt;/li&gt;&lt;li&gt;&lt;a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2009/11/03/first-look-at-rails-3-0-pre/' title='Permanent Link: First look at rails 3.0.pre'&gt;First look at rails 3.0.pre&lt;/a&gt; &lt;small&gt; This article is out of date in some aspects....&lt;/small&gt;&lt;/li&gt;&lt;/ol&gt;</description>
         <guid isPermaLink="false">http://drnicwilliams.com/?p=650</guid>
         <pubDate>Thu, 12 Nov 2009 03:30:23 +0000</pubDate>
         <content:encoded><![CDATA[<div style="padding:10px;background-color:black;">
<a rel="nofollow" target="_blank" href="http://drnicwilliams.com/wp-content/uploads/torrents/Dead Simple Unit Testing - Dr Nic Williams - Rails Underground 2009.torrent"><img style="width:100%;" src="http://img.skitch.com/20091112-chanatee6aucyjqnxi54iaae3x.png" alt="Skills Matter : Rails Underground 2009: on Dead simple JavaScript Testing"/></a>
</div>
<p>Formats: <a rel="nofollow" target="_blank" href="http://drnicwilliams.com/wp-content/uploads/torrents/Dead Simple Unit Testing - Dr Nic Williams - Rails Underground 2009.torrent">Video/Screencast</a> (410 Mb, torrent) | <a rel="nofollow" target="_blank" href="http://skillsmatter.com/podcast/ajax-ria/dead-simple-javascript-unit-tests-in-rails-with-blue-ridge-and-screw-unit">Video only</a> (vimeo)</p>
<div class="notice">
<p>Start downloading the <a rel="nofollow" target="_blank" href="http://drnicwilliams.com/wp-content/uploads/torrents/Dead Simple Unit Testing - Dr Nic Williams - Rails Underground 2009.torrent">torrent</a> now, read this article 37 times and the video might be ready to watch.</p>
</div>
<p>Writing tests are great for helping you design and think out your code, and the bonus is you end up with a test suite to aide in fighting against regressions. Why? It&#8217;s embarrassing when your JavaScript doesn&#8217;t work in production.</p>
<p>But how do you get started with testing JavaScript? How do you make it easy? I mean, so easy that you&#8217;d feel stupid to not write tests?</p>
<p>And how do you know if your designer/HTML-chopper has broken your JavaScript? How do you find out if JavaScript is broken in CI builds? And what is the appropriate punishment for designers who break JavaScript?</p>
<p>Finally, it is now uber easy to get started: the <a rel="nofollow" target="_blank" href="http://github.com/relevance/blue-ridge">blue-ridge</a> plugin for Rails. (I previously <a rel="nofollow" target="_blank" href="http://drnicwilliams.com/2009/06/07/tdd-for-greasemonkey-scripts-and-introducing-ninja-search-js/">discussed it</a> near the bottom)</p>
<p>To spread the word, I travelled to London, England for the <a rel="nofollow" target="_blank" href="http://www.rails-underground.com/">Rails Underground</a> conference a few months ago. The presentation is <a rel="nofollow" target="_blank" href="http://skillsmatter.com/podcast/ajax-ria/dead-simple-javascript-unit-tests-in-rails-with-blue-ridge-and-screw-unit">now online</a> (recorded and published by SkillsMatter).</p>
<p>I was also recording the screen during the presentation and we&#8217;ve composited the two together (a la <a rel="nofollow" target="_blank" href="http://www.confreaks.com/">confreaks</a>) and it&#8217;s available via <a rel="nofollow" target="_blank" href="http://drnicwilliams.com/wp-content/uploads/torrents/Dead Simple Unit Testing - Dr Nic Williams - Rails Underground 2009.torrent">BitTorrent</a>. If you can seed for the next few days, that would be greatly appreciated too.</p>
<p>The talk is 45 minutes and questions are 6 mins. (I sadly don&#8217;t repeat into the microphone some of the questions because the room acoustics were good and everyone could hear everyone else&#8217;s questions. Sorry.)</p>
<p><a rel="nofollow" target="_blank" href="http://drnicwilliams.com/wp-content/uploads/torrents/Dead Simple Unit Testing - Dr Nic Williams - Rails Underground 2009.torrent">Go get it now</a>.</p>
<h2 id="why_blue_ridge">Why Blue Ridge?</h2>
<p>This recording was done in July 2009, a few months ago. Is Blue Ridge still the bees-knees? I think so. It has issues, edge cases and bugs, but I don&#8217;t think there is a similar nor better Rails extension that includes (out of the box) a headless test runner, a bundle of test libraries (Screw.Unit, Smoke, etc), Rails generators, and automated discovery of &#8220;the designer broke our JavaScript!&#8221; lynch-mobbing (see my branch below).</p>
<p>These are the things I want. If there&#8217;s a better testing environment (say on HTMLUnit instead of env.js), then I think the killer packaging is to bundle it all up, with the features above, so it is drop-in, dead simple to use.</p>
<h2 id="my_history_with_javascript_testing">My history with JavaScript testing</h2>
<p>In the introduction I talk about my life with JavaScript and testing. Here is the extended summary if it&#8217;s interesting to you at all:</p>
<ul>
<li>2005:
<ul>
<li>ASP.NET + Ajax == &#8220;crapola&#8221;</li>
<li>Rails promo: &#8220;easier to do Ajax than not to&#8221;</li>
<li>Inline JavaScript helpers</li>
</ul>
</li>
<li>2006:
<ul>
<li>RJS to generate JavaScript</li>
</ul>
</li>
<li>2007:
<ul>
<li>JavaScript only in its own files</li>
<li>Unobtrusive JavaScript</li>
<li>Got myself into terrible mess with MyConfPlan</li>
<li>How to test JavaScript?</li>
</ul>
</li>
<li>2008:
<ul>
<li>Figured out how to test it</li>
<li>Write a PeepCode but never published it</li>
<li>Wrote <a rel="nofollow" target="_blank" href="http://newjs.rubyforge.org/">newjs</a> and <a rel="nofollow" target="_blank" href="http://jsunittest.com/">jsunittest</a></li>
</ul>
</li>
<li>2009:
<ul>
<li>Found <a rel="nofollow" target="_blank" href="http://github.com/relevance/blue-ridge">BlueRidge plugin for Rails</a></li>
<li>Headless test runner</li>
<li>BDD tests via Screw.Unit</li>
<li>Generators</li>
</ul>
</li>
</ul>
<h2 id="miscellaneous">Miscellaneous</h2>
<p>I mention a couple of miscellaneous things. Here&#8217;s a summary.</p>
<p><a rel="nofollow" target="_blank" href="http://github.com/drnic/blue-ridge">My fork of blue-ridge</a> has the feature to render sample HTML from your templates. It wasn&#8217;t accepted into the primary blue-ridge library because it was rspec only. Perhaps someone can make it work for test/unit etc.</p>
<p>I alias the <code>script/generate</code> command:</p>
<pre><code>alias gen="script/generate"
</code></pre>
<p>I&#8217;m extending TextMate with Ciarán Walsh&#8217;s <a rel="nofollow" target="_blank" href="http://ciaranwal.sh/projectplus">ProjectPlus</a> plug-in (<a rel="nofollow" target="_blank" href="http://github.com/ciaran/projectplus/">source</a>). It&#8217;s sweet.</p>
<h2>Thanks</h2>
<p>Thanks to Mark Coleman for organising <a rel="nofollow" target="_blank" href="http://www.rails-underground.com/">Rails Underground</a>, inviting me over, and having the sessions recorded. And to SkillsMatter for recording and publishing the raw footage.</p>
<p>Thanks to <a rel="nofollow" target="_blank" href="http://bjeanes.com/">Bo Jeanes</a> for helping to get Final Cut Pro to mash the screencast and the SkillsMatter video into one video.</p>
<p>Thanks to Jack Chen for hacking some code to push the video up to s3 (when Transmit and BaconDrop were failing me)</p>


<p>Related posts:<ol><li><a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2010/03/15/using-coffeescript-in-rails-and-even-on-heroku/' title='Permanent Link: Using CoffeeScript in Rails and even on Heroku'>Using CoffeeScript in Rails and even on Heroku</a> <small>I&#8217;m pretty excited about CoffeeScript as a clean-syntax replacement for...</small></li><li><a rel="nofollow" target="_blank" href='http://drnicwilliams.com/presentations/' title='Permanent Link: Presentations'>Presentations</a> <small> RailsConf 2010: Contributing to Open Source Not sure how...</small></li><li><a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2009/11/03/first-look-at-rails-3-0-pre/' title='Permanent Link: First look at rails 3.0.pre'>First look at rails 3.0.pre</a> <small> This article is out of date in some aspects....</small></li></ol></p><img src="http://feeds.feedburner.com/~r/mocra/~4/AcWfRFR3xmA" height="1" width="1"/>]]></content:encoded>
         <category>Mocra</category>
      <feedburner:origLink>http://drnicwilliams.com/2009/11/12/dead-simple-javascript-unit-testing-in-rails/</feedburner:origLink></item>
      <item>
         <title>Hacking someone’s gem with github and gemcutter</title>
         <link>http://feedproxy.google.com/~r/mocra/~3/4I-bA7HLVnI/</link>
         <description>Ever used a rubygem, found a bug, and just wanted to quickly bust out the big guns and fix it quickly? The gem command doesn&amp;#8217;t come packed with a way to find the original source repository for a gem. At best, most gems at least come bundled with the complete source, tests and documentation. Some [...]


Related posts:&lt;ol&gt;&lt;li&gt;&lt;a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2008/12/21/migrating-project-websites-to-github-pages-with-sake-tasks-new-websites-with-jekyll_generator/' title='Permanent Link: Migrating project websites to github pages with sake tasks, new websites with jekyll_generator'&gt;Migrating project websites to github pages with sake tasks, new websites with jekyll_generator&lt;/a&gt; &lt;small&gt; Its almost Christmas time and that means presents. It...&lt;/small&gt;&lt;/li&gt;&lt;li&gt;&lt;a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2008/10/31/newgem-100-all-thanks-to-cucumber/' title='Permanent Link: newgem 1.0.0 all thanks to Cucumber'&gt;newgem 1.0.0 all thanks to Cucumber&lt;/a&gt; &lt;small&gt;The New Gem Generator (newgem) was exciting, moderately revolutionary, and...&lt;/small&gt;&lt;/li&gt;&lt;/ol&gt;</description>
         <guid isPermaLink="false">http://drnicwilliams.com/?p=635</guid>
         <pubDate>Wed, 04 Nov 2009 06:44:17 +0000</pubDate>
         <content:encoded><![CDATA[<p><img src="http://img.skitch.com/20091104-fthwimr335wsm3rfgad9a7jh5k.jpg" alt="gemcutter" style="float:right;"/></p>
<p>Ever used a rubygem, found a bug, and just wanted to quickly bust out the big guns and fix it quickly?</p>
<p>The <code>gem</code> command doesn&#8217;t come packed with a way to find the original source repository for a gem. At best, most gems at least come bundled with the complete source, tests and documentation. Some gems <a rel="nofollow" target="_blank" href="http://github.com/notahat/machinist/issues#issue/14">don&#8217;t</a>. Fair enough, since having access to the complete source via the gem still doesn&#8217;t allow you to fix a bug and share it with the world.</p>
<p>For that you access to the repo, a quick way to fork it, and a post-github way to share a gem version from yours truly.</p>
<p>The <code>github</code> gem and gemcutter are the modern day tools of master hackermanship.</p>
<h1 id="instant_forking_fun">Instant forking fun</h1>
<p>Let&#8217;s say you find a bug in a gem, say <code>rails</code>, and you want to go to town on its source.</p>
<p>You know the gem is called <code>rails</code> but you&#8217;ve no idea what the github repo is called. Never fear. </p>
<pre><code>$ gem sources -a http://gemcutter.org
$ sudo gem install github
$ gh clone --search rails
Select a repository to clone:
1.  rails/rails                         # Ruby on Rails
2.  technoweenie/restful-authentication # Generates common user ...
3.  justinfrench/formtastic             # A Rails form builder plugin ...
?
</code></pre>
<p>Press <code>1</code> and you&#8217;ll get a clone of <code>rails/rails</code>.</p>
<p>Alternately, if you want a fork or you know the exact user/repo already:</p>
<pre><code>$ gh clone rails/rails
</code></pre>
<p>Now, fork your own version:</p>
<pre><code>$ cd rails
$ gh fork
</code></pre>
<p>You now have your own fork. The <code>origin</code> remote also now points to your fork rather than the <code>rails/rails</code> repository:</p>
<pre><code>$ git remote show origin
* remote origin
  Fetch URL: git@github.com:drnic/rails.git
  Push  URL: git@github.com:drnic/rails.git
</code></pre>
<p>So, make your changes, push them. Send a pull request or github issue or lighthouse ticket or what have you.</p>
<p>Want to get to the github project home page for your fork?</p>
<pre><code>$ gh home
</code></pre>
<h1 id="instant_gem_sharing">Instant gem sharing</h1>
<p>Let&#8217;s say you patched the <code>rails</code> gem <a rel="nofollow" target="_blank" href="http://github.com/drnic/rails/commit/3c26910cfd5aa4b484d63e912b3881c31f19782a">itself</a> but you want to share your changes via your own gem.</p>
<p>In the olden days, github did this for you. Now you use <a rel="nofollow" target="_blank" href="http://gemcutter.org/">gemcutter</a>, and a little manual effort to do your own renaming.</p>
<p>First, install the gems locally, use them, and make sure all is good.</p>
<p>For rails, you install the edge gems (3.0.pre) with:</p>
<pre><code>$ rake install
</code></pre>
<p>You can&#8217;t see &#8216;rake install&#8217; in the <code>rake -T</code> list (hence my patch), but I think the following expression displays all tasks regardless if they have a description or not:</p>
<pre><code>$ rake -P | grep "^r"
</code></pre>
<p>Rails is composed of several gems, unlike most projects that are distributed as a single gem. Here we want to share our commit within a new <code>drnic-rails</code> gem, but not touch the others.</p>
<p>Edit the <code>railties/rails.gemspec</code> file from:</p>
<pre><code>Gem::Specification.new do |s|
  s.platform = Gem::Platform::RUBY
  s.name = 'rails'
  s.version = '3.0.pre'
...
</code></pre>
<p>and give your personal gem a new name:</p>
<pre><code>Gem::Specification.new do |s|
  s.platform = Gem::Platform::RUBY
  s.name = 'drnic-rails'
  s.version = '3.0.pre'
</code></pre>
<p>To build and distribute the new gem:</p>
<pre><code>$ gem build railties/rails.gemspec
$ sudo gem install gemcutter
$ gem push drnic-rails-3.0.pre.gem
  Pushing gem to Gemcutter...
  Successfully registered gem: drnic-rails (3.0.pre)
</code></pre>
<p>Follow any first-time gemcutter instructions and SUCCESS! Now I have my own <a rel="nofollow" target="_blank" href="http://gemcutter.org/gems/drnic-rails">drnic-rails</a> gem.</p>
<h1 id="summary">Summary</h1>
<p>To find, clone, and fork any rubygem that is hosted on github:</p>
<pre><code>$ sudo gem install drnic-github
$ gh clone --search rails
$ gh fork
</code></pre>
<p>To personalise the gem and share it on gemcutter:</p>
<pre><code>&gt; edit the project.gemspec to have a unique name, e.g. yourname-project
$ gem build project.gemspec
$ sudo gem install gemcutter
$ gem push yourname-project-1.0.0.gem
</code></pre>
<p>I think this makes it much easier, faster and more fun to hack other people&#8217;s stuff.</p>


<p>Related posts:<ol><li><a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2008/12/21/migrating-project-websites-to-github-pages-with-sake-tasks-new-websites-with-jekyll_generator/' title='Permanent Link: Migrating project websites to github pages with sake tasks, new websites with jekyll_generator'>Migrating project websites to github pages with sake tasks, new websites with jekyll_generator</a> <small> Its almost Christmas time and that means presents. It...</small></li><li><a rel="nofollow" target="_blank" href='http://drnicwilliams.com/2008/10/31/newgem-100-all-thanks-to-cucumber/' title='Permanent Link: newgem 1.0.0 all thanks to Cucumber'>newgem 1.0.0 all thanks to Cucumber</a> <small>The New Gem Generator (newgem) was exciting, moderately revolutionary, and...</small></li></ol></p><img src="http://feeds.feedburner.com/~r/mocra/~4/4I-bA7HLVnI" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://drnicwilliams.com/2009/11/04/hacking-someones-gem-with-github-and-gemcutter/</feedburner:origLink></item>
   </channel>
</rss><!-- fe4.yql.bf1.yahoo.com compressed/chunked Fri Feb 10 15:08:27 UTC 2012 -->

