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

<channel>
	<title>gregs &#187; comps</title>
	<atom:link href="http://gregs.tcias.co.uk/category/comps/feed/" rel="self" type="application/rss+xml" />
	<link>http://gregs.tcias.co.uk</link>
	<description>helping me remember what I figure out</description>
	<lastBuildDate>Fri, 03 Feb 2012 01:04:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Small update to my jasmine BDD post</title>
		<link>http://gregs.tcias.co.uk/2011/09/25/small-update-to-my-jasmine-bdd-post/</link>
		<comments>http://gregs.tcias.co.uk/2011/09/25/small-update-to-my-jasmine-bdd-post/#comments</comments>
		<pubDate>Sun, 25 Sep 2011 19:55:31 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[jasmine]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=720</guid>
		<description><![CDATA[Following on from my post way back in July, I have created a repository over at the github, with some updated examples surrounding validation, adding comments to posts and some refactoring. I am currently looking into DI for javascript objects, &#8230; <a href="http://gregs.tcias.co.uk/2011/09/25/small-update-to-my-jasmine-bdd-post/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Following on from my post way back in July, I have created a <a href="https://github.com/gregstewart/node-blog" title="Node-blog github repository">repository</a> over at the github, with some updated examples surrounding validation, adding comments to posts and some refactoring. </p>
<p>I am currently looking into DI for javascript objects, as well as <a href="http://www.phantomjs.org/" title="PhantomJS: Headless WebKit with JavaScript API">phantom.js</a> and <a href="https://github.com/velesin/jasmine-jquery" title="Jasmine-jquery github repository">jasmine-jquery</a> to start putting together some examples for user journey testing and easier testing of jquery widgets and fixture loading.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2011/09/25/small-update-to-my-jasmine-bdd-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First steps with Jasmine</title>
		<link>http://gregs.tcias.co.uk/2011/07/12/first-steps-with-jasmine/</link>
		<comments>http://gregs.tcias.co.uk/2011/07/12/first-steps-with-jasmine/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 16:27:08 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[jasmine]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=712</guid>
		<description><![CDATA[New job and opportunities. One of the core approaches to developing here, is the use TDD. Now in a JS/UI kind of role this is really novel approach (well at least for me). I don't know how many times in &#8230; <a href="http://gregs.tcias.co.uk/2011/07/12/first-steps-with-jasmine/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>New job and opportunities. One of the core approaches to developing here, is the use TDD. Now in a JS/UI kind of role this is really novel approach (well at least for me). I don't know how many times in the past I have lamented the fact that I needed to click through way too many steps to get to the issue at hand and then rinse and repeat to debug/fix. Even once I had wrapped my head round Chrome's debugger this approach still took way too long. I had dabbled a little in TDD and BDD on personal ruby projects, but never from a UI perspective and when faced with a monumental UI code base I just didn't have the stomach to tackle the problem retro fit tests. Also to be honest the JavaScript testing frameworks just didn't click with me, until Node.js and Jasmine that is.</p>
<p>With Node.js installed grab the following modules using npm</p>
<ul>
<li>coffee-script</li>
<li>jasmine-node</li>
</ul>
<p>Easiest way to get tests running type 'node ./spec.js ' at the command line, which is pointing to ./spec/ folder</p>
<p>In my BlogSpec.js file let's start with some basic tests</p>
<div class="igBar"><span id="lcode-9"><a href="#" onclick="javascript:showPlainTxt('code-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-9">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">describe<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'blog creation'</span>, function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; it<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'should have a title attribute'</span>, function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; expect<span style="color:#006600; font-weight:bold;">&#40;</span>testBlog.<span style="">title</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">toBeDefined</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; it<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'should have a title'</span>, function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; expect<span style="color:#006600; font-weight:bold;">&#40;</span>testBlog.<span style="">title</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">not</span>.<span style="">toBeNull</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>When you run the spec with : 'node-blog git:(master) ✗ node spec.js' the test should fail</p>
<div class="igBar"><span id="lcode-10"><a href="#" onclick="javascript:showPlainTxt('code-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-10">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Started</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">FF</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Spec blog creation</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; it should have a title attribute</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; Error: ReferenceError: testBlog is not defined</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; at new &amp;lt;anonymous&amp;gt; <span style="color:#006600; font-weight:bold;">&#40;</span>/Users/gregstewart/Projects/node-blog/node_modules/jasmine-node/lib/jasmine-node/jasmine-<span style="color:#800000;color:#800000;">1</span>.<span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">1</span>.<span style="">js</span>:<span style="color:#800000;color:#800000;">94</span>:<span style="color:#800000;color:#800000;">50</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; at <span style="color:#006600; font-weight:bold;">&#91;</span>object Object<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="">fail</span> <span style="color:#006600; font-weight:bold;">&#40;</span>/Users/gregstewart/Projects/node-blog/node_modules/jasmine-node/lib/jasmine-node/jasmine-<span style="color:#800000;color:#800000;">1</span>.<span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">1</span>.<span style="">js</span>:<span style="color:#800000;color:#800000;">1963</span>:<span style="color:#800000;color:#800000;">27</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; at <span style="color:#006600; font-weight:bold;">&#91;</span>object Object<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="">execute</span> <span style="color:#006600; font-weight:bold;">&#40;</span>/Users/gregstewart/Projects/node-blog/node_modules/jasmine-node/lib/jasmine-node/jasmine-<span style="color:#800000;color:#800000;">1</span>.<span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">1</span>.<span style="">js</span>:<span style="color:#800000;color:#800000;">970</span>:<span style="color:#800000;color:#800000;">15</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; at <span style="color:#006600; font-weight:bold;">&#91;</span>object Object<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="">next_</span> <span style="color:#006600; font-weight:bold;">&#40;</span>/Users/gregstewart/Projects/node-blog/node_modules/jasmine-node/lib/jasmine-node/jasmine-<span style="color:#800000;color:#800000;">1</span>.<span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">1</span>.<span style="">js</span>:<span style="color:#800000;color:#800000;">1739</span>:<span style="color:#800000;color:#800000;">31</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; at <span style="color:#006600; font-weight:bold;">&#91;</span>object Object<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="">start</span> <span style="color:#006600; font-weight:bold;">&#40;</span>/Users/gregstewart/Projects/node-blog/node_modules/jasmine-node/lib/jasmine-node/jasmine-<span style="color:#800000;color:#800000;">1</span>.<span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">1</span>.<span style="">js</span>:<span style="color:#800000;color:#800000;">1692</span>:<span style="color:#800000;color:#800000;">8</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; at <span style="color:#006600; font-weight:bold;">&#91;</span>object Object<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="">execute</span> <span style="color:#006600; font-weight:bold;">&#40;</span>/Users/gregstewart/Projects/node-blog/node_modules/jasmine-node/lib/jasmine-node/jasmine-<span style="color:#800000;color:#800000;">1</span>.<span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">1</span>.<span style="">js</span>:<span style="color:#800000;color:#800000;">2018</span>:<span style="color:#800000;color:#800000;">14</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; at <span style="color:#006600; font-weight:bold;">&#91;</span>object Object<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="">next_</span> <span style="color:#006600; font-weight:bold;">&#40;</span>/Users/gregstewart/Projects/node-blog/node_modules/jasmine-node/lib/jasmine-node/jasmin% </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>So everything is as expected at this stage, let's start work on getting the basic tests to pass. First off let's create out Blog object</p>
<div class="igBar"><span id="lcode-11"><a href="#" onclick="javascript:showPlainTxt('code-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-11">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Blog = function<span style="color:#006600; font-weight:bold;">&#40;</span>title<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; this.<span style="">title</span> = title;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Blog.<span style="">prototype</span>.<span style="">getTitle</span> = function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; return this.<span style="">title</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">exports.<span style="">Blog</span> = Blog; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>And not let's bring the Blog object into our test and initialise it:</p>
<div class="igBar"><span id="lcode-12"><a href="#" onclick="javascript:showPlainTxt('code-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-12">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">var Blog = require<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'../Blog'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">Blog</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">describe<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'blog creation'</span>, function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; var testBlog;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; beforeEach<span style="color:#006600; font-weight:bold;">&#40;</span>function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; testBlog = new Blog<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; it<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'should have a title attribute'</span>, function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; expect<span style="color:#006600; font-weight:bold;">&#40;</span>testBlog.<span style="">title</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">toBeDefined</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; it<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'should have a title'</span>, function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; expect<span style="color:#006600; font-weight:bold;">&#40;</span>testBlog.<span style="">title</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">not</span>.<span style="">toBeNull</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Now let's get the first test to pass, by editing our Blog.js file</p>
<div class="igBar"><span id="lcode-13"><a href="#" onclick="javascript:showPlainTxt('code-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-13">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Blog = function<span style="color:#006600; font-weight:bold;">&#40;</span>title<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; this.<span style="">title</span> = typeof title !== <span style="color:#CC0000;">'undefined'</span> ? title : null;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Blog.<span style="">prototype</span>.<span style="">getTitle</span> = function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; return this.<span style="">title</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">exports.<span style="">Blog</span> = Blog; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Nearly there, only problem is that our second test is failing because we require a title to not be null.</p>
<div class="igBar"><span id="lcode-14"><a href="#" onclick="javascript:showPlainTxt('code-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-14">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">var Blog = require<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'../Blog'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">Blog</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">describe<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'blog creation'</span>, function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; var testBlog;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; beforeEach<span style="color:#006600; font-weight:bold;">&#40;</span>function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; testBlog = new Blog<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'test'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; it<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'should have a title attribute'</span>, function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; expect<span style="color:#006600; font-weight:bold;">&#40;</span>testBlog.<span style="">title</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">toBeDefined</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; it<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'should have a title value'</span>, function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; expect<span style="color:#006600; font-weight:bold;">&#40;</span>testBlog.<span style="">title</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">not</span>.<span style="">toBeNull</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Let's see what the output looks like:</p>
<div class="igBar"><span id="lcode-15"><a href="#" onclick="javascript:showPlainTxt('code-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-15">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">➜  node-blog git:<span style="color:#006600; font-weight:bold;">&#40;</span>master<span style="color:#006600; font-weight:bold;">&#41;</span> ✗ node spec.<span style="">js</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Started</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">..</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="">Spec</span> blog creation</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Finished in <span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">001</span> seconds</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">1</span> test, <span style="color:#800000;color:#800000;">2</span> assertions, <span style="color:#800000;color:#800000;">0</span> failures </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>And just because I can, let's rewrite the Blog.js in Coffee Script:</p>
<div class="igBar"><span id="lcode-16"><a href="#" onclick="javascript:showPlainTxt('code-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-16">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">class Blog</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; constructor:<span style="color:#006600; font-weight:bold;">&#40;</span>@title<span style="color:#006600; font-weight:bold;">&#41;</span> -&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="">getTitle</span>: -&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @title</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">exports.<span style="">Blog</span> = Blog; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>How much terser is that?</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2011/07/12/first-steps-with-jasmine/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Oh My Zsh</title>
		<link>http://gregs.tcias.co.uk/2011/05/20/oh-my-zsh/</link>
		<comments>http://gregs.tcias.co.uk/2011/05/20/oh-my-zsh/#comments</comments>
		<pubDate>Fri, 20 May 2011 15:36:11 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[*nix]]></category>
		<category><![CDATA[comps]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=683</guid>
		<description><![CDATA[Stumbled across a post on Oh My Zsh this morning and on a pure whim decided to give it a whirl. After 8 hours or so of use, I am really, really liking it. It's the small things. The git integration &#8230; <a href="http://gregs.tcias.co.uk/2011/05/20/oh-my-zsh/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Stumbled across a <a href="http://thechangelog.com/post/5452652236/hooray-oh-my-zsh-has-been-updated">post</a> on <a href="https://github.com/robbyrussell/oh-my-zsh" target="_blank">Oh My Zsh</a> this morning and on a pure whim decided to give it a whirl. After 8 hours or so of use, I am really, really liking it. It's the small things.</p>
<p><a href="http://gregs.tcias.co.uk/wp-content/uploads/2011/05/Screen-shot-2011-05-20-at-4.23.36-PM.png"><img class="aligncenter size-full wp-image-684" title="Oh My Zsh" src="http://gregs.tcias.co.uk/wp-content/uploads/2011/05/Screen-shot-2011-05-20-at-4.23.36-PM.png" alt="" width="533" height="156" /></a></p>
<p>The git integration shown in the above screenshot is just is the icing on the cake, seriously worth spending some time on this if you spend any length of time at the Terminal.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2011/05/20/oh-my-zsh/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>iPhone tracking</title>
		<link>http://gregs.tcias.co.uk/2011/04/21/iphone-tracking/</link>
		<comments>http://gregs.tcias.co.uk/2011/04/21/iphone-tracking/#comments</comments>
		<pubDate>Thu, 21 Apr 2011 08:51:29 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[iphone]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[geo]]></category>
		<category><![CDATA[gis]]></category>
		<category><![CDATA[mapping]]></category>
		<category><![CDATA[tracking]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=667</guid>
		<description><![CDATA[So apparently Apple has been a tad naughty and been tracking where us iPhone and iPad 3G users roam. Two researchers have published these findings along with an app that overlays the data on an OpenStreetMap map. So this is &#8230; <a href="http://gregs.tcias.co.uk/2011/04/21/iphone-tracking/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So apparently Apple has been a tad naughty and <a href="http://arstechnica.com/apple/news/2011/04/how-apple-tracks-your-location-without-your-consent-and-why-it-matters.ars?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=rss">been tracking</a> where us iPhone and iPad 3G users roam. Two researchers <a href="http://radar.oreilly.com/2011/04/apple-location-tracking.html">have published these findings</a> along with <a href="http://petewarden.github.com/iPhoneTracker/">an app</a> that overlays the data on an OpenStreetMap map. So this is me:</p>
<p style="text-align: center;"><a href="http://gregs.tcias.co.uk/wp-content/uploads/2011/04/Screen-shot-2011-04-21-at-9.33.07-AM.jpg"><img class="aligncenter size-full wp-image-668" title="Greg's Iphone tracking" src="http://gregs.tcias.co.uk/wp-content/uploads/2011/04/Screen-shot-2011-04-21-at-9.33.07-AM.jpg" alt="Greg's Iphone tracking" width="601" height="445" /></a></p>
<p>I am disappointed that this is turned on by default, not so much for myself as I find the information interesting, but it's always best to ask first, right? I know plenty of people who are very sensitive about this type of information. And apparently I don't venture to far north of the river either.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2011/04/21/iphone-tracking/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>node.js chat server</title>
		<link>http://gregs.tcias.co.uk/2011/04/05/node-js-chat-server/</link>
		<comments>http://gregs.tcias.co.uk/2011/04/05/node-js-chat-server/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 14:28:55 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[socket.io]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=656</guid>
		<description><![CDATA[Since I have a bit of time on my hands right now, I took a look at node.js and socket.io. The outcome, a really simple chat client/server written in JavaScript. Source is up over at Github, with some instructions on &#8230; <a href="http://gregs.tcias.co.uk/2011/04/05/node-js-chat-server/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Since I have a bit of time on my hands right now, I took a look at node.js and socket.io. The outcome, a really simple chat client/server written in JavaScript. Source is up over at <a href="https://github.com/gregstewart/chat.io">Github</a>, with some instructions on getting started.</p>
<p style="text-align: center;"><a href="http://gregs.tcias.co.uk/wp-content/uploads/2011/04/Screen-shot-2011-04-05-at-3.25.59-PM.png"><img class="size-full wp-image-659" title="Screen shot 2011-04-05 at 3.25.59 PM" src="http://gregs.tcias.co.uk/wp-content/uploads/2011/04/Screen-shot-2011-04-05-at-3.25.59-PM.png" alt="" width="463" height="500" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2011/04/05/node-js-chat-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Folder disk usage</title>
		<link>http://gregs.tcias.co.uk/2011/04/01/folder-disk-usage/</link>
		<comments>http://gregs.tcias.co.uk/2011/04/01/folder-disk-usage/#comments</comments>
		<pubDate>Fri, 01 Apr 2011 13:50:39 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[*nix]]></category>
		<category><![CDATA[comps]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[disk]]></category>
		<category><![CDATA[space]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=653</guid>
		<description><![CDATA[Today my server ran out of disk space. With the help of my friend Ed I was able to pin point the exact location. If you run this command from the root of your server: PLAIN TEXT CODE: du -sh &#8230; <a href="http://gregs.tcias.co.uk/2011/04/01/folder-disk-usage/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today my server ran out of disk space. <img src='http://gregs.tcias.co.uk/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  With the help of my friend Ed I was able to pin point the exact location. If you run this command from the root of your server:</p>
<div class="igBar"><span id="lcode-19"><a href="#" onclick="javascript:showPlainTxt('code-19'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-19">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">du -sh * </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>You will get something like the following:</p>
<div class="igBar"><span id="lcode-20"><a href="#" onclick="javascript:showPlainTxt('code-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-20">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">5</span>.1M&nbsp; &nbsp; bin</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">4</span>.0K&nbsp; &nbsp; boot</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">8</span>.0K&nbsp; &nbsp; dev</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">5</span>.3M&nbsp; &nbsp; etc</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">795M&nbsp; &nbsp; home</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">11M&nbsp;lib</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">0</span>&nbsp; &nbsp;lib64</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">16K&nbsp;lost+found</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">4</span>.0K&nbsp; &nbsp; media</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">4</span>.0K&nbsp; &nbsp; mnt</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">4</span>.0K&nbsp; &nbsp; opt</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">0</span>&nbsp; &nbsp;proc</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">26M&nbsp;root</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">3</span>.8M&nbsp; &nbsp; sbin</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">4</span>.0K&nbsp; &nbsp; selinux</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">4</span>.0K&nbsp; &nbsp; srv</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">0</span>&nbsp; &nbsp;sys</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">0</span>&nbsp; &nbsp;tmp</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">1</span>.3G&nbsp; &nbsp; usr</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">2</span>.4G&nbsp; &nbsp; var </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Then you can start drilling down the folders until you find the exact culprit. In my case a log file had grown to 8 Gig in size.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2011/04/01/folder-disk-usage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>This site is now powered by Nginx</title>
		<link>http://gregs.tcias.co.uk/2011/03/22/this-site-is-now-powered-by-nginx/</link>
		<comments>http://gregs.tcias.co.uk/2011/03/22/this-site-is-now-powered-by-nginx/#comments</comments>
		<pubDate>Tue, 22 Mar 2011 16:58:35 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[*nix]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[comps]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[web server]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[squeeze]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=644</guid>
		<description><![CDATA[I took the plunge this afternoon and switched from Apache 2 to NGinx. For the most part I followed the instructions posted here. Since I am now running Debian Squeeze there were a few things to note: spawn-fcgi: there's a &#8230; <a href="http://gregs.tcias.co.uk/2011/03/22/this-site-is-now-powered-by-nginx/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I took the plunge this afternoon and switched from Apache 2 to NGinx. For the most part I followed the instructions <a href="http://library.linode.com/web-servers/nginx/php-fastcgi/debian-5-lenny">posted here</a>. Since I am now running Debian Squeeze there were a few things to note:</p>
<ol>
<li>spawn-fcgi: there's a package for it so I just used that :
<div class="igBar"><span id="lcode-25"><a href="#" onclick="javascript:showPlainTxt('code-25'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-25">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sudo apt-get install spawn-fcgi </div>
</li>
</ol>
</div>
</div>
</div>
<p></li>
<li>the stop/start script complained when adding it to the boot/shutdown cycle, but one posted in the comments worked:
<div class="igBar"><span id="lcode-26"><a href="#" onclick="javascript:showPlainTxt('code-26'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-26">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">#!/bin/bash</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">### BEGIN INIT INFO</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"># Provides: php-fastcgi</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"># Required-Start: $all</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"># Required-Stop: $all</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"># Default-Start: <span style="color:#800000;color:#800000;">2</span> <span style="color:#800000;color:#800000;">3</span> <span style="color:#800000;color:#800000;">4</span> <span style="color:#800000;color:#800000;">5</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"># Default-Stop: <span style="color:#800000;color:#800000;">0</span> <span style="color:#800000;color:#800000;">1</span> <span style="color:#800000;color:#800000;">6</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"># Short-Description: starts the php-fastcgi process</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"># Description: starts php-fastcgi using start-stop-daemon</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">### END INIT INFO</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">PHP_SCRIPT=/usr/bin/php-fastcgi</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">FASTCGI_USER=www-data</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">RETVAL=<span style="color:#800000;color:#800000;">0</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">case <span style="color:#CC0000;">"$1"</span> in</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">start<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">su - $FASTCGI_USER -c $PHP_SCRIPT</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">RETVAL=$?</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">;;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">stop<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">killall -<span style="color:#800000;color:#800000;">9</span> php5-cgi</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">RETVAL=$?</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">;;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">restart<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">killall -<span style="color:#800000;color:#800000;">9</span> php5-cgi</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">su - $FASTCGI_USER -c $PHP_SCRIPT</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">RETVAL=$?</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">;;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">*<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">echo <span style="color:#CC0000;">"Usage: php-fastcgi {start|stop|restart}"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">exit <span style="color:#800000;color:#800000;">1</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">;;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">esac </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">exit $RETVAL </div>
</li>
</ol>
</div>
</div>
</div>
<p></li>
<li>Next to stop Apache from starting up run:
<div class="igBar"><span id="lcode-27"><a href="#" onclick="javascript:showPlainTxt('code-27'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-27">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sudo update-rc.<span style="">d</span> -f apache2 remove </div>
</li>
</ol>
</div>
</div>
</div>
<p></li>
<li>On the rewrite front, I needed to <a href="http://michaelshadle.com/2009/03/19/finally-using-nginxs-try-files-directive">add the following</a> to my virtual host configuration to have those seo friendly urls up and running again:
<div class="igBar"><span id="lcode-28"><a href="#" onclick="javascript:showPlainTxt('code-28'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-28">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">try_files $uri $uri/ /index.<span style="">php</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2011/03/22/this-site-is-now-powered-by-nginx/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Merging PDFs</title>
		<link>http://gregs.tcias.co.uk/2011/03/11/merging-pdfs/</link>
		<comments>http://gregs.tcias.co.uk/2011/03/11/merging-pdfs/#comments</comments>
		<pubDate>Fri, 11 Mar 2011 15:50:49 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[coldfusion]]></category>
		<category><![CDATA[itext]]></category>
		<category><![CDATA[merge]]></category>
		<category><![CDATA[pdf]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=636</guid>
		<description><![CDATA[I have just posted two small utility functions to merge PDF documents together for those working in CF. You can view them here . Or inline below. The first function takes an array of PDF documents and merges them into &#8230; <a href="http://gregs.tcias.co.uk/2011/03/11/merging-pdfs/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have just posted two small utility functions to merge PDF documents together for those working in CF. You can view them <a href="https://gist.github.com/866034">here</a> . Or inline below.</p>
<p>The first function takes an array of PDF documents and merges them into one. This was handy when different pages for a report had different styling requirements (such a full background colouring bleeding across the margins)</p>
<p><script src="https://gist.github.com/866034.js?file=gistfile1.cfm"></script></p>
<p>The second function stamps a pdf document over another pdf document at certain position. I needed this for a document that had a table dynamically generated that spanned multiple pages and I wanted the footer to not overlap the table content (I could not figure out how to use a css based solution because of the margins).</p>
<p><script src="https://gist.github.com/866034.js?file=gistfile2.cfm"></script></p>
<p>Anyway maybe somebody else will find these handy.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2011/03/11/merging-pdfs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calling a web API</title>
		<link>http://gregs.tcias.co.uk/2011/03/11/calling-a-web-api/</link>
		<comments>http://gregs.tcias.co.uk/2011/03/11/calling-a-web-api/#comments</comments>
		<pubDate>Fri, 11 Mar 2011 14:12:32 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tropo]]></category>
		<category><![CDATA[heroku]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=631</guid>
		<description><![CDATA[A few weeks back I stumbled across a post showing how to create a baby monitor type application using Tropo and Phono courtesy of the JavaScript weekly newsletter. This got me thinking about our applications and I thought it would &#8230; <a href="http://gregs.tcias.co.uk/2011/03/11/calling-a-web-api/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><!-- p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px} p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Arial; color: #333233; min-height: 14.0px} p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Arial; color: #333233} span.s1 {text-decoration: underline ; color: #002fee} span.s2 {font: 12.0px Arial; color: #333233} -->A few weeks back I stumbled across <a href="http://blog.phono.com/2011/02/17/how-to-build-a-voip-based-baby-monitor/?utm_source=javascriptweekly&amp;utm_medium=email">a post showing how to create a baby monitor type application</a> using <a href="http://www.tropo.com/">Tropo</a> and <a href="http://www.phono.com/">Phono</a> courtesy of the JavaScript weekly newsletter. This got me thinking about our applications and I thought it would be kind of cool to use a Voice based interface to hit our API to retrieve an valuation from our system.</p>
<p>Over the course of a few evening I knocked up a working demo using Rails and Tropo, that can dial our AVM using Skype. If you'd like to give it a whirl dial this number using Skype: +990009369991484011, select option 1 and then enter 8633100 followed by the hash (#) key. The resulting text to speech is a little rough, but pretty cool none the less I thought.</p>
<p>If I can I'll post the sample code up to github in the near future.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2011/03/11/calling-a-web-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby, Rails, Git and Heroku</title>
		<link>http://gregs.tcias.co.uk/2011/02/17/ruby-rails-git-and-heroku/</link>
		<comments>http://gregs.tcias.co.uk/2011/02/17/ruby-rails-git-and-heroku/#comments</comments>
		<pubDate>Thu, 17 Feb 2011 17:26:00 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[autotest]]></category>
		<category><![CDATA[rspec]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=614</guid>
		<description><![CDATA[Over Christmas and last month, I decided to resurrect www.tcias.co.uk. Initially it was just a static html site, but I decided to re-build it using Ruby and Rails. While it's very much like using a sledgehammer to tap in a &#8230; <a href="http://gregs.tcias.co.uk/2011/02/17/ruby-rails-git-and-heroku/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Over Christmas and last month, I decided to resurrect <a href="http://www.tcias.co.uk/">www.tcias.co.uk</a>. Initially it was just a static html site, but I decided to re-build it using Ruby and Rails. While it's very much like using a sledgehammer to tap in a small protruding nail, I figured it was a simple enough project to explore building a Rails app. I had a few goals in mind:</p>
<ul>
<li>Use <a href="http://git-scm.com/">Git</a></li>
<li>Build it using tests (<a href="http://rspec.info/">Rspec</a>)</li>
<li>and conversely take a look at BBD</li>
<li>Refactor common elements using partials</li>
<li>Have fun</li>
</ul>
<p><a href="http://heroku.com/">Heroku</a> came along after the initial build because my server seemed to struggle serving the app using a combination of Apache and Passenger Phusion (looks like I need more RAM...). Overall the experience has simply put been great. Building an app using the Ruby and Rails toolset is just a pleasure. <a href="http://rvm.beginrescueend.com/">RVM</a> for ruby version management, Bundler for Gem management, <a href="https://github.com/grosser/autotest">autotest</a> for <a href="http://ph7spot.com/musings/getting-started-with-autotest">continuous background tests</a>, easy deployment with <a href="http://git-scm.com/">Git</a> integration. Compared to the CF world I am in [big caveat this might not be true for you], the rails ecosystm is incredibly rich, well documented, functional and fun.</p>
<p>I started off by following the Rails guide over at <a href="http://ruby.railstutorial.org/chapters/">Rails Tutorial</a> and borrowed the set up to get started. After creating my project, the first thing I got to grips with was getting <a href="http://git-scm.com/">Git</a> set up. I use both a local repository and a remote one over at <a href="https://github.com/gregstewart/Teacup-In-A-Storm">Github</a>, Knowing that your code is versioned in two places is quite a comfort and I have since started using it for absolutely everything locally and have pushed a few other projects (terribly old projects that I am a little embarrassed about, but being the sentimental individual didn't want to loose) on to <a href="https://github.com/">Github</a>. </p>
<p>Then came setting up <a href="https://github.com/grosser/autotest">autotest</a>, having this run in the background with Growl integration gives you instant notification that your tests are passing or failing whenever you save a file. This is so incredibly useful and responsive. I really love the continuous testing nature of this setup.</p>
<p>Given the nature of the site, the coding part was easy-ish and I am sure there are a plenty of things I have done like a noob.</p>
<p>Where all this really comes to shine is during deployment time. I opted for <a href="http://heroku.com/">Heroku</a>, it wasn't so much a choice as a case of I'd be stupid not to. The documentation for signing up and getting started is first class (as it is with <a href="https://github.com/">Github</a> by the way). Once you have your account, created your app and linked it to your git repository, deploying your code is a simple case of typing:</p>
<div class="igBar"><span id="lcode-31"><a href="#" onclick="javascript:showPlainTxt('code-31'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-31">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">git push heroku master </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>From then on in, you just watch the code being checked out, gem dependency being resolved and your app launching. Knowing that your site is Ok thanks to your tests, the one line deployment command is pure joy.</p>
<p>To give you an indication of how great this setup is, consider that I decided to switch from <a href="http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/">erb</a> files to <a href="http://haml-lang.com/">Haml</a>. I spent a few hours reading up and converting my erb files over, while having autotest running showing me where things were breaking (due to my lack of knowledge of the new syntax) or working. Then pushing changes into Git. I confess I had also cast my eye over the resulting output (old habits die hard <img src='http://gregs.tcias.co.uk/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> ) and finally running a one line deployment to Heroku. Job done and once again a pleasure and full of confidence about the result.</p>
<p>Where there any downsides? Well not downsides, but hiccups, wrapping my head around RVM and gem management was a bit bewildering especially when some gems were being used unexpectedly, the problem lay with what's between the chair and the keyboard. Some of the RSpec view testing tripped me up. When you decide to test the content of views, eg:</p>
<div class="igBar"><span id="lcode-32"><a href="#" onclick="javascript:showPlainTxt('code-32'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-32">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">response.<span style="">should</span> have_selector<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">"title"</span>, :content =&gt; <span style="color:#CC0000;">"Something"</span><span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Don't forget to include render_views after your describe statement for the controller, or else your tests will fail and you will be be scratching your head as to why that is the case. :S</p>
<p>There's a lot to take in and it is a little overwhelming when things do not work as intended, but the information to resolve these is out there and with a careful reading of the error messages it does not take very long to figure out.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2011/02/17/ruby-rails-git-and-heroku/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

