<?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>Richard Hart / Hates_ &#187; computing</title>
	<atom:link href="http://www.ur-ban.com/blog/category/computing/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ur-ban.com/blog</link>
	<description>Programming &#38; Life - ur-ban.com</description>
	<lastBuildDate>Sat, 28 Jan 2012 21:33:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Accessing values in your plist file from your iPhone/iPad app</title>
		<link>http://www.ur-ban.com/blog/2011/02/23/accessing-values-in-your-plist-file-in-your-iphoneipad-app/</link>
		<comments>http://www.ur-ban.com/blog/2011/02/23/accessing-values-in-your-plist-file-in-your-iphoneipad-app/#comments</comments>
		<pubDate>Wed, 23 Feb 2011 17:46:23 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[objective-c]]></category>

		<guid isPermaLink="false">http://www.ur-ban.com/blog/?p=2058</guid>
		<description><![CDATA[Recently I&#8217;ve been coding some iPhone and iPad apps with multiple targets, all sharing the same codebase. Previously I had been using Preprocessor Macros to get the job done, but that soon turns messy and hard to maintain. I&#8217;ve since moved to just storing target specific values in each apps related plist file. Retrieving a [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been coding some iPhone and iPad apps with multiple targets, all sharing the same codebase. Previously I had been using <strong>Preprocessor Macros </strong>to get the job done, but that soon turns messy and hard to maintain. I&#8217;ve since moved to just storing target specific values in each apps related plist file. Retrieving a value is as simple as:</p>
<pre>
<div class="codecolorer-container objc vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;<span style="color: #400080;">NSDictionary</span><span style="color: #002200;">*</span> infoDict <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSBundle</span> mainBundle<span style="color: #002200;">&#93;</span> infoDictionary<span style="color: #002200;">&#93;</span>;<br />
&nbsp;<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>someString <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>infoDict objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;SomeKey&quot;</span><span style="color: #002200;">&#93;</span>;</div></div>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ur-ban.com/blog/2011/02/23/accessing-values-in-your-plist-file-in-your-iphoneipad-app/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>nginx SSL PEM_read_bio:bad end line</title>
		<link>http://www.ur-ban.com/blog/2010/12/09/nginx-ssl-pem_read_biobad-end-line/</link>
		<comments>http://www.ur-ban.com/blog/2010/12/09/nginx-ssl-pem_read_biobad-end-line/#comments</comments>
		<pubDate>Thu, 09 Dec 2010 12:05:11 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://www.ur-ban.com/blog/?p=1969</guid>
		<description><![CDATA[Installing the intermediate certificates on our server gave me the following error while trying to start up nginx again: &#160; &#40;SSL: error:0906D066:PEM routines:PEM_read_bio:bad end line&#41; The end of the file looked fine, but the problem was half way through it. Somehow the concatenation had joined two lines together: &#160; -----END CERTIFICATE----------BEGIN CERTIFICATE----- This just needed [...]]]></description>
			<content:encoded><![CDATA[<p>Installing the intermediate certificates on our server gave me the following error while trying to start up nginx again:</p>
<pre>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; <span style="color: #7a0874; font-weight: bold;">&#40;</span>SSL: error:0906D066:PEM routines:PEM_read_bio:bad end line<span style="color: #7a0874; font-weight: bold;">&#41;</span></div></div>
</pre>
<p>The end of the file looked fine, but the problem was half way through it. Somehow the concatenation had joined two lines together:</p>
<pre>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; <span style="color: #660033;">-----END</span> CERTIFICATE----------BEGIN CERTIFICATE-----</div></div>
</pre>
<p>This just needed a line break to fix:</p>
<pre>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; <span style="color: #660033;">-----END</span> CERTIFICATE-----<br />
&nbsp; <span style="color: #660033;">-----BEGIN</span> CERTIFICATE-----</div></div>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ur-ban.com/blog/2010/12/09/nginx-ssl-pem_read_biobad-end-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu: Curl development headers with SSL support</title>
		<link>http://www.ur-ban.com/blog/2010/11/26/curl-development-headers-with-ssl-support/</link>
		<comments>http://www.ur-ban.com/blog/2010/11/26/curl-development-headers-with-ssl-support/#comments</comments>
		<pubDate>Fri, 26 Nov 2010 00:08:50 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://www.ur-ban.com/blog/?p=1948</guid>
		<description><![CDATA[Just been trying to install Passenger on a new Ubuntu EC2 instance and passenger is giving me the error: &#160; * Curl development headers with SSL support... not found Took some digging around but turns out I was just missing the libcurl4-openssl-dev package: &#160; sudo apt-get install libcurl4-openssl-dev]]></description>
			<content:encoded><![CDATA[<p>Just been trying to install Passenger on a new Ubuntu EC2 instance and passenger is giving me the error:</p>
<pre>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; * Curl development headers with SSL support... not found</div></div>
</pre>
<p>Took some digging around but turns out I was just missing the libcurl4-openssl-dev package:</p>
<pre>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; sudo apt-get install libcurl4-openssl-dev</div></div>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ur-ban.com/blog/2010/11/26/curl-development-headers-with-ssl-support/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SSH Tunnels with Postgres &amp; pgAdmin</title>
		<link>http://www.ur-ban.com/blog/2010/10/25/ssh-tunnels-with-postgres-pgadmin/</link>
		<comments>http://www.ur-ban.com/blog/2010/10/25/ssh-tunnels-with-postgres-pgadmin/#comments</comments>
		<pubDate>Mon, 25 Oct 2010 19:16:50 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">http://www.ur-ban.com/blog/?p=1924</guid>
		<description><![CDATA[One of my previous posts showed how to use an SSH Tunnel to connect to a remote MySQL server. Since moving to Postgres I&#8217;ve been wanting to do the same thing with pgAdmin, which sadly isn&#8217;t as simple. There&#8217;s no way of creating the tunnel automatically in the app so we need to resort to [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="aligncenter" src="http://www.ur-ban.com/galleryv2/d/16194-1/pngeA9kSQrgdy.png" alt="" width="250" height="258" /></p>
<p>One of my <a href="http://www.ur-ban.com/blog/2009/10/26/why-use-phpmyadmin-when-you-can-ssh/">previous posts</a> showed how to use an SSH Tunnel to connect to a remote MySQL server. Since moving to Postgres I&#8217;ve been wanting to do the same thing with pgAdmin, which sadly isn&#8217;t as simple. There&#8217;s no way of creating the tunnel automatically in the app so we need to resort to the terminal.</p>
<p>The first step is as before, we create the SSH tunnel to our server:</p>
<pre>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; ssh -fNg -L 5555:localhost:5432 {your_username}@{yourdomain.com}</div></div>
</pre>
<p>Here I&#8217;m mapping the remote Postgres post 5432 to the local post 5555. Now this is where things start to differ. I had been trying to connect as the local &#8216;postgres&#8217; user but continually received authentication errors. You need to create a user on the server that relates to your machine&#8217;s local user. So if your local username is &#8220;foo&#8221; you need to create a user in Postgres with the same name. First log into the psql console:</p>
<pre>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; psql template1</div></div>
</pre>
<p>Then issue the commands:</p>
<pre>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; CREATE USER foo;<br />
&nbsp; ALTER USER foo WITH PASSWORD 'password';<br />
&nbsp; ALTER USER foo WITH CREATEUSER CREATEDB;</div></div>
</pre>
<p>Then in pgAdmin, simply connect with user foo and you&#8217;re good to go.</p>
<p><strong>UPDATE</strong>: I&#8217;ve since discovered this is related to IDENT authentication. Switching to PASSWORD authentication allows you to use any username/password combination.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ur-ban.com/blog/2010/10/25/ssh-tunnels-with-postgres-pgadmin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tagging in Notational Velocity</title>
		<link>http://www.ur-ban.com/blog/2010/03/18/tagging-in-notational-velocity/</link>
		<comments>http://www.ur-ban.com/blog/2010/03/18/tagging-in-notational-velocity/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 22:21:36 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[productivity]]></category>

		<guid isPermaLink="false">http://www.ur-ban.com/blog/?p=1750</guid>
		<description><![CDATA[Recently I switched from Evernote to Notational Velocity. I was so sick of the Evernote iPhone app and saw that Notational Velocity synced with Simplenote. Since trying them both out I haven&#8217;t looked back. Now, Notational Velocity supports tagging but Simplenote doesn&#8217;t, and as I like to search by tag, this was a bit of [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="alignnone" src="http://www.ur-ban.com/galleryv2/d/16145-1/notational_velocity_001.png" alt="" width="570" height="273" /></p>
<p>Recently I switched from Evernote to Notational Velocity. I was so sick of the Evernote iPhone app and saw that Notational Velocity synced with Simplenote. Since trying them both out I haven&#8217;t looked back. Now, Notational Velocity supports tagging but Simplenote doesn&#8217;t, and as I like to search by tag, this was a bit of a problem. So taking the Twitter approach, I simply hashtag my notes, which makes them incredibly easy to find in both Notational Velocity and Simplenote. I don&#8217;t put the hashtag in the name of the note but just as the first line. I found that putting the tag in the name looked a bit untidy in SimpleNote. A nice side effect is that in Simplenote, the tags appear as the preview line. Problem solved. #notationalvelocity #simplenote</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ur-ban.com/blog/2010/03/18/tagging-in-notational-velocity/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Missing menubar icons in OSX 10.6.2</title>
		<link>http://www.ur-ban.com/blog/2009/11/11/missing-menubar-icons-in-osx-10-6-2/</link>
		<comments>http://www.ur-ban.com/blog/2009/11/11/missing-menubar-icons-in-osx-10-6-2/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 11:41:00 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[osx]]></category>

		<guid isPermaLink="false">http://www.ur-ban.com/blog/?p=1238</guid>
		<description><![CDATA[A whole load of menubar icons disappeared after installing 10.6.2. Seems it&#8217;s a problem related to me doing a small hack in the past to disable Spotlight. Steven Seeger&#8217;s fix restored the menubar to it&#8217;s full glory. &#160; sudo mv /System/Library/CoreServices/Search.{bundle,bak} &#160; killall SystemUIServer]]></description>
			<content:encoded><![CDATA[<p>A whole load of menubar icons disappeared after installing 10.6.2. Seems it&#8217;s a problem related to me doing a small hack in the past to disable Spotlight. <a href="http://discussions.apple.com/thread.jspa?messageID=10558343">Steven Seeger&#8217;s fix</a> restored the menubar to it&#8217;s full glory.</p>
<pre>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; sudo mv /System/Library/CoreServices/Search.{bundle,bak}<br />
&nbsp; killall SystemUIServer</div></div>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ur-ban.com/blog/2009/11/11/missing-menubar-icons-in-osx-10-6-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Essential reading for developers</title>
		<link>http://www.ur-ban.com/blog/2009/11/08/essential-reading/</link>
		<comments>http://www.ur-ban.com/blog/2009/11/08/essential-reading/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 15:26:01 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[books]]></category>

		<guid isPermaLink="false">http://www.ur-ban.com/blog/?p=1229</guid>
		<description><![CDATA[I&#8217;ve been meaning to write up a list of what books I think every developer, aspiring or seasoned should read. So let&#8217;s cut to the chase, and in no particular order: Code Complete If there was ever a bible for coding, this is it. It&#8217;s even Bible sized. A nice size to chuck at those [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been meaning to write up a list of what books I think every developer, aspiring or seasoned should read. So let&#8217;s cut to the chase, and in no particular order:</p>
<p style="text-align: center;"><img class="aligncenter" src="http://images.ur-ban.com/galleryv2/d/16120-1/code_complete.png" alt="" width="150" height="183" /></p>
<p><strong>Code Complete</strong><br />
If there was ever a bible for coding, this is it. It&#8217;s even Bible sized. A nice size to chuck at those annoying developers who just have no clue.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://images.ur-ban.com/galleryv2/d/16118-1/clean_code.png" alt="" width="150" height="199" /></p>
<p><strong>Clean Code</strong><br />
I would consider this book the &#8220;Ten Commandments&#8221; of coding and compliments Code Complete very very very well. If Code Complete teaches you how to be a Christian, then Clean Code teaches you how to be Jesus.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://images.ur-ban.com/galleryv2/d/16122-1/refactoring_to_patterns.png" alt="" width="150" height="202" /></p>
<p><strong>Refactoring to Patterns</strong><br />
What I love about this book is that it you learn the fundamentals of refactoring at the same time as design patterns. The GoF Design Patterns book is quite heavy going. The examples aren&#8217;t well laid out and can be confusing especially if you&#8217;re not familiar with SmallTalk The examples in refactoring to patterns all take pretty familiar real world bits of code and walk you through the process of refactoring them into sensible patterns.</p>
<p>Three books? Is that it? Yup. In my mind those are the only three books that are essential reading, no matter what form of development you do. If you even remotely care about coding, then go to Amazon now and buy these books. Read them and take a good long hard look at your own code. If on the other hand you feel &#8220;You can&#8217;t be bothered&#8221; to read, learn and improve, then why are you doing something you don&#8217;t love or care about? You&#8217;re in the wrong industry if you&#8217;re not prepared to take time, all the time, to learn new things. Once you&#8217;ve read those, then you&#8217;re ready to move onto more specialised books. Here are some of my other favourite development books from over the years:</p>
<p>The Productive Programmer<br />
The Art of Agile Development<br />
Practices of an Agile Developer<br />
Joel on Software<br />
Unix Power Tools<br />
Programming Perl<br />
Essential Java<br />
Well Grounded Rubyist<br />
Design Patterns in Ruby<br />
CSS Mastery<br />
Prioritizing Web Usability</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ur-ban.com/blog/2009/11/08/essential-reading/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t use PHPMyAdmin. SSH tunnel instead.</title>
		<link>http://www.ur-ban.com/blog/2009/10/26/why-use-phpmyadmin-when-you-can-ssh/</link>
		<comments>http://www.ur-ban.com/blog/2009/10/26/why-use-phpmyadmin-when-you-can-ssh/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 21:10:36 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.ur-ban.com/blog/?p=1202</guid>
		<description><![CDATA[If you&#8217;re still using phpMyAdmin to admin your remote database, then you&#8217;re doing it wrong. Don&#8217;t expose your database to the outside world like this, instead use a SSH tunnel. In your terminal simply create the tunnel: ssh -fNg -L 8888:127.0.0.1:3306 {your_username}@{yourdomain.com} Then in your MySQL interface of choice just connect to 127.0.0.1 port 8888 [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re still using phpMyAdmin to admin your remote database, then you&#8217;re doing it wrong. Don&#8217;t expose your database to the outside world like this, instead use a SSH tunnel. In your terminal simply create the tunnel:</p>
<pre class="textmate-source"><span class="source source_shell">  ssh -fNg -L 8888:127.0.0.1:3306 {your_username}@{yourdomain.com}</span></pre>
<p>Then in your MySQL interface of choice just connect to 127.0.0.1 port 8888 and voila, you&#8217;ll be connected to your remote database.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://images.ur-ban.com/galleryv2/d/16112-1/ssh-tunnel-1.png" alt="" width="395" height="320" /></p>
<p>Apps like Querious even let you setup the connection internally without having to tunnel through in Terminal.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://images.ur-ban.com/galleryv2/d/16116-1/ssh-tunnel-2.png" alt="" width="410" height="491" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ur-ban.com/blog/2009/10/26/why-use-phpmyadmin-when-you-can-ssh/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Law of Demeter and the delegate method</title>
		<link>http://www.ur-ban.com/blog/2009/10/25/law-of-demeter-and-the-delegate-method/</link>
		<comments>http://www.ur-ban.com/blog/2009/10/25/law-of-demeter-and-the-delegate-method/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 13:02:52 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[bestpractice]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.ur-ban.com/blog/?p=1193</guid>
		<description><![CDATA[The Law of Demeter, or Principle of Least Knowledge is a fairly simple design pattern, which, simply put means that an object should only talk to it&#8217;s immediate &#8220;friends&#8221; The law states that a method M of and object O may only invoke the methods of the following kind: 1. a method on O itself [...]]]></description>
			<content:encoded><![CDATA[<p>The Law of Demeter, or Principle of Least Knowledge is a fairly simple design pattern, which, simply put means that an object should only talk to it&#8217;s immediate &#8220;friends&#8221;</p>
<p>The law states that a method M of and object O may only invoke the methods of the following kind:</p>
<p>1. a method on O itself<br />
2. any parameters passed to M<br />
3. any objects instantiated within M<br />
4. any direct components of O</p>
<p>The classic example coined by David Bock used a Paperboy (one object) delivering a paper, then extracting money from a Customer&#8217;s (another object) Wallet (and another):</p>
<pre class="textmate-source"><span class="source source_ruby"><span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Paperboy</span></span>
    <span class="meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">get_payment</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">(</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_ruby">customer</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">)</span></span>
      <span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>money <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_augmented keyword_operator_assignment_augmented_ruby">+=</span> customer<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>wallet<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>take_out<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_numeric constant_numeric_ruby">10</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
    <span class="keyword keyword_control keyword_control_ruby">end</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>In the &#8220;real world&#8221; the Paperboy would ask the customer for the money who would then take it out for them, rather then the Paperboy reaching into the customer&#8217;s back pocket and getting it for themself.</p>
<p>Really we want something as follows:</p>
<pre class="textmate-source"><span class="source source_ruby"><span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Paperboy</span></span>
    <span class="meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">get_payment</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">(</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_ruby">customer</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">)</span></span>
      <span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>money <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_augmented keyword_operator_assignment_augmented_ruby">+=</span> customer<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>get_payment<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_numeric constant_numeric_ruby">10</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
    <span class="keyword keyword_control keyword_control_ruby">end</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span>

<span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Customer</span></span>
    <span class="meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">get_payment</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">(</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_ruby">amount</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">)</span></span>
      wallet<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>take_out<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_numeric constant_numeric_ruby">10</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
    <span class="keyword keyword_control keyword_control_ruby">end</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>This may all seem trivial and a waste of time, but what happens if some Customers want to pay by cheque? Those decisions should have an impact on the Paperboy, otherwise we end up with:</p>
<pre class="textmate-source"><span class="source source_ruby"><span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Paperboy</span></span>
    <span class="meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">get_payment</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">(</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_ruby">customer</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">)</span></span>
      <span class="keyword keyword_control keyword_control_ruby">if</span> customer<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>pay_by_cash?
        <span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>money <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_augmented keyword_operator_assignment_augmented_ruby">+=</span> customer<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>wallet<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>take_out<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_numeric constant_numeric_ruby">10</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
      <span class="keyword keyword_control keyword_control_ruby">elsif</span> customer<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>pay_by_cheque?
        <span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>money <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_augmented keyword_operator_assignment_augmented_ruby">+=</span> customer<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>cheque_book<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>write_cheque<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_numeric constant_numeric_ruby">10</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
      <span class="keyword keyword_control keyword_control_ruby">end</span>
    <span class="keyword keyword_control keyword_control_ruby">end</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>Where as it makes more sense for the change to be contained within the Customer:</p>
<pre class="textmate-source"><span class="source source_ruby"><span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Paperboy</span></span>
    <span class="meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">get_payment</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">(</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_ruby">customer</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">)</span></span>
      <span class="variable variable_language variable_language_ruby">self</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>money <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_augmented keyword_operator_assignment_augmented_ruby">+=</span> customer<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>get_payment<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_numeric constant_numeric_ruby">10</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
    <span class="keyword keyword_control keyword_control_ruby">end</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span>

<span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Customer</span></span>
    <span class="meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">get_payment</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">(</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_ruby">amount</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">)</span></span>
      <span class="keyword keyword_control keyword_control_ruby">if</span> pay_by_cash?
        wallet<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>take_out<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_numeric constant_numeric_ruby">10</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
      <span class="keyword keyword_control keyword_control_ruby">elsif</span> pay_by_cheque?
        cheque_book<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>write_cheque<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_numeric constant_numeric_ruby">10</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
      <span class="keyword keyword_control keyword_control_ruby">end</span>
    <span class="keyword keyword_control keyword_control_ruby">end</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>So what does this have to do with Rails and the delegate method? The delegate method adds a quick and simple way of following the Law of Demeter without having to do very much at all.</p>
<pre class="textmate-source"><span class="source source_ruby"><span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Order</span></span>
    belongs_to <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>customer</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span>

<span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Customer</span></span>
    has_many <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>orders</span>
    has_one <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>credit_card</span>
    has_one <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>bank_account</span>

    <span class="meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">payment_method</span></span>
      <span class="keyword keyword_control keyword_control_ruby">if</span> pay_by_card?
        credit_card
      <span class="keyword keyword_control keyword_control_ruby">elsif</span> pay_by_account?
        bank_account
      <span class="keyword keyword_control keyword_control_ruby">end</span>
    <span class="keyword keyword_control keyword_control_ruby">end</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span>

<span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">CreditCard</span></span>
    belongs_to <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>customer</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span>

<span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">BankAccount</span></span>
    belongs_to <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>customer</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>This setup means to get an Order&#8217;s payment we would have to say:</p>
<pre class="textmate-source"><span class="source source_ruby">  <span class="variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby">@</span>order</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>customer<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>payment_method<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>withdraw<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span>amount<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span></span></pre>
<p>But if we simply change our objects as such:</p>
<pre class="textmate-source"><span class="source source_ruby"><span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Order</span></span>
    belongs_to <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>customer</span>
    delegate <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>withdraw_payment</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>to</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>customer</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span>

<span class="meta meta_class meta_class_ruby">  <span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Customer</span></span>
    has_many <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>orders</span>
    has_one <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>credit_card</span>
    has_one <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>bank_account</span>

    <span class="meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">withdraw_payment</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">(</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_ruby">amount</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">)</span></span>
      <span class="keyword keyword_control keyword_control_ruby">if</span> pay_by_card?
        credit_card<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>withdraw<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span>amount<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
      <span class="keyword keyword_control keyword_control_ruby">elsif</span> pay_by_account?
        bank_account<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>withdraw<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span>amount<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
      <span class="keyword keyword_control keyword_control_ruby">end</span>
    <span class="keyword keyword_control keyword_control_ruby">end</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>Now all we have to say is:</p>
<pre class="textmate-source"><span class="source source_ruby">  <span class="variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby">@</span>order</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>withdraw_payment<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span>amount<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span></span></pre>
<p>So at any time, the details of how a payment  is to be decided can be contained with the Customer. This is of course a simplistic example, but hopefully explains how you chould be using this handy feature.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ur-ban.com/blog/2009/10/25/law-of-demeter-and-the-delegate-method/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>From TextMate to Vim</title>
		<link>http://www.ur-ban.com/blog/2009/10/24/from-textmate-to-vim/</link>
		<comments>http://www.ur-ban.com/blog/2009/10/24/from-textmate-to-vim/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 16:00:43 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[computing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://www.ur-ban.com/blog/?p=1179</guid>
		<description><![CDATA[I&#8217;ve finally done it. After months and months of on-off usage of Vim, I&#8217;m now finally using it 100% of the time. It&#8217;s been a long and hard road getting here, but let me tell you, it&#8217;s been well worth it. I now feel like I absolutely fly through my code. I&#8217;ve read many a [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="aligncenter" src="http://images.ur-ban.com/galleryv2/d/16110-1/vim.png" alt="" width="550" height="352" /></p>
<p>I&#8217;ve finally done it. After months and months of on-off usage of Vim, I&#8217;m now finally using it 100% of the time. It&#8217;s been a long and hard road getting here, but let me tell you, it&#8217;s been well worth it. I now feel like I absolutely fly through my code. I&#8217;ve read many a time, people saying that watching someone using Vim is like watching something mystical, and I can see why. Looking at how I edit code in Vim now, makes me feel clumsy when I think back to using other editors like TextMate. Don&#8217;t get me wrong, TextMate is a wonderful editor, but there is just something about the speed and finesse of editing in Vim which I have just fallen in love with.</p>
<p>I wrote about trying MacVim before and how I just felt it lacked the spit and polish that TextMate does. But now, I can&#8217;t remember why I originally felt that way. There&#8217;s a simple elegance to the Vim, yet with this awesome power available to you. Switching wasn&#8217;t easy in the slightest. I would load Vim up for an hour, tinker around, get frustrated and go back to Textmate. Then a month later I&#8217;d try again, learn a new command, last two hours and go back to TextMate. A few more months and hours turned into a full day, then the full day turned into a couple of days, and then I never looked back.</p>
<p>One of the keys to hitting the ground running is having a good config. I originally used <a href="http://github.com/jferris/config_files">jferris</a>&#8216;s vimfiles but moved to <a href="http://github.com/scrooloose/vimfiles">scrooloose&#8217;s</a> files not long ago. It practically has every plugin you could ever need to make life in Vim sublime.</p>
<p>Some other handy references I&#8217;ve used along the way have been vimtutor, the Vim Recipies Cookbook, the Vim Tips Wiki. To aid my own memory of useful commands I&#8217;ve even started my own <a href="http://vimstuff.tumblr.com/">Vim tumblr</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ur-ban.com/blog/2009/10/24/from-textmate-to-vim/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.600 seconds -->

