<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.jordanelver.co.uk/~d/styles/atom10full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.jordanelver.co.uk/~d/styles/itemcontent.css" type="text/css" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom">
 
  <title>Jordan Elver</title>
  <subtitle>The personal website of Jordan Elver</subtitle>
  
  <link href="http://jordanelver.co.uk/" />
  <updated>2008-12-31T02:40:13+00:00</updated>
  <author>
    <name>Jordan Elver</name>
    <email>me@jordanelver.co.uk</email>
  </author>
  <id>http://jordanelver.co.uk/</id>
  
  <link rel="self" href="http://feeds.jordanelver.co.uk/jordanelver" type="application/atom+xml" /><entry>
    <title>htop - a prettier top</title>
    <link href="/articles/2008/12/31/htop-a-prettier-top" />
    <id>tag:jordanelver.co.uk,2008-12-31:1230690300</id>
    <updated>2008-12-31T02:25:00+00:00</updated>
    <content type="html">&lt;p&gt;You use &lt;a href="http://en.wikipedia.org/wiki/Top_%28Unix%29"&gt;top&lt;/a&gt; right? No? Well, that&amp;#8217;s probably because top is not the friendliest
program in the world. Yes, it gets the job done, but it could be prettier.
As I was using top more and more for monitoring my VPS, I looked for something a bit nicer.&lt;/p&gt;
&lt;p&gt;This is where &lt;a href="http://htop.sourceforge.net/"&gt;htop&lt;/a&gt; comes in. It&amp;#8217;s top, but with colours, progress bars, and a
process tree view. Much better. Try it, you might like it.&lt;/p&gt;
&lt;p&gt;&lt;img src="/images/htop.jpg" /&gt;&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Changing Recent Commits with Git</title>
    <link href="/articles/2008/12/16/changing-recent-commits-with-git" />
    <id>tag:jordanelver.co.uk,2008-12-16:1229457625</id>
    <updated>2008-12-16T20:00:25+00:00</updated>
    <content type="html">&lt;p&gt;Have you ever committed to your repo and realised you&amp;#8217;ve done something a bit silly? I just did that. I moved to a new machine and forgot to setup my &lt;code&gt;.gitconfig&lt;/code&gt; with the correct username and email, so when I committed, the commit had the wrong user against it. Not a big problem, but it just looks a bit&amp;#8230;well, untidy.&lt;/p&gt;
&lt;p&gt;Fear not. Git is all-powerful and allows you to change your mistake even
though you&amp;#8217;ve already committed it. Thanks to Tekkub on the 
&lt;a href="http://groups.google.com/group/github"&gt;GitHub Google Group&lt;/a&gt; for
the nudge in the right direction.&lt;/p&gt;
&lt;h4&gt;How does I dos it?&lt;/h4&gt;
&lt;p&gt;Like this.&lt;/p&gt;
&lt;div class="UltraViolet"&gt;&lt;pre class="all_hallows_eve"&gt;&lt;span class="line-numbers"&gt;   1 &lt;/span&gt; git reset --soft HEAD^
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This will reset your working copy to the state before you committed and remove
the commit so you can make changes to your working copy (if needed) and re-commit.&lt;/p&gt;
&lt;p&gt;Re-commit the changes.&lt;/p&gt;
&lt;div class="UltraViolet"&gt;&lt;pre class="all_hallows_eve"&gt;&lt;span class="line-numbers"&gt;   1 &lt;/span&gt; git commit -m &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;Changed something&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you&amp;#8217;ve already pushed to &lt;a href="http://www.github.com"&gt;GitHub&lt;/a&gt; or another external repo, you can re-push, but you&amp;#8217;ll need 
to add &lt;code&gt;--force&lt;/code&gt; because we have removed a commit locally and Git doesn&amp;#8217;t like that.&lt;/p&gt;
&lt;div class="UltraViolet"&gt;&lt;pre class="all_hallows_eve"&gt;&lt;span class="line-numbers"&gt;   1 &lt;/span&gt; git push origin --force
&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I&amp;#8217;m not sure whether this would be a good idea if someone else has cloned your repo, but
I&amp;#8217;m ok because I am the only person who pushes to this one.&lt;/p&gt;
&lt;p&gt;Git is great, but powerful, so be careful. I&amp;#8217;m sure it would be easy to completely
trash your repo with the wrong series of commands.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Google Analytics Ecommerce Tracking</title>
    <link href="/articles/2008/08/07/google-analytics-ecommerce-tracking" />
    <id>tag:jordanelver.co.uk,2008-08-07:1218120401</id>
    <updated>2008-08-07T15:46:41+01:00</updated>
    <content type="html">&lt;p&gt;So you&amp;#8217;ve installed &lt;a href="http://www.google.com/analytics"&gt;Google Analytics&lt;/a&gt;, the superb 
free web analytics software and it&amp;#8217;s telling you all sorts of things about your site,
most of which you don&amp;#8217;t even understand. You&amp;#8217;re learning what a &lt;a href="http://en.wikipedia.org/wiki/Bounce_Rate"&gt;Bounce Rate&lt;/a&gt;
is and realising how powerful this thing really is.&lt;/p&gt;
&lt;p&gt;Well, it gets even better. I&amp;#8217;ve recently discovered its&amp;#8217; Ecommerce tracking feature.
It allows you to capture Ecommerce related statistics alongside your normal web related
statistics. Once you have it correctly setup for your site you can see how much
money you&amp;#8217;ve taken in sales, how many transactions have taken place, how many 
products have been purchased, and your Ecommerce conversion rate. Very nice.&lt;/p&gt;
&lt;h4&gt;Make it so&lt;/h4&gt;
&lt;p&gt;In order to activate Ecommerce tracking, you need to firstly turn on the feature 
within Google Analytics, and secondly add some extra JavaScript code to your receipt or thanks page.&lt;/p&gt;
&lt;p&gt;To turn on the feature, go to the Profile Settings for your site, click Edit (top right)
and under E-Commerce Website, select &amp;#8220;Yes, an E-Commerce Site&amp;#8221;.
 
Here&amp;#8217;s the extra code you need to add to the receipt page straight from &lt;a href="http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&amp;amp;answer=55528"&gt;Google&amp;#8217;s help page&lt;/a&gt;.&lt;/p&gt;
&lt;div class="UltraViolet"&gt;&lt;pre class="all_hallows_eve"&gt;&lt;span class="line-numbers"&gt;   1 &lt;/span&gt; &lt;span class="Keyword"&gt;&amp;lt;&lt;/span&gt;script type&lt;span class="Keyword"&gt;=&lt;/span&gt;&lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;text/javascript&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class="Keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="line-numbers"&gt;   2 &lt;/span&gt; &lt;span class="SourceBase"&gt;var&lt;/span&gt; gaJsHost &lt;span class="Keyword"&gt;=&lt;/span&gt; &lt;span class="SourceBase"&gt;(&lt;/span&gt;&lt;span class="SourceBase"&gt;(&lt;/span&gt;&lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;https:&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class="Keyword"&gt;==&lt;/span&gt; &lt;span class="SourceBase"&gt;document&lt;/span&gt;&lt;span class="SourceBase"&gt;.&lt;/span&gt;&lt;span class="SourceBase"&gt;location&lt;/span&gt;&lt;span class="SourceBase"&gt;.&lt;/span&gt;&lt;span class="SourceBase"&gt;protocol&lt;/span&gt;&lt;span class="SourceBase"&gt;)&lt;/span&gt; ? &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;https://ssl.&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; : &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;http://www.&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class="SourceBase"&gt;)&lt;/span&gt;&lt;span class="SourceBase"&gt;;&lt;/span&gt;
&lt;span class="line-numbers"&gt;   3 &lt;/span&gt; &lt;span class="SourceBase"&gt;document&lt;/span&gt;&lt;span class="SourceBase"&gt;.&lt;/span&gt;&lt;span class="SupportFunction"&gt;write&lt;/span&gt;&lt;span class="SourceBase"&gt;(&lt;/span&gt;&lt;span class="SupportFunction"&gt;unescape&lt;/span&gt;&lt;span class="SourceBase"&gt;(&lt;/span&gt;&lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;%3Cscript src='&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class="Keyword"&gt;+&lt;/span&gt; gaJsHost &lt;span class="Keyword"&gt;+&lt;/span&gt; &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class="SourceBase"&gt;)&lt;/span&gt;&lt;span class="SourceBase"&gt;)&lt;/span&gt;&lt;span class="SourceBase"&gt;;&lt;/span&gt;
&lt;span class="line-numbers"&gt;   4 &lt;/span&gt; &lt;span class="Keyword"&gt;&amp;lt;&lt;/span&gt;/script&lt;span class="Keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="line-numbers"&gt;   5 &lt;/span&gt; 
&lt;span class="line-numbers"&gt;   6 &lt;/span&gt; &lt;span class="Keyword"&gt;&amp;lt;&lt;/span&gt;script type&lt;span class="Keyword"&gt;=&lt;/span&gt;&lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;text/javascript&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class="Keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="line-numbers"&gt;   7 &lt;/span&gt; &lt;span class="SourceBase"&gt;var&lt;/span&gt; pageTracker &lt;span class="Keyword"&gt;=&lt;/span&gt; _gat&lt;span class="SourceBase"&gt;.&lt;/span&gt;_getTracker&lt;span class="SourceBase"&gt;(&lt;/span&gt;&lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;UA-XXXXX-1&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class="SourceBase"&gt;)&lt;/span&gt;&lt;span class="SourceBase"&gt;;&lt;/span&gt;
&lt;span class="line-numbers"&gt;   8 &lt;/span&gt; pageTracker&lt;span class="SourceBase"&gt;.&lt;/span&gt;_trackPageview&lt;span class="SourceBase"&gt;(&lt;/span&gt;&lt;span class="SourceBase"&gt;)&lt;/span&gt;&lt;span class="SourceBase"&gt;;&lt;/span&gt;
&lt;span class="line-numbers"&gt;   9 &lt;/span&gt; 
&lt;span class="line-numbers"&gt;  10 &lt;/span&gt; pageTracker&lt;span class="SourceBase"&gt;.&lt;/span&gt;_addTrans&lt;span class="SourceBase"&gt;(&lt;/span&gt;
&lt;span class="line-numbers"&gt;  11 &lt;/span&gt;   &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;1234&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class="SourceBase"&gt;,                                     &lt;/span&gt;&lt;span class="Comment"&gt;&lt;span class="Comment"&gt;//&lt;/span&gt; Order ID&lt;/span&gt;
&lt;span class="line-numbers"&gt;  12 &lt;/span&gt;   &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;Mountain View&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class="SourceBase"&gt;,                            &lt;/span&gt;&lt;span class="Comment"&gt;&lt;span class="Comment"&gt;//&lt;/span&gt; Affiliation&lt;/span&gt;
&lt;span class="line-numbers"&gt;  13 &lt;/span&gt;   &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;11.99&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class="SourceBase"&gt;,                                    &lt;/span&gt;&lt;span class="Comment"&gt;&lt;span class="Comment"&gt;//&lt;/span&gt; Total&lt;/span&gt;
&lt;span class="line-numbers"&gt;  14 &lt;/span&gt;   &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;1.29&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class="SourceBase"&gt;,                                     &lt;/span&gt;&lt;span class="Comment"&gt;&lt;span class="Comment"&gt;//&lt;/span&gt; Tax&lt;/span&gt;
&lt;span class="line-numbers"&gt;  15 &lt;/span&gt;   &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;5&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class="SourceBase"&gt;,                                        &lt;/span&gt;&lt;span class="Comment"&gt;&lt;span class="Comment"&gt;//&lt;/span&gt; Shipping&lt;/span&gt;
&lt;span class="line-numbers"&gt;  16 &lt;/span&gt;   &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;San Jose&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class="SourceBase"&gt;,                                 &lt;/span&gt;&lt;span class="Comment"&gt;&lt;span class="Comment"&gt;//&lt;/span&gt; City&lt;/span&gt;
&lt;span class="line-numbers"&gt;  17 &lt;/span&gt;   &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;California&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class="SourceBase"&gt;,                               &lt;/span&gt;&lt;span class="Comment"&gt;&lt;span class="Comment"&gt;//&lt;/span&gt; State&lt;/span&gt;
&lt;span class="line-numbers"&gt;  18 &lt;/span&gt;   &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;USA&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;                                       &lt;span class="Comment"&gt;&lt;span class="Comment"&gt;//&lt;/span&gt; Country&lt;/span&gt;
&lt;span class="line-numbers"&gt;  19 &lt;/span&gt; &lt;span class="SourceBase"&gt;)&lt;/span&gt;&lt;span class="SourceBase"&gt;;&lt;/span&gt;
&lt;span class="line-numbers"&gt;  20 &lt;/span&gt; 
&lt;span class="line-numbers"&gt;  21 &lt;/span&gt; pageTracker&lt;span class="SourceBase"&gt;.&lt;/span&gt;_addItem&lt;span class="SourceBase"&gt;(&lt;/span&gt;
&lt;span class="line-numbers"&gt;  22 &lt;/span&gt;   &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;1234&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class="SourceBase"&gt;,                                     &lt;/span&gt;&lt;span class="Comment"&gt;&lt;span class="Comment"&gt;//&lt;/span&gt; Order ID&lt;/span&gt;
&lt;span class="line-numbers"&gt;  23 &lt;/span&gt;   &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;DD44&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class="SourceBase"&gt;,                                     &lt;/span&gt;&lt;span class="Comment"&gt;&lt;span class="Comment"&gt;//&lt;/span&gt; SKU&lt;/span&gt;
&lt;span class="line-numbers"&gt;  24 &lt;/span&gt;   &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;T-Shirt&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class="SourceBase"&gt;,                                  &lt;/span&gt;&lt;span class="Comment"&gt;&lt;span class="Comment"&gt;//&lt;/span&gt; Product Name &lt;/span&gt;
&lt;span class="line-numbers"&gt;  25 &lt;/span&gt;   &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;Green Medium&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class="SourceBase"&gt;,                             &lt;/span&gt;&lt;span class="Comment"&gt;&lt;span class="Comment"&gt;//&lt;/span&gt; Category&lt;/span&gt;
&lt;span class="line-numbers"&gt;  26 &lt;/span&gt;   &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;11.99&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class="SourceBase"&gt;,                                    &lt;/span&gt;&lt;span class="Comment"&gt;&lt;span class="Comment"&gt;//&lt;/span&gt; Price&lt;/span&gt;
&lt;span class="line-numbers"&gt;  27 &lt;/span&gt;   &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;1&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;                                         &lt;span class="Comment"&gt;&lt;span class="Comment"&gt;//&lt;/span&gt; Quantity&lt;/span&gt;
&lt;span class="line-numbers"&gt;  28 &lt;/span&gt; &lt;span class="SourceBase"&gt;)&lt;/span&gt;&lt;span class="SourceBase"&gt;;&lt;/span&gt;
&lt;span class="line-numbers"&gt;  29 &lt;/span&gt; 
&lt;span class="line-numbers"&gt;  30 &lt;/span&gt; pageTracker&lt;span class="SourceBase"&gt;.&lt;/span&gt;_trackTrans&lt;span class="SourceBase"&gt;(&lt;/span&gt;&lt;span class="SourceBase"&gt;)&lt;/span&gt;&lt;span class="SourceBase"&gt;;&lt;/span&gt;
&lt;span class="line-numbers"&gt;  31 &lt;/span&gt; &lt;span class="Keyword"&gt;&amp;lt;&lt;/span&gt;/script&lt;span class="Keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you&amp;#8217;re already using Analytics, the first few lines will be familier to you. They&amp;#8217;re
just the standard page tracking calls. The bits we&amp;#8217;re interested in are the 
&lt;code&gt;pageTacker._addTrans()&lt;/code&gt;, &lt;code&gt;pageTracker._addItem()&lt;/code&gt; and &lt;code&gt;pageTracker._trackTrans()&lt;/code&gt; methods.
You&amp;#8217;ll need to fill in the relevant details, and more importantly repeat the &lt;code&gt;_addItem&lt;/code&gt; 
call for each item within the order. The method for doing this will obviously differ depending
on your server side choices, but for Rails I&amp;#8217;ve got something similar to this.&lt;/p&gt;
&lt;div class="UltraViolet"&gt;&lt;pre class="all_hallows_eve"&gt;&lt;span class="line-numbers"&gt;   1 &lt;/span&gt; &lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;&amp;lt;%&lt;/span&gt; &lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;@&lt;/span&gt;order&lt;/span&gt;&lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;.&lt;/span&gt;&lt;span class="FunctionName"&gt;items&lt;/span&gt;&lt;/span&gt;&lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;.&lt;/span&gt;&lt;span class="FunctionName"&gt;each&lt;/span&gt;&lt;/span&gt; &lt;span class="Keyword"&gt;do &lt;/span&gt;&lt;span class="SourceBase"&gt;|&lt;/span&gt;&lt;span class="SourceBase"&gt;item&lt;/span&gt;&lt;span class="SourceBase"&gt;|&lt;/span&gt; &lt;span class="SourceBase"&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class="line-numbers"&gt;   2 &lt;/span&gt; 
&lt;span class="line-numbers"&gt;   3 &lt;/span&gt;   pageTracker._addItem(
&lt;span class="line-numbers"&gt;   4 &lt;/span&gt;     &lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;@&lt;/span&gt;order&lt;/span&gt;&lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;.&lt;/span&gt;&lt;span class="FunctionName"&gt;order_id&lt;/span&gt;&lt;/span&gt; &lt;span class="SourceBase"&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;,                     // Order ID
&lt;span class="line-numbers"&gt;   5 &lt;/span&gt;     &lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;@&lt;/span&gt;order&lt;/span&gt;&lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;.&lt;/span&gt;&lt;span class="FunctionName"&gt;sku&lt;/span&gt;&lt;/span&gt; &lt;span class="SourceBase"&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;,                          // SKU
&lt;span class="line-numbers"&gt;   6 &lt;/span&gt;     &lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;&amp;lt;%=&lt;/span&gt; item&lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;.&lt;/span&gt;&lt;span class="FunctionName"&gt;product&lt;/span&gt;&lt;/span&gt;&lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;.&lt;/span&gt;&lt;span class="FunctionName"&gt;name&lt;/span&gt;&lt;/span&gt; &lt;span class="SourceBase"&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;,                   // Product Name 
&lt;span class="line-numbers"&gt;   7 &lt;/span&gt;     &lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;&amp;lt;%=&lt;/span&gt; item&lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;.&lt;/span&gt;&lt;span class="FunctionName"&gt;product&lt;/span&gt;&lt;/span&gt;&lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;.&lt;/span&gt;&lt;span class="FunctionName"&gt;category&lt;/span&gt;&lt;/span&gt; &lt;span class="SourceBase"&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;,               // Category
&lt;span class="line-numbers"&gt;   8 &lt;/span&gt;     &lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;&amp;lt;%=&lt;/span&gt; item&lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;.&lt;/span&gt;&lt;span class="FunctionName"&gt;unit_price&lt;/span&gt;&lt;/span&gt; &lt;span class="SourceBase"&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;,                     // Price
&lt;span class="line-numbers"&gt;   9 &lt;/span&gt;     &lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;&amp;lt;%=&lt;/span&gt; item&lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;.&lt;/span&gt;&lt;span class="FunctionName"&gt;qauntity&lt;/span&gt;&lt;/span&gt; &lt;span class="SourceBase"&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;                        // Quantity
&lt;span class="line-numbers"&gt;  10 &lt;/span&gt;   );
&lt;span class="line-numbers"&gt;  11 &lt;/span&gt; 
&lt;span class="line-numbers"&gt;  12 &lt;/span&gt; &lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;&amp;lt;%&lt;/span&gt; &lt;span class="Keyword"&gt;end&lt;/span&gt; &lt;span class="SourceBase"&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You should now start to get E-Commerce stats showing up under the Ecommerce section of
Google Analytics.
  
h4. References&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&amp;amp;answer=55528"&gt;Google Analytics Help&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://www.epikone.com/blog/2008/07/02/google-analytics-e-commerce-tracking-pt-4-tacking-lead-gen-forms/"&gt;Analytics Talk&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry>
  
  <entry>
    <title>Git Patching Flexibility</title>
    <link href="/articles/2008/08/04/git-patching-flexibility" />
    <id>tag:jordanelver.co.uk,2008-08-04:1217860406</id>
    <updated>2008-08-04T15:33:26+01:00</updated>
    <content type="html">&lt;p&gt;I don&amp;#8217;t know about you, but when I&amp;#8217;m coding I&amp;#8217;ll often need to make a change 
that&amp;#8217;s unrelated to the current feature or bug I am working on. I&amp;#8217;ll notice a
spelling mistake, a typo, or some other small code change. You don&amp;#8217;t want to 
commit the unrelated change as part of your overall commit because, well, 
it&amp;#8217;s unrelated. It should be its own commit with its own commit message.
This will make it much easier to read the commit log and cuts down on confusion.
People won&amp;#8217;t have to ask &amp;#8220;Why did they change that? It has nothing to do with the change&amp;#8221;&lt;/p&gt;
&lt;p&gt;When I used Subversion, you had to remove the unrelated change, commit, then 
add it back in and commit again. Maybe there was a nicer way, but I didn&amp;#8217;t 
know it. Git is much nicer.&lt;/p&gt;
&lt;p&gt;When you stage a file ready for committing, Git allows you to only stage a 
certain part or parts of the file, which it calls hunks.&lt;/p&gt;
&lt;p&gt;So, run:&lt;/p&gt;
&lt;div class="UltraViolet"&gt;&lt;pre class="all_hallows_eve"&gt;&lt;span class="line-numbers"&gt;   1 &lt;/span&gt; git add --patch &lt;span class="Keyword"&gt;&amp;lt;&lt;/span&gt;filename&lt;span class="Keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Git will show you a diff of the first difference that it wants to stage and
will ask if you&amp;#8217;d like to stage the current hunk, like this:&lt;/p&gt;
&lt;div class="UltraViolet"&gt;&lt;pre class="all_hallows_eve"&gt;&lt;span class="line-numbers"&gt;   1 &lt;/span&gt; Stage this hunk [y/n/a/d/s/?]? 
&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The options in this example are:&lt;/p&gt;
&lt;div class="UltraViolet"&gt;&lt;pre class="all_hallows_eve"&gt;&lt;span class="TextBase"&gt;y - stage this hunk&lt;/span&gt;
&lt;span class="TextBase"&gt;n - do not stage this hunk&lt;/span&gt;
&lt;span class="TextBase"&gt;a - stage this and all the remaining hunks in the file&lt;/span&gt;
&lt;span class="TextBase"&gt;d - do not stage this hunk nor any of the remaining hunks in the file&lt;/span&gt;
&lt;span class="TextBase"&gt;s - split the current hunk into smaller hunks&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Choose what you&amp;#8217;d like to do with the current hunk. Git will continue to go through the 
rest of the hunks in the file, asking you what to do with each one.
  
When you&amp;#8217;ve decided which hunks should be staged, commit as normal and only
those changes will form part of the commit. You can then add the rest of 
your changes and commit again.&lt;/p&gt;
&lt;p&gt;It&amp;#8217;s the flexibility that&amp;#8217;s great. It works with you, not against you.&lt;/p&gt;
&lt;p&gt;For a much more in depth look at the capabilities of &lt;code&gt;git add --patch&lt;/code&gt;, see
the following article.&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://tomayko.com/writings/the-thing-about-git"&gt;The Thing About Git&lt;/a&gt; by &lt;a href="http://tomayko.com/"&gt;Ryan Tomayko&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry>
  
  <entry>
    <title>How to generate / request an SSL certificate</title>
    <link href="/articles/2008/07/24/how-to-generate-request-an-ssl-certificate" />
    <id>tag:jordanelver.co.uk,2008-07-24:1216906084</id>
    <updated>2008-07-24T14:28:04+01:00</updated>
    <content type="html">&lt;p&gt;Generating an SSL certificate can be confusing if you&amp;#8217;ve never done it
before. Actually, it&amp;#8217;s confusing if you have done it before. Hopefully this 
should remind me how to do it in the future!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;PLEASE NOTE:&lt;/strong&gt; I am no expert on SSL, but this does the job for me.&lt;/p&gt;
&lt;p&gt;I recently had to do this after the &lt;a href="http://www.ubuntu.com/usn/usn-612-1"&gt;Debian security vulnerability&lt;/a&gt;
affected one of my SSL certificates.&lt;/p&gt;
&lt;p&gt;I currently get my SSL cerficiates through &lt;a href="http://www.namecheap.com"&gt;NameCheap&lt;/a&gt; for $10.
They are re-sellers of RapidSSL and GeoTrust certificates. Mine is a RapidSSL.&lt;/p&gt;
&lt;h4&gt;Generate a private key and Certificate Signing Request&lt;/h4&gt;
&lt;p&gt;We need to generate an OpenSSL keypair and a &lt;a href="http://en.wikipedia.org/wiki/Certificate_signing_request" title="CSR"&gt;Certificate Signing Request&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The keypair consists of two cryptographic keys. A public and private. The public
key is included with the CSR along with other applicant information such as name,
company, etc. The private key is used to sign the CSR request.&lt;/p&gt;
&lt;p&gt;A CSR is what you send to your chosen Certificate Authority (CA) to request that
they supply you with an SSL certificate. It includes your identifying information
and the public key for your server/site.&lt;/p&gt;
&lt;p&gt;Generate it like this.&lt;/p&gt;
&lt;div class="UltraViolet"&gt;&lt;pre class="all_hallows_eve"&gt;&lt;span class="line-numbers"&gt;   1 &lt;/span&gt; openssl req -new -newkey rsa:1024 -nodes -keyout example.key -out example.csr
&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You&amp;#8217;ll be prompted to enter information such as Common Name, Organisation, Country etc.&lt;/p&gt;
&lt;p&gt;It should be fairly straight forward, but your CA will let you know if you&amp;#8217;ve done it wrong, I&amp;#8217;m sure.&lt;/p&gt;
&lt;p&gt;This will create &lt;code&gt;example.key&lt;/code&gt; (the private key) and &lt;code&gt;example.csr&lt;/code&gt; (the CSR).&lt;/p&gt;
&lt;h4&gt;Requesting your certificate&lt;/h4&gt;
&lt;p&gt;This part should be easy. Normally your CA will have a form on their website which allows you
to paste in your CSR. This obviously varies from company to company. Once you have given them
your CSR, they will first ask you for money, and then generate your CRT file. Yay!&lt;/p&gt;
&lt;p&gt;I&amp;#8217;m only scratching the surface of SSL here. OpenSSL has a massive amount of options. There is much to learn.&lt;/p&gt;
&lt;h4&gt;References&lt;/h4&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href="https://help.ubuntu.com/community/OpenSSL"&gt;More information on OpenSSL commands&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry>
  
  <entry>
    <title>Rails Deployment with Git, Vlad and SSH Agent Forwarding</title>
    <link href="/articles/2008/07/10/rails-deployment-with-git-vlad-and-ssh-agent-forwarding" />
    <id>tag:jordanelver.co.uk,2008-07-10:1215719510</id>
    <updated>2008-07-10T20:51:50+01:00</updated>
    <content type="html">&lt;p&gt;I&amp;#8217;m switching my code repositories over to Git from Subversion. For the most
part it&amp;#8217;s going well. I&amp;#8217;m having some issues with line endings, but that&amp;#8217;s for
another post. I&amp;#8217;m still getting to grips with day to day usage, but can already
see that it&amp;#8217;s going to be a great improvement on Subversion.&lt;/p&gt;
&lt;p&gt;This is how I&amp;#8217;ve setup Vlad, Git, and SSH to work together.&lt;/p&gt;
&lt;h4&gt;Vlad Configuration&lt;/h4&gt;
&lt;p&gt;I use &lt;a href="http://rubyhitsquad.com/Vlad_the_Deployer.html"&gt;Vlad&lt;/a&gt; to deploy my projects to the staging/live server, so I needed
to re-configure Vlad to support Git. This was very simple to do. In my &lt;code&gt;Rakefile&lt;/code&gt;, I
included the Git class instead of the Subversion class. This removes the
Subversion specific commands and includes the Git specific commands instead.&lt;/p&gt;
&lt;div class="UltraViolet"&gt;&lt;pre class="all_hallows_eve"&gt;&lt;span class="line-numbers"&gt;   1 &lt;/span&gt; &lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;-&lt;/span&gt;require 'vlad/subversion'&lt;/span&gt;
&lt;span class="line-numbers"&gt;   2 &lt;/span&gt; &lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;+&lt;/span&gt;require 'vlad/git'&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I also changed the repository address in my &lt;code&gt;config/deploy.rb&lt;/code&gt; file.&lt;/p&gt;
&lt;div class="UltraViolet"&gt;&lt;pre class="all_hallows_eve"&gt;&lt;span class="line-numbers"&gt;   1 &lt;/span&gt; &lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;-&lt;/span&gt;set :repository, 'https://sub.version.server/repo'&lt;/span&gt;
&lt;span class="line-numbers"&gt;   2 &lt;/span&gt; &lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;+&lt;/span&gt;set :repository, 'git@github.com:username/repo.git'&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;These are the only changes I needed to make.&lt;/p&gt;
&lt;h4&gt;SSH and Git setup&lt;/h4&gt;
&lt;p&gt;Git uses SSH keys to control access to repositories. As I&amp;#8217;m using GitHub as
my deployment Git repository, I needed to identify myself with them. To do this,
I supplied them with my SSH public key. &lt;a href="http://github.com/guides/providing-your-ssh-key#linux"&gt;GitHub have good instructions on how to do this&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As the code is cloned from GitHub directly to the deployment server (not my machine),
my private SSH key would also need to be installed on the deployment server.&lt;/p&gt;
&lt;p&gt;Vlad deployment now works! This will checkout the latest HEAD and deploy it to the server.
&lt;a href="http://scie.nti.st/2007/9/25/vlad-the-deployer-and-git"&gt;You can set the specific revision that you want&lt;/a&gt; in your &lt;code&gt;config/deploy.rb&lt;/code&gt; as well if
required. I&amp;#8217;m not doing that at the moment.&lt;/p&gt;
&lt;h4&gt;So, what&amp;#8217;s the problem?&lt;/h4&gt;
&lt;p&gt;The problem is that you need to install your private SSH key on the deployment 
server. I didn&amp;#8217;t want to do this in case the server was ever compromised. 
If it was compromised, the attacker could also theoretically get into
other systems using that key if it didn&amp;#8217;t have a passphrase. This would be bad.
My key does have a passphrase, but why install it when you don&amp;#8217;t really need to?&lt;/p&gt;
&lt;h4&gt;Making it more secure&lt;/h4&gt;
&lt;p&gt;Fortunately, there&amp;#8217;s a rather nifty solution to this problem &amp;mdash; SSH agent forwarding.
In order to do so, you must first be using SSH Agent. SSH Agent allows you to 
authenticate yourself once per session, so you don&amp;#8217;t have to enter your password
every time you connect to the server. If you&amp;#8217;re already using SSH keys and have
SSH Agent running on your system (which is the default in Ubuntu), you just need to do:&lt;/p&gt;
&lt;div class="UltraViolet"&gt;&lt;pre class="all_hallows_eve"&gt;&lt;span class="line-numbers"&gt;   1 &lt;/span&gt; ssh-add &lt;span class="Keyword"&gt;~&lt;/span&gt;/.ssh/&lt;span class="Keyword"&gt;&amp;lt;&lt;/span&gt;keyname&lt;span class="Keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You&amp;#8217;ll be prompted for the passphrase to the key. Once you enter it, you should be able
to connect to any servers using that key without entering it again. This is very handy anyway
regardless of whether you&amp;#8217;re going to be using forwarding or not.&lt;/p&gt;
&lt;p&gt;See &lt;a href="http://en.wikipedia.org/wiki/Ssh-agent#Setting_Up_Ssh_Agent"&gt;this wikipedia page&lt;/a&gt; for more information.&lt;/p&gt;
&lt;h4&gt;How to setup the forwarding&lt;/h4&gt;
&lt;p&gt;This is where the forwarding comes in. SSH can forward requests for authentication
back to the original SSH Agent process running on your machine. So, you can connect
to your deployment server and then connect to another server without re-entering 
your passphrase or having to install any keys on the deployment machine itself.
Much coolness. This negates the need to install any other keys on the deployment 
server itself.&lt;/p&gt;
&lt;p&gt;There is a very well explained article called &lt;a href="http://www.unixwiz.net/techtips/ssh-agent-forwarding.html"&gt;An Illustrated Guide to SSH Agent Forwarding&lt;/a&gt; over at &lt;a href="http://www.unixwiz.net"&gt;Unixwiz.net&lt;/a&gt;
that goes into a lot of detail about how this all works. It&amp;#8217;s well worth a read.&lt;/p&gt;
&lt;p&gt;This is how to set it up.&lt;/p&gt;
&lt;p&gt;Edit your ~/.ssh/config file and add something like this:&lt;/p&gt;
&lt;div class="UltraViolet"&gt;&lt;pre class="all_hallows_eve"&gt;&lt;span class="line-numbers"&gt;   1 &lt;/span&gt; &lt;span class="SourceBase"&gt;Host&lt;/span&gt; &lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;&amp;lt;name&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class="line-numbers"&gt;   2 &lt;/span&gt;   &lt;span class="Keyword"&gt;HostName&lt;/span&gt; &amp;lt;ip or host&amp;gt;
&lt;span class="line-numbers"&gt;   3 &lt;/span&gt;   &lt;span class="Keyword"&gt;User&lt;/span&gt; &amp;lt;username&amp;gt;
&lt;span class="line-numbers"&gt;   4 &lt;/span&gt;   &lt;span class="Keyword"&gt;IdentityFile&lt;/span&gt; ~/.ssh/&amp;lt;filename&amp;gt;
&lt;span class="line-numbers"&gt;   5 &lt;/span&gt;   &lt;span class="Keyword"&gt;ForwardAgent&lt;/span&gt; yes
&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This is all you need. If you&amp;#8217;ve got SSH Agent running, you&amp;#8217;re sorted.&lt;/p&gt;
&lt;p&gt;Incidentally, you can add these sections for as many hosts as required. It saves you 
having to type out lots of command line switches all the time. Just leave out the 
&lt;code&gt;ForwardAgent yes&lt;/code&gt; line.&lt;/p&gt;
&lt;h4&gt;References&lt;/h4&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://github.com/guides/providing-your-ssh-key#linux"&gt;GitHub &amp;#8211; Providing your SSH key&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://scie.nti.st/2007/9/25/vlad-the-deployer-and-git"&gt;Vlad the Deployer and Git&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Ssh-agent#Setting_Up_Ssh_Agent"&gt;SSH Agent on Wikipedia&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://www.unixwiz.net/techtips/ssh-agent-forwarding.html"&gt;An Illustrated Guide to SSH Agent Forwarding&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://dysinger.net/2008/04/30/deploying-with-capistrano-git-and-ssh-agent/"&gt;Deploying with Capistrano, Git and SSH-Agent&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry>
  
  <entry>
    <title>w00t! First post evar!</title>
    <link href="/articles/2008/06/17/hello-and-welcome" />
    <id>tag:jordanelver.co.uk,2008-06-17:1213709307</id>
    <updated>2008-06-17T14:28:27+01:00</updated>
    <content type="html">&lt;p&gt;Hello. The proper site is now live. It&amp;#8217;s been way too long coming, but now it&amp;#8217;s
here. I built it using &lt;a href="http://webby.rubyforge.net/"&gt;Webby&lt;/a&gt;. Hopefully there&amp;#8217;ll be some posts
explaining how that was done soon.&lt;/p&gt;
&lt;p&gt;P.S. I know some people won&amp;#8217;t like the colours, but I do.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Rake dependencies</title>
    <link href="/articles/2008/06/30/rake-dependencies" />
    <id>tag:jordanelver.co.uk,2008-06-30:1214816418</id>
    <updated>2008-06-30T10:00:18+01:00</updated>
    <content type="html">&lt;p&gt;Rake tasks are great for all sorts of small tasks. They give you a bit
of structure to what would normally be a shell or ruby script.
However, the thing I like about rake tasks are dependencies.&lt;/p&gt;
&lt;h4&gt;A simple example&lt;/h4&gt;
&lt;p&gt;You see, you can make one task rely on another. Take this.&lt;/p&gt;
&lt;div class="UltraViolet"&gt;&lt;pre class="all_hallows_eve"&gt;&lt;span class="line-numbers"&gt;   1 &lt;/span&gt; desc &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;Make coffee&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class="line-numbers"&gt;   2 &lt;/span&gt; task &lt;span class="Constant"&gt;&lt;span class="Constant"&gt;:&lt;/span&gt;coffee&lt;/span&gt; &lt;span class="SourceBase"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="Constant"&gt;&lt;span class="Constant"&gt;:&lt;/span&gt;get_mug&lt;/span&gt; &lt;span class="Keyword"&gt;do&lt;/span&gt;
&lt;span class="line-numbers"&gt;   3 &lt;/span&gt;   puts &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;Making a coffee&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class="line-numbers"&gt;   4 &lt;/span&gt; &lt;span class="Keyword"&gt;end&lt;/span&gt;
&lt;span class="line-numbers"&gt;   5 &lt;/span&gt; 
&lt;span class="line-numbers"&gt;   6 &lt;/span&gt; task &lt;span class="Constant"&gt;&lt;span class="Constant"&gt;:&lt;/span&gt;get_mug&lt;/span&gt; &lt;span class="Keyword"&gt;do&lt;/span&gt;
&lt;span class="line-numbers"&gt;   7 &lt;/span&gt;   puts &lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;Getting a mug&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class="line-numbers"&gt;   8 &lt;/span&gt; &lt;span class="Keyword"&gt;end&lt;/span&gt;
&lt;span class="line-numbers"&gt;   9 &lt;/span&gt; 
&lt;span class="line-numbers"&gt;  10 &lt;/span&gt; rake get_mug
&lt;span class="line-numbers"&gt;  11 &lt;/span&gt; &lt;span class="Keyword"&gt;&amp;gt;&lt;/span&gt; &lt;span class="SourceBase"&gt;Getting&lt;/span&gt; a mug
&lt;span class="line-numbers"&gt;  12 &lt;/span&gt; 
&lt;span class="line-numbers"&gt;  13 &lt;/span&gt; rake coffee
&lt;span class="line-numbers"&gt;  14 &lt;/span&gt; &lt;span class="Keyword"&gt;&amp;gt;&lt;/span&gt; &lt;span class="SourceBase"&gt;Getting&lt;/span&gt; a mug
&lt;span class="line-numbers"&gt;  15 &lt;/span&gt; &lt;span class="Keyword"&gt;&amp;gt;&lt;/span&gt; &lt;span class="SourceBase"&gt;Making&lt;/span&gt; a coffee
&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Easy to understand isn&amp;#8217;t it? &lt;code&gt;coffee&lt;/code&gt; depends on &lt;code&gt;get_mug&lt;/code&gt;, so &lt;code&gt;get_mug&lt;/code&gt; will be
called before the main &lt;code&gt;coffee&lt;/code&gt; task every time &lt;code&gt;rake coffee&lt;/code&gt; is run.&lt;/p&gt;
&lt;h4&gt;A better example&lt;/h4&gt;
&lt;p&gt;You can also redefine task dependencies without altering the original task.
For example, on this blog I have a task which creates index pages for
the category pages. I want this to run everytime the &lt;code&gt;build&lt;/code&gt; task is run. I could
modify the original &lt;code&gt;build&lt;/code&gt; task, but a much nicer and cleaner way is to 
redefine the task and add the dependant task like so.&lt;/p&gt;
&lt;div class="UltraViolet"&gt;&lt;pre class="all_hallows_eve"&gt;&lt;span class="line-numbers"&gt;   1 &lt;/span&gt; task &lt;span class="Constant"&gt;&lt;span class="Constant"&gt;:&lt;/span&gt;build&lt;/span&gt; &lt;span class="SourceBase"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="String"&gt;&lt;span class="String"&gt;'&lt;/span&gt;blog:categories:create_indexes&lt;span class="String"&gt;'&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This will keep any existing dependencies that the build task originally had and
also add my new one. Ain&amp;#8217;t it pretty?&lt;/p&gt;
&lt;h4&gt;References&lt;/h4&gt;
&lt;p&gt;Thanks to the guys at &lt;a href="http://www.railsenvy.com"&gt;Rails Envy&lt;/a&gt; for their tutorial&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://www.railsenvy.com/2007/6/11/ruby-on-rails-rake-tutorial"&gt;Ruby on Rails Rake Tutorial [aka. How rake turned me into an alcoholic]&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry>
  
  <entry>
    <title>Git bash completion = Yay!</title>
    <link href="/articles/2008/06/18/git-completion-yay" />
    <id>tag:jordanelver.co.uk,2008-06-19:1213830316</id>
    <updated>2008-06-19T00:05:16+01:00</updated>
    <content type="html">&lt;p&gt;If you&amp;#8217;ve heard of, or are already using bash completion, you&amp;#8217;ll know how great it is.
Here&amp;#8217;s how to use it with &lt;a href="http://en.wikipedia.org/wiki/Git_(software)"&gt;Git&lt;/a&gt;.&lt;/p&gt;
&lt;h4&gt;How to get the sweetness?&lt;/h4&gt;
&lt;p&gt;I&amp;#8217;m using Ubuntu (Hardy), but setup instructions should be similar for others.
For Ubuntu, uncomment this section in &lt;code&gt;/etc/bash.bashrc&lt;/code&gt; and you&amp;#8217;ve enabled bash
completion. You&amp;#8217;ll need to open a new terminal for it to take affect.&lt;/p&gt;
&lt;div class="UltraViolet"&gt;&lt;pre class="all_hallows_eve"&gt;&lt;span class="line-numbers"&gt;   1 &lt;/span&gt; &lt;span class="Comment"&gt;&lt;span class="Comment"&gt;#&lt;/span&gt;if [ -f /etc/bash_completion ]; then&lt;/span&gt;
&lt;span class="line-numbers"&gt;   2 &lt;/span&gt; &lt;span class="Comment"&gt;&lt;span class="Comment"&gt;#&lt;/span&gt; . /etc/bash_completion&lt;/span&gt;
&lt;span class="line-numbers"&gt;   3 &lt;/span&gt; &lt;span class="Comment"&gt;&lt;span class="Comment"&gt;#&lt;/span&gt;fi&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;&lt;h4&gt;How to enable Git completion&lt;/h4&gt;
&lt;p&gt;You&amp;#8217;ll need the bash completion file for Git. This file details how the Git commands
will be completed. The file comes as part of the Git distribution.&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;Download the lastest git release from &lt;a href="http://www.kernel.org/pub/software/scm/git/"&gt;http://www.kernel.org/pub/software/scm/git/&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;Find the &lt;code&gt;git-completion.bash&lt;/code&gt; file in the &lt;code&gt;contrib/&lt;/code&gt; directory and copy to the &lt;code&gt;/etc/bash_completion.d/&lt;/code&gt; directory&lt;/li&gt;
	&lt;li&gt;Start a new login shell (logout/login or start a new Terminal tab)&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;Try it out&lt;/h4&gt;
&lt;p&gt;Now, typing &lt;code&gt;git &amp;lt;tab&amp;gt;&amp;lt;tab&amp;gt;&lt;/code&gt; should list all of the various git commands (of which there are many).
However, the really cool part is that it will also list your branches for you. Typing
&lt;code&gt;git checkout &amp;lt;tab&amp;gt;&amp;lt;tab&amp;gt;&lt;/code&gt; within your Git repo will list all of the branches you have.&lt;/p&gt;
&lt;div class="UltraViolet"&gt;&lt;pre class="all_hallows_eve"&gt;&lt;span class="line-numbers"&gt;   1 &lt;/span&gt; jord@jordan /home/jord/webby&lt;span class="SourceBase"&gt;&lt;span class="SourceBase"&gt;(&lt;/span&gt;master&lt;span class="SourceBase"&gt;)&lt;/span&gt;&lt;/span&gt; $ git checkout &lt;span class="Keyword"&gt;&amp;lt;&lt;/span&gt;tab&lt;span class="Keyword"&gt;&amp;gt;&lt;/span&gt;&lt;span class="Keyword"&gt;&amp;lt;&lt;/span&gt;tab&lt;span class="Keyword"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="line-numbers"&gt;   2 &lt;/span&gt; HEAD    master
&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;RSI, be gone!&lt;/p&gt;
&lt;h4&gt;Thanks&lt;/h4&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://blog.bitfluent.com/post/27983389/git-utilities-you-cant-live-without"&gt;Bitfluent&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content>
  </entry>
  
</feed>
