<?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>matt.west.co.tt &#187; Ruby</title>
	<atom:link href="http://matt.west.co.tt/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://matt.west.co.tt</link>
	<description>adventures of a retro electro media hacker type person</description>
	<lastBuildDate>Mon, 25 Jul 2011 21:37:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Migrating Ruby Twitter apps to OAuth</title>
		<link>http://matt.west.co.tt/ruby/migrating-ruby-twitter-apps-to-oauth/</link>
		<comments>http://matt.west.co.tt/ruby/migrating-ruby-twitter-apps-to-oauth/#comments</comments>
		<pubDate>Sat, 14 Aug 2010 15:32:43 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://matt.west.co.tt/?p=173</guid>
		<description><![CDATA[Migrating Twitter API apps from basic authentication to OAuth is up there with hoovering the bathroom and taking out the recycling in the &#8220;irritating chores to put off for another day&#8221; stakes. However, Twitter&#8217;s announcement that they&#8217;re dropping basic authentication support at the end of this month has made this task altogether more urgent, like [...]]]></description>
			<content:encoded><![CDATA[<p>Migrating Twitter API apps from basic authentication to OAuth is up there with hoovering the bathroom and taking out the recycling in the &#8220;irritating chores to put off for another day&#8221; stakes. However, Twitter&#8217;s announcement that they&#8217;re <a href="http://groups.google.com/group/twitter-development-talk/browse_thread/thread/c03fa2b1ae90d2a9?hl=en_US">dropping basic authentication support at the end of this month</a> has made this task altogether more urgent, like an unexpected visit from the mother-in-law.</p>
<p>If you&#8217;re using the <a href="http://twitter.rubyforge.org/">Ruby Twitter gem</a> by John Nunemaker, you&#8217;ll be happy to learn that it supports OAuth. You&#8217;ll be less happy to see that the example code on the homepage merrily omits the difficult part:<br />
<code><br />
# NOT SHOWN: granting access to twitter on website<br />
# and using request token to generate access token<br />
</code></p>
<p>If your Twitter app is of the simple &#8216;bot&#8217; variety, with a single dedicated account where everything happens, and no need for end users to authenticate against it, then most of the example code and documentation floating around the internet is overkill, sending you down the path of sessions and callback URLs, when all you really want to know is: what do I put in the <a href="https://twitter.com/apps/new">&#8216;register an application&#8217;</a> form? How do I get hold of these tokens? And what do I do with this PIN code it&#8217;s just given me?</p>
<p>I eventually found <a href="http://blog.beefyapps.com/2010/01/simple-ruby-oauth-with-twitter/">a blog post at BeefyApps which cleared things up immensely</a>, and so I&#8217;ve now reshuffled their code snippet into a mini command line utility which will spit out those all-important tokens and tell you how to use them.</p>
<p><strong><a href="http://gist.github.com/524376">twitter_oauth_setup.rb</a></strong> on gist.github.com</p>
]]></content:encoded>
			<wfw:commentRss>http://matt.west.co.tt/ruby/migrating-ruby-twitter-apps-to-oauth/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>DivIDEo &#8211; Spectrum streaming video</title>
		<link>http://matt.west.co.tt/demoscene/divideo-spectrum-streaming-video/</link>
		<comments>http://matt.west.co.tt/demoscene/divideo-spectrum-streaming-video/#comments</comments>
		<pubDate>Mon, 03 May 2010 15:06:36 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Demoscene]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Spectrum]]></category>

		<guid isPermaLink="false">http://matt.west.co.tt/?p=148</guid>
		<description><![CDATA[Six years after my first tentative attempts at streaming video from the DivIDE interface were presented at Notcon 2004, I&#8217;ve finally come up with a system that I&#8217;m happy with. It boasts 25fps playback with audio somewhere above the &#8216;nails in a vacuum cleaner&#8217; quality of previous attempts (through the use of delta compression on [...]]]></description>
			<content:encoded><![CDATA[<p>Six years after my first tentative attempts at streaming video from the DivIDE interface were presented at Notcon 2004, I&#8217;ve finally come up with a system that I&#8217;m happy with. It boasts 25fps playback with audio somewhere above the &#8216;nails in a vacuum cleaner&#8217; quality of previous attempts (through the use of delta compression on the video data and variable bitrate audio to use up whatever processor time is left), a one-shot conversion utility that handles all the video decoding, rendering and re-packing, and a player routine that more or less respects the ATA spec (so won&#8217;t fall apart as soon as someone else tries it on a different CompactFlash card. Hopefully). Here&#8217;s how I presented it at the Outline demo party:</p>
<p><object width="480" height="279"><param name="movie" value="http://www.youtube.com/v/bVO5NUy7uZE&#038;hl=en_GB&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/bVO5NUy7uZE&#038;hl=en_GB&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="279"></embed></object></p>
<p>The full description, and a whole bunch of downloads, is on the <a href="http://divideo.zxdemo.org/">DivIDEo project website</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://matt.west.co.tt/demoscene/divideo-spectrum-streaming-video/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Midibeep</title>
		<link>http://matt.west.co.tt/music/midibeep/</link>
		<comments>http://matt.west.co.tt/music/midibeep/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 00:11:52 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Music]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Spectrum]]></category>

		<guid isPermaLink="false">http://matt.west.co.tt/?p=130</guid>
		<description><![CDATA[Last week I posted possibly the most tedious Basic type-in listing ever to World Of Spectrum: (continues for approx 1500 more lines) Anyone typing it in in its entirety would be rewarded with this: Download midibeep_minute_waltz.mp3 Not bad for an evening&#8217;s work. Mind you, I did take an ever so teeny shortcut, by writing a [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I posted possibly <a href="http://www.worldofspectrum.org/forums/showthread.php?t=27028">the most tedious Basic type-in listing ever</a> to <a href="http://www.worldofspectrum.org/forums/">World Of Spectrum</a>:</p>
<p><img src="http://matt.west.co.tt/images/beep.png" width="320" height="240" alt="5 BEEP 0.212765, 20; 10 BEEP 0.106383,19..." /><br />
<em>(continues for approx 1500 more lines)</em></p>
<p>Anyone typing it in in its entirety would be rewarded with this:</p>
<p><a href="http://www.zxdemo.org/gasman/music/midibeep_minute_waltz.mp3">Download midibeep_minute_waltz.mp3</a></p>
<p>Not bad for an evening&#8217;s work. Mind you, I did take an ever so teeny shortcut, by writing a Ruby program to convert a MIDI file to BEEP format. (Any .mid file will do, although ones with a single instrument will survive the rather primitive selective-note-butchering process better. Oh, and anything much longer than this one will exceed the 48K Spectrum memory&#8230;) And now you can try it out too:</p>
<ul>
<li><a href="http://github.com/gasman/midibeep/">Midibeep source/downloads at Github</a></li>
<li><a href="http://www.zxdemo.org/extra/src/Mid2BEEP.zip">Midibeep Windows build</a> (thanks to Karl McNeil)</li>
<li><a href="http://www.zxdemo.org/gasman/music/chopin.tap">Minute Waltz (TAP, 38K)</a></li>
</ul>
<p><strong>Update 2010-05-26:</strong> Karl McNeil has adapted Midibeep into a variant called Mid2ASM, which outputs an assembler listing rather than Basic &#8211; this enables the data to be packed much more efficiently, paving the way for altogether longer pieces of music. <a href="http://www.zxdemo.org/extra/src/Mid2ASM.zip">Download Mid2ASM</a> (453K, Windows EXE included)</p>
<p><strong>Update 2010-06-02:</strong> Another update from Karl, featuring a Windows GUI, more space-saving tweaks, and embedding the output in a Basic REM statement. <a href="http://www.zxdemo.org/extra/src/Mid2ASM-2.zip">Download Mid2ASM v2</a> (3.4Mb)</p>
<p><strong>Update 2011-04-09:</strong> Karl McNeil has released the last version of Mid2ASM for a while, <a href="ftp://ftp.worldofspectrum.org/pub/sinclair/tools/pc/Mid2ASM.zip">version 3.2</a> &#8211; featuring primitive importing from .sid .psg and .wav, and the choice of Basic or assembly output. The <a href="ftp://ftp.worldofspectrum.org/pub/sinclair/tools/pc/Mid2ASM_SRC.zip">source archive</a> also contains the command-line version, midibeep2.</p>
]]></content:encoded>
			<wfw:commentRss>http://matt.west.co.tt/music/midibeep/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
<enclosure url="http://www.zxdemo.org/gasman/music/midibeep_minute_waltz.mp3" length="1780424" type="audio/mpeg" />
		</item>
		<item>
		<title>Sleeper &#8211; mapping European night trains</title>
		<link>http://matt.west.co.tt/ruby/sleeper/</link>
		<comments>http://matt.west.co.tt/ruby/sleeper/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 21:24:06 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://matt.west.co.tt/?p=118</guid>
		<description><![CDATA[It&#8217;s now been 10 months and 10 demo parties since I last saw the inside of an airport (with plenty more to come over the next couple of months&#8230; parties that is, not airports), and for any eco-conscious European traveller like me, knowing which sleeper trains to catch is the key to happy travels. So, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://sleeper.demozoo.org/"><img src="http://matt.west.co.tt/images/sleeper.jpg" width="250" height="201" alt="" style="float: left; padding-right: 8px;" /></a> It&#8217;s now been 10 months and 10 demo parties since I last saw the inside of an airport (with plenty more to come over the next couple of months&#8230; parties that is, not airports), and for any eco-conscious European traveller like me, knowing which sleeper trains to catch is the key to happy travels. So, it&#8217;s a bit of a shame that there&#8217;s no single website you can go to to find out the best sleeper train to get to European Destination X. Sure, <a href="http://www.seat61.com/">Seat 61</a> is a fantastic resource for finding out how to get to your country of choice, but you can never be sure whether you&#8217;d get better results by heading just across the border, or tweaking your journey times slightly&#8230;</p>
<p>So, in a classic case of building a website to scratch a personal itch, and not wanting to let niggly licencing issues get in the way of a cool idea&#8230; <strong><a href="http://sleeper.demozoo.org/">Sleeper</a></strong> is my new website aimed at searching and mapping the European sleeper train network in its entirety. It&#8217;s been put together with <a href="http://www.ruby-lang.org/">Ruby</a>, <a href="http://www.rubyonrails.org/">Rails</a> (gosh, that&#8217;s rather apt isn&#8217;t it&#8230;), <a href="http://geokit.rubyforge.org/">Geokit</a>, Google Maps, <a href="http://wiki.github.com/why/hpricot">Hpricot</a> and my own freshly open-sourced <a href="http://github.com/gasman/bahn/">Bahn</a> library for snarfing data from <a href="http://www.bahn.de/">Deutsche Bahn</a>&#8216;s website, and hopefully it can give you a fuller picture than ever before of what actually exists in the wonderful world of sleeper trains. Right now it stops short of providing one overall definitive map of the network (it would probably crash your browser if I tried plotting it on Google Maps), but that&#8217;s on the todo list.</p>
]]></content:encoded>
			<wfw:commentRss>http://matt.west.co.tt/ruby/sleeper/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Deploying a Rails app without a database using Capistrano</title>
		<link>http://matt.west.co.tt/ruby/capistrano-without-a-database/</link>
		<comments>http://matt.west.co.tt/ruby/capistrano-without-a-database/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 16:08:23 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://matt.west.co.tt/?p=113</guid>
		<description><![CDATA[So you&#8217;ve got a simple-but-devastatingly-clever Rails app that doesn&#8217;t use a database, you&#8217;ve dutifully added the line to config/environment.rb to disable the ActiveRecord framework, and now you&#8217;re ready to unleash it to the world, using Capistrano for deployment. But when you run &#8216;cap deploy:cold&#8217;, it merrily tries to run database migrations and fails with &#8220;uninitialized [...]]]></description>
			<content:encoded><![CDATA[<p>So you&#8217;ve got a simple-but-devastatingly-clever Rails app that doesn&#8217;t use a database, you&#8217;ve dutifully added the line to config/environment.rb to disable the ActiveRecord framework, and now you&#8217;re ready to unleash it to the world, using Capistrano for deployment. But when you run &#8216;cap deploy:cold&#8217;, it merrily tries to run database migrations and fails with &#8220;uninitialized constant ActiveRecord&#8221;. How do you make Capistrano behave?</p>
<p>A simple question, with a simple answer, but one which is curiously absent from the internet. Googlejuice ahoy!</p>
<p>Stick this at the bottom of config/deploy.rb:</p>
<pre>namespace :deploy do
	desc "Override deploy:cold to NOT run migrations - there's no database"
	task :cold do
		update
		start
	end
end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://matt.west.co.tt/ruby/capistrano-without-a-database/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>FreshBEEP</title>
		<link>http://matt.west.co.tt/spectrum/freshbeep/</link>
		<comments>http://matt.west.co.tt/spectrum/freshbeep/#comments</comments>
		<pubDate>Sun, 04 Jan 2009 02:06:58 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Spectrum]]></category>

		<guid isPermaLink="false">http://matt.west.co.tt/?p=111</guid>
		<description><![CDATA[Kicking off 2009 in style with a website-in-a-day, FreshBEEP is my answer to a pressing problem on the Spectrum scene: people are releasing new games all the time, but they&#8217;re being overlooked due to a lack of a prominent central place to announce them. However, it turns out that on the World of Spectrum What&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p><img style="float: right; margin-left: 8px; margin-bottom: 8px;" src="http://matt.west.co.tt/images/freshbeep.png" width="256" height="172" alt=""> Kicking off 2009 in style with a website-in-a-day, <a href="http://freshbeep.zxdemo.org/">FreshBEEP</a> is my answer to a pressing problem on the Spectrum scene: people are releasing new games all the time, but they&#8217;re being overlooked due to a lack of a prominent central place to announce them. However, it turns out that on the <a href="http://www.worldofspectrum.org/whatsnew.html">World of Spectrum What&#8217;s New page</a>, nestled amongst the hive of other site activity that gets mentioned there, Martijn has been dutifully labelling new releases under a &#8220;New software for 2008&#8243; banner. One swift bit of mashup work later (does it count as a mashup if it&#8217;s only coming from one site?) and these are now being pulled out into a friendly blog-like format, with an all-important RSS feed. It&#8217;s not particularly clever, but it scratches an itch&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://matt.west.co.tt/spectrum/freshbeep/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>The Ninja Milkman Conspiracy (and Maze)</title>
		<link>http://matt.west.co.tt/demoscene/ninja-milkman-conspiracy/</link>
		<comments>http://matt.west.co.tt/demoscene/ninja-milkman-conspiracy/#comments</comments>
		<pubDate>Sun, 05 Oct 2008 21:15:16 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Demoscene]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Spectrum]]></category>

		<guid isPermaLink="false">http://matt.west.co.tt/?p=106</guid>
		<description><![CDATA[I&#8217;m a bit behind in my blogging, so I&#8217;ve got a bit of a &#8220;what I did this summer&#8221; catchup to do. First up is The Ninja Milkman Conspiracy, a cheap and cheerful oldskool scrolly Speccy demo made for this August&#8217;s International Vodka Party, featuring the classic circle interference effect, some creative use of dithering, [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center"><img src="http://pouet.net/screenshots/51422.png" alt="" width="320" height="240" /></p>
<p>I&#8217;m a bit behind in my blogging, so I&#8217;ve got a bit of a &#8220;what I did this summer&#8221; catchup to do. First up is <b>The Ninja Milkman Conspiracy</b>, a cheap and cheerful oldskool scrolly Speccy demo made for this August&#8217;s International Vodka Party, featuring the classic circle interference effect, some creative use of dithering, and a dancing robot. What more could you ask for? The title, incidentally, was just something random and irrelevant to save it from being called &#8216;IVP 2008 demo&#8217; (which is just as well, because there were already 2 other demos in the competition called that) but is actually a reference to the milkman at one of our offices who is able to deliver the milk and disappear without making a sound.</p>
<p>&#8230;All of which is ordinary enough, but the exciting thing (if you&#8217;re the sort of person to get excited about build scripts) is, um, the build script. I&#8217;ve been happily using makefiles for ages, but this time I finally flipped at the amount of redundant boilerplate you need to shove in there for a typical Spectrum project, even a small one like this &#8211; having to remember command line syntax, having to explicitly set up dependencies even though they&#8217;re all clearly marked as &#8216;include&#8217; lines in the assembler file &#8211; so I came up with <b>Maze</b>, a Spectrum-oriented replacement for Make written in Ruby. Inevitably, being a scratch-my-own-itch sort of program, it&#8217;s a bit more hard-coded (and tuned towards my own way of working) than I&#8217;d like, but I reckon it&#8217;s enough of an improvement over bog-standard makefiles that it could conceivably be useful to other people. And if it is, maybe I&#8217;ll be encouraged to rewrite it in a more open-ended way some time&#8230;</p>
<ul>
<li><a href="http://www.zxdemo.org/f/200808/gasman_-_ninja_milkman_conspiracy.zip">Download The Ninja Milkman Conspiracy</a> (TAP, 12Kb)</li>
<li><a href="http://www.zxdemo.org/extra/src/ninja_milkman_conspiracy_src.zip">The Ninja Milkman Conspiracy source code, including Maze</a> (27Kb)</li>
<li><a href="http://matt.west.co.tt/files/maze/maze_documentation.txt">Maze documentation</a> and <a href="http://matt.west.co.tt/files/maze/ninja_milkman_conspiracy.mazefile.txt">TNMC Mazefile</a>, to whet your appetite&#8230;</li>
<li><a href="http://pouet.net/prod.php?which=51422">The Ninja Milkman Conspiracy on Pouet</a></li>
]]></content:encoded>
			<wfw:commentRss>http://matt.west.co.tt/demoscene/ninja-milkman-conspiracy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Some rather opinionated plugins</title>
		<link>http://matt.west.co.tt/rants/opinionated-plugins/</link>
		<comments>http://matt.west.co.tt/rants/opinionated-plugins/#comments</comments>
		<pubDate>Sat, 30 Aug 2008 14:54:24 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Rants]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://matt.west.co.tt/?p=105</guid>
		<description><![CDATA[Update: The belongs_to patch has now made it into core Rails. Thanks to Jon for persevering with it where I threw in the towel, and to Koz and Pratik for giving it their attention. I&#8217;m still not entirely convinced that going through the conventional channels (as opposed to &#8220;whinging on a blog&#8221;) would have yielded [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> The belongs_to patch has now made it into core Rails. Thanks to Jon for persevering with it where I threw in the towel, and to Koz and Pratik for giving it their attention. I&#8217;m still not entirely convinced that going through the conventional channels (as opposed to &#8220;whinging on a blog&#8221;) would have yielded the crucial feedback to get the patch in a state where it could be accepted, but all&#8217;s well that ends well&#8230;</p>
<hr />
<img src="/images/jump_the_shark.gif" width="248" height="186" alt="A shark, being jumped, yesterday." title="A shark, being jumped, yesterday." style="float: right; border: 4px solid silver; margin: 10px;" />Take this as the rantings of a pissed-off curmudgeon who&#8217;s had his <a href="http://rails.lighthouseapp.com/projects/8994/tickets/142-patch-belongs_to-association-not-updated-when-assigning-to-foreign-key">second core patch rejected</a> if you will, but it&#8217;s my sad duty to report that Rails has <a href="http://www.jumptheshark.com/help.jspa">jumped the shark</a>. It happened when it stopped being a framework and started being a collection of opinions instead.</p>
<p>You see, in my book a framework is something that&#8217;s meant to make programmers work more effectively &#8211; not to lecture them about what they&#8217;re doing wrong. Lecturing can be a good thing, as long as it ultimately results in better code &#8211; I&#8217;ll happily admit that following the Rails learning curve has taught me an awful lot about good programming practices. More and more though, I&#8217;m finding it being used to justify just plain broken features: If it doesn&#8217;t work, it&#8217;s your fault for not doing it the right way. Take this bit of profoundly broken behaviour:</p>
<p><i>let&#8217;s say we have a Company model, which belongs_to :city</i></p>
<pre>&gt;&gt; torchbox = Company.find_by_name('Torchbox')
=&gt; #&lt;Company id: 1, name: "Torchbox", city_id: 1&gt;
&gt;&gt; torchbox.city
=&gt; #&lt;City id: 1, name: "London"&gt;</pre>
<p>Aha, we&#8217;ve got the city wrong. Let&#8217;s reassign a bundle of attributes then, like we would if we were doing this through a web form:</p>
<pre>&gt;&gt; torchbox.attributes = {:name =&gt; 'Torchbox', :city_id =&gt; 2}
=&gt; {:name =&gt; 'Torchbox', :city_id =&gt; 2}</pre>
<p>Right, so now we should retrieve the correct one.</p>
<pre>&gt;&gt; torchbox.city
=&gt; #&lt;City id: 1, name: "London"&gt;</pre>
<p>Er, oops.<br />
<span id="more-105"></span><br />
But no &#8211; according to the response on that ticket, Rails isn&#8217;t at fault, because there&#8217;s a convoluted way I can rewrite my code to make that not happen. Out in the real world we would refer to that as &#8220;a workaround for the bug&#8221;. But Rails doesn&#8217;t have bugs&#8230; it just has opinions. My code sucks, as indicated by the fact that it doesn&#8217;t work, and if I just learn to write it in a way that doesn&#8217;t suck then I&#8217;ll become a better programmer. In that way, the Rails developers have, intentionally or not, painted themselves into a position where they&#8217;re immune to criticism: Rails works perfectly logically to them, because they wrote it. There&#8217;s no counter-intuitive behaviour to them, because they know the codebase back to front and understand exactly what it&#8217;s doing and not doing. Anyone who believes it is counter-intuitive just has a different opinion to them, and should be forced to either accept their opinions or get out of the Rails party.</p>
<p>Well, quite frankly that&#8217;s bollocks isn&#8217;t it? Even if their method is genuinely better according to some metric I don&#8217;t understand (and I don&#8217;t believe it is: my original approach works perfectly well the other 98% of the time and is in fact such a well-established way of doing things that even <em>the Lighthouse website where I reported the bug</em> does it that way) &#8211; my approach <em>is</em> better according to the rather more important measure of being <strong>the one I thought of first</strong>. The big promise of agile development was that we&#8217;d all spend more time implementing what we want to implement, and less time fighting against the mundane details of our platform. Any time the platform forces me to get out of the flow of building my application and figure out how to bend Rails to do what I want it to do, that&#8217;s a FAIL for agile programming and for Rails.</p>
<p>And if the code I write is something that logically should work, that I so passionately believe <em>must</em> work that I&#8217;m willing to spend my own time tracking down the reason why it doesn&#8217;t work, fixing it, testing the fix, writing it up and handing my results to you on a plate, then if you don&#8217;t agree then you&#8217;d damn well better have a better reason than &#8220;meh, I don&#8217;t really like doing it that way&#8221;.</p>
<p>But wait, there&#8217;s still hope! If I act as cheerleader on the Rails core mailing list, then I might be able to drum up enough support to get my patch pushed through! Well, nuts to that. I&#8217;ve put enough effort into fixing their broken software already, and now I have no desire to spend even more effort campaigning for a result that doesn&#8217;t even personally affect me any more, because now I&#8217;ve got a plugin that fixes it, and nobody but me will ever know about it until they get bitten by that bug themselves, spend several hours tearing their hair out over it, and eventually stumble upon this blog post. Hello there. I suppose you&#8217;d like to know how to fix it then? <a href="http://code.torchbox.com/svn/rails/plugins/belongs_to_synchronisation/">Here, have a plugin.</a></p>
<p>So, having stuck the knife in, allow me to give it an extra twist by stating that <strong>indenting with spaces is shit</strong>. Tab characters make sense for the same reason that using &lt;h1&gt; rather than &lt;font size=&#8221;36&#8243;&gt; makes sense for HTML headings: it&#8217;s meaningful markup that indicates the purpose of that whitespace, and allows the reader to tune its appearance and behaviour, such as how much space it takes up and what happens when you move your cursor through it. And no, I don&#8217;t care about your vim profile that does automatic tab conversion. Some people actually like using other text editors, and if you use tab characters in your files then your choice isn&#8217;t limited to editors with esoteric make-your-text-behave-like-something-it-isn&#8217;t features, but is instead limited to editors which can insert the characters you tell it to without arsing everything up. (Unfortunately, it turns out that some editors aren&#8217;t capable of that, as we discovered: the Rails mode of Eclipse insists on chucking spaces in, even after we changed every conceivable preference setting.)</p>
<p>This is where my <a href="http://code.torchbox.com/svn/rails/plugins/retabulate/">retabulate plugin</a> comes in. It converts the customary two-space indent into tabs, both via an explicit rake task that does a sweep of your codebase, and by intercepting any new files created via script/generate. It can&#8217;t deal with YAML files though, because the YAML spec obnoxiously insists that only spaces are valid.</p>
<p>Enjoy these plugins&#8230; or ignore them entirely if you prefer. Hurrah for freedom of choice.</p>
]]></content:encoded>
			<wfw:commentRss>http://matt.west.co.tt/rants/opinionated-plugins/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Comet Chaos</title>
		<link>http://matt.west.co.tt/spectrum/comet-chaos/</link>
		<comments>http://matt.west.co.tt/spectrum/comet-chaos/#comments</comments>
		<pubDate>Mon, 07 Jul 2008 00:01:16 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Spectrum]]></category>
		<category><![CDATA[Talks]]></category>

		<guid isPermaLink="false">http://matt.west.co.tt/?p=103</guid>
		<description><![CDATA[Thanks to Oleg for reminding me at OpenTech that I still hadn&#8217;t written this up yet&#8230; This started out as an experiment in Comet techniques (which allow you to actively push data out from web servers without the client having to initiate the request) which quickly ballooned in ambitiousness &#8211; I didn&#8217;t set out to [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to Oleg for reminding me at <a href="http://www.ukuug.org/events/opentech2008/">OpenTech</a> that I still hadn&#8217;t written this up yet&#8230;</p>
<p>This started out as an experiment in Comet techniques (which allow you to actively push data out from web servers without the client having to initiate the request) which quickly ballooned in ambitiousness &#8211; I didn&#8217;t set out to write Just Another Chat Application after all. The end result is a realtime multiplayer Javascript conversion of the Spectrum wargame Chaos&#8230; or a reasonable chunk of it, at least.</p>
<p><strong><a href="http://chaos.zxdemo.org/">Play Comet Chaos now</a></strong></p>
<p>If you&#8217;re interested in the workings behind it, check out this video from my <a href="http://oxford.geeknights.net/2008/jun-25th/">Oxford Geek Nights</a> presentation to hear about how Comet is like a small child on a car journey, find out how close web developers can get to world domination, and watch a live demonstration going pear-shaped. </p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/zz11l8IlPsg&#038;hl=en&#038;fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/zz11l8IlPsg&#038;hl=en&#038;fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p><span id="more-103"></span><br />
Other resources:</p>
<ul>
<li><a href="http://oxford.geeknights.net/2008/jun-25th/talks/microslot-MatthewWestcott.pdf">Presentation slides</a></li>
<li><a href="http://rubyforge.org/projects/shooting-star">Shooting Star</a>, the Rails Comet library</li>
<li><a href="http://shooting-star.rubyforge.org/wiki/wiki.pl?Making_A_Chat_System_Within_5_Minutes">Shooting Star walkthrough</a></li>
<li><a href="http://svn.matt.west.co.tt/svn/chaos/trunk/">Comet Chaos Subversion repository</a></li>
</ul>
<p>But if you&#8217;d rather just dive in and have a play, that&#8217;s fine too&#8230; For those of you unfamiliar with Chaos, it&#8217;s a turn-based game for 2-8 players, each one playing a wizard who has to try and kill of all opponents by casting spells. Most of these come in the form of creatures which you can move across the board to attack opposing creatures and wizards. As ever, <a href="ftp://ftp.worldofspectrum.org/pub/sinclair/games-info/c/Chaos.txt">World Of Spectrum has the full instructions</a>.</p>
<p>Be aware that the current release is rather incomplete and experimental: the repertoire of spells is limited to creatures, &#8216;disbelieve&#8217; and lightning bolts, the combat system is virtually non-existent (everything has a 50% chance of killing everything else), killing wizards isn&#8217;t tested, and the finer points of game mechanics (flying/mountable/undead creatures, ranged combat, law vs chaos) are unimplemented. But don&#8217;t let that put you off&#8230;</p>
<p>An equally important omission &#8211; and possibly the major reason why it&#8217;s attracted minimal user testing and feedback right now &#8211; is that there&#8217;s no way to invite other players, other than marking your game as &#8216;public&#8217; so that it appears on the homepage. (Non-public games still have guessable URLs, though.) To join up with other players you&#8217;ll need to organise things on other channels, such as IRC. Ideally it needs proper user signups, invitations, notifications and friend lists&#8230;</p>
<p>Gosh. I wonder if this could be one of those &#8220;social network&#8221; things all the cool kids are talking about? And that various wise people at conferences say you should never implement yourself, but piggyback on an established one instead? I suppose that means it&#8217;s time for me to swallow my pride and investigate the Facebook and/or OpenSocial APIs soon then.</p>
]]></content:encoded>
			<wfw:commentRss>http://matt.west.co.tt/spectrum/comet-chaos/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>tracker2ay</title>
		<link>http://matt.west.co.tt/music/tracker2ay/</link>
		<comments>http://matt.west.co.tt/music/tracker2ay/#comments</comments>
		<pubDate>Sat, 10 May 2008 20:33:59 +0000</pubDate>
		<dc:creator>matt</dc:creator>
				<category><![CDATA[Demoscene]]></category>
		<category><![CDATA[Music]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Spectrum]]></category>

		<guid isPermaLink="false">http://matt.west.co.tt/?p=100</guid>
		<description><![CDATA[Here&#8217;s a utility prompted by zxbruno and Eq both asking, in the space of two days, how to convert STC, SQT and PT3 music files to something you can actually play on a Spectrum. For those not in the know, STC and friends are Spectrum tracker file formats originally introduced by Sergey Bulba&#8216;s AY Emulator [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a utility prompted by zxbruno and <a href="http://equ.in/ox/">Eq</a> both asking, in the space of two days, how to convert STC, SQT and PT3 music files to something you can actually play on a Spectrum. For those not in the know, STC and friends are Spectrum tracker file formats originally introduced by <a href="http://bulba.untergrund.net/">Sergey Bulba</a>&#8216;s <em>AY Emulator</em> and which are now the de-facto standard for archiving Spectrum demoscene music (most prominently on <a href="http://www.zxdemo.org/">ZXDemo</a>, <a href="http://zxtunes.com/">ZXTunes</a> and Sergey&#8217;s epic <a href="http://bulba.untergrund.net/music_e.htm">Tr_songs</a> archive). Which means it&#8217;s a bit unfortunate that there&#8217;s not been an obvious way to transfer them back to the Spectrum.</p>
<p>In principle it should just be a case of locating the appropriate Z80 player routine and bundling that together with the music data. In practice it involves a lot of faffing about (such as repointing pointers to make up for slight rubbishness in the SQT data format, and writing a 5-line Basic loader/player). Now, thanks to this utility, you just need to type <tt>tracker2ay mysong.stc mysong.tap</tt> instead. (Oh, and it can convert to TAP, TZX or AY.)</p>
<ul>
<li><a href="http://matt.west.co.tt/files/tracker2ay/tracker2ay-0.1.win32.zip">tracker2ay: standalone Windows executable (1.4Mb)</a></li>
<li><a href="http://matt.west.co.tt/files/tracker2ay/tracker2ay-0.1.mac-linux.tar.gz">tracker2ay: Mac/Linux/everything-else executable (runs anywhere where a Ruby interpreter is available) (32Kb)</a></li>
<li><a href="http://matt.west.co.tt/files/tracker2ay/tracker2ay-0.1.src.tar.gz">tracker2ay: source code (22Kb)</a></li>
</ul>
<p>If at this point you&#8217;re screaming &#8220;But why does it have separate source code if it&#8217;s written in Ruby, which is an interpreted language?&#8221; then award yourself 20 geek points. Ah, you see, this time I&#8217;ve been playing with <a href="http://www.erikveen.dds.nl/rubyscript2exe/">rubyscript2exe</a> (and <a href="http://www.erikveen.dds.nl/tar2rubyscript/">tar2rubyscript</a>) to create all-in-one executables that everyone can enjoy without worrying about library dependencies and things. (But obfuscates the code in the process. But in a good way.) Please do check out the source code if you&#8217;re curious about that sort of thing, because I reckon it&#8217;s one of the best bits of code I&#8217;ve written in a long time, in a &#8216;nicely-written code&#8217; sort of way rather than &#8216;evil complicated hacks that go together to do something superficially elegant&#8217;.</p>
]]></content:encoded>
			<wfw:commentRss>http://matt.west.co.tt/music/tracker2ay/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

