<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">
  <title type="text">Effectif Development</title>
  <generator uri="http://nestacms.com">Nesta</generator>
  <id>tag:effectif.com,2009:/</id>
  
  <link href="http://effectif.com/" rel="alternate" />
  <subtitle type="text">Web development (Ruby, JavaScript), Learning Lean, and Agile</subtitle>
  <updated>2012-05-15T09:00:00+01:00</updated>
  <author>
    <name>Graham Ashton</name>
    <uri>http://effectif.com</uri>
    <email>graham@effectif.com</email>
  </author>
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/effectif-development" /><feedburner:info uri="effectif-development" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry>
    <title>Write a quick draft while it's fresh</title>
    <link href="http://feedproxy.google.com/~r/effectif-development/~3/DFxWm0jy5Xo/blog-on-your-mobile" rel="alternate" type="text/html" />
    <id>tag:effectif.com,2012-05-15:/writing-tips/blog-on-your-mobile</id>
    <content type="html">
      &lt;p&gt;As a bootstrapper, it's important that I spend enough time getting my
      product's name out there. For me, that means blogging. I've recently
      been writing a couple of paragraphs the instant that I have an idea for
      a post. That usually means writing "on your mobile" (or in my case, on
      my iPod).&lt;/p&gt;
      
      &lt;p&gt;I used to capture a one line summary of an idea in my todo list, but
      sometimes I'd struggle to recover my thoughts when trying to write it
      up.&lt;/p&gt;
      
      &lt;p&gt;In the last week I've written several 200 word drafts on my iPod.
      They've since been edited into blog posts that I'm rather pleased with.
      If you have an iOS device the iA Writer app (iPhone/iPod/iPad) is great.&lt;/p&gt;
      
      &lt;p&gt;&lt;img src="/attachments/ia-writer-for-iphone.png" class="screenshot"&gt;&lt;/p&gt;
      
      &lt;p&gt;In this screenshot of the iPhone version you can see iA Writer's
      extended keyboard, with extra buttons for common punctuation marks, and
      cursor keys for navigating left and right in your copy. The iPad version
      (not shown) also has keys for jumping whole words at the time, which is
      a significant improvement over the default iPad keyboard.&lt;/p&gt;
      
      &lt;p&gt;I seem to write better with iOS than I do with a laptop, presumably
      because I can't type as fast and that gives me a bit more space to
      think. Maybe it's that, or maybe it's just because I'm using something a
      bit different.&lt;/p&gt;
      
      &lt;p&gt;Either way, iA Writer on your phone, sync'd with Dropbox is a great way
      to write the draft. I edit later on the computer, then post it.&lt;/p&gt;
      
      &lt;p&gt;Sent from my iPod&lt;/p&gt;
    </content>
    <published>2012-05-15T09:00:00+01:00</published>
    <updated>2012-05-15T09:00:00+01:00</updated>
    <category term="productivity" />
    <category term="writing-tips" />
  <feedburner:origLink>http://effectif.com/writing-tips/blog-on-your-mobile</feedburner:origLink></entry>
  <entry>
    <title>Securing Instiki with an SSH tunnel</title>
    <link href="http://feedproxy.google.com/~r/effectif-development/~3/RgzM7iA793s/securing-instiki-with-an-ssh-tunnel" rel="alternate" type="text/html" />
    <id>tag:effectif.com,2012-04-26:/system-administration/securing-instiki-with-an-ssh-tunnel</id>
    <content type="html">
      &lt;p&gt;I've been using a wiki a lot recently to keep track of my research. A wiki is the perfect tool for keeping track of all my notes, and the relationships between my ideas.&lt;/p&gt;
      
      &lt;p&gt;I've been using &lt;a href="http://www.instiki.org"&gt;Instiki&lt;/a&gt;; the UI is clean and is built with familiar technology (it's written in Rails, and its early code was the app from which DHH extracted the Rails framework). As wikis go it takes a fairly low maintenance approach, and lets you concentrate on your content.&lt;/p&gt;
      
      &lt;p&gt;Being a Rails app, you can run it with a standard Ruby web server such as Webrick. I started out running it locally on my desktop. When I started working more on my laptop I needed access to the wiki there too, so I moved the app's folder into Dropbox and synchronised the database that way (it uses a local SQLite database). That worked fine until I accidentally started it on both machines at once, and I lost a page of data.&lt;/p&gt;
      
      &lt;p&gt;Clearly, I was going to have to host it properly.&lt;/p&gt;
      
      &lt;p&gt;There is a fork of Instiki that &lt;a href="https://github.com/lazzarello/instiki-heroku"&gt;runs on Heroku&lt;/a&gt;. I'm sure it's awesome, but I'm often reluctant to use forks of apps that don't see a lot of use. You've no idea how long the fork will be maintained, and I don't fancy rolling my sleeves up when Heroku deprecate the stack that the port runs on.&lt;/p&gt;
      
      &lt;p&gt;So I decided to host it on my VPS. In theory all I'd need to do is to &lt;code&gt;tar&lt;/code&gt; up my local instiki folder, copy it over to my server and untar it. After a quick &lt;code&gt;bundle install&lt;/code&gt; I should be good to go, and indeed, I was.&lt;/p&gt;
      
      &lt;p&gt;I knocked up a quick init script to start/stop the app on bootup/shutdown, and all was well.&lt;/p&gt;
      
      &lt;p&gt;Instiki was running unprotected on port 2500. All was not well.&lt;/p&gt;
      
      &lt;h2&gt;So, what about security?&lt;/h2&gt;
      
      &lt;p&gt;You really don't want a private wiki listening on an open port. Not only is your data unprotected, but somebody might find a vulnerability in the wiki software and login to your server.&lt;/p&gt;
      
      &lt;p&gt;I had planned to filter port 2500 on my firewall, and configure Nginx to act as a proxy on port 80. This wouldn't prevent an attacker from accessing the wiki's home page, but I could secure it in Nginx with HTTP basic auth running over an SSL connection.&lt;/p&gt;
      
      &lt;p&gt;How conventional. And what a faff!&lt;/p&gt;
      
      &lt;p&gt;Instead, I've firewalled port 2500 on my server and connect to Instiki over an encrypted SSH connection. Better yet, it guarantees that only I can get at it, as only I can connect to my server with ssh!&lt;/p&gt;
      
      &lt;p&gt;So now I access Instiki in the browser by connecting to &lt;code&gt;http://localhost:2500&lt;/code&gt;.&lt;/p&gt;
      
      &lt;p&gt;I've put the ssh command that sets this up in a script, and run it whenever I want access to the wiki. At some point I'll probably run it automatically whenever I start my laptop, but for now I'm happy with running it when I need it.&lt;/p&gt;
      
      &lt;p&gt;Here's the script:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;$ cat bin/instiki-tunnel&amp;#x000A;#!/bin/sh&amp;#x000A;&amp;#x000A;ssh -f my.server.com -L localhost:2500:my.server.com:2500 -N&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;This is what the ssh options are for:&lt;/p&gt;
      
      &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;-f&lt;/code&gt; – run in the background just before launching the command.&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;-L&lt;/code&gt; – forwards all connections to &lt;code&gt;localhost&lt;/code&gt; on port 2500 to port 2500 on &lt;code&gt;my.server.com&lt;/code&gt;, via an encrypted, authenticated SSH tunnel.&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;-N&lt;/code&gt; – prevents an actual command from being run on the server.&lt;/li&gt;
      &lt;/ul&gt;
      
      
      &lt;p&gt;You've got to love SSH.&lt;/p&gt;
    </content>
    <published>2012-04-26T00:00:00+00:00</published>
    <updated>2012-04-26T00:00:00+00:00</updated>
    <category term="system-administration" />
  <feedburner:origLink>http://effectif.com/system-administration/securing-instiki-with-an-ssh-tunnel</feedburner:origLink></entry>
  <entry>
    <title>Using QUnit with CoffeeScript</title>
    <link href="http://feedproxy.google.com/~r/effectif-development/~3/b3JUitF3f4Y/qunit-boilerplate" rel="alternate" type="text/html" />
    <id>tag:effectif.com,2012-03-30:/coffeescript/qunit-boilerplate</id>
    <content type="html">
      &lt;p&gt;&lt;a href="http://docs.jquery.com/QUnit"&gt;QUnit&lt;/a&gt; is a unit testing framework for JavaScript, from the jQuery
      project. Earlier this week I &lt;a href="http://effectif.com/coffeescript/choosing-between-qunit-and-jasmine"&gt;wrote about&lt;/a&gt; how I chose it over Jasmine
      for my current project. This article explains how I setup QUnit to test
      my CoffeeScript, along with the Sinon mocking/stubbing library.&lt;/p&gt;
      
      &lt;h2&gt;Downloading QUnit&lt;/h2&gt;
      
      &lt;p&gt;Let's assume that you want to keep your tests in a folder called
      &lt;code&gt;test/javascripts&lt;/code&gt; (relative to your project's directory), and that the
      CoffeeScript code that you want to test lives in a folder called
      &lt;code&gt;app/assets/javascripts&lt;/code&gt;. This is where the files live in my Rails app; if
      you're not using Rails just substitute the appropriate paths for your project
      in the code that follows.&lt;/p&gt;
      
      &lt;p&gt;Start by making a directory to store QUnit itself, and then download &lt;code&gt;qunit.js&lt;/code&gt;
      and &lt;code&gt;qunit.css&lt;/code&gt;:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;$ mkdir -p test/javascripts/qunit&amp;#x000A;$ cd test/javascripts/qunit&amp;#x000A;$ curl -O https://raw.github.com/jquery/qunit/master/qunit/qunit.js&amp;#x000A;$ curl -O https://raw.github.com/jquery/qunit/master/qunit/qunit.css&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;We'll also want the in-browser CoffeeScript compiler so that we can compile
      CoffeeScript within &lt;code&gt;text/coffeescript&lt;/code&gt; script tags on the fly. I've stored it
      in &lt;code&gt;test/javascripts&lt;/code&gt;:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;$ cd ../&amp;#x000A;$ curl -O http://jashkenas.github.com/coffee-script/extras/coffee-script.js&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;h2&gt;The test suite HTML file&lt;/h2&gt;
      
      &lt;p&gt;QUnit needs an HTML file that will load QUnit, our CoffeeScript, and our tests
      (which are also be written in CoffeeScript). The HTML file needs a few
      placeholder elements in it that &lt;code&gt;qunit.js&lt;/code&gt; uses when rendering the results of
      your test suite.&lt;/p&gt;
      
      &lt;p&gt;The onus is on you to set this file up, but there are plenty of examples
      online. Here's mine, which I saved in &lt;code&gt;test/javascripts/index.html&lt;/code&gt;:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;:::html&amp;#x000A;&amp;lt;!DOCTYPE html&amp;gt;&amp;#x000A;&amp;lt;html&amp;gt;&amp;#x000A;&amp;lt;head&amp;gt;&amp;#x000A;  &amp;lt;meta charset="UTF-8" /&amp;gt;&amp;#x000A;  &amp;lt;title&amp;gt;QUnit Test Suite&amp;lt;/title&amp;gt;&amp;#x000A;  &amp;lt;link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen"&amp;gt;&amp;#x000A;&amp;lt;/head&amp;gt;&amp;#x000A;&amp;lt;body&amp;gt;&amp;#x000A;  &amp;lt;h1 id="qunit-header"&amp;gt;QUnit Tests&amp;lt;/h1&amp;gt;&amp;#x000A;  &amp;lt;h2 id="qunit-banner"&amp;gt;&amp;lt;/h2&amp;gt;&amp;#x000A;  &amp;lt;div id="qunit-testrunner-toolbar"&amp;gt;&amp;lt;/div&amp;gt;&amp;#x000A;  &amp;lt;h2 id="qunit-userAgent"&amp;gt;&amp;lt;/h2&amp;gt;&amp;#x000A;  &amp;lt;ol id="qunit-tests"&amp;gt;&amp;lt;/ol&amp;gt;&amp;#x000A;  &amp;lt;div id="qunit-fixture"&amp;gt;&amp;#x000A;  &amp;lt;/div&amp;gt;&amp;#x000A;  &amp;lt;script type="text/javascript" src="qunit/qunit.js"&amp;gt;&amp;lt;/script&amp;gt;&amp;#x000A;  &amp;lt;script type="text/javascript" src="coffee-script.js"&amp;gt;&amp;lt;/script&amp;gt;&amp;#x000A;  &amp;lt;script type="text/coffeescript"&amp;gt;&amp;#x000A;  &amp;lt;/script&amp;gt;&amp;#x000A;&amp;lt;/body&amp;gt;&amp;#x000A;&amp;lt;/html&amp;gt;&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;You'll notice that I've loaded &lt;code&gt;qunit.js&lt;/code&gt; and &lt;code&gt;coffee-script.js&lt;/code&gt;.&lt;/p&gt;
      
      &lt;p&gt;All we need to do now is to load our tests inside the empty
      &lt;code&gt;text/coffeescript&lt;/code&gt; script tag. To check whether everything is setup
      properly, let's add a couple of simple tests:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;:::javascript&amp;#x000A;&amp;lt;script type="text/coffeescript"&amp;gt;&amp;#x000A;  test 'true should be truthy', -&amp;gt;   &amp;#x000A;    ok(true, 'true is not truthy!')&amp;#x000A;&amp;#x000A;  test 'should be able to append to an array', -&amp;gt; &amp;#x000A;    # this test will fail, as this *isn't* how to append to an array&amp;#x000A;    equal([1, 2], [1] + 2)    &amp;#x000A;&amp;lt;/script&amp;gt;&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;h3&gt;Running your tests&lt;/h3&gt;
      
      &lt;p&gt;Just open the web page in your browser. We've used relative paths for
      everything in &lt;code&gt;index.html&lt;/code&gt;, so you can load it directly from the file system,
      with a &lt;code&gt;file:///...&lt;/code&gt; URL.&lt;/p&gt;
      
      &lt;p&gt;On a Mac? Do this:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;$ open test/javascripts/index.html&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;It should look like this:&lt;/p&gt;
      
      &lt;p&gt;&lt;img class="screenshot" src="/attachments/qunit.png" alt="QUnit test framework"&gt;&lt;/p&gt;
      
      &lt;h3&gt;Loading tests from external files&lt;/h3&gt;
      
      &lt;p&gt;You could keep all your tests in &lt;code&gt;index.html&lt;/code&gt;, but I prefer to store my code in
      separate files with a &lt;code&gt;.coffee&lt;/code&gt; extension and to just use &lt;code&gt;index.html&lt;/code&gt; as a way
      to kick everything off.&lt;/p&gt;
      
      &lt;p&gt;I've put this code in my script tag:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;:::html&amp;#x000A;&amp;lt;script type="text/coffeescript"&amp;gt;&amp;#x000A;  for file in ['models', 'controllers']                                             &amp;#x000A;    lib = "../../app/assets/javascripts/#{file}.js.coffee"                          &amp;#x000A;    load_test = -&amp;gt;                                                                  &amp;#x000A;      test = "#{file}_test.coffee"                                                  &amp;#x000A;      -&amp;gt; CoffeeScript.load(test)                                                    &amp;#x000A;    CoffeeScript.load lib, load_test()  &amp;#x000A;&amp;lt;/script&amp;gt;&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;Let's break that down a bit...&lt;/p&gt;
      
      &lt;p&gt;I've used a simple naming convention for my test files. Code in
      &lt;code&gt;app/assets/javascripts/foo.js.coffee&lt;/code&gt; is tested by code that lives in
      &lt;code&gt;test/javascripts/foo_test.coffee&lt;/code&gt;. The for loop is just loading each of my
      modules, and then (via the callback returned by &lt;code&gt;load_test&lt;/code&gt;) loading the
      corresponding tests. That's all you need to do; QUnit will do the rest.&lt;/p&gt;
      
      &lt;p&gt;The &lt;code&gt;CoffeeScript.load&lt;/code&gt; function takes a URL and a callback to run after load.
      I'm loading the tests in a callback to guarantee that the code under test has
      been loaded before the test code itself is loaded. If you don't do this you can
      see some test failures when your tests run before the code they're testing gets
      loaded.&lt;/p&gt;
      
      &lt;p&gt;If you're wondering why we need the &lt;code&gt;load_test&lt;/code&gt; function (rather than just
      passing an anonymous function as our callback), it's currying the value of the
      &lt;code&gt;test&lt;/code&gt; variable. If you don't curry it the current value of &lt;code&gt;file&lt;/code&gt; is used when
      the callback executes, rather than the value that it was set to when the
      callback is defined. So if you don't curry it, most of your test files won't
      get loaded.&lt;/p&gt;
      
      &lt;h2&gt;Loading third party libraries&lt;/h2&gt;
      
      &lt;p&gt;I use MooTools and Serenade.js in my project, so I've added these lines to the
      list of script tags:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;:::html&amp;#x000A;&amp;lt;script type="text/javascript" src="../../vendor/assets/javascripts/mootools-core-1.4.4.js"&amp;gt;&amp;lt;/script&amp;gt;&amp;#x000A;&amp;lt;script type="text/javascript" src="../../vendor/assets/javascripts/serenade.js"&amp;gt;&amp;lt;/script&amp;gt;&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;You can obviously load jQuery, YUI, etc. in the same way.&lt;/p&gt;
      
      &lt;h2&gt;Adding a stubbing/mocking library&lt;/h2&gt;
      
      &lt;p&gt;Unit testing gets painful when you can't stub or mock the objects that interact
      with the code that's under test. I didn't spend a lot of time investigating the
      options, but as I read the &lt;a href="http://sinonjs.org/docs/"&gt;Sinon docs&lt;/a&gt; I took quite a shine to it. I noticed
      that Serande.js uses &lt;a href="http://sinonjs.org/"&gt;Sinon&lt;/a&gt;, and that's a good enough recommendation for me.
      There's also a QUnit plugin which makes it "just work".&lt;/p&gt;
      
      &lt;p&gt;To install Sinon download both sinon-qunit and Sinon.JS from the &lt;a href="http://sinonjs.org/qunit/"&gt;sinon-qunit
      page&lt;/a&gt; and put them in your &lt;code&gt;test/javascripts/qunit&lt;/code&gt; folder.&lt;/p&gt;
      
      &lt;p&gt;Then add these tags to &lt;code&gt;index.html&lt;/code&gt; (but make sure you update the version
      numbers):&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;:::html&amp;#x000A;&amp;lt;script type="text/javascript" src="qunit/sinon-1.3.2.js"&amp;gt;&amp;lt;/script&amp;gt;&amp;#x000A;&amp;lt;script type="text/javascript" src="qunit/sinon-qunit-1.0.0.js"&amp;gt;&amp;lt;/script&amp;gt;&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;h2&gt;Re-running the tests automatically&lt;/h2&gt;
      
      &lt;p&gt;So that's all fairly simple, but to run the tests you have to switch to your
      browser and reload the page. That's a bit painful; wouldn't it be good if your
      test suite ran immediately when you save a &lt;code&gt;.coffee&lt;/code&gt; file? I'm now using
      &lt;code&gt;guard-livereload&lt;/code&gt; to reload the page in the browser on save.&lt;/p&gt;
      
      &lt;p&gt;I think we've dealt with enough for one article, so I'll show you how to set
      &lt;code&gt;guard-livereload&lt;/code&gt; up for QUnit (with Rails) in my next post...&lt;/p&gt;
    </content>
    <published>2012-03-30T09:00:00+00:00</published>
    <updated>2012-03-30T09:00:00+00:00</updated>
    <category term="coffeescript" />
    <category term="software-testing" />
  <feedburner:origLink>http://effectif.com/coffeescript/qunit-boilerplate</feedburner:origLink></entry>
  <entry>
    <title>QUnit or Jasmine?</title>
    <link href="http://feedproxy.google.com/~r/effectif-development/~3/SNFmrl5FkCw/choosing-between-qunit-and-jasmine" rel="alternate" type="text/html" />
    <id>tag:effectif.com,2012-03-27:/coffeescript/choosing-between-qunit-and-jasmine</id>
    <content type="html">
      &lt;p&gt;Over the last few months I've been spiking a few user interface ideas
      for the &lt;a href="http://theagileplanner.com"&gt;The Agile Planner&lt;/a&gt;, which has meant that I've been writing a
      lot of CoffeeScript. While I've been experimenting, I've been content to
      test it my work with acceptance tests written in Ruby with
      &lt;code&gt;capybara-webkit&lt;/code&gt;. Last week my CoffeeScript became a little more
      complicated, and I could feel my progress slowing down as I grappled to
      keep everything in my head. It was time to go back to TDD.&lt;/p&gt;
      
      &lt;p&gt;It's been a while since I've unit tested JavaScript in anger, so I spent
      half an hour investigating the most obvious choices. There seem to be
      two main contenders:&lt;/p&gt;
      
      &lt;ul&gt;
      &lt;li&gt;&lt;strong&gt;Jasmine&lt;/strong&gt; - a BDD framework that's clearly influenced by RSpec, and&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;QUnit&lt;/strong&gt; - a more traditional test framework from the jQuery project.&lt;/li&gt;
      &lt;/ul&gt;
      
      
      &lt;p&gt;I compared them on three criteria:&lt;/p&gt;
      
      &lt;ol&gt;
      &lt;li&gt;&lt;strong&gt;Speed of setup.&lt;/strong&gt; I tend to avoid testing tools that take me more
      than hour to get up and running.&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;Simplicity.&lt;/strong&gt; Test frameworks don't need to be complicated; they
      just need to let me specify how my code should behave and keep out of
      my way. All things being equal, I'll choose an xUnit style testing
      framework to an RSpec style framework. If you're thinking "but I
      prefer BDD!" don't forget that the "B" in BDD is just language, and
      you can use that language in any framework you like.&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;Support for Continuous Integration.&lt;/strong&gt; If you can't run your test
      suite automatically then sooner or later you'll forget to run it
      manually, and at some point ship a broken app to your users. Running
      tests in your CI build also enables you to automate continuous
      deployment, which is always a giggle.&lt;/li&gt;
      &lt;/ol&gt;
      
      
      &lt;h2&gt;Evaluating Jasmine&lt;/h2&gt;
      
      &lt;p&gt;I looked at Jasmine first. A few weeks ago I stumbled across a project
      called &lt;a href="https://github.com/bradphelan/jasminerice"&gt;Jasminerice&lt;/a&gt; that makes it really easy to unit test
      CoffeeScript in a Rails 3 project, using the Rails asset pipeline.&lt;/p&gt;
      
      &lt;p&gt;While I'm not generally a fan of investing time in technologies whose
      use is limited to a single framework (Rails), Jasminerice really
      appealed. It looks like drop-in CoffeeScript testing for Rails. I'm
      using the asset pipeline, so in theory all I'd need to do to start
      testing my code is to install the &lt;code&gt;jasminerice&lt;/code&gt; gem and start creating
      files in &lt;code&gt;spec/javascripts&lt;/code&gt;.&lt;/p&gt;
      
      &lt;p&gt;With such simplicity comes reduced flexibility. I don't use RSpec (for
      me, it can't hold a candle to MiniTest). I keep all my tests in a &lt;code&gt;test&lt;/code&gt;
      folder. My CoffeeScript/JavaScript tests are going to live in
      &lt;code&gt;test/javascript&lt;/code&gt;. I opened the Jasminerice source to see whether the
      path was configurable. It wasn't. I could have monkey patched it, but I
      was starting to feel a bit of friction.&lt;/p&gt;
      
      &lt;p&gt;What about running tests on the command line? The Jasminerice README
      pointed me to &lt;a href="https://github.com/netzpirat/guard-jasmine"&gt;guard-jasmine&lt;/a&gt;, which adds a bunch of extra features.
      As you might expect, it's a plugin for Guard that will run your tests
      when you save your &lt;code&gt;.coffee&lt;/code&gt; files, but you can also run it outside of
      Guard. It uses the &lt;a href="http://www.phantomjs.org/"&gt;PhantomJS&lt;/a&gt; headless browser, so running tests from
      the command line or on a CI server is no problem.&lt;/p&gt;
      
      &lt;p&gt;Taking a quick look back at my three criteria, how do Jasmine,
      Jasminerice and guard-jasmine stack up?&lt;/p&gt;
      
      &lt;h3&gt;Speed of setup&lt;/h3&gt;
      
      &lt;p&gt;Jasmine looked innocently straightforward to begin with, but a thorough
      read through of the three projects' README files took a while.
      guard-jasmine has a lot of options. That kind of control is often just
      what you need, but all I need to do here is write a few unit tests.&lt;/p&gt;
      
      &lt;h3&gt;Simplicity&lt;/h3&gt;
      
      &lt;p&gt;I didn't feel very clear on the relative responsibilities of the three
      projects (Jasmine, Jasminerice and guard-jasmine).
      It felt as though I'd end up reading the code in order to be confident
      that I'd set it up correctly. That's fine, but I didn't fancy doing it
      for three separate projects.&lt;/p&gt;
      
      &lt;p&gt;Then I noticed that guard-jasmine depended on RSpec, which it had added
      to my project. That's 10,000 lines of Ruby code that I don't need to
      install, just to test some JavaScript. I felt as though I'd be swimming
      against the current with MiniTest; I don't want a &lt;code&gt;spec&lt;/code&gt; directory, and
      I don't want RSpec in my bundled gems.&lt;/p&gt;
      
      &lt;h3&gt;Support for Continuous Integration&lt;/h3&gt;
      
      &lt;p&gt;guard-jasmine clearly has this aspect well and truly sorted. It looks
      fantastic.&lt;/p&gt;
      
      &lt;h3&gt;Thoughts on Jasmine&lt;/h3&gt;
      
      &lt;p&gt;If you're an RSpec fan, have time to read through all the docs and play
      around with it, guard-jasmine looks brilliant.&lt;/p&gt;
      
      &lt;h2&gt;Evaluating QUnit&lt;/h2&gt;
      
      &lt;p&gt;I'm using MooTools rather than jQuery on The Agile Planner, so my first
      question was whether or not &lt;a href="http://docs.jquery.com/QUnit"&gt;QUnit&lt;/a&gt; relies on jQuery. It doesn't; if
      jQuery is loaded it'll use it internally, otherwise it falls back to
      standard DOM manipulation techniques. This discovery was a great start;
      it's clearly been designed to be framework agnostic, and that means that
      any time I invest in learning it can be re-used on other projects, using
      different libraries.&lt;/p&gt;
      
      &lt;p&gt;I was also rather chuffed that it took me 30 seconds to find and search
      the &lt;a href="http://code.jquery.com/qunit/qunit-git.js"&gt;source code&lt;/a&gt; in order to check this out; it's easy to
      read, and there was only one file to look in. A simple and transparent
      project. Great start.&lt;/p&gt;
      
      &lt;p&gt;There only seemed to be one obvious downside to QUnit. It's designed to
      run in a browser, while I was really hoping for something that I could
      launch from Ruby. I use TConsole to run my Ruby tests and I was really
      hoping that I'd be able to find a way to launch my CoffeeScript tests
      from within TConsole. QUnit's dependency on a browser made this look
      rather unlikely out of the box.&lt;/p&gt;
      
      &lt;p&gt;Incidentally, &lt;a href="https://github.com/commondream/tconsole"&gt;TConsole&lt;/a&gt; is the best test runner I've used, in any
      language, and its high time I blogged about it.&lt;/p&gt;
      
      &lt;p&gt;So how does QUnit stand up against my three criteria?&lt;/p&gt;
      
      &lt;h3&gt;Speed of setup&lt;/h3&gt;
      
      &lt;p&gt;Setting up QUnit is easy, though not that succinctly documented. You
      need to make an HTML file with a few pre-defined tags in, and then load
      &lt;code&gt;qunit.css&lt;/code&gt; and &lt;code&gt;qunit.js&lt;/code&gt; in the file's &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; tag.&lt;/p&gt;
      
      &lt;p&gt;You also need to load your CoffeeScript libraries and test files (which
      is fairly easy) and then load the web page in your browser.&lt;/p&gt;
      
      &lt;p&gt;That's all there is to it. Once you've got hold of the files, it's fast.&lt;/p&gt;
      
      &lt;h3&gt;Simplicity&lt;/h3&gt;
      
      &lt;p&gt;I can't imagine how it could be simpler. There are no gems to install,
      just three files to download and a snippet of code to edit.&lt;/p&gt;
      
      &lt;p&gt;There is, of course, a downside...&lt;/p&gt;
      
      &lt;h3&gt;Support for Continuous Integration&lt;/h3&gt;
      
      &lt;p&gt;Out of the box, you can't run QUnit from the command line. I did some
      Googling and it appears as though you can get a QUnit driver for
      JsTestDriver (whatever that means - &lt;a href="http://code.google.com/p/js-test-driver/"&gt;JsTestDriver&lt;/a&gt; is hosted on Google
      Code and the home page is terrible; it's one of those projects where
      only those who have used it can get started quickly). I'll give
      JsTestDriver a proper go some other time.&lt;/p&gt;
      
      &lt;p&gt;There are a few blog posts floating around in which people talk about
      refactoring QUnit to make it easier to run in a command line
      environment. I wonder whether anybody has got it going with PhantomJS
      yet...&lt;/p&gt;
      
      &lt;h3&gt;Thoughts on QUnit&lt;/h3&gt;
      
      &lt;p&gt;I love the small size, simplicity of installation (and the lack of
      external dependencies), and the fact that I can start writing tests
      without even involving Bundler. Seriously, trying it out without
      involving Bundler was noticeably refreshing.&lt;/p&gt;
      
      &lt;h2&gt;What I picked...&lt;/h2&gt;
      
      &lt;p&gt;It was an easy decision in the end; I went with QUnit.&lt;/p&gt;
      
      &lt;p&gt;I doubt I'll be running my CoffeeScript tests from the console, and will
      just use JsTestDriver for continuous integration. I'll use
      &lt;code&gt;guard-livereload&lt;/code&gt; to automatically refresh my in-browser tests when my
      code/tests change.&lt;/p&gt;
      
      &lt;p&gt;In another post I'll show you exactly what I've got in my QUnit HTML
      file, and how I'm loading my CoffeeScript.&lt;/p&gt;
      
      &lt;p&gt;If you can't wait for that post either &lt;a href="http://twitter.com/grahamashton"&gt;nag me on Twitter&lt;/a&gt; and I'll
      make you a gist, or do some Googling. There are already a few gists out
      there, and a few threads on Stack Overflow. And if you go and find
      those, just remember that if you compile your CoffeeScript with &lt;code&gt;-b&lt;/code&gt;
      (the "bare" option), you're doing it wrong!&lt;/p&gt;
      
      &lt;h2&gt;Links&lt;/h2&gt;
      
      &lt;ul&gt;
      &lt;li&gt;&lt;a href="http://pivotal.github.com/jasmine"&gt;Jasmine&lt;/a&gt;, &lt;a href="https://github.com/bradphelan/jasminerice"&gt;Jasminerice&lt;/a&gt; and &lt;a href="https://github.com/netzpirat/guard-jasmine"&gt;guard-jasmine&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="http://docs.jquery.com/QUnit"&gt;QUnit&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="http://www.phantomjs.org/"&gt;PhantomJS&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href="https://github.com/commondream/tconsole"&gt;TConsole&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    </content>
    <published>2012-03-27T09:00:00+00:00</published>
    <updated>2012-03-27T09:00:00+00:00</updated>
    <category term="coffeescript" />
    <category term="software-testing" />
  <feedburner:origLink>http://effectif.com/coffeescript/choosing-between-qunit-and-jasmine</feedburner:origLink></entry>
  <entry>
    <title>Showing your laptop battery status in tmux</title>
    <link href="http://feedproxy.google.com/~r/effectif-development/~3/Bx44GrOZ6sM/battery-status-in-tmux" rel="alternate" type="text/html" />
    <id>tag:effectif.com,2012-03-09:/system-administration/battery-status-in-tmux</id>
    <content type="html">
      &lt;p&gt;You can configure the tmux status bar to show pretty much anything you
      like. To include your laptop battery's current charge, all you need to
      do is to write a script that prints your current charge level.&lt;/p&gt;
      
      &lt;p&gt;I was going to write this script myself, but then I had a bright idea. I
      thought I'd have a quick look in Brian Hogan's recent &lt;a href="http://pragprog.com/book/bhtmux/tmux"&gt;Tmux book&lt;/a&gt;
      to see whether or not he'd thought to include this tip, and surprise
      surprise, he has. He also links to a rather &lt;a href="https://raw.github.com/richoH/dotfiles/master/bin/battery"&gt;nifty script&lt;/a&gt; on GitHub
      that will output your battery status on Linux, FreeBSD and OS X.&lt;/p&gt;
      
      &lt;p&gt;So here's what you do. Start by downloading the script and putting it
      somewhere in your &lt;code&gt;PATH&lt;/code&gt;:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;$ curl -O https://raw.github.com/richo/dotfiles/master/bin/battery&amp;#x000A;$ mv battery ~/bin/battery&amp;#x000A;$ chmox +x ~/bin/battery&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;The battery script will only print any output if you pass it a command
      line option of &lt;code&gt;Charging&lt;/code&gt; or &lt;code&gt;Discharging&lt;/code&gt;.&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;$ ~/bin/battery&amp;#x000A;$ ~/bin/battery Discharging&amp;#x000A;51%&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;You can also configure it to print a row of hearts (instead of the
      percentage) by setting the &lt;code&gt;CUTE_BATTERY_INDICATOR&lt;/code&gt; environment
      variable. Neat.&lt;/p&gt;
      
      &lt;p&gt;Now add this line to your &lt;code&gt;.tmux.conf&lt;/code&gt; file (it should all be on one
      line, but I've split it here for formatting purposes):&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;set -g status-right "#(~/bin/battery Discharging; ~/bin/battery Charging) \&amp;#x000A;    | %e %B %R"&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;Reload your Tmux config (if you're not sure how to do that without
      restarting Tmux, this would be a perfect time to go and buy Brian's
      &lt;a href="http://pragprog.com/book/bhtmux/tmux"&gt;ebook&lt;/a&gt; -- he tells you on page 18).&lt;/p&gt;
      
      &lt;p&gt;The characters on the end set the format of the date and time. Those are
      the settings I use; if you want to change the format refer to the
      &lt;code&gt;strftime(3)&lt;/code&gt; man page for alternative format characters.&lt;/p&gt;
    </content>
    <published>2012-03-09T08:00:00+00:00</published>
    <updated>2012-03-09T08:00:00+00:00</updated>
    <category term="mac-os-x" />
    <category term="system-administration" />
  <feedburner:origLink>http://effectif.com/system-administration/battery-status-in-tmux</feedburner:origLink></entry>
  <entry>
    <title>Move commits from one branch to another</title>
    <link href="http://feedproxy.google.com/~r/effectif-development/~3/XR53YpgUNpk/move-commit-from-one-branch-to-another" rel="alternate" type="text/html" />
    <id>tag:effectif.com,2012-03-06:/git/move-commit-from-one-branch-to-another</id>
    <content type="html">
      &lt;p&gt;Have you ever made a few commits on a branch, only to later realise that
      you should have been working on a topic branch (i.e. a branch specific
      to the task you're working on)? So long as you haven't yet shared any
      of these commits with anybody else, you can easily move them on to a new
      branch, and then remove them from your current branch.&lt;/p&gt;
      
      &lt;h2&gt;Making the topic branch&lt;/h2&gt;
      
      &lt;p&gt;When I decide that I'd be better off working in a topic branch, the first thing
      I do is commit any outstanding work. It doesn't matter if the tests aren't
      currently passing; we'll just undo the commit after we've switched branches.&lt;/p&gt;
      
      &lt;p&gt;So let's do a "WIP" (Work In Progress) commit and make the branch:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;$ git add .&amp;#x000A;$ git commit -m "WIP"&amp;#x000A;$ git checkout -b some-feature&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;You can also make a new branch with the &lt;code&gt;git branch&lt;/code&gt; command, but I prefer
      &lt;code&gt;checkout -b&lt;/code&gt; as it also switches you to the new branch immediately (whereas
      &lt;code&gt;git branch&lt;/code&gt; will just make the new branch, leaving you on your current
      branch).&lt;/p&gt;
      
      &lt;p&gt;Your "WIP" commit will now be stored safely at the head of the branch that you
      were on and also on the new &lt;code&gt;some-feature&lt;/code&gt; branch.&lt;/p&gt;
      
      &lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; If you're not familiar with branching, you can check that your
      most recent work is on the new branch before you continue:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;$ git log -p some-feature&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;h2&gt;Removing commits from master&lt;/h2&gt;
      
      &lt;p&gt;All you need to do now is to switch back to the &lt;code&gt;master&lt;/code&gt; branch and remove any
      work that you'd rather develop on the topic branch. If the work to remove is
      just your last commit you can use &lt;code&gt;git reset&lt;/code&gt; to roll the branch back:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;$ git checkout master&amp;#x000A;$ git reset --hard HEAD^&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;The &lt;code&gt;--hard&lt;/code&gt; option tells git to set the head of the current branch to the
      commit that you specify, while &lt;em&gt;modifying the files on disk&lt;/em&gt; to match the
      contents of the repository.&lt;/p&gt;
      
      &lt;p&gt;The &lt;code&gt;HEAD^&lt;/code&gt; syntax refers to the previous commit to the head of the current
      branch (i.e. the last commit on the branch), so this will roll us back one
      commit. You can add extra &lt;code&gt;^&lt;/code&gt; characters, so &lt;code&gt;HEAD^^^&lt;/code&gt; will throw away three
      commits.&lt;/p&gt;
      
      &lt;p&gt;If you want to go back more than a couple of commits you can use the tilde
      syntax to save some typing:&lt;/p&gt;
      
      &lt;ul&gt;
      &lt;li&gt;&lt;code&gt;HEAD~1&lt;/code&gt; is equivalent to &lt;code&gt;HEAD^&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;HEAD~2&lt;/code&gt; is equivalent to &lt;code&gt;HEAD^^&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code&gt;HEAD~8&lt;/code&gt; is equivalent to &lt;code&gt;HEAD^^^^^^^^&lt;/code&gt;&lt;/li&gt;
      &lt;/ul&gt;
      
      
      &lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Be careful with the &lt;code&gt;--hard&lt;/code&gt; option to &lt;code&gt;git reset&lt;/code&gt;. It isn't
      something to be afraid of, but you do need to make sure that you've committed
      all your local changes to another branch before you run it.&lt;/p&gt;
      
      &lt;h2&gt;Back to work...&lt;/h2&gt;
      
      &lt;p&gt;Now we can switch back to the topic branch and carry on from where we left off.&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;$ git checkout some-feature&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;If you had some work in progress that you saved with a "WIP" commit message you
      can back that commit out now, without losing the changes (they'll still be on
      your filesystem). We'll use &lt;code&gt;git reset&lt;/code&gt; again, but without the &lt;code&gt;--hard&lt;/code&gt; option:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;$ git reset HEAD^&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;All that'll do is to remove the last commit from your repository, without
      actually changing your files.&lt;/p&gt;
      
      &lt;p&gt;And there you are; all the commits that you deleted from &lt;code&gt;master&lt;/code&gt; are now on your topic branch.&lt;/p&gt;
      
      &lt;h2&gt;An insurance policy&lt;/h2&gt;
      
      &lt;p&gt;Should you make a mistake while you're fiddling around with branches and &lt;code&gt;git&amp;#x000A;reset --hard&lt;/code&gt; you could find yourself in a position where you've thrown a bunch
      of commits away by mistake. It's unlikely but -- let's face it -- could happen.
      Don't worry, Git has got your back, and you can &lt;a href="http://effectif.com/git/recovering-lost-git-commits"&gt;recover lost commits&lt;/a&gt;
      without too much trouble.&lt;/p&gt;
    </content>
    <published>2012-03-06T12:30:00+00:00</published>
    <updated>2012-03-06T12:30:00+00:00</updated>
    <category term="git" />
  <feedburner:origLink>http://effectif.com/git/move-commit-from-one-branch-to-another</feedburner:origLink></entry>
  <entry>
    <title>Navigating your bundled gems in Vim</title>
    <link href="http://feedproxy.google.com/~r/effectif-development/~3/ZB3cCFOXCbM/using-ctags-with-bundler-gems" rel="alternate" type="text/html" />
    <id>tag:effectif.com,2012-02-28:/vim/using-ctags-with-bundler-gems</id>
    <content type="html">
      &lt;p&gt;Do you sometimes find yourself wanting to read the code of a method in one of the gems that your project is using? Wouldn't it be good if you could put your cursor on the method or class in question, and press a key to jump straight to the definition within the gem's source code? With the &lt;code&gt;ctags&lt;/code&gt; program you can, and with Ivan Tkalin's &lt;code&gt;guard-ctags-bundler&lt;/code&gt; gem your tag files will be automatically updated when you add new gems to your bundle.&lt;/p&gt;
      
      &lt;h2&gt;Installing ctags&lt;/h2&gt;
      
      &lt;p&gt;You'll want a recent version of ctags for use with Ruby. Check for a recent version with:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;$ ctags --version&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;If &lt;code&gt;ctags&lt;/code&gt; isn't found (or you get an error message because the &lt;code&gt;--version&lt;/code&gt; switch isn't supported) you'll need to install Exuberant ctags.&lt;/p&gt;
      
      &lt;p&gt;On Debian or Ubuntu, try this:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;$ sudo apt-get install exuberant-ctags&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;On the Mac I'd recommend installing it with &lt;a href="http://mxcl.github.com/homebrew/"&gt;Homebrew&lt;/a&gt;:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;$ brew install ctags&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;Test it by typing &lt;code&gt;ctags -R&lt;/code&gt; inside your project's directory. It should create a &lt;code&gt;tags&lt;/code&gt; file that Vim can read to navigate around the classes and methods defined in your own project.&lt;/p&gt;
      
      &lt;p&gt;To add support for navigating around your bundled gems, we need to setup &lt;code&gt;guard-ctags-bundler&lt;/code&gt;.&lt;/p&gt;
      
      &lt;h2&gt;Installing guard-ctags-bundler&lt;/h2&gt;
      
      &lt;p&gt;Add these two gems to the development group in your &lt;code&gt;Gemfile&lt;/code&gt;:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;group :development do&amp;#x000A;  gem 'guard-ctags-bundler'&amp;#x000A;  gem 'rb-readline'&amp;#x000A;end&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;You don't strictly need &lt;code&gt;rb-readline&lt;/code&gt;, but Guard's prompt improves dramatically when readline support is enabled.&lt;/p&gt;
      
      &lt;p&gt;Run &lt;code&gt;bundle&lt;/code&gt;, and then create your &lt;code&gt;Guardfile&lt;/code&gt;:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;$ bundle install&amp;#x000A;$ guard init ctags-bundler&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;You can edit the paths in your &lt;code&gt;Guardfile&lt;/code&gt; if you like, but the default should work well with most Rails projects and gems. Run &lt;code&gt;guard&lt;/code&gt;, and then edit your &lt;code&gt;Gemfile&lt;/code&gt; and run &lt;code&gt;bundle install&lt;/code&gt; in another terminal. Guard should report that it has re-generated a &lt;code&gt;gems.tags&lt;/code&gt; file.&lt;/p&gt;
      
      &lt;p&gt;If you leave &lt;code&gt;guard&lt;/code&gt; running while you're working it'll keep the tags files up to date for you.&lt;/p&gt;
      
      &lt;h2&gt;Configure Vim&lt;/h2&gt;
      
      &lt;p&gt;Vim will automatically read the &lt;code&gt;tags&lt;/code&gt; file, but we'll have to tell it to read the &lt;code&gt;gems.tags&lt;/code&gt; file too. Add this to your &lt;code&gt;~/.vimrc&lt;/code&gt; file:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;set tags+=gems.tags&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;h2&gt;Don't store tags files in version control&lt;/h2&gt;
      
      &lt;p&gt;Your tags files are continually updated as you edit your project, and because they're automatically generated it doesn't make any sense to check them in. If you're using &lt;code&gt;git&lt;/code&gt; you can tell it to ignore the tags files in all your projects like this:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;$ cat &amp;lt;&amp;lt;EOF &amp;gt;&amp;gt; ~/.gitignore&amp;#x000A;tags&amp;#x000A;gems.tags&amp;#x000A;EOF&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;h2&gt;Using ctags in Vim&lt;/h2&gt;
      
      &lt;p&gt;Find a method in your project that you know is defined in one of the Gems in your bundle. Position the cursor on the method call, and press &lt;code&gt;Ctrl-]&lt;/code&gt;. You should find yourself looking at the code in the gem where the method is defined. To jump back to where you came from press &lt;code&gt;Ctrl-T&lt;/code&gt; (these keybindings are the same ones used for following hyperlinks in Vim's help system).&lt;/p&gt;
      
      &lt;p&gt;Vim's &lt;code&gt;ctags&lt;/code&gt; support can do a lot more than that (such as opening the code in a split), and Vim's help on using ctags is excellent. Read it by typing &lt;code&gt;:help 29.1&lt;/code&gt; within Vim.&lt;/p&gt;
      
      &lt;h2&gt;Useful links&lt;/h2&gt;
      
      &lt;ul&gt;
      &lt;li&gt;The &lt;a href="https://github.com/ivalkeen/guard-ctags-bundler"&gt;guard-ctags-bundler GitHub page&lt;/a&gt;.&lt;/li&gt;
      &lt;li&gt;&lt;a href="http://vimdoc.sourceforge.net/htmldoc/usr_29.html"&gt;Section 29&lt;/a&gt; of the Vim manual.&lt;/li&gt;
      &lt;/ul&gt;
    </content>
    <published>2012-02-28T09:00:00+00:00</published>
    <updated>2012-02-28T09:00:00+00:00</updated>
    <category term="ruby" />
    <category term="vim" />
  <feedburner:origLink>http://effectif.com/vim/using-ctags-with-bundler-gems</feedburner:origLink></entry>
  <entry>
    <title>Running MacVim in your terminal</title>
    <link href="http://feedproxy.google.com/~r/effectif-development/~3/D7ebGTRdZSU/running-vim-with-ruby-support-in-terminal" rel="alternate" type="text/html" />
    <id>tag:effectif.com,2012-02-13:/vim/running-vim-with-ruby-support-in-terminal</id>
    <content type="html">
      &lt;p&gt;A recent version of Vim comes with every copy of Mac OS X. When Apple compiled it they didn't link it against Ruby, which means that you can't use &lt;code&gt;/usr/bin/vi&lt;/code&gt; with any Ruby based plugins. MacVim (which includes Ruby support) normally runs with a GUI, but you can run it in a terminal when you type &lt;code&gt;vi&lt;/code&gt; if you prefer.&lt;/p&gt;
      
      &lt;p&gt;If MacVim isn't already installed, go and &lt;a href="http://code.google.com/p/macvim/"&gt;download it&lt;/a&gt; now.&lt;/p&gt;
      
      &lt;p&gt;When you run MacVim using the application icon it runs a binary inside your Applications folder. MacVim's disk image also contains a script called &lt;code&gt;mvim&lt;/code&gt; that you can put in a folder in your &lt;code&gt;$PATH&lt;/code&gt; so that you can launch that same binary from the command line. If you haven't already done so, install the &lt;code&gt;mvim&lt;/code&gt; script. You can get advice on how to do that by typing &lt;code&gt;:help mvim&lt;/code&gt; inside MacVim; they recommend putting the script in &lt;code&gt;/usr/local/bin&lt;/code&gt;.&lt;/p&gt;
      
      &lt;p&gt;To get the &lt;code&gt;vi&lt;/code&gt; command to run MacVim without the GUI we can make a symlink to the &lt;code&gt;mvim&lt;/code&gt; script, and call it &lt;code&gt;vi&lt;/code&gt;. Assuming you put the &lt;code&gt;mvim&lt;/code&gt; script in &lt;code&gt;/usr/local/bin&lt;/code&gt;, this should do it (though you might need sudo, depending on how your Mac is setup):&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;$ ln -s /usr/local/bin/mvim /usr/local/bin/vi&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;Let's setup a link for &lt;code&gt;vim&lt;/code&gt; too, in case you're ever tempted to run it
      that way:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;$ ln -s /usr/local/bin/mvim /usr/local/bin/vim&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;We'll also need to tell Bash to clear its cache of where all your programs live, so that it'll search &lt;code&gt;$PATH&lt;/code&gt; for &lt;code&gt;vi&lt;/code&gt; again and find the new script, instead of the file in &lt;code&gt;/usr/bin/vi&lt;/code&gt;:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;$ type vi&amp;#x000A;vi is hashed (/usr/bin/vi)&amp;#x000A;$ hash -r&amp;#x000A;$ type vi&amp;#x000A;vi is /usr/local/bin/vi&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;If you want to check that you're actually running MacVim, run &lt;code&gt;vi&lt;/code&gt; like this:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;$ vi --version&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;You should see "MacOS X (unix) version" in the first couple of lines of output.&lt;/p&gt;
      
      &lt;h2&gt;Launching the GUI&lt;/h2&gt;
      
      &lt;p&gt;When you're running MacVim on the console you can switch to the GUI simply by entering &lt;code&gt;:gui&lt;/code&gt; from within Vim. It can be quite handy; try &lt;code&gt;help :macvim&lt;/code&gt; for more...&lt;/p&gt;
    </content>
    <published>2012-02-13T08:55:00+00:00</published>
    <updated>2012-02-13T08:55:00+00:00</updated>
    <category term="mac-os-x" />
    <category term="vim" />
  <feedburner:origLink>http://effectif.com/vim/running-vim-with-ruby-support-in-terminal</feedburner:origLink></entry>
  <entry>
    <title>Patching "bundle open" to set your current directory</title>
    <link href="http://feedproxy.google.com/~r/effectif-development/~3/omwOI-FfgTM/opening-gems-in-vim" rel="alternate" type="text/html" />
    <id>tag:effectif.com,2012-02-06:/vim/opening-gems-in-vim</id>
    <content type="html">
      &lt;p&gt;Ruby programmers need to be able to read the source code of the libraries
      (gems) that they use. &lt;a href="http://gembundler.com"&gt;Bundler&lt;/a&gt; makes it easy to load the source of a gem into your editor, with the &lt;code&gt;bundle open&lt;/code&gt; command:&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;$ bundle open activerecord&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;It checks your &lt;code&gt;$EDITOR&lt;/code&gt; environment variable to open the gem's code in your
      favourite editor.&lt;/p&gt;
      
      &lt;p&gt;It works great with Textmate, but (as &lt;a href="https://twitter.com/beng/status/165805951272747008"&gt;pointed out&lt;/a&gt; by Ben Griffiths)
      when used with Vim it could be improved slightly by changing the current
      directory to the gem's folder before running Vim.&lt;/p&gt;
      
      &lt;p&gt;Inspired by Ben's shell script, I wrote a short Bash function to replace
      the &lt;code&gt;bundle&lt;/code&gt; command that ships with Bundler. It's a useful technique;
      worth blogging about simply to point out to those who haven't dabbled in
      it how handy shell scripting can be...&lt;/p&gt;
      
      &lt;pre&gt;&lt;code&gt;bundle () &amp;#x000A;{ &amp;#x000A;    if [ "$1" == "open" ]; then&amp;#x000A;        shift&amp;#x000A;        ( cd $($(which bundle) show $*) &amp;amp;&amp;amp; $EDITOR . )&amp;#x000A;    else&amp;#x000A;        $(which bundle) $*&amp;#x000A;    fi&amp;#x000A;}&amp;#x000A;&lt;/code&gt;&lt;/pre&gt;
      
      &lt;p&gt;The function shadows the &lt;code&gt;bundle&lt;/code&gt; command (in the event that two commands
      should have the same name, functions are run in preference to external
      scripts).&lt;/p&gt;
      
      &lt;p&gt;The script checks to see whether its first argument is "open". If it is,
      the first command is removed from the argument list (with &lt;code&gt;shift&lt;/code&gt;) and
      then the real &lt;code&gt;bundle&lt;/code&gt; program is called with &lt;code&gt;$(which bundle)&lt;/code&gt;. The
      &lt;code&gt;$*&lt;/code&gt; variable contains all the arguments that were passed to the
      function (minus the "open" that we just shifted off the front), so it's
      really just calling Bundler's &lt;code&gt;show&lt;/code&gt; command to find the path to the
      gem's folder.&lt;/p&gt;
      
      &lt;p&gt;The path is handed to &lt;code&gt;cd&lt;/code&gt; so that we change directory, and then the editor is
      run in the current directory.&lt;/p&gt;
      
      &lt;p&gt;The brackets surrounding the &lt;code&gt;cd... &amp;amp;&amp;amp; $EDITOR .&lt;/code&gt; command run the commands in a
      separate process, which prevents our current shell's current directory from
      being changed. If we didn't do that then we'd find our current directory
      would be the gem's directory, after we quit our editor.&lt;/p&gt;
    </content>
    <published>2012-02-06T00:00:00+00:00</published>
    <updated>2012-02-06T00:00:00+00:00</updated>
    <category term="ruby" />
    <category term="vim" />
  <feedburner:origLink>http://effectif.com/vim/opening-gems-in-vim</feedburner:origLink></entry>
  <entry>
    <title>Holy shit, I'm an entrepreneur!</title>
    <link href="http://feedproxy.google.com/~r/effectif-development/~3/VRpk_Okslh4/becoming-an-entrepreneur" rel="alternate" type="text/html" />
    <id>tag:effectif.com,2012-01-27:/articles/becoming-an-entrepreneur</id>
    <content type="html">
      &lt;p&gt;I wound down my freelancing business at the end of 2011 in order to
      dedicate some time to building my own product. For a long time now I've
      felt there's been a need for a better Agile planning app that caters to
      those of us who practice Extreme Programming and Scrum.&lt;/p&gt;
      
      &lt;p&gt;I'm not going to elaborate too much here on what I feel is missing from
      the existing apps, but discussions with other developers have
      consistently reinforced my thinking; there's a better way to do it.&lt;/p&gt;
      
      &lt;p&gt;I've been throwing the key features around in my head for several years
      now. I started out by telling myself not to be so daft &amp;ndash; "the
      world doesn't need yet another Agile project management app!" And yet,
      I struggle to use any of the existing apps. It seems that I'm not alone,
      as building your own an agile app is so common that it's become
      something of a clich&amp;eacute; in developer circles.&lt;/p&gt;
      
      &lt;p&gt;Early in 2011 I approached a good friend and &lt;a href="http://www.everyinteraction.com"&gt;excellent designer&lt;/a&gt;
      with some sketches of what I'd like to be using, and he converted them
      into beautiful screenshots. You can see them on the &lt;a href="http://theagileplanner.com/tour"&gt;tour page&lt;/a&gt;.&lt;/p&gt;
      
      &lt;p&gt;The developers that have seen the mockups have all seemed keen to use
      it. That's a great start, but the question that has been nagging at the
      back of my mind is whether they'd buy it if they didn't know me. Would
      they even think it was worth a look? How many people really have the
      same problem that I do?&lt;/p&gt;
      
      &lt;h2&gt;Going Lean&lt;/h2&gt;
      
      &lt;p&gt;How do you test whether anybody would pay for your product idea?
      Asking your friends is all well and good, and it's great when they're
      enthusiastic, but they're also biased. For the most part they already
      know how I approach project management, and they know that it works.
      They also want me to succeed, so they're egging me on.&lt;/p&gt;
      
      &lt;p&gt;Their positivity has encouraged me to give the idea a proper go -- I've
      given up the day job to focus all my attention on building a company
      around the idea. And yet, I can't risk investing several months of my
      life in building my vision of the perfect agile app, as &lt;a href="http://blog.asmartbear.com/customer-validation.html"&gt;I am not my
      customer&lt;/a&gt;!&lt;/p&gt;
      
      &lt;p&gt;So I'm giving the techniques in &lt;a href="http://theleanstartup.com"&gt;The Lean Startup&lt;/a&gt; a try.&lt;/p&gt;
      
      &lt;p&gt;I need to invest as little effort as I can in order to demonstrate that
      I stand a good chance of selling my app. I need to build a minimum
      viable product (MVP):&lt;/p&gt;
      
      &lt;blockquote&gt;&lt;p&gt;The minimum viable product is that version of a new product which
      allows a team to collect the maximum amount of validated learning with
      the least effort. -- &lt;a href="http://www.startuplessonslearned.com/2010/09/good-enough-never-is-or-is-it.html"&gt;Eric Ries&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;
      
      &lt;p&gt;So how do I identify my first MVP? To do that I need to identify a
      hypothesis to test, and then think of ways to test it.&lt;/p&gt;
      
      &lt;p&gt;I'll be writing more on that in a later post. I'm also writing a series
      of articles called &lt;a href="http://theagileplanner.com/blog/building-agile-planner"&gt;Building the Agile Planner&lt;/a&gt; over on the Agile
      Planner blog (you can &lt;a href="http://theagileplanner.com/articles.xml"&gt;subscribe here&lt;/a&gt;), where I'll be writing up how
      things have gone. Forthcoming posts on effectif.com will either cover
      what I'm learning about Lean, or more of the standard technical stuff
      that I've posted in the past.&lt;/p&gt;
    </content>
    <published>2012-01-27T00:00:00+00:00</published>
    <updated>2012-01-27T00:00:00+00:00</updated>
    <category term="agile" />
  <feedburner:origLink>http://effectif.com/articles/becoming-an-entrepreneur</feedburner:origLink></entry>
</feed>

