<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Kernow Soul]]></title>
  <link href="http://kernowsoul.com/atom.xml" rel="self"/>
  <link href="http://kernowsoul.com/"/>
  <updated>2014-03-21T14:54:07+00:00</updated>
  <id>http://kernowsoul.com/</id>
  <author>
    <name><![CDATA[Jamie Dyer]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[How to Rumble Like a Boss]]></title>
    <link href="http://kernowsoul.com/blog/2013/10/16/how-to-rumble-like-a-boss/"/>
    <updated>2013-10-16T16:43:00+01:00</updated>
    <id>http://kernowsoul.com/blog/2013/10/16/how-to-rumble-like-a-boss</id>
    <content type="html"><![CDATA[<p><img class="right" src="http://kernowsoul.com/images/posts/rails-rumble-logo.png" title="Rails Rumble Logo" ></p>

<p>Having been both a <a href="http://railsrumble.com/participants">competitor</a> and an <a href="http://railsrumble.com/experts">expert judge</a> in the <a href="http://railsrumble.com/">Rails Rumble</a> I have a unique  insight into what makes a good entry and some of the pitfalls entrants can fall into when building their applications.</p>

<p>I&rsquo;m going to take you through my top tips on how to improve the score <a href="http://railsrumble.com/experts">judges</a> will give your app in the <a href="http://railsrumble.com/">Rails Rumble</a> competition. Or any other hackathon such as the <a href="http://nodeknockout.com/">Node Knockout</a> or <a href="http://djangodash.com/">Django Dash</a> for that matter.</p>

<p>I&rsquo;m sure many of you will identify with this&hellip; you spend 48 hours working hard, having a great time with your team and creating an app with loads of amazing features you&rsquo;re really proud of. Judgment day comes and you take look at the results page to see how your team scored and what comments the judges made. You get some great feedback from the judges but maybe the score it slightly lower than you expected, but no feedback on feature X or Y. Intrigued you delve into the analytics, database and logs of your app to see exactly what the judges did when using your app only to discover some the features you built have not been used.</p>

<p>I&rsquo;ve been there and it can be frustrating, but don&rsquo;t worry, follow a few simple tips and you&rsquo;ll make sure the judges see your app as it should be viewed. Back in 2009 I was part of a Rails Ruble team of 3 that created a table football stats tracking app called <a href="https://github.com/kernow/wuzlr">Wuzlr</a>. We built a ton of features and were really proud of our creation, we even used the app daily for months after the Rumble. However the app didn&rsquo;t score as well as we hoped during the expert judging phase, what did we do wrong? We didn&rsquo;t take into consideration how judges would score our app and thought building a good app would be enough.</p>

<p>This year (2013) there are around 500 teams competing in the <a href="http://railsrumble.com/">Rails Rumble</a>. The <a href="http://railsrumble.com/organizers">organizers</a> do a really good job of making it as easy as possible for the judges while also making it fair for all the entrants. This year should be the most trouble free yet for the judges thanks to the hard work of the <a href="http://railsrumble.com/organizers">organizers</a>. Even so, keep in mind all the judges are volenteers and have a limited amount of time to spend reviewing apps. Make sure your app stands out from the crowd, an easy to use, engaging, (fun), interesting, well designed app will suck the judges in and ensure they spend more time reviewing your entry.</p>

<p>To do well in this kind of competition it&rsquo;s important to understand how your app will be judged to ensure you give it the best chance. I&rsquo;ve come up with list of tips to help show your app off to the judges in the best possible way. Bring forth the list&hellip;</p>

<ol>
<li>Consider your login system, or if you even need one at all. One of the biggest hurdles to testing an entry is creating an account to login. While gems like Devise make it really easy to implement a login system, out of the box they do not allow users to sign up quickly. Don&rsquo;t make judges confirm their email address in order to login, this takes time and reduces the amount of time they will spend using your app. Consider using Facebook and twitter authentication as it&rsquo;s much faster. Best of all don&rsquo;t make judges login at all, I came across at least one entry last year with a login system where it served no purpose. (also see point 6)</li>
<li>If you&rsquo;re requesting access to my Facebook, Twitter, or Github account don&rsquo;t ask for more access than you need. An app last year requested full access to users Github account including read, write and delete access to private repositories! There was no need for the app to have this kind of access. Now I don&rsquo;t know about you but I&rsquo;m not going to trust the safety of my private repos to an application coded by some very sleep deprived guys in 48 hours.</li>
<li>&ldquo;Don&rsquo;t make me think&rdquo;. As we have discovered judges have 100&rsquo;s of applications to go through and a limited amount of time to judge each one. Make your app easy to understand and use, this will help your score. If an app is too difficult to understand or use judges may not be aware of everything it does.</li>
<li>Make a video. If your app isn&rsquo;t instantly usable consider creating a short video or screencast to demonstrate how your app works, hell even if your app is a piece of cake to use it&rsquo;s a really good idea to make a video, you&rsquo;d be surprised how many things get missed.
Design IS important, don&rsquo;t make it an after thought. If you don&rsquo;t have a designer on your team get one. You are allowed to work on wireframes and mock ups before the competition starts, use this time to plan your app so you know exactly what your doing as soon as the 48 hours starts. Time is precious, don&rsquo;t waste any.</li>
<li>Consider creating demo accounts or adding dummy data to better show off how your app works. One of the mistakes I made with the Wuzlr app was the majority of the stats were only generated after 3 game results had been entered. No judge entered 3 game results when testing so none of them saw the majority of the app. Adding automatically generated dummy data would have solved this problem.</li>
<li>Make your app easy to test, some apps I tested last year required me to invite friends from Facebook or Twitter. To test this on my own requires 2 accounts with the provider, or I would need another person. Consider if your app really needs to require friend invites, if it does make it as easy as possible to connect with other users. Anything that causes delays in being able to test your app is likely to cause it to have a lower score.</li>
<li>Finally, don&rsquo;t forget the importance of your apps description and screenshot on the competition entires page, first impressions count. Make sure to write a description that clearly and concisely describes what your app does, a couple of sentences and no more. It&rsquo;s good to let judges know what they&rsquo;re testing before they see your app. After writing your description and uploading a screenshot check what it looks like on the entries page, quite often descriptions are truncated on the index pages where most judges will be reading the descriptions.</li>
</ol>


<p>Hopefully these tips will help you in creating an app with the best chance of doing well in the <a href="http://railsrumble.com/">Rails Rumble</a>. Good luck and I look forward to seeing what the teams come up with this year.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[4 Ways to Avoid Merge Commits in Git (or How to Stop Being a Git Twit)]]></title>
    <link href="http://kernowsoul.com/blog/2012/06/20/4-ways-to-avoid-merge-commits-in-git/"/>
    <updated>2012-06-20T00:49:00+01:00</updated>
    <id>http://kernowsoul.com/blog/2012/06/20/4-ways-to-avoid-merge-commits-in-git</id>
    <content type="html"><![CDATA[<p>I&rsquo;m sure you&rsquo;ve all come across merge commits when using Git, those pesky commits with a message reading something like <code>Merge branch 'master' of github.com:kernow/Project-X</code>. We&rsquo;ve all been guilty of creating git merge commits, but don&rsquo;t worry there&rsquo;s a way to stop being a &ldquo;Git Twit&rdquo; and make everyone in your team happy which will no doubt lead to them buying you cake! But first, how do these commits get into the repository in the first place? You start out being a good gitizen, <code>git checkout master</code>, <code>git pull</code>, feverishly code away, commit, commit, commit. Woo I&rsquo;m done, everyone will love my wicked new code! <code>git push</code> rejection!! what! Other people have been working too, jerks. <code>git pull</code>, <code>git push</code>, and there we have it, a merge commit. So how do we stop this madness?</p>

<h3>Rebase to the rescue</h3>

<p>When running <code>git pull</code> we need to rebase, and so to the first way to avoid merge commits&hellip;</p>

<ol>
<li><p><code>git pull --rebase</code> What&rsquo;s happening here? Git will rewind (undo) all of your local commits, pull down the remote commits then replay your local commits on top of the newly pulled remote commits. If any conflicts arise that git can&rsquo;t handle you&rsquo;ll be given the opportunity to manually merge the commits then simply run <code>git rebase --continue</code> to carry on replaying your local commits.</p></li>
<li><p>Tell git to always rebase when pulling, to do this on a project level add this to your <code>.git/config</code> file:
<figure class="code"><div class="highlight"><table><tbody><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
</pre></td><td class="code"><pre><code class=""><span class="line">[branch &ldquo;master&rdquo;]
</span><span class="line">  rebase = true</span></code></pre></td></tr></tbody></table></div></figure>
Or do it all on the command line with <code>git config branch.master.rebase true</code></p></li>
<li><p>Add a global config option to always rebase when pulling
<figure class="code"><div class="highlight"><table><tbody><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
</pre></td><td class="code"><pre><code class=""><span class="line">[branch]
</span><span class="line">  autosetuprebase = always</span></code></pre></td></tr></tbody></table></div></figure>
Or again do it all on the command line with <code>git config --global branch.autosetuprebase always</code></p></li>
<li><p>And the final way, which is what I personally use, in <code>~/.gitconfig</code>
<figure class="code"><div class="highlight"><table><tbody><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
</pre></td><td class="code"><pre><code class=""><span class="line">[alias]
</span><span class="line">  pl = pull &mdash;rebase</span></code></pre></td></tr></tbody></table></div></figure>
I have a bunch of aliases setup so I can type less and save myself those valuable microseconds. This will allow you to type <code>git pl</code> (or in my case <code>g pl</code> as I have <code>git</code> aliased to <code>g</code>) and it will automatically rebase. If I want to do a pull and not rebase for a specific reason I can use the command <code>git pull</code> which will do an pull without rebaseing.</p></li>
</ol>


<p>Of course you could use the 3rd solution and run the command <code>git pull --no-rebase</code> but that involves more typing, and I&rsquo;m a lazy typer!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[BRUG Talk]]></title>
    <link href="http://kernowsoul.com/blog/2010/09/29/brug-talk/"/>
    <updated>2010-09-29T15:38:00+01:00</updated>
    <id>http://kernowsoul.com/blog/2010/09/29/brug-talk</id>
    <content type="html"><![CDATA[<p>I&rsquo;ll be doing a talk at <a href="http://bristolrb.org">BRUG</a> tomorrow evening (29th September 2010) on JavaScript <a href="http://kernowsoul.com/blog/tags/testing/">testing</a> covering some of the more awkward testing scenarios you may come across in <a href="http://kernowsoul.com/blog/tags/javascript/">JavaScript</a> land. This months BRUG is at <a href="http://wearebeef.co.uk/">Beef Towers</a>, hopefully we&rsquo;ll see some new faces this month.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Programatically Simulating JavaScript Events in a Test Environment]]></title>
    <link href="http://kernowsoul.com/blog/2010/08/20/programatically-simulating-javascript-events-in-a-test-environment/"/>
    <updated>2010-08-20T16:32:00+01:00</updated>
    <id>http://kernowsoul.com/blog/2010/08/20/programatically-simulating-javascript-events-in-a-test-environment</id>
    <content type="html"><![CDATA[<p>Yesterday I was implementing a feature on <a href="http://tutorhub.com">tutorhub.com</a> where I wanted to disable the sending of chat messages when the party you&rsquo;re talking to goes offline. I ran into a problem while trying to write the tests for this feature and thought I&rsquo;d share it in case someone else finds it useful.</p>

<p>When in a chat, messages are sent either using the send button or by pressing the enter key. Testing the correct behaviour on button press is straight forward. I&rsquo;m using <a href="http://pivotal.github.com/jasmine/">Jasmine</a> and <a href="https://github.com/kernow/jsmocha">jsMocha</a> for testing and <a href="http://jquery.com">jQuery</a> for implementation.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
</pre></td><td class='code'><pre><code class='javascript'><span class='line'><span class="nx">beforeEach</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
</span><span class='line'>  <span class="c1">// code that disables the sending of messages here</span>
</span><span class='line'>
</span><span class='line'>  <span class="c1">// setup UI.runner for mocking</span>
</span><span class='line'>  <span class="kd">var</span> <span class="nx">mock</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Mock</span><span class="p">(</span><span class="nx">UI</span><span class="p">.</span><span class="nx">runner</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'>  <span class="c1">// add an expectation that raise is never called</span>
</span><span class='line'>  <span class="nx">UI</span><span class="p">.</span><span class="nx">runner</span><span class="p">.</span><span class="nx">expects</span><span class="p">(</span><span class="s1">&#39;raise&#39;</span><span class="p">).</span><span class="nx">passing</span><span class="p">(</span><span class="s1">&#39;message_send&#39;</span><span class="p">,</span> <span class="nx">Match</span><span class="p">.</span><span class="nx">an_object</span><span class="p">).</span><span class="nx">never</span><span class="p">();</span>
</span><span class='line'><span class="p">});</span>
</span><span class='line'>
</span><span class='line'><span class="nx">it</span><span class="p">(</span><span class="s2">&quot;should not allow messages to be sent&quot;</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
</span><span class='line'>  <span class="c1">// add some text to the textarea</span>
</span><span class='line'>  <span class="nx">$</span><span class="p">(</span><span class="s2">&quot;#chat-form textarea&quot;</span><span class="p">).</span><span class="nx">val</span><span class="p">(</span><span class="s2">&quot;the text I want to send&quot;</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'>  <span class="c1">// simulate the click event</span>
</span><span class='line'>  <span class="nx">$</span><span class="p">(</span><span class="s2">&quot;#send-button&quot;</span><span class="p">).</span><span class="nx">click</span><span class="p">();</span>
</span><span class='line'><span class="p">});</span>
</span></code></pre></td></tr></table></div></figure>


<p>Our UI code raises events that our main application code listens to in order to send out the messages. Here I setup a mock in the before block saying the raise method should never be called with the &lsquo;message_send&rsquo; parameter. Then in the test I insert some text into the text area and simulate a click event on the send button.</p>

<p>It became slightly more tricky when I came to test the enter key functionality, our implementation code looks something like this:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class='javascript'><span class='line'><span class="nx">$</span><span class="p">(</span><span class="s2">&quot;#chat-form textarea&quot;</span><span class="p">).</span><span class="nx">unbind</span><span class="p">().</span><span class="nx">keyup</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">e</span><span class="p">){</span>
</span><span class='line'>  <span class="k">if</span> <span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">which</span> <span class="o">===</span> <span class="mi">13</span><span class="p">)</span> <span class="p">{</span>
</span><span class='line'>    <span class="c1">// send message code here</span>
</span><span class='line'>  <span class="p">}</span>
</span><span class='line'><span class="p">});</span>
</span></code></pre></td></tr></table></div></figure>


<p>In order to programatically simulate a press of the enter key I needed to pass an event object containing a which value of 13. After a bit of hunting around I found the <a href="http://api.jquery.com/category/events/event-object/">jQuery.Event</a> object, that allows the creation of events which can then be fired. The test for disabling the enter key looked like this:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
</pre></td><td class='code'><pre><code class='javascript'><span class='line'><span class="nx">beforeEach</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
</span><span class='line'>  <span class="c1">// code that disables the sending of messages here</span>
</span><span class='line'>
</span><span class='line'>  <span class="c1">// setup UI.runner for mocking</span>
</span><span class='line'>  <span class="kd">var</span> <span class="nx">mock</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Mock</span><span class="p">(</span><span class="nx">UI</span><span class="p">.</span><span class="nx">runner</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'>  <span class="c1">// add an expectation that raise is never called</span>
</span><span class='line'>  <span class="nx">UI</span><span class="p">.</span><span class="nx">runner</span><span class="p">.</span><span class="nx">expects</span><span class="p">(</span><span class="s1">&#39;raise&#39;</span><span class="p">).</span><span class="nx">passing</span><span class="p">(</span><span class="s1">&#39;message_send&#39;</span><span class="p">,</span> <span class="nx">Match</span><span class="p">.</span><span class="nx">an_object</span><span class="p">).</span><span class="nx">never</span><span class="p">();</span>
</span><span class='line'><span class="p">});</span>
</span><span class='line'>
</span><span class='line'><span class="nx">it</span><span class="p">(</span><span class="s2">&quot;should not allow messages to be sent&quot;</span><span class="p">,</span> <span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
</span><span class='line'>  <span class="c1">// add some text to the textarea</span>
</span><span class='line'>  <span class="nx">$</span><span class="p">(</span><span class="s2">&quot;#chat-form textarea&quot;</span><span class="p">).</span><span class="nx">val</span><span class="p">(</span><span class="s2">&quot;the text I want to send&quot;</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'>  <span class="c1">// create a new keyup event</span>
</span><span class='line'>  <span class="kd">var</span> <span class="nx">e</span> <span class="o">=</span> <span class="nx">jQuery</span><span class="p">.</span><span class="nx">Event</span><span class="p">(</span><span class="s2">&quot;keyup&quot;</span><span class="p">);</span>
</span><span class='line'>
</span><span class='line'>  <span class="c1">// set the key that was pressed to the enter key</span>
</span><span class='line'>  <span class="nx">e</span><span class="p">.</span><span class="nx">which</span> <span class="o">=</span> <span class="mi">13</span><span class="p">;</span>
</span><span class='line'>
</span><span class='line'>  <span class="c1">// trigger the event on the textarea element</span>
</span><span class='line'>  <span class="nx">$</span><span class="p">(</span><span class="s2">&quot;#chat-form textarea&quot;</span><span class="p">).</span><span class="nx">trigger</span><span class="p">(</span><span class="nx">e</span><span class="p">);</span>
</span><span class='line'><span class="p">});</span>
</span></code></pre></td></tr></table></div></figure>


<p>Using this technique it should be possible to programatically simulate any key event in a test environment.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Introducing Scupper, the JavaScript Library for Easily Dealing With HTML Snippets in Test Suites]]></title>
    <link href="http://kernowsoul.com/blog/2010/01/06/introducing-scupper-the-javascript-library-for-easily-dealing-with-html-snippets-in-test-suites/"/>
    <updated>2010-01-06T15:32:00+00:00</updated>
    <id>http://kernowsoul.com/blog/2010/01/06/introducing-scupper-the-javascript-library-for-easily-dealing-with-html-snippets-in-test-suites</id>
    <content type="html"><![CDATA[<p>I came across a problem today while writing tests in JavaScript. The code I was testing required a snippet of HTML to work with. A user list needed to be reordered depending on their status. No problem I thought, I&rsquo;ll create div to store an HTML snippet, then before my test I&rsquo;ll duplicate and copy it into a test div.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
</pre></td><td class='code'><pre><code class='html'><span class='line'><span class="nt">&lt;div</span> <span class="na">id=</span><span class="s">&quot;snippets&quot;</span> <span class="na">style=</span><span class="s">&quot;display:none&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>  <span class="nt">&lt;ul</span> <span class="na">id=</span><span class="s">&quot;user-list-snippet&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>    <span class="nt">&lt;li</span> <span class="na">id=</span><span class="s">&quot;user-0&quot;</span><span class="nt">&gt;</span>Shaun White<span class="nt">&lt;span</span> <span class="na">class=</span><span class="s">&#39;user-0-status&#39;</span><span class="nt">&gt;</span>busy<span class="nt">&lt;/span&gt;&lt;/li&gt;</span>
</span><span class='line'>    <span class="nt">&lt;li</span> <span class="na">id=</span><span class="s">&quot;user-1&quot;</span><span class="nt">&gt;</span>Jeremy Jones<span class="nt">&lt;span</span> <span class="na">class=</span><span class="s">&#39;user-1-status&#39;</span><span class="nt">&gt;</span>online<span class="nt">&lt;/span&gt;&lt;/li&gt;</span>
</span><span class='line'>    <span class="nt">&lt;li</span> <span class="na">id=</span><span class="s">&quot;user-2&quot;</span><span class="nt">&gt;</span>Jake Burton<span class="nt">&lt;span</span> <span class="na">class=</span><span class="s">&#39;user-2-status&#39;</span><span class="nt">&gt;</span>offline<span class="nt">&lt;/span&gt;&lt;/li&gt;</span>
</span><span class='line'>    <span class="nt">&lt;li</span> <span class="na">id=</span><span class="s">&quot;user-3&quot;</span><span class="nt">&gt;</span>Tara Dakides<span class="nt">&lt;span</span> <span class="na">class=</span><span class="s">&#39;user-3-status&#39;</span><span class="nt">&gt;</span>online<span class="nt">&lt;/span&gt;&lt;/li&gt;</span>
</span><span class='line'>  <span class="nt">&lt;/ul&gt;</span>
</span><span class='line'><span class="nt">&lt;/div&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>And the JavaScript to copy the element:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='javascript'><span class='line'><span class="nx">$</span><span class="p">(</span><span class="s2">&quot;#user-list-snippet&quot;</span><span class="p">).</span><span class="nx">clone</span><span class="p">().</span><span class="nx">removeAttr</span><span class="p">(</span><span class="s2">&quot;id&quot;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s2">&quot;id&quot;</span><span class="p">,</span> <span class="s2">&quot;user-list&quot;</span><span class="p">).</span><span class="nx">appendTo</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#dom_test&#39;</span><span class="p">));</span>
</span></code></pre></td></tr></table></div></figure>


<p>Of course when working with id&rsquo;s in HTML they have to be unique so the technique caused some of the other tests in the suite to fail, I needed to find another way to do this. One thing I hate is using <a href="http://jquery.com">jQuery</a> to create more than a few dom elements as it gets complex very quickly and it&rsquo;s not easy to see if the code is producing the desired HTML at a glance.</p>

<p>After taking a break I came up with a simple solution, the Scupper library was about to be written. I wanted to write snippets in HTML so I kept the snippet used in the first attempt. I then created a library that collected all of the snippets from the dom, storing them internally, before deleting them from the dom. This allowed the dom to be free from conflicting id&rsquo;s and general pollution. The HTML snippet became:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
</pre></td><td class='code'><pre><code class='html'><span class='line'><span class="nt">&lt;div</span> <span class="na">id=</span><span class="s">&quot;snippets&quot;</span> <span class="na">style=</span><span class="s">&quot;display:none&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>  <span class="nt">&lt;div</span> <span class="na">id=</span><span class="s">&quot;user-list-snippet&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>    <span class="nt">&lt;ul</span> <span class="na">id=</span><span class="s">&quot;user-list&quot;</span><span class="nt">&gt;</span>
</span><span class='line'>      <span class="nt">&lt;li</span> <span class="na">id=</span><span class="s">&quot;user-0&quot;</span><span class="nt">&gt;</span>Shaun White<span class="nt">&lt;span</span> <span class="na">class=</span><span class="s">&#39;user-0-status&#39;</span><span class="nt">&gt;</span>busy<span class="nt">&lt;/span&gt;&lt;/li&gt;</span>
</span><span class='line'>      <span class="nt">&lt;li</span> <span class="na">id=</span><span class="s">&quot;user-1&quot;</span><span class="nt">&gt;</span>Jeremy Jones<span class="nt">&lt;span</span> <span class="na">class=</span><span class="s">&#39;user-1-status&#39;</span><span class="nt">&gt;</span>online<span class="nt">&lt;/span&gt;&lt;/li&gt;</span>
</span><span class='line'>      <span class="nt">&lt;li</span> <span class="na">id=</span><span class="s">&quot;user-2&quot;</span><span class="nt">&gt;</span>Jake Burton<span class="nt">&lt;span</span> <span class="na">class=</span><span class="s">&#39;user-2-status&#39;</span><span class="nt">&gt;</span>offline<span class="nt">&lt;/span&gt;&lt;/li&gt;</span>
</span><span class='line'>      <span class="nt">&lt;li</span> <span class="na">id=</span><span class="s">&quot;user-3&quot;</span><span class="nt">&gt;</span>Tara Dakides<span class="nt">&lt;span</span> <span class="na">class=</span><span class="s">&#39;user-3-status&#39;</span><span class="nt">&gt;</span>online<span class="nt">&lt;/span&gt;&lt;/li&gt;</span>
</span><span class='line'>    <span class="nt">&lt;/ul&gt;</span>
</span><span class='line'>  <span class="nt">&lt;/div&gt;</span>
</span><span class='line'><span class="nt">&lt;/div&gt;</span>
</span></code></pre></td></tr></table></div></figure>


<p>The containing div #user-list-snippet gives an element to latch onto in order to grab the contents inside. I created a method that sucks up all snippets inside a dom element and stores them:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
</pre></td><td class='code'><pre><code class='javascript'><span class='line'><span class="nx">init</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">element_id</span><span class="p">){</span>
</span><span class='line'>  <span class="kd">var</span> <span class="nx">element</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#&#39;</span> <span class="o">+</span> <span class="nx">element_id</span><span class="p">);</span>
</span><span class='line'>  <span class="nx">element</span><span class="p">.</span><span class="nx">children</span><span class="p">().</span><span class="nx">each</span><span class="p">(</span><span class="kd">function</span><span class="p">(</span><span class="nx">i</span><span class="p">,</span> <span class="nx">elm</span><span class="p">){</span>
</span><span class='line'>    <span class="nx">elm</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="nx">elm</span><span class="p">);</span>
</span><span class='line'>    <span class="nx">Scupper</span><span class="p">.</span><span class="nx">items</span><span class="p">[</span><span class="nx">elm</span><span class="p">.</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;id&#39;</span><span class="p">)]</span> <span class="o">=</span> <span class="nx">elm</span><span class="p">.</span><span class="nx">html</span><span class="p">();</span>
</span><span class='line'>  <span class="p">});</span>
</span><span class='line'>  <span class="nx">element</span><span class="p">.</span><span class="nx">empty</span><span class="p">();</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>All that was needed is an easy way to pull them out an insert them into the dom:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class='javascript'><span class='line'><span class="nx">insert_into</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">source_id</span><span class="p">,</span> <span class="nx">destination_id</span><span class="p">){</span>
</span><span class='line'>  <span class="k">return</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#&#39;</span> <span class="o">+</span> <span class="nx">destination_id</span><span class="p">).</span><span class="nx">append</span><span class="p">(</span><span class="nx">Scupper</span><span class="p">.</span><span class="nx">retrieve</span><span class="p">(</span><span class="nx">source_id</span><span class="p">));</span>
</span><span class='line'><span class="p">},</span>
</span><span class='line'>
</span><span class='line'><span class="nx">retrieve</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">id</span><span class="p">){</span>
</span><span class='line'>  <span class="k">if</span><span class="p">(</span><span class="nx">Scupper</span><span class="p">.</span><span class="nx">items</span><span class="p">[</span><span class="nx">id</span><span class="p">]</span> <span class="o">!==</span> <span class="kc">undefined</span><span class="p">){</span>
</span><span class='line'>    <span class="k">return</span> <span class="nx">Scupper</span><span class="p">.</span><span class="nx">items</span><span class="p">[</span><span class="nx">id</span><span class="p">];</span>
</span><span class='line'>  <span class="p">}</span><span class="k">else</span><span class="p">{</span>
</span><span class='line'>    <span class="k">throw</span> <span class="s2">&quot;Requested Scupper element not found with id: &quot;</span> <span class="o">+</span> <span class="nx">id</span><span class="p">;</span>
</span><span class='line'>  <span class="p">}</span>
</span><span class='line'><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>Calling insert_into() grabs the snippet HTML and inserts it into the specified dom element ready for the test to use it.</p>

<p>If you want to use Scupper the source is <a href="http://github.com/kernow/Scupper/">freely available on github</a>.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Shoulda Macro Should_render_a_form_to]]></title>
    <link href="http://kernowsoul.com/blog/2009/10/07/shoulda-macro-shouldrenderaformto/"/>
    <updated>2009-10-07T16:49:00+01:00</updated>
    <id>http://kernowsoul.com/blog/2009/10/07/shoulda-macro-shouldrenderaformto</id>
    <content type="html"><![CDATA[<p>I&rsquo;ve been writing a fair number of functional tests recently, one thing that kept cropping up was the need to check if a form had been rendered and that it is going to perform a particular action. Shoulda has a should_render_a_form macro, unfortunately it&rsquo;s been depreciated and doesn&rsquo;t do anything other than check a form element has been rendered in the view.</p>

<p>I decided to come up with my own macro that checks the specifics of a form element, enter should_render_a_form_to. This takes three arguments, a description, an options hash and a block that contains the expected url. You can use the macro as follows&hellip;</p>

<p>Check there is a form posting to the new_user_post_path:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">should_render_a_form_to</span><span class="p">(</span><span class="s2">&quot;create a new post&quot;</span><span class="p">,</span> <span class="p">{</span><span class="ss">:method</span> <span class="o">=&gt;</span> <span class="s2">&quot;post&quot;</span><span class="p">})</span> <span class="p">{</span> <span class="n">new_user_post_path</span><span class="p">(</span><span class="vi">@user</span><span class="o">.</span><span class="n">id</span><span class="p">)</span> <span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>Check there is a form putting to the user_post_path and that the form has the id of &lsquo;post_edit_form&rsquo;:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">should_render_a_form_to</span><span class="p">(</span><span class="s2">&quot;update a post&quot;</span><span class="p">,</span> <span class="p">{</span><span class="ss">:method</span> <span class="o">=&gt;</span> <span class="s2">&quot;put&quot;</span><span class="p">,</span> <span class="ss">:id</span> <span class="o">=&gt;</span> <span class="s2">&quot;post_edit_form&quot;</span><span class="p">})</span> <span class="p">{</span> <span class="n">user_post_path</span><span class="p">(</span> <span class="ss">:user_id</span> <span class="o">=&gt;</span> <span class="vi">@user</span><span class="o">.</span><span class="n">id</span><span class="p">,</span> <span class="ss">:id</span> <span class="o">=&gt;</span> <span class="mi">1</span><span class="p">)</span> <span class="p">}</span>
</span></code></pre></td></tr></table></div></figure>


<p>The macro code is available on <a href="http://github.com/kernow/shoulda/tree/form_macro">github</a> with test coverage. If you just want to cut and paste into your own macro&rsquo;s file:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">def</span> <span class="nf">should_render_a_form_to</span><span class="p">(</span><span class="n">description</span><span class="p">,</span> <span class="n">options</span> <span class="o">=</span> <span class="p">{},</span> <span class="o">&amp;</span><span class="n">block</span><span class="p">)</span>
</span><span class='line'>  <span class="n">should</span> <span class="s2">&quot;render a form to </span><span class="si">#{</span><span class="n">description</span><span class="si">}</span><span class="s2">&quot;</span> <span class="k">do</span>
</span><span class='line'>    <span class="n">expected_url</span>  <span class="o">=</span> <span class="nb">instance_eval</span><span class="p">(</span><span class="o">&amp;</span><span class="n">block</span><span class="p">)</span>
</span><span class='line'>    <span class="n">form_method</span>   <span class="o">=</span> <span class="k">case</span> <span class="n">options</span><span class="o">[</span><span class="ss">:method</span><span class="o">]</span>
</span><span class='line'>      <span class="k">when</span> <span class="s2">&quot;post&quot;</span><span class="p">,</span> <span class="s2">&quot;put&quot;</span><span class="p">,</span> <span class="s2">&quot;delete&quot;</span> <span class="p">:</span> <span class="s2">&quot;post&quot;</span>
</span><span class='line'>      <span class="k">else</span> <span class="s2">&quot;get&quot;</span>
</span><span class='line'>      <span class="k">end</span>
</span><span class='line'>    <span class="n">assert_select</span> <span class="s2">&quot;form[action=?][method=?]&quot;</span><span class="p">,</span>
</span><span class='line'>                  <span class="n">expected_url</span><span class="p">,</span>
</span><span class='line'>                  <span class="n">form_method</span><span class="p">,</span>
</span><span class='line'>                  <span class="kp">true</span><span class="p">,</span>
</span><span class='line'>                  <span class="s2">&quot;The template doesn&#39;t contain a &lt;form&gt; element with the action </span><span class="si">#{</span><span class="n">expected_url</span><span class="si">}</span><span class="s2">&quot;</span> <span class="k">do</span> <span class="o">|</span><span class="n">elms</span><span class="o">|</span>
</span><span class='line'>
</span><span class='line'>      <span class="k">if</span> <span class="n">options</span><span class="o">[</span><span class="ss">:id</span><span class="o">]</span>
</span><span class='line'>        <span class="n">elms</span><span class="o">.</span><span class="n">each</span> <span class="k">do</span> <span class="o">|</span><span class="n">elm</span><span class="o">|</span>
</span><span class='line'>          <span class="n">assert_select</span> <span class="n">elm</span><span class="p">,</span>
</span><span class='line'>                        <span class="s2">&quot;#</span><span class="si">#{</span><span class="n">options</span><span class="o">[</span><span class="ss">:id</span><span class="o">]</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">,</span>
</span><span class='line'>                        <span class="kp">true</span><span class="p">,</span>
</span><span class='line'>                        <span class="s2">&quot;The template doesn&#39;t contain a &lt;form&gt; element with the id </span><span class="si">#{</span><span class="n">options</span><span class="o">[</span><span class="ss">:id</span><span class="o">]</span><span class="si">}</span><span class="s2">&quot;</span>
</span><span class='line'>        <span class="k">end</span>
</span><span class='line'>      <span class="k">end</span>
</span><span class='line'>
</span><span class='line'>      <span class="k">unless</span> <span class="sx">%w{get post}</span><span class="o">.</span><span class="n">include?</span> <span class="n">options</span><span class="o">[</span><span class="ss">:method</span><span class="o">]</span>
</span><span class='line'>        <span class="n">assert_select</span> <span class="s2">&quot;input[name=_method][value=?]&quot;</span><span class="p">,</span>
</span><span class='line'>                      <span class="n">options</span><span class="o">[</span><span class="ss">:method</span><span class="o">]</span><span class="p">,</span>
</span><span class='line'>                      <span class="kp">true</span><span class="p">,</span>
</span><span class='line'>                      <span class="s2">&quot;The template doesn&#39;t contain a &lt;form&gt; for </span><span class="si">#{</span><span class="n">expected_url</span><span class="si">}</span><span class="s2"> using the method </span><span class="si">#{</span><span class="n">options</span><span class="o">[</span><span class="ss">:method</span><span class="o">]</span><span class="si">}</span><span class="s2">&quot;</span>
</span><span class='line'>      <span class="k">end</span>
</span><span class='line'>    <span class="k">end</span>
</span><span class='line'>  <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>The macro checks both the forms action attribute as well as the hidden input rails uses to specify the method where necessary. I&rsquo;ve also been playing with creating a macro to check for a form with specific fields such as should_render_a_form_with_fields. This is proving to be slightly more difficult than I originally anticipated and defining a nice interface to the method has been rather tricky.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Vlad the Deployer Hoptoad Integration]]></title>
    <link href="http://kernowsoul.com/blog/2009/09/04/vlad-the-deployer-hoptoad-integration/"/>
    <updated>2009-09-04T11:46:00+01:00</updated>
    <id>http://kernowsoul.com/blog/2009/09/04/vlad-the-deployer-hoptoad-integration</id>
    <content type="html"><![CDATA[<p>I&rsquo;ve just had to setup <a href="http://hoptoadapp.com">Hoptoad</a> for one of our apps that uses <a href="http://rubyhitsquad.com/Vlad_the_Deployer.html">Vlad</a> for deployment, the integration isn&rsquo;t quite as easy as with <a href="http://www.capify.org">Capistrano</a>. I couldn&rsquo;t find much information on how to integrate the two so I thought I&rsquo;d share my solution.</p>

<p>The original Hoptoad task for use with Capistrano needed a little modification.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">task</span> <span class="ss">:notify_hoptoad</span> <span class="k">do</span>
</span><span class='line'>  <span class="n">rails_env</span> <span class="o">=</span> <span class="n">fetch</span><span class="p">(</span><span class="ss">:rails_env</span><span class="p">,</span> <span class="s2">&quot;production&quot;</span><span class="p">)</span>
</span><span class='line'>  <span class="n">local_user</span> <span class="o">=</span> <span class="no">ENV</span><span class="o">[</span><span class="s1">&#39;USER&#39;</span><span class="o">]</span> <span class="o">||</span> <span class="no">ENV</span><span class="o">[</span><span class="s1">&#39;USERNAME&#39;</span><span class="o">]</span>
</span><span class='line'>  <span class="n">notify_command</span> <span class="o">=</span> <span class="s2">&quot;rake hoptoad:deploy TO=</span><span class="si">#{</span><span class="n">rails_env</span><span class="si">}</span><span class="s2"> REVISION=</span><span class="si">#{</span><span class="n">current_revision</span><span class="si">}</span><span class="s2"> REPO=</span><span class="si">#{</span><span class="n">repository</span><span class="si">}</span><span class="s2"> USER=</span><span class="si">#{</span><span class="n">local_user</span><span class="si">}</span><span class="s2">&quot;</span>
</span><span class='line'>  <span class="nb">puts</span> <span class="s2">&quot;Notifying Hoptoad of Deploy (</span><span class="si">#{</span><span class="n">notify_command</span><span class="si">}</span><span class="s2">)&quot;</span>
</span><span class='line'>  <span class="sb">`</span><span class="si">#{</span><span class="n">notify_command</span><span class="si">}</span><span class="sb">`</span>
</span><span class='line'>  <span class="nb">puts</span> <span class="s2">&quot;Hoptoad Notification Complete.&quot;</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>fetch is a Capistrano method so needed to be removed, we can use the <a href="http://hitsquad.rubyforge.org/vlad/doco/getting_started_txt.html">Vlad environment pattern</a> for this. I also wanted to use the git information for the user instead of the system user, finally as far as I can tell the git commit SHA being deployed is not available in Vlad.</p>

<p>In the Vlad deployment script I added a Hoptoad task to replace the default Capistrano task provided by Hoptoad.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">task</span> <span class="ss">:notify_hoptoad</span> <span class="o">=&gt;</span> <span class="o">[</span><span class="ss">:git_user</span><span class="p">,</span> <span class="ss">:git_revision</span><span class="o">]</span> <span class="k">do</span>
</span><span class='line'>  <span class="n">notify_command</span> <span class="o">=</span> <span class="s2">&quot;rake hoptoad:deploy TO=</span><span class="si">#{</span><span class="n">rails_env</span><span class="si">}</span><span class="s2"> REVISION=</span><span class="si">#{</span><span class="n">current_sha</span><span class="si">}</span><span class="s2"> REPO=</span><span class="si">#{</span><span class="n">repository</span><span class="si">}</span><span class="s2"> USER=&#39;</span><span class="si">#{</span><span class="n">current_user</span><span class="si">}</span><span class="s2">&#39;&quot;</span>
</span><span class='line'>  <span class="nb">puts</span> <span class="s2">&quot;Notifying Hoptoad of Deploy (</span><span class="si">#{</span><span class="n">notify_command</span><span class="si">}</span><span class="s2">)&quot;</span>
</span><span class='line'>  <span class="sb">`</span><span class="si">#{</span><span class="n">notify_command</span><span class="si">}</span><span class="sb">`</span>
</span><span class='line'>  <span class="nb">puts</span> <span class="s2">&quot;Hoptoad Notification Complete.&quot;</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>Then added it as a dependency for the deploy task</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">task</span> <span class="ss">:deploy</span> <span class="o">=&gt;</span> <span class="o">[</span><span class="ss">:update</span><span class="p">,</span> <span class="ss">:migrate</span><span class="p">,</span> <span class="ss">:start_app</span><span class="p">,</span> <span class="ss">:notify_hoptoad</span><span class="o">]</span>
</span></code></pre></td></tr></table></div></figure>


<p>There are a couple of helper tasks I&rsquo;ve added to get the git user and the SHA of the commit being deployed</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">remote_task</span> <span class="ss">:git_revision</span> <span class="k">do</span>
</span><span class='line'>  <span class="n">set</span> <span class="ss">:current_sha</span><span class="p">,</span> <span class="n">run</span><span class="p">(</span><span class="s2">&quot;cd </span><span class="si">#{</span><span class="no">File</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">scm_path</span><span class="p">,</span> <span class="s1">&#39;repo&#39;</span><span class="p">)</span><span class="si">}</span><span class="s2">; git rev-parse origin/master&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'>
</span><span class='line'><span class="n">task</span> <span class="ss">:git_user</span> <span class="k">do</span>
</span><span class='line'>  <span class="n">set</span> <span class="ss">:current_user</span><span class="p">,</span> <span class="sb">`git config --get user.name`</span><span class="o">.</span><span class="n">strip</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[For the Love of Table Football, Why I Stayed Up for 48 Hours]]></title>
    <link href="http://kernowsoul.com/blog/2009/08/24/for-the-love-of-table-football-why-i-stayed-up-for-48-hours/"/>
    <updated>2009-08-24T01:05:00+01:00</updated>
    <id>http://kernowsoul.com/blog/2009/08/24/for-the-love-of-table-football-why-i-stayed-up-for-48-hours</id>
    <content type="html"><![CDATA[<p><strong>Update:</strong> wuzlr.com is no longer a live site</p>

<p>What a weekend! it all started on Friday night, a feverish last minute planning session began on how we would implement &#8220;Wuzlr&#8221;. We&#8217;d bounced around some ideas earlier in the week and had a pretty good idea of what we wanted, whittling that down into a set of features we could implement in 48 hours was no easy task, there was so many good ideas and we didn&#8217;t have time to implement them all. At 1am it all began&#8230;</p>




<h3>The Pitch</h3>




<p>If your office is anything like ours things get pretty serious whenever a game of table football breaks out (especially when <a href="http://twitter.com/theozaurus">@theozaurus</a> is playing). We&#8217;ve wanted a way to track who&#8217;s the best in the office for quite some time, finally we have just the thing, and so do you. Wuzlr is a table football league tracking application that lets you see performance over time with all sorts of fun and interesting facts and figures displayed.</p>




<p>Wuzlr (or wuzler if you use the correct non web 2.0 spelling) is the Austrian word for table football and just so happened to be the first domain we came across that&#8217;s still available. We also liked the hat tip to the &#8216;e&#8217; dropping crowd, no, not you party people, I&#8217;m talking about flickr and the like.</p>




<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/gGYnFlC7i7E&hl=en&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/gGYnFlC7i7E&hl=en&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>




<h3>Application Features</h3>




<ul>
  <li>Create leagues and record all your games,
<s>Check out the <a href="#">Jiva office league</a></s></li>

  <li>Compare yourself to other players,
Me Vs. Theo <br /><img src="http://kernowsoul.com/images/uploaded/wuzlr-compare.jpg" style="margin-top: 20px;margin-bottom: 20px;" /></li>

  <li>View your nemesis, best team mate, worst team mate and more, <s><a href="#">my player page</a></s></li>

  <li>League standings, games played per day, table bias, most dedicated players (who&#8217;s put the most time in) <br /><img src="http://kernowsoul.com/images/uploaded/wuzlr-graphs.jpg" style="margin-top: 20px;margin-bottom: 20px;" /></li>
</ul>




<h3>Our Team</h3>




<ul>
  <li>Jamie Dyer <a href="http://twitter.com/kernowsoul">@kernowsoul</a> Developer for <a href="http://jivatechnology.com/">Jiva</a></li>
  <li>Theo Coushion <a href="http://twitter.com/theozaurus">@theozaurus</a> Developer for <a href="http://jivatechnology.com/">Jiva</a></li>
  <li>Peter Coles <a href="http://twitter.com/fatelvis">@fatelvis</a> Designer for <a href="http://www.existem.com/">Existem</a></li>
</ul>




<p>Yes we know the site looks terrible in IE, who uses IE anyway?</p>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[My Computer Loves Autotest-fsevent]]></title>
    <link href="http://kernowsoul.com/blog/2009/06/04/my-computer-loves-autotest-fsevent/"/>
    <updated>2009-06-04T13:10:00+01:00</updated>
    <id>http://kernowsoul.com/blog/2009/06/04/my-computer-loves-autotest-fsevent</id>
    <content type="html"><![CDATA[<p>I&rsquo;m a big fan of <a href="http://www.zenspider.com/ZSS/Products/ZenTest/">autotest</a> for testing, unfortunately it does stress my poor MacBook Pro and makes the fan go berserk if running anything other than the most simple of test suites. This is due to autotest having to check each file in your project for changes.</p>

<p>No more will autotest stress out my mac, <a href="http://www.bitcetera.com/en/products/autotest-fsevent">autotest-fsevent</a> is a great gem that uses OS X&rsquo;s FSEvent system to be notified when files have changed rather than having to constantly poll the filesystem. You need mac OS X 10.5 or later to take advantage of FSEvent.</p>

<p>The other nice thing autotest-fsevent does is take care of all the .autotest config options, I managed to delete my entire config file which I&rsquo;ve been tweaking for as long as I can remember trying to get the perfect setup.</p>

<p>I can now run even the most demanding of test suites and my computer barely breaks a sweat. Thanks <a href="http://www.bitcetera.com">bitcetera</a>, my computer &hearts;&rsquo;s you.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[DRYing Up Multiple User Contexts With Shoulda Macros]]></title>
    <link href="http://kernowsoul.com/blog/2009/05/22/drying-up-multiple-user-contexts-with-shoulda-macros/"/>
    <updated>2009-05-22T00:14:00+01:00</updated>
    <id>http://kernowsoul.com/blog/2009/05/22/drying-up-multiple-user-contexts-with-shoulda-macros</id>
    <content type="html"><![CDATA[<p>Today I&rsquo;ve been writing tests for a legacy Rails application I inherited recently. The application has several user roles, each role having varying permissions. To deal with this nicely I setup <a href="http://thoughtbot.com/projects/shoulda">shoulda</a> macro&rsquo;s to create contexts for each of the user roles, public user, standard user, admin user etc. then in my tests I could write&hellip;</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">public_context</span> <span class="k">do</span>
</span><span class='line'>
</span><span class='line'>  <span class="n">context</span> <span class="s2">&quot;on GET to :index&quot;</span> <span class="k">do</span>
</span><span class='line'>    <span class="n">setup</span> <span class="k">do</span>
</span><span class='line'>      <span class="n">get</span> <span class="ss">:index</span>
</span><span class='line'>    <span class="k">end</span>
</span><span class='line'>
</span><span class='line'>    <span class="n">should_redirect_to</span><span class="p">(</span><span class="s2">&quot;root url&quot;</span><span class="p">)</span> <span class="p">{</span> <span class="n">root_url</span> <span class="p">}</span>
</span><span class='line'>  <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'>
</span><span class='line'><span class="n">signed_in_user_context</span> <span class="k">do</span>
</span><span class='line'>
</span><span class='line'>  <span class="n">context</span> <span class="s2">&quot;on GET to :index&quot;</span> <span class="k">do</span>
</span><span class='line'>    <span class="n">setup</span> <span class="k">do</span>
</span><span class='line'>      <span class="n">get</span> <span class="ss">:index</span>
</span><span class='line'>    <span class="k">end</span>
</span><span class='line'>
</span><span class='line'>    <span class="n">should_redirect_to</span><span class="p">(</span><span class="s2">&quot;user url&quot;</span><span class="p">)</span> <span class="p">{</span> <span class="n">user_url</span> <span class="p">}</span>
</span><span class='line'>  <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>This is pretty standard practice now and something I picked up from looking at the code produced by the guys at <a href="http://thoughtbot.com">Thought Bot</a>. While working on the test suite it became apparent many of the methods behaved in the same way for multiple user roles. I wanted to come up with a way to run a group of tests under multiple user roles without having to duplicate any code. Shoulda macros to the rescue again! After creating another macro to deal with multiple contexts I can write my tests like this&hellip;</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="n">multiple_contexts</span> <span class="s1">&#39;public_context&#39;</span><span class="p">,</span> <span class="s1">&#39;signed_in_user_context&#39;</span> <span class="k">do</span>
</span><span class='line'>
</span><span class='line'>  <span class="n">context</span> <span class="s2">&quot;on GET to :show&quot;</span> <span class="k">do</span>
</span><span class='line'>    <span class="n">setup</span> <span class="k">do</span>
</span><span class='line'>      <span class="vi">@advert</span> <span class="o">=</span> <span class="no">Factory</span><span class="p">(</span><span class="ss">:advert</span><span class="p">)</span>
</span><span class='line'>      <span class="n">get</span> <span class="ss">:show</span><span class="p">,</span> <span class="ss">:id</span> <span class="o">=&gt;</span> <span class="vi">@advert</span><span class="o">.</span><span class="n">to_param</span>
</span><span class='line'>    <span class="k">end</span>
</span><span class='line'>
</span><span class='line'>    <span class="n">should_render_with_layout</span> <span class="ss">:application</span>
</span><span class='line'>    <span class="n">should_render_template</span> <span class="ss">:show</span>
</span><span class='line'>    <span class="n">should_not_set_the_flash</span>
</span><span class='line'>    <span class="n">should_assign_to</span><span class="p">(</span> <span class="ss">:advert</span> <span class="p">)</span> <span class="p">{</span> <span class="vi">@advert</span> <span class="p">}</span>
</span><span class='line'>    <span class="n">should_respond_with</span> <span class="ss">:success</span>
</span><span class='line'>  <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>


<p>And the shoulda macro code itself&hellip;</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="k">def</span> <span class="nf">multiple_contexts</span><span class="p">(</span><span class="o">*</span><span class="n">contexts</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">blk</span><span class="p">)</span>
</span><span class='line'>  <span class="n">contexts</span><span class="o">.</span><span class="n">each</span> <span class="p">{</span> <span class="o">|</span><span class="n">context</span><span class="o">|</span>
</span><span class='line'>    <span class="nb">send</span><span class="p">(</span><span class="n">context</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">blk</span><span class="p">)</span> <span class="k">if</span> <span class="nb">respond_to?</span><span class="p">(</span><span class="n">context</span><span class="p">)</span>
</span><span class='line'>  <span class="p">}</span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'>
</span><span class='line'><span class="k">def</span> <span class="nf">public_context</span><span class="p">(</span><span class="o">&amp;</span><span class="n">blk</span><span class="p">)</span>
</span><span class='line'>  <span class="n">context</span> <span class="s2">&quot;The public&quot;</span> <span class="k">do</span>
</span><span class='line'>    <span class="n">setup</span> <span class="p">{</span> <span class="n">sign_out</span> <span class="p">}</span>
</span><span class='line'>    <span class="n">merge_block</span><span class="p">(</span><span class="o">&amp;</span><span class="n">blk</span><span class="p">)</span>
</span><span class='line'>  <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'>
</span><span class='line'><span class="k">def</span> <span class="nf">signed_in_user_context</span><span class="p">(</span><span class="o">&amp;</span><span class="n">blk</span><span class="p">)</span>
</span><span class='line'>  <span class="n">context</span> <span class="s2">&quot;A signed in user&quot;</span> <span class="k">do</span>
</span><span class='line'>    <span class="n">setup</span> <span class="k">do</span>
</span><span class='line'>      <span class="vi">@user</span> <span class="o">=</span> <span class="no">Factory</span><span class="p">(</span><span class="ss">:user</span><span class="p">)</span>
</span><span class='line'>      <span class="n">sign_in_as</span> <span class="vi">@user</span>
</span><span class='line'>    <span class="k">end</span>
</span><span class='line'>    <span class="n">merge_block</span><span class="p">(</span><span class="o">&amp;</span><span class="n">blk</span><span class="p">)</span>
</span><span class='line'>  <span class="k">end</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Running JSLint Through TextMate]]></title>
    <link href="http://kernowsoul.com/blog/2009/04/27/running-jslint-through-textmate/"/>
    <updated>2009-04-27T17:44:00+01:00</updated>
    <id>http://kernowsoul.com/blog/2009/04/27/running-jslint-through-textmate</id>
    <content type="html"><![CDATA[<p><strong>UPDATE: I now use <a href="http://www.jshint.com/">jsHint</a> which is more configurable, there&rsquo;s an excellent <a href="http://fgnass.posterous.com/jslint-in-textmate">TextMate bundle</a> available</strong></p>

<p>I&rsquo;ve been developing with JavaScript a lot recently and found <a href="http://www.jslint.com/">JSLint</a> to be a rather useful tool for picking up syntax errors. Being primarily a <a href="http://www.ruby-lang.org/en/">ruby</a> developer I have a nasty habit of omitting semicolons from the end of lines.</p>

<p>I found an article on <a href="http://www.phpied.com/jslint-on-mac-textmate/">running JSLint through a TextMate command</a> but found <a href="http://wonko.com/post/pretty-jslint-output-for-textmate">Ryan&rsquo;s script</a> didn&rsquo;t quite work with the output from the version of JSLint I&rsquo;m using so I thought I&rsquo;d share my modifications.</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
</pre></td><td class='code'><pre><code class='ruby'><span class='line'><span class="c1">#!/usr/bin/env ruby</span>
</span><span class='line'><span class="nb">require</span> <span class="s1">&#39;cgi&#39;</span>
</span><span class='line'>
</span><span class='line'><span class="n">lint</span> <span class="o">=</span> <span class="sb">`/usr/bin/java -jar ~/Library/JSLint/js.jar ~/Library/JSLint/jslint.js &quot;$TM_FILEPATH&quot;`</span>
</span><span class='line'>
</span><span class='line'><span class="n">lint</span><span class="o">.</span><span class="n">gsub!</span><span class="p">(</span><span class="sr">/(line \d+ character \d+:) ([^\n]+)\n([^\n]+)/m</span><span class="p">)</span> <span class="k">do</span>
</span><span class='line'>  <span class="s2">&quot;&lt;p&gt;&lt;strong&gt;</span><span class="si">#{</span><span class="no">CGI</span><span class="o">.</span><span class="n">escapeHTML</span><span class="p">(</span><span class="vg">$1</span><span class="p">)</span><span class="si">}</span><span class="s2">&lt;/strong&gt; </span><span class="si">#{</span><span class="no">CGI</span><span class="o">.</span><span class="n">escapeHTML</span><span class="p">(</span><span class="vg">$2</span><span class="p">)</span><span class="si">}</span><span class="s2">&lt;/p&gt;&quot;</span> <span class="o">&lt;&lt;</span>
</span><span class='line'>    <span class="p">(</span><span class="vg">$3</span> <span class="p">?</span> <span class="s2">&quot;&lt;pre&gt;</span><span class="si">#{</span><span class="no">CGI</span><span class="o">.</span><span class="n">escapeHTML</span><span class="p">(</span><span class="vg">$3</span><span class="p">)</span><span class="si">}</span><span class="s2">&lt;/pre&gt;&quot;</span> <span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">)</span>
</span><span class='line'><span class="k">end</span>
</span><span class='line'>
</span><span class='line'><span class="n">lint</span><span class="o">.</span><span class="n">gsub!</span><span class="p">(</span><span class="sr">/^(jslint:.*at )/</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)</span>
</span><span class='line'>
</span><span class='line'><span class="nb">print</span> <span class="o">&lt;&lt;</span><span class="no">HTML</span>
</span><span class='line'><span class="sh">&lt;!doctype&gt;</span>
</span><span class='line'><span class="sh">&lt;html&gt;</span>
</span><span class='line'><span class="sh">&lt;head&gt;</span>
</span><span class='line'><span class="sh">  &lt;style type=&quot;text/css&quot;&gt;</span>
</span><span class='line'><span class="sh">    p { margin-bottom: 0; }</span>
</span><span class='line'><span class="sh">    pre {</span>
</span><span class='line'><span class="sh">      background: #f5f5f5;</span>
</span><span class='line'><span class="sh">      border: 1px solid #cfcfcf;</span>
</span><span class='line'><span class="sh">      font-size: 12px;</span>
</span><span class='line'><span class="sh">      margin-top: 2px;</span>
</span><span class='line'><span class="sh">      padding: 2px 4px;</span>
</span><span class='line'><span class="sh">    }</span>
</span><span class='line'><span class="sh">  &lt;/style&gt;</span>
</span><span class='line'><span class="sh">&lt;/head&gt;</span>
</span><span class='line'><span class="sh">&lt;body&gt;</span>
</span><span class='line'><span class="sh">  #{lint}</span>
</span><span class='line'><span class="sh">&lt;/body&gt;</span>
</span><span class='line'><span class="sh">&lt;/html&gt;</span>
</span><span class='line'><span class="no">HTML</span>
</span></code></pre></td></tr></table></div></figure>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[New Bars and Rubber for the Steed]]></title>
    <link href="http://kernowsoul.com/blog/2008/12/22/new-bars-and-rubber-for-the-steed/"/>
    <updated>2008-12-22T20:18:00+00:00</updated>
    <id>http://kernowsoul.com/blog/2008/12/22/new-bars-and-rubber-for-the-steed</id>
    <content type="html"><![CDATA[<p><img src="http://kernowsoul.com/images/uploaded/bike-iphone.jpg" alt="Lemond Fillmore with bull horn bars and orange rubber" /></p>

<p>A couple of weeks ago I had to replace the old tires on my Fillmore as I&rsquo;d worn through the green ones that came with the bike. Took a bit of getting used to the orange but it&rsquo;s definitely growing on me.</p>

<p>This last weekend I managed a puncture the inner tube while pulling the pump off which required a trip to <a href="http://www.stradacycles.co.uk/"/>Strada Cycles</a>. I ended up replacing the bars and break callipers so it turned out to be a much more expensive trip than I was expecting. Just shy of £100 got me a new inner tube and I was back on the road again.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Javascript_auto_include Plugin Updated]]></title>
    <link href="http://kernowsoul.com/blog/2008/12/02/javascriptautoinclude-plugin-updated/"/>
    <updated>2008-12-02T16:04:00+00:00</updated>
    <id>http://kernowsoul.com/blog/2008/12/02/javascriptautoinclude-plugin-updated</id>
    <content type="html"><![CDATA[<p><strong>UPDATE: This plugin is no longer maintained, I recommend using the <a href="https://rubygems.org/gems/sprockets">Sprockets gem</a>.</strong></p>

<p>I&rsquo;ve updated the <a href="https://github.com/kernow/javascript_auto_include">javascript_auto_include plugin</a> to include changes from <a href="http://github.com/abradburne">abradburne</a> and <a href="http://github.com/jimp79">jimp79</a>. Thanks to these guys the plugin now supports nested controllers so you can add javascript to a paths like admin/users and admin/users/show/1 etc.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[MySQL Order by Rand on Large Data Sets]]></title>
    <link href="http://kernowsoul.com/blog/2008/12/01/mysql-order-by-rand-on-large-data-sets/"/>
    <updated>2008-12-01T17:50:00+00:00</updated>
    <id>http://kernowsoul.com/blog/2008/12/01/mysql-order-by-rand-on-large-data-sets</id>
    <content type="html"><![CDATA[<p>More of a note to self than a real post. <a href="http://www.paperplanes.de/archives/2008/4/24/mysql_nonos_order_by_rand/">Great solution to extremely slow order by rand() queries</a> when used on large data sets. Using this technique a query previously taking nearly 0.2 seconds was reduced to around 0.01 seconds.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Running Merb on a Shared Host Without Compiler Permissions]]></title>
    <link href="http://kernowsoul.com/blog/2008/11/21/running-merb-on-a-shared-host-without-compiler-permissions/"/>
    <updated>2008-11-21T13:54:00+00:00</updated>
    <id>http://kernowsoul.com/blog/2008/11/21/running-merb-on-a-shared-host-without-compiler-permissions</id>
    <content type="html"><![CDATA[<p>I ran into a problem earlier today when testing a <a href="http://merbivore.com">Merb</a> application in a shared hosting environment running <a href="http://www.modrails.com">Phusion Passenger</a>. Like most shared hosts access to compilers is not allowed for obvious security reasons, this causes a problem when trying to run a Merb app. Merb makes use of <a href="http://rubyforge.org/projects/rubyinline/">RubyInline</a> which needs to compile a C application in your home folder before it can run so when the user you&rsquo;re running Merb under doesn&rsquo;t have permission to run C compilers you&rsquo;ll get an error similar to:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>sh: /usr/bin/gcc: Permission denied
</span></code></pre></td></tr></table></div></figure>


<p>The way to get around this is to have a privileged user compile the C application for you, then copy it to your users home folder. The easiest way to do this is to generate and run a Merb app as the root user:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>merb-gen app tmp-merb
</span><span class='line'>merb
</span><span class='line'>Ctrl+C
</span></code></pre></td></tr></table></div></figure>


<p>Then copy the RubyInline C application to the users home folder:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>cp -R /root/.ruby_inline /home/&lt;username&gt;
</span></code></pre></td></tr></table></div></figure>


<p>Make sure the file ownership is set correctly:</p>

<figure class='code'><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>chown -R &lt;username&gt;:&lt;username&gt; /home/&lt;username&gt;/.ruby_inline
</span></code></pre></td></tr></table></div></figure>


<p>After this you should be able to run Merb as expected. If you&rsquo;re still getting errors relating to file permissions after following the instructions above you&rsquo;ll need to combine the fix from <a href="http://www.viget.com/extend/rubyinline-in-shared-rails-environments/">Vignet</a> and put the .ruby_inline folder in a place accessible to both the apache user and the user running the Merb app, I&rsquo;ve not tested this but it should work.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Updating RubyGems on OSX]]></title>
    <link href="http://kernowsoul.com/blog/2008/10/23/updating-rubygems-on-osx/"/>
    <updated>2008-10-23T23:54:00+01:00</updated>
    <id>http://kernowsoul.com/blog/2008/10/23/updating-rubygems-on-osx</id>
    <content type="html"><![CDATA[<p><strong>UPDATE: This article is now rather old, Ruby Gems 1.8.15 is the latest version and should be <a href="https://rubygems.org/pages/download">grabbed from here</a></strong></p>

<p>Slightly late to the show I updated to RubyGems 1.3.0 today, the upgrade isn&rsquo;t as straight forward as usual on OSX 10.5 and requires a little extra work.</p>

<p><a href="http://rails.wincent.com">wincent.com</a> posted up some <a href="http://rails.wincent.com/wiki/Updating_to_RubyGems_1.3.0_on_Mac_OS_X_Leopard_10.5.4">instructions on how to upgrade to RubyGems 1.3.0</a> which are useful for anyone having issues.</p>

<p><strong>UPDATE:</strong> It looks like this issue is not specific to OSX, I was updating a couple of Linux servers and had to follow the same procedure.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Colour Profiles in Photoshop for Web Design]]></title>
    <link href="http://kernowsoul.com/blog/2008/09/26/colour-profiles-in-photoshop-for-web-design/"/>
    <updated>2008-09-26T18:06:00+01:00</updated>
    <id>http://kernowsoul.com/blog/2008/09/26/colour-profiles-in-photoshop-for-web-design</id>
    <content type="html"><![CDATA[<p>While getting the photo of my <a href="http://kernowsoul.com/blog/2008/09/26/my-new-business-cards-have-arrived/">new business card</a> ready for the web I fired up Photoshop on the laptop. I soon realised I&rsquo;d not used Photoshop on the laptop before, when I hit the save for web button my lovely photo changed into something hideously washed out. As someone who rarely uses Photoshop these days I always forget how to set-up colour profiles and spent quite some time doing this on the desktop machine.</p>

<p>To my relief a quick google search and a couple of minutes later I was all set-up and had exported my photo exactly how it should be. Thanks <a href="http://www.usabilitypost.com">Usability Post</a> for your amazingly simple and accurate <a href="http://www.usabilitypost.com/2008/07/30/photoshop-color-profiles-for-web-images/">guide to setting up colour profiles for web design</a>.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[My New Business Cards Have Arrived]]></title>
    <link href="http://kernowsoul.com/blog/2008/09/26/my-new-business-cards-have-arrived/"/>
    <updated>2008-09-26T17:55:00+01:00</updated>
    <id>http://kernowsoul.com/blog/2008/09/26/my-new-business-cards-have-arrived</id>
    <content type="html"><![CDATA[<p>I&rsquo;ve been making do with some terrible old business cards for the last few years and thought it was about time for some nice new ones. I wanted to go for something clean and simple so designed them with just a little type, a bit of custom kerning then shot them off to the <a href="http://moo.com">nice little moo bot</a> for printing. I have to say I do quite like the playful tone and little touches moo uses in their communications, it makes you feel happy.</p>

<p><img src="http://kernowsoul.com/images/uploaded/business-card.jpg" alt="Jamie Dyer business card" /></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Is Anyone Else Excited About Merb 1.0?]]></title>
    <link href="http://kernowsoul.com/blog/2008/09/26/is-anyone-else-excited-about-merb-10/"/>
    <updated>2008-09-26T00:03:00+01:00</updated>
    <id>http://kernowsoul.com/blog/2008/09/26/is-anyone-else-excited-about-merb-10</id>
    <content type="html"><![CDATA[<p>I certainly am, Merb 1.0 is due to be announced at <a href="http://www.merbcamp.com">MerbCamp</a> on the 11th October 2008. Right now the guys are hard at work polishing the knobs and working on documentation.</p>

<p>I&rsquo;ve been following <a href="http://merbivore.com">Merb</a> with interest ever since I first heard about it. One of the things I found hard to keep up with &ndash; just dipping into it now and then &ndash; was the speed of development and change. Every time I had a few minutes to play with it everything had changed. Its a bit like having the rug pulled out from under you every time you manage to get to your knees.</p>

<p>The 1.0 release Merb should be far more stable, and with some decent documentation I hope it will start taking off quickly, the barrier to entry will be greatly reduced. Even though I won&rsquo;t be at MerbCamp I&rsquo;ll certainly be following it closely.</p>

<p>I wonder if the 1.0 release will be promptly followed by a 1.0.1 release, as is tradition.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[UK Does It Better... I Agree]]></title>
    <link href="http://kernowsoul.com/blog/2008/09/21/uk-does-it-better-i-agree/"/>
    <updated>2008-09-21T14:43:00+01:00</updated>
    <id>http://kernowsoul.com/blog/2008/09/21/uk-does-it-better-i-agree</id>
    <content type="html"><![CDATA[<p>So the rain has backed off for the first sustained period since I moved back to the UK, I&rsquo;ve taken the opportunity to lay on the grass in the sun and read a book I picked up the other day, <a href="http://punkmarketing.com">Punk Marketing</a>. Not that far in and I&rsquo;m all ready enjoying it, who would have thought a book on marketing could be entertaining!</p>

<p>I came across a quote I thought I would share&hellip;</p>

<blockquote><p>&ldquo;Go to a multiplex, sit through the ads, and see how abused you feel by the start of the movie. Then to to a cinema in the UK and motive that most people turn up to view those commercials. Because they are actually fun-sensible and intriguing and full of messages that make people applaud.Yes, shout out with glee! These are entertaining, funny, well-produced, and cool. Four terms you&rsquo;d never use to describe an ad at movies in the US of A today.&rdquo;</p></blockquote>

<p>I couldn&rsquo;t agree more, those poor Canadians are force fed the majority the USA&rsquo;s crappy ads. What&rsquo;s probably worse is that often the product or service isn&rsquo;t even available to them! I digress, having suffered with the Canadians for the last three years I can say I would gladly watch several hours of English commercials than a single US ad break.</p>

<p>In closing&hellip; Well done Britain, we produce some of the best ads in the world.</p>
]]></content>
  </entry>
  
</feed>
