<?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>iamhigham.com</title>
	<atom:link href="http://iamhigham.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://iamhigham.com</link>
	<description>adventures of a software developer</description>
	<lastBuildDate>Sat, 16 Jul 2011 19:43:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Personalised URL shortener (in Ruby)</title>
		<link>http://iamhigham.com/2011/07/personalised-url-shortener-in-ruby/</link>
		<comments>http://iamhigham.com/2011/07/personalised-url-shortener-in-ruby/#comments</comments>
		<pubDate>Sat, 16 Jul 2011 19:43:19 +0000</pubDate>
		<dc:creator>danhigham</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://iamhigham.com/?p=153</guid>
		<description><![CDATA[Quick one! Bought the domain high.am the other day, vain I know! Anyway, decided one of the must haves for said domain was a decent URL shortener. Created a shortener based on some PHP code found at http://high.am/rnhyi4, running it on Passenger using Redis for storage. https://github.com/danhigham/URL-Shortener]]></description>
			<content:encoded><![CDATA[<p>Quick one! Bought the domain high.am the other day, vain I know! Anyway, decided one of the must haves for said domain was a decent URL shortener. </p>
<p>Created a shortener based on some PHP code found at <a href="http://high.am/rnhyi4">http://high.am/rnhyi4</a>, running it on Passenger using Redis for storage.</p>
<p><a href="https://github.com/danhigham/URL-Shortener">https://github.com/danhigham/URL-Shortener</a></p>
]]></content:encoded>
			<wfw:commentRss>http://iamhigham.com/2011/07/personalised-url-shortener-in-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Say hello to &#8220;Deskimus Prime&#8221;</title>
		<link>http://iamhigham.com/2011/05/say-hello-to-deskimus-prime/</link>
		<comments>http://iamhigham.com/2011/05/say-hello-to-deskimus-prime/#comments</comments>
		<pubDate>Thu, 12 May 2011 15:01:17 +0000</pubDate>
		<dc:creator>danhigham</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://iamhigham.com/?p=147</guid>
		<description><![CDATA[Okay, so for a while now I had heard standing desks were a really good thing and I have had, for quite some time, an IKEA desk more than capable of this. After seeing @ollylegg transform his office desk with coke cans I decided to take the plunge. So, @first65, I will see your &#8220;Megadesk&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so for a while now I had heard standing desks were a really good thing and I have had, for quite some time, an IKEA desk more than capable of this.</p>
<p>After seeing @ollylegg <a href="http://wildfalcon.com/archives/2011/05/12/standing-room-only-a-new-use-for-coke-cans/">transform</a> his office desk with coke cans I decided to take the plunge. So, @first65, I will see your &#8220;Megadesk&#8221; and raise it (quite literally). </p>
<p>Ladies and Gents, I give you, Deskimus Prime.</p>
<p><img src="http://iamhigham.com/wp-content/uploads/2011/05/DeskimusPrime.jpg"></p>
]]></content:encoded>
			<wfw:commentRss>http://iamhigham.com/2011/05/say-hello-to-deskimus-prime/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Deserializing classes in Ruby using YAML.load</title>
		<link>http://iamhigham.com/2011/05/deserializing-classes-in-ruby-using-yaml-load/</link>
		<comments>http://iamhigham.com/2011/05/deserializing-classes-in-ruby-using-yaml-load/#comments</comments>
		<pubDate>Thu, 12 May 2011 09:53:20 +0000</pubDate>
		<dc:creator>danhigham</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://iamhigham.com/?p=141</guid>
		<description><![CDATA[Quick note: when using YAML.load to deserialize an instance of a class that was serialized using to_yaml may end up not working! I have an object called ApplicationProvision, call to_yaml and it looks like this ; "--- !ruby/object:ApplicationProvision \nconfiguration: \n- !ruby/object:InstantStack::StackConfigurationOption \n default_value: NginX\n possible_values: \n - Apache\n - NginX\n question_key: web_server\n question_text: Do you [...]]]></description>
			<content:encoded><![CDATA[<p>Quick note: when using YAML.load to deserialize an instance of a class that was serialized using to_yaml may end up not working! I have an object called ApplicationProvision, call to_yaml and it looks like this ;<br />
<code><br />
"--- !ruby/object:ApplicationProvision \nconfiguration: \n- !ruby/object:InstantStack::StackConfigurationOption \n  default_value: NginX\n  possible_values: \n  - Apache\n  - NginX\n  question_key: web_server\n  question_text: Do you want to host from Apache or NginX?\n  question_type: multiple_choice\n  response_value: NginX\n- !ruby/object:InstantStack::StackConfigurationOption \n  default_value: MySQL\n  possible_values: \n  - MySQL\n  - SQLite\n  question_key: db_server\n  question_text: Do you want to host the database from MySQL or SQLite?\n  question_type: multiple_choice\n  response_value: MySQL\nguid: 993b9956-df61-4612-a8b4-c71937603467\nprevious_stage: 5\nregion: 1\nsize: 4\nstack: 21\nstate: :configured\n"<br />
</code> .. perfect</p>
<p>However deserialized, it looks like this;<br />
<code><br />
#&lt;ApplicationProvision:0x105716000<br />
 @class="ApplicationProvision",<br />
 @ivars=<br />
  {"region"=&gt;1,<br />
   "stack"=&gt;21,<br />
   "size"=&gt;4,<br />
   "previous_stage"=&gt;5,<br />
   "guid"=&gt;"993b9956-df61-4612-a8b4-c71937603467",<br />
   "configuration"=&gt;<br />
    [#&lt;InstantStack::StackConfigurationOption:0x105717540<br />
      @default_value="NginX",<br />
      @possible_values=["Apache", "NginX"],<br />
      @question_key="web_server",<br />
      @question_text="Do you want to host from Apache or NginX?",<br />
      @question_type="multiple_choice",<br />
      @response_value="NginX"&gt;,<br />
     #&lt;InstantStack::StackConfigurationOption:0x1057169d8<br />
      @default_value="MySQL",<br />
      @possible_values=["MySQL", "SQLite"],<br />
      @question_key="db_server",<br />
      @question_text="Do you want to host the database from MySQL or SQLite?",<br />
      @question_type="multiple_choice",<br />
      @response_value="MySQL"&gt;],<br />
   "state"=&gt;:configured}&gt;<br />
</code></p>
<p>Not good! Little bit of reading around this problem and I found this <a href="http://stackoverflow.com/questions/4705867/rails-doesnt-load-classes-on-deserializing-yaml-marshal-objects">post</a> on StackOverflow.</p>
<p>Add a require_dependency at the top of the class in context and everything works fine</p>
<p><code></p>
<p>#&lt;ApplicationProvision:0x10585aec0<br />
 @configuration=<br />
  [#&lt;InstantStack::StackConfigurationOption:0x10585c400<br />
    @default_value="NginX",<br />
    @possible_values=["Apache", "NginX"],<br />
    @question_key="web_server",<br />
    @question_text="Do you want to host from Apache or NginX?",<br />
    @question_type="multiple_choice",<br />
    @response_value="NginX"&gt;,<br />
   #&lt;InstantStack::StackConfigurationOption:0x10585b898<br />
    @default_value="MySQL",<br />
    @possible_values=["MySQL", "SQLite"],<br />
    @question_key="db_server",<br />
    @question_text="Do you want to host the database from MySQL or SQLite?",<br />
    @question_type="multiple_choice",<br />
    @response_value="MySQL"&gt;],<br />
 @guid="993b9956-df61-4612-a8b4-c71937603467",<br />
 @previous_stage=5,<br />
 @region=1,<br />
 @size=4,<br />
 @stack=21,<br />
 @state=:configured&gt;<br />
</code></p>
<p>et voila!</p>
]]></content:encoded>
			<wfw:commentRss>http://iamhigham.com/2011/05/deserializing-classes-in-ruby-using-yaml-load/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vimeo &#8220;Watch Later&#8221; RSS feeds</title>
		<link>http://iamhigham.com/2011/03/vimeo-watch-later-rss-feeds/</link>
		<comments>http://iamhigham.com/2011/03/vimeo-watch-later-rss-feeds/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 14:57:27 +0000</pubDate>
		<dc:creator>danhigham</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://iamhigham.com/?p=125</guid>
		<description><![CDATA[I am a big fan of Vimeo, the content is great and the site is really nice too. Having bought a Boxee box a few months ago I have been getting more and more in to watching online content on my TV at home. Last night I started to add some RSS feeds from Vimeo, [...]]]></description>
			<content:encoded><![CDATA[<p>I am a big fan of Vimeo, the content is great and the site is really nice too. Having bought a Boxee box a few months ago I have been getting more and more in to watching online content on my TV at home. Last night I started to add some RSS feeds from Vimeo, I started off by adding one particular person and then a group etc. </p>
<p>What I really wanted to do was to mark stuff for viewing at home in the evening, during the day, the watch later feature in Vimeo is perfect for this. To my horror there was no way of consuming these on the boxee as there is no RSS feed for &#8220;watch later&#8221;, at that point the only alternative was to like a video and then use the &#8220;likes&#8221; RSS feed, but that seemed a bit backwards, liking a video before I had even watched it, no thanks!</p>
<p>So, having the afternoon free today I knocked up a simple app using Sinatra to do the oauth dance with Vimeo and then make your watch later album publicly available forever more as RSS. Head on over to <a href="http://vimeowatchlater.heroku.com">http://vimeowatchlater.heroku.com</a> and follow the instructions, it&#8217;s pretty simple. Check out my watch later feed at  <a href="http://vimeowatchlater.heroku.com/danhigham">http://vimeowatchlater.heroku.com/danhigham</a>.</p>
<p>NOTE: This is hosted on heroku and I have been forced to store data in /tmp! You may have to re-auth against vimeo with a browser every once in a while or maybe not!</p>
<p>Thanks goes to matthooks for his gem at <a href="https://github.com/matthooks/vimeo">https://github.com/matthooks/vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://iamhigham.com/2011/03/vimeo-watch-later-rss-feeds/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Managing CoffeeScript in Sinatra / Ruby</title>
		<link>http://iamhigham.com/2011/03/managing-coffeescript-in-sinatra-ruby/</link>
		<comments>http://iamhigham.com/2011/03/managing-coffeescript-in-sinatra-ruby/#comments</comments>
		<pubDate>Sat, 26 Mar 2011 11:42:23 +0000</pubDate>
		<dc:creator>danhigham</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://iamhigham.com/?p=95</guid>
		<description><![CDATA[Over the last couple of weeks I have been working on a project for a client that involved building a couple of small applications in Sinatra (a light web framework for Ruby). Both applications have a RESTful interface, as is the nature of Sinatra, and a javascript frontend using jQuery to make asynchronous requests. I [...]]]></description>
			<content:encoded><![CDATA[<p>Over the last couple of  weeks I have been working on a project for a client that involved building a couple of small applications in Sinatra (a light web framework for Ruby). Both applications have a RESTful interface, as is the nature of Sinatra, and a javascript frontend using jQuery to make asynchronous requests. I made the decision to run with CoffeeScript as it makes creating js classes a doddle and keeps the client side code readable and uniform in style.</p>
<p>Originally I had stuck to one big coffee script file, but this began to grow a little out of control as the functionality of the app expanded, so I decided to break things up. Using the coffee-script gem, I just added a couple more coffee script files, one for my classes and one for general utility type functions. Two problems quickly made themselves apparent;</p>
<p>1. Coffeescript, by default, generates javascript files inside a closed scope. Not sure this is the correct way to phrase it, but I will show you what I mean. All the javascript it generates is enclosed in this <code>(function() { ... }).call(this);</code>, this effectively places everything inside its own scope, which means if you define a class for use by the application it won&#8217;t be accessible by anything unless its defined in the same .coffeescript file. The coffeescript compiler has an option to remove these called &#8211;bare, I needed to make sure that is run for class type coffeescript files.</p>
<p>2. I found that for some reason (at least in OS X) when Ruby tried to compile more than one coffeescript at a time, it would choke. I was using the &#8220;therubyracer&#8221; gem along with &#8220;coffee-script&#8221;, so I assume the coffee-script gem was using V8 to compile the javascript. As you can imagine, when the page was initially loaded several requests were made for .js files that were actually the compiled output of a coffeescript file, the Ruby process would end up at 100%, choked!</p>
<p>Whats more, there is really no real need to have the coffee-script compiler involved at all in a production environment, so here is what I wanted to do. When the application was run in development, generate and cache the javascript files, that way I could deploy those to live and when it was run in production skip the coffee-script part of the application all together. I started off by swapping out just using the coffee-script gem and opted if for a Rack filter called rack-coffee, git repo is <a href="https://github.com/mattly/rack-coffee">here</a> and my fork of it is <a href="https://github.com/danhigham/rack-coffee">here</a>. This gem, rather than compiling the coffeescript from the Sinatra application itself, will do it when Rack is handling the initial request for the .js file, it&#8217;s a pretty straight forward class and does the job very nicely, handing compilation of the coffeescript off to the command line compiler itself.</p>
<p>At that point, rack-coffee never actually compiled the script to the filesystem, just to STDOUT when it was out of date or returned a 304 (Not Modified) if it was in date. So, first step, cache to the filesystem. Below you can see the changes I made to rack-coffee;</p>
<p><iframe src="https://github.com/danhigham/rack-coffee/commit/0901691a37428936f42c249828c878ec122044d2#diff-0" style="border:none; width:100%; height : 300px;"></iframe></p>
<p>The main two changes to notice are firstly the brew function, that now waits for the coffee-script command to finish running and the changes to the call function that add the &#8211;bare parameter if its compiling a file in the set class_urls path and also read the compiled .js file and return it as the output for the Rack request.</p>
<p>So from then on, every time the app compiled a coffee-script file it would leave a compile .js file in the path set by the output_path setting. To use this in a sinatra application we would include it like so;</p>
<p>[ruby]<br />
use Rack::Coffee, {<br />
    :root => File.dirname(__FILE__) + &#8216;/coffee&#8217;,<br />
    :urls => &#8216;/app_scripts&#8217;,<br />
    :class_urls => &#8216;/app_scripts/classes&#8217;,<br />
    &#58;output_path => &#8216;/public&#8217;<br />
  }<br />
[/ruby]</p>
<p>Assuming that coffee-script and indeed the rack-coffee library is referenced correctly, every time a .js file is requested from either /app_scripts or /app_scripts/classes it compiles and stores a javascript file to the output_path without or with the &#8211;bare flag respectively. The :root parameter shows the library where to find the actual coffee-script source. </p>
<p>So all that is left now is to tell Sinatra to skip this Rack filter when in production mode, this is easy! I use bundler, so my Gemfile looks like this;</p>
<p>[ruby]<br />
source &#8216;http://rubygems.org&#8217;</p>
<p>group :development do<br />
  gem &#8216;coffee-script&#8217;<br />
  gem &#8216;rack-coffee&#8217;<br />
  gem &#8216;therubyracer&#8217;<br />
end</p>
<p>group :default do<br />
  gem &#8216;sinatra&#8217;<br />
  gem &#8216;json&#8217;<br />
  gem &#8216;oauth&#8217;<br />
  gem &#8216;mechanize&#8217;<br />
  gem &#8216;multipart-post&#8217;<br />
end<br />
[/ruby]</p>
<p>So, here we can see all the coffeescript libs are only required in a development environment. As for the application itself, just pop an if statement round your call to use the Rack filter, like this;</p>
<p>[ruby]<br />
if ENV['RACK_ENV'].to_sym == :development<br />
  puts &#8220;This is development, all coffeescripts are generated&#8230;&#8221;</p>
<p>  require &#8216;coffee-script&#8217;<br />
  require File.dirname(__FILE__) + &#8216;/lib/coffee&#8217;</p>
<p>  use Rack::Coffee, {<br />
    :root => File.dirname(__FILE__) + &#8216;/coffee&#8217;,<br />
    :urls => &#8216;/app_scripts&#8217;,<br />
    :class_urls => &#8216;/app_scripts/classes&#8217;,<br />
    &#58;output_path => &#8216;/public&#8217;<br />
  }<br />
end<br />
[/ruby]</p>
<p>There we have it, a simple set up to compile coffeescript in development but fallback to the cached js output in production. This of course is just <strong><em>my</em></strong> solution, if you have an even better one, then please feel free to let me know.</p>
<p>UPDATE : Having spoken on Twitter with the creator of CoffeeScript, @jashkenas, I learnt that rather than using &#8211;bare to expose my classes to the Global scope, its better just to expose the interface by declaring them using the browser &#8216;window&#8217; object. Like this;</p>
<p>[ruby]<br />
class window.MyClass</p>
<p>  say_hello: () -><br />
    alert &#8216;hello&#8217;<br />
[/ruby]</p>
<p>This would still be referable in javascript as simply &#8216;MyClass&#8217;, much better!</p>
]]></content:encoded>
			<wfw:commentRss>http://iamhigham.com/2011/03/managing-coffeescript-in-sinatra-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First jQuery extension method, in CoffeeScript!</title>
		<link>http://iamhigham.com/2011/02/first-jquery-extension-method-in-coffeescript/</link>
		<comments>http://iamhigham.com/2011/02/first-jquery-extension-method-in-coffeescript/#comments</comments>
		<pubDate>Thu, 10 Feb 2011 12:02:01 +0000</pubDate>
		<dc:creator>danhigham</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://iamhigham.com/?p=85</guid>
		<description><![CDATA[I have never been one to write extension methods in jQuery, I suppose that&#8217;s because I have not written anything that hasn&#8217;t already been done already or it&#8217;s just not useful! I have been getting in to using CoffeeScript recently and having written a quick extension for Radiant to allow its use, and also integrating [...]]]></description>
			<content:encoded><![CDATA[<p>I have never been one to write extension methods in jQuery, I suppose that&#8217;s because I have not written anything that hasn&#8217;t already been done already or it&#8217;s just not useful!</p>
<p>I have been getting in to using CoffeeScript recently and having written a quick extension for Radiant to allow its use, and also integrating the wonderful Ace editor I decided to do a quick post just to show how effective it can be. CoffeeScript is mark down for Javascript, two advantages to using it;</p>
<p>It reduces the overall amount of code you have to write,<br />
it increases the consistency of the resulting javascript code although there is still an onus on the author to keep things tidy.</p>
<p>I wanted to write a small extension method to find divs with a certain class, date parse the content of the div, change the content to just the day and then apply a style based on the month.</p>
<p>Here is the CoffeeScript;</p>
<p>[javascript]# jQuery function to change a div with a date in it in to a calendar<br />
jQuery.fn.calendarify = () -><br />
  month_names = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']</p>
<p>  for cal_span in this<br />
    do (cal_span) -><br />
      if !$(cal_span).hasClass &#8216;mini-calendar&#8217;</p>
<p>        # assign generic calendar css class to span<br />
        $(cal_span).addClass &#8216;mini-calendar&#8217;</p>
<p>        date = new Date cal_span.innerText<br />
        month = date.getMonth()<br />
        day = date.getDate()</p>
<p>        $(cal_span).addClass month_names[month]<br />
        cal_span.innerText = day</pre>
<p></code><br />
[/javascript]<br />
And now for the generated javascript;</p>
<p>[javascript]<br />
jQuery.fn.calendarify = function() {<br />
    var cal_span, month_names, _i, _len, _results;<br />
    month_names = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'];<br />
    _results = [];<br />
    for (_i = 0, _len = this.length; _i < _len; _i++) {<br />
      cal_span = this[_i];<br />
      _results.push((function(cal_span) {<br />
        var date, day, month;<br />
        if (!$(cal_span).hasClass('mini-calendar')) {<br />
          $(cal_span).addClass('mini-calendar');<br />
          date = new Date(cal_span.innerText);<br />
          month = date.getMonth();<br />
          day = date.getDate();<br />
          $(cal_span).addClass(month_names[month]);<br />
          return cal_span.innerText = day;<br />
        }<br />
      })(cal_span));<br />
    }<br />
    return _results;<br />
  };[/javascript]</p>
<p>I certainly prefer the former, obviously there is the occasional problem that markdown languages present but even then you can fallback and place normal javascript blocks inline with your coffeescript. </p>
<p>CoffeeScript lives <a href="http://jashkenas.github.com/coffee-script/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://iamhigham.com/2011/02/first-jquery-extension-method-in-coffeescript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Database backed DNS server in Ruby</title>
		<link>http://iamhigham.com/2011/02/database-backed-dns-server-in-ruby/</link>
		<comments>http://iamhigham.com/2011/02/database-backed-dns-server-in-ruby/#comments</comments>
		<pubDate>Thu, 03 Feb 2011 14:29:36 +0000</pubDate>
		<dc:creator>danhigham</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://iamhigham.com/?p=78</guid>
		<description><![CDATA[Wether you want to be able to register silly domain names like check.out.this.silly.domain.iamhigham.com or you wish to create domain entries programmatically, the following handy piece of Ruby is for you. One of the reasons I enjoy using Ruby so much is the wider community&#8217;s passion for creating just about anything in this awesome language, for [...]]]></description>
			<content:encoded><![CDATA[<p>Wether you want to be able to register silly domain names like check.out.this.silly.domain.iamhigham.com or you wish to create domain entries programmatically, the following handy piece of Ruby is for you. </p>
<p>One of the reasons I enjoy using Ruby so much is the wider community&#8217;s passion for creating just about anything in this awesome language, for example <a href="http://www.oriontransfer.co.nz/software/ruby-dns/index">RubyDNS</a> by OrionTransfer. Looking at the example on the aforementioned link you can see a a fully daemonised DNS server which can resolve anything you can throw at it.</p>
<p>It doesn&#8217;t take a total genius (me!) to then integrate a very simple collection queried from MongoDB using the &#8220;mongo&#8221; gem and add a few more &#8220;transaction.respond!&#8221; statements&#8230;</p>
<p>[ruby]<br />
db = Connection.new.db(&#8216;dnsstore&#8217;)<br />
entries = db.collection(&#8216;dnsentries&#8217;)</p>
<p>entries.find().each do |entry|<br />
    puts &#8220;Matching entry #{entry['domain']}&#8221;</p>
<p>    match(entry["domain"], :A) do |transaction|<br />
        transaction.respond!(entry["host"])<br />
    end<br />
end<br />
[/ruby]</p>
<p>Add this to the code on the examples page to form a DNS server that loads records from a database on start-up!</p>
<p>Add an entry to my servers IP tables for UDP:53 and were done. All I need to do now is wait for my registrar to register ns1.tactusworks.com as a name server! Let me check&#8230;. nope, nothing <img src='http://iamhigham.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />  </p>
<p>Go ahead though, try it, open up bash, run nslookup tell it which nameserver to use;</p>
<p><code>server www.tactusworks.com</code></p>
<p>and then just type in a domain to check, any old domain name is from my datacenter&#8217;s DNS server and dev.rackableapps.com is from the Ruby DNS server! </p>
]]></content:encoded>
			<wfw:commentRss>http://iamhigham.com/2011/02/database-backed-dns-server-in-ruby/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Heroku: I was a little slow on the bandwagon, but I like, a lot!</title>
		<link>http://iamhigham.com/2011/01/heroku-i-was-a-little-slow-on-the-bandwagon-but-i-like-a-lot/</link>
		<comments>http://iamhigham.com/2011/01/heroku-i-was-a-little-slow-on-the-bandwagon-but-i-like-a-lot/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 00:13:51 +0000</pubDate>
		<dc:creator>danhigham</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://iamhigham.com/?p=72</guid>
		<description><![CDATA[Seems I have been a little slow to pick up on just how awesome Heroku is. I have been aware of it for a while but was never really bothered enough to take a proper look. Having done so, I am glad I have! I decided to just do a quick app to host a [...]]]></description>
			<content:encoded><![CDATA[<p>Seems I have been a little slow to pick up on just how awesome Heroku is. I have been aware of it for a while but was never really bothered enough to take a proper look. Having done so, I am glad I have!</p>
<p>I decided to just do a quick app to host a piece of code I put in to a Radiant extension a few weeks back to make previews of image collections, photo album style. I created the application locally, committing merrily to my local Git repo and occasionally pushing to GitHub as normal, signed in to Heroku and created an application, which was too easy! </p>
<p>After creating the application on Heroku itself, it&#8217;s a case of installing the Heroku gem and adding Heroku as a Git remote node. All thats left is to push to Heroku, that&#8217;s it, nothing else, the application is deployed! Heroku even has a post push hook in Git to make sure it detects any new gems you may have added to your Gemfile file since your last push. </p>
<p>So, my original concern with Heroku, was the lack of oomph with only one Dyno (this is Heroku&#8217;s term for a web process) but actually it seems pretty good. So, go ahead and take a look at what I built in just a couple of hours, nothing amazing but given how easy this was to get up and running I can&#8217;t grumble.</p>
<p><a href="http://magickmosaic.heroku.com/">http://magickmosaic.heroku.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://iamhigham.com/2011/01/heroku-i-was-a-little-slow-on-the-bandwagon-but-i-like-a-lot/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Generate website headers using RMagick</title>
		<link>http://iamhigham.com/2011/01/generate-website-headers-using-rmagick/</link>
		<comments>http://iamhigham.com/2011/01/generate-website-headers-using-rmagick/#comments</comments>
		<pubDate>Fri, 21 Jan 2011 20:53:33 +0000</pubDate>
		<dc:creator>danhigham</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://iamhigham.com/?p=69</guid>
		<description><![CDATA[I needed to generate some headers in a particular font for a client and rather than do the task using the GIMP I decided to write a ruby script to do it instead. The following code creates separate images with the phrases from the array rendered in a particular font. [ruby]#!/usr/bin/ruby require &#8216;rubygems&#8217; require &#8216;rmagick&#8217; [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to generate some headers in a particular font for a client and rather than do the task using the GIMP I decided to write a ruby script to do it instead.</p>
<p>The following code creates separate images with the phrases from the array rendered in a particular font.</p>
<p>[ruby]#!/usr/bin/ruby<br />
require &#8216;rubygems&#8217;<br />
require &#8216;rmagick&#8217;</p>
<p>include Magick</p>
<p>words = ["Cupcakes", "Prices", "Workshops", "Special Occassions", "Gallery", "Corporate", "Kind Words", "Any Questions?", "Contact"]</p>
<p>words.each do |x|<br />
  canvas = Image.new(300, 40).transparent(&#8216;white&#8217;)<br />
  canvas.background_color = &#8216;white&#8217;</p>
<p>  gc = Draw.new</p>
<p>  gc.font(&#8220;&#8216;/Users/danhigham/Projects/scripts/font.ttf&#8217;&#8221;)<br />
  gc.pointsize(40)<br />
  gc.stroke(&#8220;transparent&#8221;)<br />
  gc.fill(&#8220;#87256F&#8221;)<br />
  gc.text_align(CenterAlign)<br />
  gc.text_undercolor(&#8220;transparent&#8221;)<br />
  gc.text(150,30, x)</p>
<p>  gc.draw(canvas)<br />
  filename = x.gsub(/\s/,&#8217;_').gsub(/\?/,&#8221;)<br />
  canvas.write(&#8220;#{filename}.png&#8221;)<br />
end[/ruby]</p>
]]></content:encoded>
			<wfw:commentRss>http://iamhigham.com/2011/01/generate-website-headers-using-rmagick/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Customising an embedded google calendar</title>
		<link>http://iamhigham.com/2011/01/customising-an-embedded-google-calendar/</link>
		<comments>http://iamhigham.com/2011/01/customising-an-embedded-google-calendar/#comments</comments>
		<pubDate>Sun, 16 Jan 2011 16:36:06 +0000</pubDate>
		<dc:creator>danhigham</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://iamhigham.com/?p=60</guid>
		<description><![CDATA[A recent client requested a calendar she could use on her website to display events, immediately my thoughts turned to Google calendar. After creating and embedding the Google calendar in an iframe I noticed the style didn&#8217;t quite fit with the rest of the site, it looked ok but just didn&#8217;t follow suit. I was [...]]]></description>
			<content:encoded><![CDATA[<p>A recent client requested a calendar she could use on her website to display events, immediately my thoughts turned to Google calendar. After creating and embedding the Google calendar in an iframe I noticed the style didn&#8217;t quite fit with the rest of the site, it looked ok but just didn&#8217;t follow suit. </p>
<p>I was surprised to find that adding CSS rules to the parent document didn&#8217;t work, even when adding an !important directive to each rule. The reason for this became obvious and actually two-fold;</p>
<p>1. The host document and the document in the iframe are completely separate. This seems an obvious statement to make but quite easy to overlook none the less.</p>
<p>2. The document in the iframe is on a separate domain (google.com in fact) which of course means that most browsers will block any attempt made from another domain to modify content within that document.</p>
<p>After trying all sorts of techniques to circumvent this issue, even proxying the content via my server I actually stumbled on a rather simple solution. Looking at the settings for a Google calendar you are given an snippet of code for embedding it in an iframe, that snippet has a URL in it which looks like this;</p>
<p><code>http://www.google.com/calendar/embed?src=p58tvijpfqoe83deo2prnd6pqg%40group.calendar.google.com&#038;ctz=Europe/London</code></p>
<p>This is where you point your iframe to and is the location of the base document for your calendar, take this URL and grab the source (I used wget). Create a new page on your site with the markup retrieved from the aforementioned URL, there are two lines in the code that need updating and they look something like this;</p>
<p><code>&lt;link type="text/css" rel="stylesheet" href="969ff39784188d8d017a0c60c8f2558aembedcompiled_fastui.css"></p>
<p>&lt;script type="text/javascript" src="969ff39784188d8d017a0c60c8f2558aembedcompiled__en_gb.js">&lt;/script><br />
</code></p>
<p>As you can see, both tags contain relative urls, they need prefixing with &#8220;https://www.google.com/calendar/&#8221; so they look like this;</p>
<p><code>&lt;link type="text/css" rel="stylesheet" href="https://www.google.com/calendar/969ff39784188d8d017a0c60c8f2558aembedcompiled_fastui.css"></p>
<p>&lt;script type="text/javascript" src="https://www.google.com/calendar/969ff39784188d8d017a0c60c8f2558aembedcompiled__en_gb.js">&lt;/script><br />
</code></p>
<p>Now you are able to point your iframe to the new page on YOUR domain and not Google&#8217;s, add custom CSS declarations to the new document to override elements in the Google calendar.. job done!</p>
<p>One of the changes this has allowed me to make is the ability to wrap the title of a calendar item in the month view, a feature that has been requested to Google by a lot of people!</p>
]]></content:encoded>
			<wfw:commentRss>http://iamhigham.com/2011/01/customising-an-embedded-google-calendar/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
	</channel>
</rss>
