<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dr Nic</title>
	<atom:link href="http://drnicwilliams.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://drnicwilliams.com</link>
	<description>Ruby makes Rails, Javascript makes Ajax, Dr Nic makes Magic</description>
	<lastBuildDate>Sat, 12 Nov 2011 01:05:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>How to stop killing people with your public speeches</title>
		<link>http://drnicwilliams.com/2011/11/11/how-to-stop-killing-people-with-your-public-speeches/</link>
		<comments>http://drnicwilliams.com/2011/11/11/how-to-stop-killing-people-with-your-public-speeches/#comments</comments>
		<pubDate>Sat, 12 Nov 2011 00:11:19 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Speaking]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/?p=819</guid>
		<description><![CDATA[Let&#8217;s do the math. If you give a speech to 200 people for 30 minutes you are consuming 100 hours of human life. Giving an hour-long talk to a thousand people? That&#8217;s six weeks of human life devoted to your talk. *gulp*! Let&#8217;s assume 6 weeks of human life is at stake. It is not [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s do the math.</p>
<p>If you give a speech to 200 people for 30 minutes <strong>you are consuming 100 hours of human life</strong>.</p>
<p>Giving an hour-long talk to a thousand people? That&#8217;s <strong>six weeks</strong> of human life devoted to your talk.</p>
<p><strong>*gulp*</strong>! </p>
<p>Let&#8217;s assume 6 weeks of human life is at stake. It is not a loan and you cannot give it back. One hour after you finish speaking, you&#8217;ve used up 6 weeks of human life.</p>
<p>If you&#8217;re bad enough for long enough you kill a whole person.</p>
<p>Mathematically, if 1000 people witness your speech and 0 of them change any aspect of their life then you should not have given the talk. You used up 6 weeks of human life and achieved nothing.</p>
<p>Let&#8217;s all pledge together:</p>
<ul>
<li>I am valuable</li>
<li>I will continue to share my ideas and my work in public</li>
<li>I will continue to improve the craft of sharing publicly (for example, speech craft and blogging)</li>
<li>I will respect the time of other people as a gift</li>
<li>I will change lives</li>
</ul>
<p>This pledge needs a name; anyone?</p>
<p>You are an incredible individual. You have done things, seen things, diagnosed things, solved things that no one else has done. No one else has the accumulated knowledge and reasoning that you have. You were the one who conclusively deduced that all solutions to World Peace involved chocolate biscuits.</p>
<p>You are also unique in your methods of communication. You have different stories, different mental models, and different approaches to communication. You do that thing with your voice and your posture. As a child you were beaten up for being different. As an adult it makes you extremely valuable.</p>
<p>There are human beings who need to have their lives changed by you. Your value is when other people behave differently because of you.</p>
<h2 id="what_to_do_next">What to do next?</h2>
<p>There is no check box, pass or fail, &#8220;crossing the finish line&#8221; in public speaking. I&#8217;d rather watch you play Guitar Hero. Aim higher.  Take responsibility for your communication. Look at the human beings in front of you and rock their world.</p>
<h2 id="how">How?</h2>
<p>Like the craft of software development, there is the craft of communication.</p>
<p>Practise the craft of communication. Limit the minutes/hours/days/weeks that you use of other people&#8217;s lives. Write your speeches and then practise them to increasingly larger audiences. </p>
<h3 id="8220i8217m_not_very_good_at_speeches8221">&#8220;I&#8217;m not very good at speeches&#8221;</h3>
<p>Write small speeches for small audiences. As you improve, increase the size of the audience. If it&#8217;s necessary to achieve your goal, increase the duration of your talk. Though how often can you communicate 80% of your message in just 5 to 15 minutes? </p>
<p>If you are given 45 minutes at a conference to speak, you are permitted by me to speak for 15 minutes only. If you know you only have 15 minutes, perhaps invite one or two other people to share during the remaining time. Or give back the remaining time to the audience. Ask them to use it to think about or explore the idea you&#8217;ve shared with them.</p>
<p><em>&#8220;Where can I find small audiences?&#8221;</em> If you&#8217;re practising a large audience speech, then pull a handful of people into a room and they can alpha test your talk. As a small group they&#8217;ll probably do something annoying like give feedback. You&#8217;re probably self-conscious enough that your brain is full of negative self-feedback, so you may or may not want their feedback. But let them give it to you. &#8220;Thanks, that&#8217;s a good idea&#8221; is the reward you give them back.</p>
<p>Next, find another small audience. The jokes won&#8217;t be as funny in small audiences. Large audiences laugh louder and stronger. Do the talk again.</p>
<p>Follow up with the first group &#8211; did they do anything different in their lives after your talk? Did they talk about your ideas or thoughts during the week? If your speech is good then some small nugget will carry with them, regardless that they are a friend/peer/family member.</p>
<p>Don&#8217;t worry too much if you don&#8217;t rock their world: friends and peers tend to not learn as much from you. &#8220;You can&#8217;t be a guru in your home town.&#8221; That&#8217;s not the job of a friend. Friends are there to laugh at you and put you in embarrassing situations for their own amusement. Nonetheless, it&#8217;s interesting to see if your small friendly audiences thought about your talk in the days afterwards.</p>
<p>Even in a small room with friends, unload on them with energy and passion. Practise your communication as much as you practise your content.</p>
<h3 id="8220where_can_i_learn_speech_craft8221">&#8220;Where can I learn speech craft?&#8221;</h3>
<p>Toastmasters.</p>
<p>You learnt to drive with your parents and a driving instructor. You learnt software development by writing small demo apps and pair programming. And yet some people have the audacity to stand on stage in front of 100s of people and be terrible. Those people are not you. You will not suck. You are going to learn the craft of speaking because you want to use people&#8217;s time well and you want to change their life. </p>
<p>Toastmasters is a club format. There is no &#8220;school&#8221; concept. Rather a group of 20 people meet twice a month and each time they all suck less. They stop stuttering. They tell interesting stories. Everyone learns something fascinating from other members who have different backgrounds and professions.</p>
<p>The practise format is interesting and successful. You give three types of speeches: 5-7 minute prepared talks, 1-3 minute impromptu talks, and 2-3 minute improptu evaluation talks about the previous speakers. That&#8217;s right, you get immediate evaluation from another club member!</p>
<p>Every club is different so visit a few of them to find a club that you like. Some a filled with old farts who value meeting protocol over having a good time. Some clubs like doing competitions. Some clubs meet weekly. Some clubs meet for breakfast or lunch or in the evening.</p>
<p>It&#8217;s relatively cheap.</p>
<p>You will learn the craft of speaking and leadership. And conversely, though not explicitly promised in any Toastmasters literature, you&#8217;ll stop killing people.</p>
<h2 id="is_it_really_that_important">Is it really that important?</h2>
<p>Personally, I think its a bit unfair of a presenter to be bad in front of a large audience for a long duration and say &#8220;I&#8217;m sorry if I was bad. I&#8217;m trying to get better.&#8221; </p>
<p>But! It is far far worse is the competent presenter who does no preparation, does a terrible job, and merely hopes it goes better next time. There are human lives at stake. One of them might be mine.</p>
<p>As a public speaker you have a gift &#8211; human lives. You have their time and their open minds. Aim high. Change lives. You are special. I hope to experience you speaking awesomely at a conference near me soon!</p>
<h2 id="thanks">Thanks</h2>
<p>Thanks to <a href="http://zachholman.com/" title="Zach Holman">Zach Holman</a> for our chat on the plane back from <a href="http://www.rubymidwest.com/" title="Ruby Midwest">Ruby MidWest</a> and for proof reading and fixing the post. He is a great speaker and will definitely <strike><del datetime="2011-11-11T16:03:10+00:00">convince you of whatever snake oil he&#8217;s selling</del></strike> rock your world. Just <a href="http://zachholman.com/talk/how-github-uses-github-to-build-github">look at these slides</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2011/11/11/how-to-stop-killing-people-with-your-public-speeches/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Never fear $ in READMEs again</title>
		<link>http://drnicwilliams.com/2011/06/11/never-fear-dollar-in-readmes-again/</link>
		<comments>http://drnicwilliams.com/2011/06/11/never-fear-dollar-in-readmes-again/#comments</comments>
		<pubDate>Fri, 10 Jun 2011 15:37:37 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Trick]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/?p=809</guid>
		<description><![CDATA[Ever see example shell commands like this and wish you could paste them in? Fear no more. A pastie is at hand. Here&#8217;s how to install it: In your `.bash_profile` add the following: Thanks @dwaite and others for `$@` instead of `$0 $1 &#8230;`. Related posts:Pastie paradise Summary: click to select Ever tried emailing someone [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2007/06/28/pastie-paradise/' rel='bookmark' title='Permanent Link: Pastie paradise'>Pastie paradise</a> <small>Summary: click to select Ever tried emailing someone a chunk...</small></li><li><a href='http://drnicwilliams.com/2006/09/22/remote-shell-with-ruby/' rel='bookmark' title='Permanent Link: Remote Shell with Ruby'>Remote Shell with Ruby</a> <small>I wrote Composite Primary Keys and Dr Nic&#8217;s Magic Models...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Ever see example shell commands like this and wish you could paste them in?</p>
<p><script src="https://gist.github.com/1019041.js?file=example_readme.sh"></script></p>
<p>Fear no more. A <a href="https://gist.github.com/1019041">pastie is at hand</a>.</p>
<p><script src="https://gist.github.com/1019041.js?file=$"></script></p>
<p>Here&#8217;s how to install it:</p>
<p><script src="https://gist.github.com/1019041.js?file=install.sh"></script></p>
<p>In your `.bash_profile` add the following:</p>
<p><script src="https://gist.github.com/1019041.js?file=prompt_addition.sh"></script></p>
<h3>Thanks</h3>
<p><a href="http://twitter.com/dwaite">@dwaite</a> and others for `$@` instead of `$0 $1 &#8230;`.</p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2007/06/28/pastie-paradise/' rel='bookmark' title='Permanent Link: Pastie paradise'>Pastie paradise</a> <small>Summary: click to select Ever tried emailing someone a chunk...</small></li><li><a href='http://drnicwilliams.com/2006/09/22/remote-shell-with-ruby/' rel='bookmark' title='Permanent Link: Remote Shell with Ruby'>Remote Shell with Ruby</a> <small>I wrote Composite Primary Keys and Dr Nic&#8217;s Magic Models...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2011/06/11/never-fear-dollar-in-readmes-again/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Trialing RedCar instead of TextMate &#8211; replacing my aliases</title>
		<link>http://drnicwilliams.com/2011/04/27/replacing-aliases-to-use-redcar-or-textmate/</link>
		<comments>http://drnicwilliams.com/2011/04/27/replacing-aliases-to-use-redcar-or-textmate/#comments</comments>
		<pubDate>Tue, 26 Apr 2011 18:31:38 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Mocra]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/?p=803</guid>
		<description><![CDATA[I&#8217;m interested to trial RedCar in my life, instead of TextMate. So I need RedCar to appear on my screen whenever I think &#8220;give me an editor&#8221;. I&#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:<ol><li><a href='http://drnicwilliams.com/2010/08/01/packaging-textmate-bundles-in-os-x-dmgs/' rel='bookmark' 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 href='http://drnicwilliams.com/2010/06/01/validate-and-save-your-ruby-in-textmate-with-secret-rubinus-superpowers/' rel='bookmark' 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>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m interested to trial <a 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><script src="https://gist.github.com/942597.js"> </script></p>
<p>This file comes from my <a 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 href='http://drnicwilliams.com/2010/08/01/packaging-textmate-bundles-in-os-x-dmgs/' rel='bookmark' 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 href='http://drnicwilliams.com/2010/06/01/validate-and-save-your-ruby-in-textmate-with-secret-rubinus-superpowers/' rel='bookmark' 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>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2011/04/27/replacing-aliases-to-use-redcar-or-textmate/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Making CI easier to do than not to with Hudson CI and Vagrant</title>
		<link>http://drnicwilliams.com/2010/11/09/making-ci-easier-to-do-than-not-to-with-hudson-ci-and-vagrant/</link>
		<comments>http://drnicwilliams.com/2010/11/09/making-ci-easier-to-do-than-not-to-with-hudson-ci-and-vagrant/#comments</comments>
		<pubDate>Mon, 08 Nov 2010 17:36:34 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Hudson]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[VM]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/?p=784</guid>
		<description><![CDATA[It irked me a little that I could develop on one stack (OS X, Rubinius, Sqlite3), run continuous integration (CI) on another stack (Ubuntu, Ruby 1.8.7, Postgresql), and deploy into another stack (Gentoo, Ruby 1.9.2, MySQL). I think what irks and worries me is that there are three sets of differences to be aware of. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://skitch.com/drnic/d9mk1/inconsistency-between-environments"><img src="http://img.skitch.com/20101108-j11f4dk5745wieuu8i9skybat4.preview.png" style="float: right; width: 200px;"></a></p>
<p>It irked me a little that I could develop on one stack (OS X, Rubinius, Sqlite3), run continuous integration (CI) on another stack (Ubuntu, Ruby 1.8.7, Postgresql), and deploy into another stack (Gentoo, Ruby 1.9.2, MySQL). I think what irks and worries me is that there are three sets of differences to be aware of. A bug in production? Was it a missing test scenario or one of the many differences between production and CI environments?</p>
<p>So I think I have two solutions. </p>
<p>First, use a VM that matches the production environment. Each different production environment would mean another VM. If you are managing your own production environment, then all you need is the tools (described in this article) to recreate your production environment in a VM. </p>
<p>Second, use a clone of your production environment. That is, if you deploy to Engine Yard AppCloud then run CI in Engine Yard AppCloud; if you deploy to a single Ubuntu instance on Slicehost, the have another matching Ubuntu instance on Slicehost.</p>
<p>I&#8217;ll write about the first solution &#8211; using VMs &#8211; here, and I&#8217;ll write on the <a href="http://www.engineyard.com/blog/" title="Ruby on Rails Blog | Engine Yard">Engine Yard Blog</a> about the solution for Engine Yard AppCloud customers. For AppCloud users life will be even easier because there are zero setup steps to ensure you have consistent environments. It&#8217;s been one of my favorite projects in the two months since I arrived at Engine Yard.</p>
<p>I&#8217;ll also introduce a CLI for talking to Hudson &#8211; one that assumes you are working on Ruby/Rails projects &#8211; and makes it really easy to get up and running with a server, your Rails/Ruby projects, and any VMs you need (optional for Hudson, but they are the point of my line of thinking).</p>
<p>And I&#8217;ll introduce Vagrant, a CLI for creating/managing/destroying VMs.</p>
<p>Oh, and I&#8217;ll introduce Hudson CI.</p>
<p>Ok, let&#8217;s fix all our CI problems in one go&#8230;</p>
<h3 id="hudson_ci">Hudson CI</h3>
<p>I needed a CI tool to allow tests to run inside VMs or on remote servers/VMs. Back in May I found and fell in love with <a href="http://hudson-ci.org/" title="Hudson CI">Hudson CI</a>. Fortunately it had support for &#8220;slaves&#8221;, and a way for CI jobs (your applications or rubygems) to select which slaves can be used. Hudson is also great because it is easy to try out (one click to <a href="https://hudson.dev.java.net/hudson.jnlp">install and launch</a>), easy to configure, and has 350+ plugins.</p>
<p><a href="http://wiki.hudson-ci.org/display/HUDSON/Meet+Hudson">What is Hudson?</a></p>
<h3 id="cli_for_hudson">CLI for Hudson</h3>
<p>Charles Lowell&#8217;s <a href="https://github.com/cowboyd/hudson.rb">hudson.rb</a> project is a CLI for launching Hudson (it&#8217;s bundled inside the gem), and a set of CLI tasks to add/remove projects (jobs), add slaves, trigger builds and more. </p>
<pre><code>gem install hudson
</code></pre>
<p>You can launch Hudson via:</p>
<pre><code>hudson server  # Default: --port 3001
open http://localhost:3001
</code></pre>
<p>It currently assumes you are working on Ruby projects, using bundler, and attempts to create a useful set of default steps for your CI jobs.</p>
<pre><code>cd /some/rails3/app
hudson create . --host localhost --port 3001 --template rails3
</code></pre>
<p>Hudson CI will automatically start running steps to install your application&#8217;s gems, database, and run your tests. When it does it on your local machine it&#8217;s not that impressive. When it happens on a fresh VM or slave node and you didn&#8217;t have to do anything to set it up, it&#8217;s awesome.</p>
<h3 id="v_is_for_vagrant_virtualbox_and_all_things_vm">V is for Vagrant, VirtualBox and all things VM</h3>
<p>If you can script it, then you can automate it. Fortunately, as a virtual machine <a href="http://www.virtualbox.org/" title="VirtualBox">VirtualBox</a> is both scriptable <em>and</em> FREE! Secondly, if you have a VM, you&#8217;ll need to script its setup/provisioning; so fortunately there exists <a href="https://github.com/opscode/chef">chef</a> and <a href="https://github.com/lak/puppet">puppet</a>, amongst others.</p>
<p>Thirdly, if you are really really really lazy, like me, you will want <a href="http://vagrantup.com/">Vagrant</a>. Created by <a href="http://mitchellhashimoto.com/">Mitchell Hashimoto</a> and <a href="http://nickelcode.com/">John Bender</a>, Vagrant is a tool for building and distributing virtualized development environments. Everyone in your team have their own OS/configuration? Got Windows users on your team? Use Vagrant.</p>
<p>Once you have VirtualBox installed, getting any of your projects live within a VM is trival:</p>
<pre><code>gem install vagrant
vagrant box add base http://files.vagrantup.com/lucid32.box
vagrant init
vagrant up
vagrant ssh
$ cd /vagrant/
$ ls -al
</code></pre>
<p>You will now see the contents of your project folder, but from within the VM instance! They are linked &#8211; a change to either is automatically reflected inside and outside of the VM.</p>
<p>In this example, the Guest OS being downloaded and installed into VirtualBox (note: without any GUI) is <a href="http://releases.ubuntu.com/lucid/" title="Ubuntu 10.04.1 LTS (Lucid Lynx)">Ubuntu Lucid</a>, but you could use any VirtualBox packaged unix system.</p>
<p>For wonderful guided tour of Vagrant see the <a href="http://vimeo.com/9976342">Getting Started</a> video.</p>
<p><iframe src="http://player.vimeo.com/video/9976342" width="400" height="225" frameborder="0"></iframe>
<p><a href="http://vimeo.com/9976342">Vagrant &#8211; Getting Started</a> from <a href="http://vimeo.com/mitchellh">Mitchell Hashimoto</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
</p>
<h3 id="hudson_ci_vagrant_perfect_ci">Hudson CI + Vagrant = Perfect CI</h3>
<p>Whether you choose to use VMs for a production-like development environment (a good idea for anyone, a wonderful idea for Windows developers who are very far removed from their production experience), it is a very good idea to have a CI environment as similar to your production environment as possible. Here, we want a VM instance with all the components/utilities/rubies set up that you have in production.</p>
<p>I have created an <a href="https://github.com/drnic/railsapp-vagrant">example Rails application</a> that is setup to use Vagrant for a CI slave VM.</p>
<p>See the README for complete instructions. See the <a href="https://github.com/drnic/railsapp-vagrant/blob/master/Vagrantfile">Vagrantfile</a> and the <a href="https://github.com/drnic/railsapp-vagrant/tree/master/cookbooks/">cookbooks</a> folder for the configuration and provisioning recipes.</p>
<p>Once you have the VM instantiated, you add it to your Hudson CI master (either the localhost one above or your remotely hosted server) with the CLI:</p>
<pre><code>hudson add_node localhost --name "VM" --label railsapp-vagrant ...
</code></pre>
<p>(See the <a href="https://github.com/drnic/railsapp-vagrant">example Rails application</a> for the other flags I used to get this working). It is now available to all Hudson jobs; but has a label &#8220;railsapp-vagrant&#8221; to allow jobs (Hudson&#8217;s name for a project) to specify that slave node specifically.</p>
<p>To add the Rails application to Hudson CI, and force it to run the tests in this VM:</p>
<pre><code>hudson create . --template rails3 --assigned-node railsapp-vagrant
</code></pre>
<p>If you visit the Hudson master (at <code>http://localhost:3010</code> in the example) you will see the job automatically running (&#8220;building&#8221;) within your VM. It will use bundler to install the gems, and run all the tests.</p>
<p><img src="http://img.skitch.com/20101108-jpitj3arquqthqndhs4eagmy89.png"></p>
<p><img src="http://img.skitch.com/20101108-f4ndidacj2cjxy249nbd82sjg6.png"></p>
<h3 id="that8217s_it">That&#8217;s it?</h3>
<p>I know, CI is historically a pain in the arse. When CruiseControl was the only CI kid-on-the-block, it was standard for people to respond &#8220;4 days&#8221; to the question &#8220;How long does it take to get set up?&#8221; </p>
<p>It can now be really easy.</p>
<p>More importantly than being easy, you are running an application&#8217;s tests within an isolated VM that you can design to match your production environment.</p>
<p>I think there can be a good future for CI and Rails applications. <strong>Thoughts on this solution?</strong></p>
<h3 id="thanks">Thanks</h3>
<p>Some of the technology in this article is old, other bits are very new, but for all of it I thank all the creators and contributors. Hudson CI was created by <a href="http://www.kohsuke.org/">Kohsuke Kawaguchi</a> during his days at Sun. He is now offering Hudson support services via his company <a href="http://infradna.com/" title="InfraDNA | The Hudson company">InfraDNA</a>. </p>
<p>The <a href="https://github.com/cowboyd/hudson.rb">Hudson.rb project</a> was created by <a href="http://cogentdude.com/">Charles Lowell</a> to bundle the Hudson CI and some common useful plugins for Ruby/Rails projects. He came all the way to Gothenburg, Sweden for <a href="http://nordicruby.com/" title="Nordic Ruby Conference – Gothenburg, Sweden May 21-23, 2010">NordicRuby</a> conference (great conference by the way!) I fell in love with Hudson and started helping Charles on Hudson.rb.</p>
<p>Thanks also to both Kohsuke and Charles for starting work on a JRuby plugin for Hudson CI, and writing up a <a href="http://infradna.com/content/hudson-jruby-integration-preliminary-report">progress report</a>.</p>
<p>Thanks to everyone who agrees that Hudson CI is awesome.</p>
<p>Thanks to Mitchell Hashimoto and John Bender for creating Vagrant. It is an incredible tool for developing within a VM (on OS X <em>or</em> Windows).</p>
<p>Finally, thanks to <a href="http://bjeanes.com/">Bo Jeanes</a> who helped on the <a href="http://www.engineyard.com/products/appcloud">Engine Yard AppCloud</a> version of this project. Coming soon!</p>
<h3 id="rubyconf_rubybayou">RubyConf &amp; RubyBayou</h3>
<p>If you&#8217;re in New Orleans this week for RubyConf, I&#8217;ll be at the local Ruby group RubyBayou talking about Hudson CI, Vagrant, and AppCloud on <a href="http://www.meetup.com/RubyBayou/calendar/14580950/" title="RubyConf &amp; Code Quality -  Ruby Bayou (New Orleans, LA) - Meetup">Thursday night</a>. There&#8217;s a happy hour from 5pm till the 7pm start.</p>
<p>Location: <a href="http://goo.gl/maps/WLNW" title="LaunchPad NOLA 643 Magazine St New Orleans, LA 70130 - Google Maps">LaunchPad NOLA, 643 Magazine St, New Orleans, LA 70130</a></p>
<p>Come and let me convince you about the wonders of Hudson CI and having a CI test environment that matches your production env. You know you want to be convinced. It&#8217;s good for you, like fruit.</p>
<h3 id="don8217t_forget_chuck_norris">Don&#8217;t forget Chuck Norris</h3>
<p>Always remember to install the <a href="http://wiki.hudson-ci.org/display/HUDSON/ChuckNorris+Plugin" title="ChuckNorris Plugin - hudson - Hudson Wiki">Chuck Norris plugin</a> for Hudson, and enable it for each job. Don&#8217;t forget Chuck Norris.</p>
]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2010/11/09/making-ci-easier-to-do-than-not-to-with-hudson-ci-and-vagrant/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Coming to America</title>
		<link>http://drnicwilliams.com/2010/08/04/coming-to-america/</link>
		<comments>http://drnicwilliams.com/2010/08/04/coming-to-america/#comments</comments>
		<pubDate>Tue, 03 Aug 2010 23:44:48 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Engine Yard]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/?p=782</guid>
		<description><![CDATA[Have you ever looked at your biological watch and thought, &#8220;it looks like it&#8217;s time to change the world?&#8221; My biological time piece has a full set of inscriptions: go to university, chase girls, get a post-graduate qualification, catch a girl, get a professional job, marry the girl, change into contracting, change into consulting (and [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever looked at your biological watch and thought, &#8220;it looks like it&#8217;s time to change the world?&#8221;</p>
<p>My biological time piece has a full set of inscriptions: go to university, chase girls, get a post-graduate qualification, catch a girl, get a professional job, marry the girl, change into contracting, change into consulting (and ponder what the difference is), work overseas (and marvel at the differences), make a baby, change into training, move back to Australia, buy a home, start a consultancy (Mocra), make another baby, grow the consultancy, and &#8230;</p>
<p>Really, I&#8217;m not sure what comes next in the script of normal life. Retire in 30 years? Create more little open source projects? Just keep growing the consultancy? Until what?</p>
<p>A few weeks ago, John Dillon, the CEO of Engine Yard, drew some pictures on a whiteboard for me and asked, &#8220;Do you want to help change the world?&#8221; Sure, a classic Steve Jobs one-liner from the history books of Apple. I said, &#8220;Yes&#8221;.</p>
<p>On the 1st of September I will start work at <a href="http://maps.google.com/maps?q=500+3rd+Street,+San+Francisco">500 3rd Street, San Francisco</a> as <a href="http://www.engineyard.com/">Engine Yard<br />
</a>&#8217;s VP, Technology. Job description: <em>help web application developers win</em>. </p>
<p><a href="http://maps.google.com/maps?f=d&amp;source=s_d&amp;saddr=46+Douglas+St,+Milton+QLD+4064,+Australia&amp;daddr=500+3rd+Street,+San+Francisco&amp;hl=en&amp;geocode=&amp;mra=ls&amp;sll=37.780991,-122.39559&amp;sspn=0.009497,0.01929&amp;g=500+3rd+Street,+San+Francisco&amp;ie=UTF8&amp;z=3"><img src="http://img.skitch.com/20100803-ethi1qtq3e5ictbwx2b919nefp.png" alt="22000km to work" style="float: right"/></a></p>
<h2 id="the_daily_commute">The daily commute</h2>
<p>Google Maps suggests my daily commute to work will be 22,300km. Some of that will be heavy morning traffic, so at say 30km/hr, that is almost 750 hours. Each way.</p>
<p>So instead, my family will pack its bags and move overseas again. Though for the first time, we&#8217;re coming to America!</p>
<h2 id="how_to_move_your_family_to_america">How to move your family to America</h2>
<p>It hasn&#8217;t been all smooth sailing on the home front since I broached the idea with my wife. Personally, have you ever turned to your wife and said, &#8220;Honey, I think we are going to move to America!&#8221;</p>
<p>Try it at home for a laugh. Perhaps your wife will say something witty or clever like mine. Something like, &#8220;No.&#8221;</p>
<p>&#8220;No, baby, really. I have something important to do for a few years. It&#8217;s in America. San Francisco. Apparently it&#8217;s lovely!&#8221;</p>
<p>&#8220;Is the weather nice?&#8221; she might ask looking for any reason to want to leave beautiful, sunny Brisbane.</p>
<p>&#8220;No. I think it&#8217;s kind of cold there. And foggy. There was even a taxi with &#8216;Fog City Taxi&#8217; on its side. But there are wonderful schools and the people are fabulous and are from all over the world!&#8221;</p>
<p>&#8220;So our young kids won&#8217;t get an American accent?&#8221; she might ask pleadingly.</p>
<p>&#8220;Well, they won&#8217;t get all of the accents, no.&#8221;</p>
<p>&#8220;&#8230;&#8221;</p>
<p>&#8220;I love you!&#8221;</p>
<p>And so eventually your wife will say yes.</p>
<h2 id="how_do_we_get_to_win_as_web_developers">How do we get to win as web developers?</h2>
<p>Choose to use Rails. Improve Rails. Improve the ecosystem above/below/around Rails. Improve our daily lives. Expand the sweet spot of Rails to solve problems. </p>
<p>In the future, can we look back at the work we did, the fun we had, the problems we solved, the time we spent working, and feel that it was worth the effort? Will we remember when we first discovered Ruby and Rails and remember the joy?</p>
<p>This is a world-changing set of issues to care about. I&#8217;ve always cared about them before now, but never had resources or reach to work on them beyond my own little projects or cunningly worded, suggestive emails/tweets/chat with other open source developers.</p>
<p>Though from now onwards I will get to work with one of the greatest concentrations of Rails talent and one of the largest <a href="http://www.engineyard.com/open-source">open source programs</a> in the our community. I&#8217;m more than just a little bit excited. Imagine working with full-time contributors to Rails, JRuby and Rubinius as well as the dozens of developers, devops and more.</p>
<p>As Engine Yard continues to grow and win then its capacity to fund and resource more contributions will grow. And then we all win faster.</p>
<p>Can you imagine what else should be funded, promoted or prioritised? I have a dozen solid ideas but I would love suggestions.</p>
<h2 id="mocra">Mocra</h2>
<p>I will miss my guys at Mocra, a wonderful Rails consultancy with clients around the world whilst based out of Brisbane, Australia. I founded and ran Mocra for the last two wonderful years. It will be slightly annoying &#8211; I won&#8217;t get to take any credit for all the success the Mocra team will have in the years to come. </p>
<p>Definitely, if you need an awesome Rails team for your project, contact <a href="http://mocra.com/">Mocra</a>. If you need a personal introduction, let me know. I know some people there.</p>
<h2 id="san_francisco">San Francisco</h2>
<p>I am very excited to move to SF and to hang out on a regular basis all the people I have only been able to see at conferences.</p>
<p>I&#8217;d also love suggestions of where a family of four (including a 4yo and 2yo; oh, plus another one due in February) could live. I&#8217;ve briefly seen parts of SF and many of the surrounding towns in the bay area. Thanks to Randall, Tammer and Marcy for their turns as tour guides during my visit a few weeks ago.</p>
]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2010/08/04/coming-to-america/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Packaging TextMate bundles in OS X DMGs</title>
		<link>http://drnicwilliams.com/2010/08/01/packaging-textmate-bundles-in-os-x-dmgs/</link>
		<comments>http://drnicwilliams.com/2010/08/01/packaging-textmate-bundles-in-os-x-dmgs/#comments</comments>
		<pubDate>Sat, 31 Jul 2010 21:11:22 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Engine Yard]]></category>
		<category><![CDATA[Mocra]]></category>
		<category><![CDATA[TextMate]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/?p=765</guid>
		<description><![CDATA[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:<ol><li><a href='http://drnicwilliams.com/2011/04/27/replacing-aliases-to-use-redcar-or-textmate/' rel='bookmark' 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 href='http://drnicwilliams.com/2010/06/01/validate-and-save-your-ruby-in-textmate-with-secret-rubinus-superpowers/' rel='bookmark' 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 href='http://drnicwilliams.com/2008/10/09/textmate-easter-egg-find-bundle-commands-by-key-combo/' rel='bookmark' 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>]]></description>
			<content:encoded><![CDATA[<p>Last week Engine Yard released a <a 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 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 href="http://github.com/engineyard/engineyard.tmbundle">README</a>), or via a beautiful DMG. <a 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 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 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 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 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\ Support/TextMate/Bundles/Engine\ 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 href='http://drnicwilliams.com/2011/04/27/replacing-aliases-to-use-redcar-or-textmate/' rel='bookmark' 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 href='http://drnicwilliams.com/2010/06/01/validate-and-save-your-ruby-in-textmate-with-secret-rubinus-superpowers/' rel='bookmark' 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 href='http://drnicwilliams.com/2008/10/09/textmate-easter-egg-find-bundle-commands-by-key-combo/' rel='bookmark' 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>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2010/08/01/packaging-textmate-bundles-in-os-x-dmgs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Validate and Save your Ruby in TextMate &#8211; with secret Rubinus superpowers</title>
		<link>http://drnicwilliams.com/2010/06/01/validate-and-save-your-ruby-in-textmate-with-secret-rubinus-superpowers/</link>
		<comments>http://drnicwilliams.com/2010/06/01/validate-and-save-your-ruby-in-textmate-with-secret-rubinus-superpowers/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 12:54:18 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Mocra]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[TextMate]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/?p=751</guid>
		<description><![CDATA[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&#8217;ll now see something like: Rubinius superpowers Do [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2011/04/27/replacing-aliases-to-use-redcar-or-textmate/' rel='bookmark' 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 href='http://drnicwilliams.com/2010/08/01/packaging-textmate-bundles-in-os-x-dmgs/' rel='bookmark' 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 href='http://drnicwilliams.com/2008/12/11/future-proofing-your-ruby-code/' rel='bookmark' 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>]]></description>
			<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 href="http://github.com/subtleGradient/javascript-tools.tmbundle">JavaScript</a> and <a href="http://github.com/jashkenas/coffee-script-tmbundle">CoffeeScript</a>)</p>
<p>So I added the same thing to my <a 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 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\ Support/TextMate/Bundles
cd ~/Library/Application\ 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 href='http://drnicwilliams.com/2011/04/27/replacing-aliases-to-use-redcar-or-textmate/' rel='bookmark' 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 href='http://drnicwilliams.com/2010/08/01/packaging-textmate-bundles-in-os-x-dmgs/' rel='bookmark' 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 href='http://drnicwilliams.com/2008/12/11/future-proofing-your-ruby-code/' rel='bookmark' 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>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2010/06/01/validate-and-save-your-ruby-in-textmate-with-secret-rubinus-superpowers/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Showcase of CoffeeScript &#8211; 2.5 mins for your next Dev Group meeting</title>
		<link>http://drnicwilliams.com/2010/05/28/showcase-of-coffeescript-2-5-mins-for-your-next-dev-group-meeting/</link>
		<comments>http://drnicwilliams.com/2010/05/28/showcase-of-coffeescript-2-5-mins-for-your-next-dev-group-meeting/#comments</comments>
		<pubDate>Fri, 28 May 2010 12:20:08 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Mocra]]></category>
		<category><![CDATA[Speaking]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/?p=733</guid>
		<description><![CDATA[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. 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:<ol><li><a href='http://drnicwilliams.com/2010/03/15/using-coffeescript-in-rails-and-even-on-heroku/' rel='bookmark' 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>]]></description>
			<content:encoded><![CDATA[<p>
<object id="sample-video" class="alignright" style="float: right" width="320" height="195" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab"><param name="src" value="http://s3.amazonaws.com/screencasts.drnicwilliams/Summary%20of%20CoffeeScript%20-%20streaming.mov" /><param name='autoplay' value="false" /><param name='controller' value="true" /><param name='loop' value="false" /><embed src="http://s3.amazonaws.com/screencasts.drnicwilliams/Summary%20of%20CoffeeScript%20-%20streaming.mov" width="320" height="195" controller="true" autoplay="false" loop="false" scale="tofit" cache="true" pluginspage="http://www.apple.com/quicktime/download/"></embed></object></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 href="http://coffeescript.org/" target="_blank">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 href="http://nordicruby.com" target="_blank">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 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 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 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 href="http://s3.amazonaws.com/screencasts.drnicwilliams/Summary%20of%20CoffeeScript%20-%20Dr%20Nic%20-%20Mocra.mov?torrent">Torrent</a> | <a 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 href='http://drnicwilliams.com/2010/03/15/using-coffeescript-in-rails-and-even-on-heroku/' rel='bookmark' 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>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2010/05/28/showcase-of-coffeescript-2-5-mins-for-your-next-dev-group-meeting/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
<enclosure url="http://s3.amazonaws.com/screencasts.drnicwilliams/Summary%20of%20CoffeeScript%20-%20streaming.mov" length="2832999" type="video/quicktime" />
<enclosure url="http://s3.amazonaws.com/screencasts.drnicwilliams/Summary%20of%20CoffeeScript%20-%20Dr%20Nic%20-%20Mocra.mov" length="599670164" type="video/quicktime" />
		</item>
		<item>
		<title>How to make a good home-made Open Source</title>
		<link>http://drnicwilliams.com/2010/04/09/how-to-make-a-good-home-made-open-source/</link>
		<comments>http://drnicwilliams.com/2010/04/09/how-to-make-a-good-home-made-open-source/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 13:38:12 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Mocra]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/?p=725</guid>
		<description><![CDATA[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; Be ready with follow-ups like &#8220;Can you pass me the Haml?&#8221; If you&#8217;ve used Ruby on Rails, Apache, Emacs, or Linux then [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/' rel='bookmark' title='Permanent Link: Home'>Home</a> <small>...</small></li><li><a href='http://drnicwilliams.com/2009/07/13/futureruby-talk-living-with-1000-open-source-projects/' rel='bookmark' 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>]]></description>
			<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 href="http://magicmodels.rubyforge.org/">Dr Nic&#8217;s Magic Models</a> was a joke. <a 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 href="http://camping.rubyforge.org/files/README.html">entertaining</a> free software.</p>
<p><a href="http://toolmantim.com/thoughts">Tim Lucas</a> created <a href="http://railscampteev5.toolmantim.com/">artistic</a> free software (&#8216;View Source&#8217; to see the header comment)</p>
<p><a href="http://chneukirchen.org/">Christian Neukirchen</a> created <a href="http://rack.rubyforge.org/">liberating</a> free software.</p>
<p><a href="http://blog.zenspider.com/">Ryan Davis</a> created free <a href="http://seattlerb.rubyforge.org/hoe/">tools</a>.</p>
<p><a href="http://ozmm.org/">Chris Wanstrath</a> <a 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 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 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 href='http://drnicwilliams.com/' rel='bookmark' title='Permanent Link: Home'>Home</a> <small>...</small></li><li><a href='http://drnicwilliams.com/2009/07/13/futureruby-talk-living-with-1000-open-source-projects/' rel='bookmark' 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>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2010/04/09/how-to-make-a-good-home-made-open-source/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Using CoffeeScript in Rails and even on Heroku</title>
		<link>http://drnicwilliams.com/2010/03/15/using-coffeescript-in-rails-and-even-on-heroku/</link>
		<comments>http://drnicwilliams.com/2010/03/15/using-coffeescript-in-rails-and-even-on-heroku/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 12:46:52 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Mocra]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/?p=713</guid>
		<description><![CDATA[I&#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:<ol><li><a href='http://drnicwilliams.com/2010/06/01/validate-and-save-your-ruby-in-textmate-with-secret-rubinus-superpowers/' rel='bookmark' 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 href='http://drnicwilliams.com/2010/05/28/showcase-of-coffeescript-2-5-mins-for-your-next-dev-group-meeting/' rel='bookmark' 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 href='http://drnicwilliams.com/2009/11/12/dead-simple-javascript-unit-testing-in-rails/' rel='bookmark' 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>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m pretty excited about <a 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 href="http://github.com/jashkenas/coffee-script-tmbundle">TextMate</a>, <a href="http://github.com/jashkenas/coffee-script/blob/master/extras/coffee.vim">Vim</a>, <a 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 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 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 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 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\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 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 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 href='http://drnicwilliams.com/2010/06/01/validate-and-save-your-ruby-in-textmate-with-secret-rubinus-superpowers/' rel='bookmark' 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 href='http://drnicwilliams.com/2010/05/28/showcase-of-coffeescript-2-5-mins-for-your-next-dev-group-meeting/' rel='bookmark' 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 href='http://drnicwilliams.com/2009/11/12/dead-simple-javascript-unit-testing-in-rails/' rel='bookmark' 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>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2010/03/15/using-coffeescript-in-rails-and-even-on-heroku/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>

