<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>professional &#8211; Grubby, but lustrous</title>
	<atom:link href="https://iridescenturchin.wordpress.com/category/professional/feed/" rel="self" type="application/rss+xml" />
	<link>https://iridescenturchin.wordpress.com</link>
	<description>Adventures in software development</description>
	<lastBuildDate>Thu, 15 Jan 2009 06:54:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<site xmlns="com-wordpress:feed-additions:1">2461596</site><cloud domain='iridescenturchin.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>https://s2.wp.com/i/webclip.png</url>
		<title>professional &#8211; Grubby, but lustrous</title>
		<link>https://iridescenturchin.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="https://iridescenturchin.wordpress.com/osd.xml" title="Grubby, but lustrous" />
	<atom:link rel='hub' href='https://iridescenturchin.wordpress.com/?pushpress=hub'/>
	<item>
		<title>The cloud&#8230;it&#8217;s full of *people*!</title>
		<link>https://iridescenturchin.wordpress.com/2009/01/15/for-once-i-didnt-do-it-myself/</link>
					<comments>https://iridescenturchin.wordpress.com/2009/01/15/for-once-i-didnt-do-it-myself/#comments</comments>
		
		<dc:creator><![CDATA[Steve Hayes]]></dc:creator>
		<pubDate>Thu, 15 Jan 2009 06:52:39 +0000</pubDate>
				<category><![CDATA[development]]></category>
		<category><![CDATA[professional]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<guid isPermaLink="false">http://iridescenturchin.wordpress.com/?p=102</guid>

					<description><![CDATA[This is the story of the development of a small piece of software to deploy to the cloud, developed by a cloud of people, and how nominally unrelated groups interacted along the way. I&#8217;m interested in having a way to easily create new Rails servers in the cloud (specifically AWS) and to deploy my apps [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>This is the story of the development of a small piece of software to deploy to the cloud, developed by a cloud of people, and how nominally unrelated groups interacted along the way.</p>
<p>I&#8217;m interested in having a way to easily create new Rails servers in the cloud (specifically AWS) and to deploy my apps to them. I&#8217;m familiar with the bits and pieces that are involved but I hadn&#8217;t stitched them together. I started to write a Rails app to manage my AWS assets, partially as a path to learning extjs, but when the AWS Console came out I ditched that and started back on the original problem. Here are the different bits that I planned to use, and how I became aware of them:</p>
<ul>
<li>Sprinkle, by Marcus Crafter (<a href="http://github.com/crafterm/sprinkle/tree/master">http://github.com/crafterm/sprinkle/tree/master</a>) &#8211; Sprinkle handles deployment of resources on Ubuntu boxes in a pretty easy-to-understand way. Unfortunately I have a strong preference for Postgres over MySql (blame Simon Harris) and the default Sprinkle deployment recipes all use MySql. Still, it didn&#8217;t take me long to make some extensions to install Postgres instead of MySql.</li>
<li>Passenger-Stack, by Ben Schwarz (<a href="http://github.com/benschwarz/passenger-stack/tree/master">http://github.com/benschwarz/passenger-stack/tree/master</a>) &#8211; Sprinkles for Apache, Passenger, Mysql, Memcached &amp; Git. I found out about this via a Ryan Allen tweet.</li>
<li>Amazon Web Services (<a href="http://aws.amazon.com/">http://aws.amazon.com/</a>) &#8211; well known, but the fairly recent addition of Elastic Block Storage (EBS) gives a way to easily create persistent data that outlives a given instance, say for a Postgres database.</li>
</ul>
<p>The last piece to this puzzle is a web site called oDesk (<a href="http://www.odesk.com/">http://www.odesk.com/</a>). I was talking to a client last week and she mentioned that she thought Australian Rails developers were the most expensive in the world. When I asked her what she was doing she said that she was using off-shore Rails developers and was finding good people who would work for US$20/hr, from India but also from the USA. It seemed like the recession in the USA was having interesting side affects. I was definitely curious how using oDesk would work from a client perspective.</p>
<p>So I had this small problem that I didn&#8217;t have time to work on, and my curiousity about oDesk, and it seemed natural to solve them together. I posted my job on oDesk &#8211; produce a script that, given an EC2 instance and an ESB volume, would automatically configure the instance to use Rails with Passenger and Postgres, storing the data on the EBS volume. In addition, provide a test application so I can verify the Capistrano deployment to the instance. I posted this as a fixed price job, and my plan was to use a few different people and compare the outcomes. I posted my job last Sunday (it&#8217;s currently Thursday).</p>
<p>I had my first response in a few hours, from within Australia! Twenty four hours didn&#8217;t bring any more responses, so I pushed my job in front of a number of Rails developers who had high ratings. Many declined as they were too busy, some thought the suggested price was too low given the need to learn about AWS, and some still haven&#8217;t responded. I got two more positive responses, one from an experienced developer in St. Petersburg and one from a less experienced developer on the east coast of the USA. The bids were $333.33 (Australia), $250.00 (Russia), and $166.67 (USA). The expected development times were 1 day, 1 day and 1 week.</p>
<p>I accepted the responses and nominated a starting date of Tuesday. On Wednesday I got my solutions from Australia and St Petersburg. I&#8217;ve tested the Russian solution and it works fine. There seem to be couple of issues in the Australian solution but the developer<br />
is being very responsive, and the USA solution isn&#8217;t due yet.</p>
<p>What&#8217;s more interesting is what else happened in the 24 hours of development. The Russian developer forked passenger-stack on GitHub and hosted the fork as a public repository on GitHub (which was fine by me). However, I found out about this through an email from Marcus Crafter, who knew I was looking for a Postgres solution and pointed the fork out to me! Then I saw these tweets from Ben Schwarz (@benschwarz) &#8220;@kouky Just so you know, someone forked passenger-stack overnight rolling postgres support in, I&#8217;ll try and pull everything together :)&#8221; and &#8220;@atnan @kouky, I&#8217;ve just blindly merged the PostgreSQL stuff as I&#8217;m up in the hills. I&#8217;ll check it all out tomorrow :)&#8221; The status message for passenger-stack on GitHub now says &#8220;Adding support for PostgreSQL. Sprinkle will prompt the user to select  MySQL/PostgreSQL server and the relevant Ruby database drivers.&#8221;</p>
<p>So it looks like my little experiment ended up sponsoring the change that I wanted in the core implementation of passenger-stack. I suppose I could have asked Ben to do it originally, but that seemed like an imposition and I would have only achieved one of my goals. Now I have a script to configure my EC2 instances automatically, a better feeling for oDesk and off-shore development, and I&#8217;ve discovered that you can always sponsor the features that you want in a piece of open source software. Well worth my costs <img src="https://s0.wp.com/wp-content/mu-plugins/wpcom-smileys/twemoji/2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iridescenturchin.wordpress.com/2009/01/15/for-once-i-didnt-do-it-myself/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">102</post-id>
		<media:content url="https://2.gravatar.com/avatar/8017d041d07431a5579406a022040e69f685ca12636894c9eda8f384623d6b14?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Steve Hayes</media:title>
		</media:content>
	</item>
		<item>
		<title>Batch Conversion of Pages file *in Leopard*</title>
		<link>https://iridescenturchin.wordpress.com/2008/04/18/batch-conversion-of-pages-file-in-leopard/</link>
					<comments>https://iridescenturchin.wordpress.com/2008/04/18/batch-conversion-of-pages-file-in-leopard/#comments</comments>
		
		<dc:creator><![CDATA[Steve Hayes]]></dc:creator>
		<pubDate>Fri, 18 Apr 2008 01:07:36 +0000</pubDate>
				<category><![CDATA[os x]]></category>
		<category><![CDATA[software tools]]></category>
		<guid isPermaLink="false">http://iridescenturchin.wordpress.com/?p=95</guid>

					<description><![CDATA[I was very proud of my Pages to rtf script, and then I upgraded to Leopard last night and it stopped working! In my search for the answer I came across this post, which solves the problem more thoroughly, though you need to combine it with information from here as well. In case you don&#8217;t [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I was very proud of my Pages to rtf script, and then I upgraded to Leopard last night and it stopped working! In my search for the answer I came across <a href="http://pagesfaq.blogspot.com/2006/11/i-have-one-thousand-pages-documents-to.html">this post</a>, which solves the problem more thoroughly, though you need to combine it with information from <a href="http://pagesfaq.blogspot.com/2007/11/which-are-applescript-document-types-in.html">here</a> as well.</p>
<p>In case you don&#8217;t want to do this yourself, here&#8217;s a script that will start Pages, prompt you for the type of export you want, and then prompt you for a destination directory, and it works under Leopard. I told you it was more thorough than my last solution <img src="https://s0.wp.com/wp-content/mu-plugins/wpcom-smileys/twemoji/2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<blockquote>
<pre class="brush: jscript; title: ; notranslate">
on open theFiles
	tell application &quot;System Events&quot;
		if process &quot;Pages&quot; exists then
			display dialog &quot;whoops, please close Pages before running droplet!&quot;
		end if
	end tell
	tell application &quot;Pages&quot;
		activate
		delay 1
		close front document
		set theList to {&quot;doc&quot;, &quot;rtf&quot;, &quot;pdf&quot;, &quot;txt&quot;}
		set theType to (choose from list theList OK button name &quot;Select&quot; with title &quot;Pages Export&quot; with prompt &quot;Choose one or more formats to export using Pages&quot; with multiple selections allowed) as text item
		set s to theType as string
		set theLocation to choose folder
		set theLocation to theLocation as string
		
		repeat with aFile in theFiles
			open aFile
			
			if theType contains &quot;doc&quot; then
				set asType to &quot;SLDocumentTypeMSWord&quot;
				set docName to name of front document
				
				-- Remove .pages extension.
				set prevTIDs to AppleScript&#039;s text item delimiters
				set AppleScript&#039;s text item delimiters to &quot;.pages&quot;
				
				-- Add .doc extension.
				set docNameNew to first text item of docName &amp; asType
				set AppleScript&#039;s text item delimiters to prevTIDs
				
				-- Save file to Desktop.
				set docPathAndName to theLocation &amp; docNameNew
				save front document as asType in docPathAndName
				
			end if
			if theType contains &quot;rtf&quot; then
				set asType to &quot;SLDocumentTypeRichText&quot;
				
				set docName to name of front document
				
				-- Remove .pages extension.
				set prevTIDs to AppleScript&#039;s text item delimiters
				set AppleScript&#039;s text item delimiters to &quot;.pages&quot;
				
				-- Add .doc extension.
				set docNameNew to first text item of docName &amp; asType
				set AppleScript&#039;s text item delimiters to prevTIDs
				
				-- Save file to Desktop.
				set docPathAndName to theLocation &amp; docNameNew
				save front document as asType in docPathAndName
			end if
			if theType contains &quot;pdf&quot; then
				set asType to &quot;SLDocumentTypePDF&quot;
				set docName to name of front document
				
				-- Remove .pages extension.
				set prevTIDs to AppleScript&#039;s text item delimiters
				set AppleScript&#039;s text item delimiters to &quot;.pages&quot;
				
				-- Add .doc extension.
				set docNameNew to first text item of docName &amp; asType
				set AppleScript&#039;s text item delimiters to prevTIDs
				
				-- Save file to Desktop.
				set docPathAndName to theLocation &amp; docNameNew
				set s to save front document as asType in docPathAndName
				
			end if
			if theType contains &quot;txt&quot; then
				set asType to &quot;SLDocumentTypePlainText&quot;
				
				set docName to name of front document
				
				-- Remove .pages extension.
				set prevTIDs to AppleScript&#039;s text item delimiters
				set AppleScript&#039;s text item delimiters to &quot;.pages&quot;
				
				-- Add .doc extension.
				set docNameNew to first text item of docName &amp; asType
				set AppleScript&#039;s text item delimiters to prevTIDs
				
				-- Save file to User Specified Location
				set docPathAndName to theLocation &amp; docNameNew
				save front document as asType in docPathAndName
			end if
			try
				close front document saving no
			end try
		end repeat
		quit
	end tell
end open
</pre>
</blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://iridescenturchin.wordpress.com/2008/04/18/batch-conversion-of-pages-file-in-leopard/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">95</post-id>
		<media:content url="https://2.gravatar.com/avatar/8017d041d07431a5579406a022040e69f685ca12636894c9eda8f384623d6b14?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Steve Hayes</media:title>
		</media:content>
	</item>
		<item>
		<title>Murray Gell-mann, in a TED video&#8230;.</title>
		<link>https://iridescenturchin.wordpress.com/2008/04/17/murray-gell-mann-in-a-ted-video/</link>
					<comments>https://iridescenturchin.wordpress.com/2008/04/17/murray-gell-mann-in-a-ted-video/#comments</comments>
		
		<dc:creator><![CDATA[Steve Hayes]]></dc:creator>
		<pubDate>Wed, 16 Apr 2008 23:26:18 +0000</pubDate>
				<category><![CDATA[professional]]></category>
		<guid isPermaLink="false">http://iridescenturchin.wordpress.com/?p=94</guid>

					<description><![CDATA[&#8220;In 1957 some of us put forward a partially complete theory of the weak force, in disagreement with the results of seven experiments. It was beautiful and we dared to publish it, believing that all those experiments must be wrong. In fact, they were all wrong.&#8221; I love that in maths and physics truth and [&#8230;]]]></description>
										<content:encoded><![CDATA[<blockquote><p>&#8220;In 1957 some of us put forward a partially complete theory of the weak force, in disagreement with the results of seven experiments. It was beautiful and we dared to publish it, believing that all those experiments must be wrong.</p>
<p>In fact, they were all wrong.&#8221;</p></blockquote>
<p>I love that in maths and physics truth and beauty are so frequently aligned, and that misalignment often indicates immature understanding. A new insight can reveal new beauty.</p>
<p>I think the same is true of programming. Your code should be at least as elegant as your problem domain (I can&#8217;t do anything about accounting *s*).</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iridescenturchin.wordpress.com/2008/04/17/murray-gell-mann-in-a-ted-video/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">94</post-id>
		<media:content url="https://2.gravatar.com/avatar/8017d041d07431a5579406a022040e69f685ca12636894c9eda8f384623d6b14?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Steve Hayes</media:title>
		</media:content>
	</item>
		<item>
		<title>Batch conversion of Pages files</title>
		<link>https://iridescenturchin.wordpress.com/2008/04/17/batch-conversion-of-pages-files/</link>
					<comments>https://iridescenturchin.wordpress.com/2008/04/17/batch-conversion-of-pages-files/#respond</comments>
		
		<dc:creator><![CDATA[Steve Hayes]]></dc:creator>
		<pubDate>Wed, 16 Apr 2008 23:16:24 +0000</pubDate>
				<category><![CDATA[software tools]]></category>
		<guid isPermaLink="false">http://iridescenturchin.wordpress.com/?p=93</guid>

					<description><![CDATA[My current assignment makes me a Mac weenie in a Microsoft world, so while I&#8217;m happily tootling along in Pages I need to be able to share stuff with my colleagues. At the moment I&#8217;m the primary author of 30+ short course descriptions, stored in separate Pages files, and I&#8217;ve been exporting them to RTF [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>My current assignment makes me a Mac weenie in a Microsoft world, so while I&#8217;m happily tootling along in Pages I need to be able to share stuff with my colleagues. At the moment I&#8217;m the primary author of 30+ short course descriptions, stored in separate Pages files, and I&#8217;ve been exporting them to RTF when I need to share them. That was initially ok, but got out of hand as the number of files grew, so yesterday I was introduced to AppleScript.</p>
<p><p>I know nothing about AppleScript, but I was able to find a script on the web (thanks again, Google) that did most of what I want. I&#8217;ll show you the script, then tell you the parts that weren&#8217;t obvious to me and slowed me down</p>
<blockquote>
<pre class="brush: jscript; title: ; notranslate">
on open theFiles
	tell application &quot;Pages&quot;
		repeat with aFile in theFiles
			open aFile
			set docName to name of front document
			-- Remove .pages extension.
			set prevTIDs to AppleScript&#039;s text item delimiters
			set AppleScript&#039;s text item delimiters to &quot;.pages&quot;
			-- Add .pdf extension.
			set docName to first text item of docName &amp; &quot;.rtf&quot;
			set AppleScript&#039;s text item delimiters to prevTIDs
			-- Save file to Desktop.
			set docPathAndName to (path to desktop as string) &amp; &quot;rtfs:&quot; &amp; docName
			save front document as &quot;.rtf&quot; in docPathAndName
			close front document
		end repeat
	end tell
end open
</pre>
</blockquote>
<p>My first challenge was that I couldn&#8217;t figure out how to get this to run! Pressing &#8220;Run&#8221; in ScriptEditor did nothing. I ended up saving it as an applet (use &#8220;Save As&#8221;, selecting FileFormat =&gt; application), and then I could drag and drop the files I wanted to convert onto the applet. Once I put the applet in the dock, that was pretty convenient.</p>
<p>The second thing that slowed me down was figuring out how to save the results to a folder (the original script saved to the desktop). What I needed was the bit &#8216; &amp; &#8220;rtfs:&#8221;&#8216; while setting the docPathAndName. Here I&#8217;m dealing with a string, and it already has a trailing &#8220;:&#8221; &#8211; I kept trying to add another one, and AppleScript gave me a message about the target not being writable, rather than not existing, which lead me astray for a while. </p>
<p>Anyway, now I can select my Pages files, drag and drop them onto the applet in my dock, and the rtf files appear in a folder on my desktop. Sweet!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iridescenturchin.wordpress.com/2008/04/17/batch-conversion-of-pages-files/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">93</post-id>
		<media:content url="https://2.gravatar.com/avatar/8017d041d07431a5579406a022040e69f685ca12636894c9eda8f384623d6b14?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Steve Hayes</media:title>
		</media:content>
	</item>
		<item>
		<title>Another &#8220;I wish I had said that&#8221;</title>
		<link>https://iridescenturchin.wordpress.com/2008/04/08/another-i-wish-i-had-said-that/</link>
					<comments>https://iridescenturchin.wordpress.com/2008/04/08/another-i-wish-i-had-said-that/#respond</comments>
		
		<dc:creator><![CDATA[Steve Hayes]]></dc:creator>
		<pubDate>Tue, 08 Apr 2008 04:36:05 +0000</pubDate>
				<category><![CDATA[professional]]></category>
		<guid isPermaLink="false">http://iridescenturchin.wordpress.com/?p=91</guid>

					<description><![CDATA[&#8220;Simplicity and elegance are unpopular because they require hard work and discipline to achieve and education to be appreciated.&#8221; &#8211; Edger W Dijkstra]]></description>
										<content:encoded><![CDATA[<p>&ldquo;Simplicity and elegance are unpopular because they require hard work and discipline to achieve and education to be appreciated.&rdquo;  &#8211; Edger W Dijkstra</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iridescenturchin.wordpress.com/2008/04/08/another-i-wish-i-had-said-that/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">91</post-id>
		<media:content url="https://2.gravatar.com/avatar/8017d041d07431a5579406a022040e69f685ca12636894c9eda8f384623d6b14?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Steve Hayes</media:title>
		</media:content>
	</item>
		<item>
		<title>Adventures in BackgroundRb</title>
		<link>https://iridescenturchin.wordpress.com/2008/03/12/adventures-in-backgroundrb/</link>
					<comments>https://iridescenturchin.wordpress.com/2008/03/12/adventures-in-backgroundrb/#comments</comments>
		
		<dc:creator><![CDATA[Steve Hayes]]></dc:creator>
		<pubDate>Wed, 12 Mar 2008 06:38:21 +0000</pubDate>
				<category><![CDATA[rails]]></category>
		<guid isPermaLink="false">http://iridescenturchin.wordpress.com/?p=90</guid>

					<description><![CDATA[We&#8217;ve been asked to produce some &#8220;nice&#8221; reports in PDF for a client, and getting it all done has been quite an adventure. We use Ruport for the reporting, which unfortunately means we also need to learn quite a bit about PDFWriter to get everything looking spiffy, and the report rendering does take a while, [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>We&#8217;ve been asked to produce some &#8220;nice&#8221; reports in PDF for a client, and getting it all done has been quite an adventure. We use <a href="http://rubyreports.org/">Ruport</a> for the reporting, which unfortunately means we also need to learn quite a bit about <a href="http://ruby-pdf.rubyforge.org/pdf-writer/">PDFWriter</a> to get everything looking spiffy, and the report rendering does take a while, but we had it all working in a controller yesterday and things were looking good. Then we deployed the application to <a href="http://www.engineyard.com/">EngineYard</a>.</p>
<p>The first thing that happened was that we got timeout errors that looked like this (courtesy of <a href="http://agilewebdevelopment.com/plugins/exception_notifier">ExceptionNotifier</a>):</p>
<pre>
A Mongrel::TimeoutError occurred in reports#cost_detail_pdf:
Mongrel timed out this thread: shutdown
/usr/lib64/ruby/gems/1.8/gems/mongrel-1.1.3/lib/mongrel.rb:221:in `within'
</pre>
<p>The support folks at EngineYard suggested that we shouldn&#8217;t be running PDF generation from within our controller, and that we should use something like <a href="http://codeforpeople.com/lib/ruby/bj/)">background job</a>, but since we wanted to report status as the job proceeded and we only had a small number of jobs, we went with <a href="http://backgroundrb.rubyforge.org/">BackgroundRb</a> instead. (If you care about the difference, look for &#8216;Backgroundrb and Bj serve different purposes&#8217; in <a href="http://www.ruby-forum.com/topic/135643">this thread</a>).</p>
<p>BackgroundRb works great once you get it going, but there were examples in the documentation that simply didn&#8217;t work for me. Here&#8217;s what worked for me in the end:</p>
<p>In my controller:</p>
<blockquote>
<pre class="brush: ruby; title: ; notranslate">
  MiddleMan.new_worker(:worker =&gt; :cost_detail_pdf_worker, :job_key =&gt; current_user.id)
  MiddleMan.ask_work(:worker =&gt; :cost_detail_pdf_worker, :job_key =&gt; current_user.id, 
                                          :worker_method =&gt; :build_report, 
                                          :data =&gt; [session[:production_id], file_name])
</pre>
</blockquote>
<p>and my worker:</p>
<blockquote>
<p>class CostDetailPdfWorker  calculated_report, :template => :default)<br />
    register_status(&#8220;Finished Rendering&#8221;)<br />
    File.open(file_path, &#8220;w&#8221;) do |file|<br />
      file << pdf
    end
    register_status("File available")
  end

end
[/sourcecode]
</p></blockquote>
<p>The next part of the adventure was getting this running on our Slicehost slice. Unfortunately, BackgroundRb requires Ruby 1.8.5, and we only had 1.8.4 (on Ubuntu 6.06 LTS). Apt-get for Ubuntu 6.06 doesn&#8217;t include Ruby 1.8.5, so I needed to install Ruby 1.8.5 from source using these <a href="http://www.rubywizards.com/viewtopic.php?pid=19">excellent instructions</a>.</p>
<p>Unfortunately, I also needed to reinstall all our gems to go with the new version of Ruby. This was mostly stragithforward, except for Postgres. The postgres gem wouldn&#8217;t build the native extensions, failing to find pg_config. <a href="http://number9.hellooperator.net/articles/2007/05/02/postgres-gem-on-ubuntu">These instructions</a> were close, but before that would work I also needed to do &#8220;apt-get install libpq-dev&#8221; (you might also need libpgsql-ruby and/or libpgsql-ruby11.8, but I already had those installed).</p>
<p>Ok, looks pretty good now. I started the backgroundrb server manually as a test, and could produce my pdf files, so the next step was to move to our production environment at Engineyard. This was the first time I tried to stop and start the BackgroundRb using Capistrano &#8211; unfortunately you can&#8217;t simply repeat the command lines in your Capistrano tasks. Fortunately, there&#8217;s also a description of <a href="http://www.brynary.com/2007/4/8/capistrano-tasks-for-backgroundrb">some tasks that do work </a>(make sure you use the start task in the comments at the end of post).</p>
<p>All in all, a nice outcome but with much more pain than I would have liked.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iridescenturchin.wordpress.com/2008/03/12/adventures-in-backgroundrb/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">90</post-id>
		<media:content url="https://2.gravatar.com/avatar/8017d041d07431a5579406a022040e69f685ca12636894c9eda8f384623d6b14?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Steve Hayes</media:title>
		</media:content>
	</item>
		<item>
		<title>Coupling rollback actions with transaction actions</title>
		<link>https://iridescenturchin.wordpress.com/2008/02/22/coupling-rollback-actions-with-transaction-actions/</link>
					<comments>https://iridescenturchin.wordpress.com/2008/02/22/coupling-rollback-actions-with-transaction-actions/#respond</comments>
		
		<dc:creator><![CDATA[Steve Hayes]]></dc:creator>
		<pubDate>Fri, 22 Feb 2008 00:25:24 +0000</pubDate>
				<category><![CDATA[rails]]></category>
		<guid isPermaLink="false">http://iridescenturchin.wordpress.com/?p=87</guid>

					<description><![CDATA[The system I&#8217;m currently developing needs to import a variety of data from another system. The data arrives in batches, and within a batch some items might be valid and some might be invalid &#8211; I expect that this is a common problem. An item in the batch might also update many different objects within [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>The system I&#8217;m currently developing needs to import a variety of data from another system. The data arrives in batches, and within a batch some items might be valid and some might be invalid &#8211; I expect that this is a common problem. An item in the batch might also update many different objects within my domain model, and I won&#8217;t necessarily know if the item is invalid until I try to commit the changes to the domain model. It became fairly clear that I had some recurring code patterns in my application, so of course I wanted to extract them into some abstraction and Ruby&#8217;s reflection gave me a nice way to capture this.
</p>
<p>What I needed was to be able to associate a piece of code that created or modified some domain objects with the code that cleaned up the changes to the domain model on rollback (assuming that the database transaction handled the persistence parts). I could have used blocks, but I find that unlabelled blocks aren&#8217;t very expressive so I decided to use methods (and their names) instead of blocks. Here&#8217;s an example of using my method, #within_transaction_with_rollback; in the example :create_reference_objects and :clear_reference_objects are methods defined somewhere else in the class.
</p>
<blockquote>
<pre class="brush: ruby; title: ; notranslate">
  def process
    within_transaction_with_rollback(:create_reference_objects, :clear_reference_objects)
  end
</pre>
</blockquote>
<p>And here&#8217;s the implementation of my method, for those who are interested. I&#8217;m sure that there are plenty of other possible implementations <img src="https://s0.wp.com/wp-content/mu-plugins/wpcom-smileys/twemoji/2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" />
</p>
<blockquote>
<pre class="brush: ruby; title: ; notranslate">
module Transactions

    def within_transaction_with_rollback(transaction_method, rollback_method)
      begin
        within_transaction(transaction_method)
      rescue
        self.send(rollback_method)
      end
    end

    def within_transaction(create_method)
      self.class.transaction do
        self.send(create_method)
      end
    end
  
end

</pre>
</blockquote>
]]></content:encoded>
					
					<wfw:commentRss>https://iridescenturchin.wordpress.com/2008/02/22/coupling-rollback-actions-with-transaction-actions/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">87</post-id>
		<media:content url="https://2.gravatar.com/avatar/8017d041d07431a5579406a022040e69f685ca12636894c9eda8f384623d6b14?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Steve Hayes</media:title>
		</media:content>
	</item>
		<item>
		<title>Interaction between finder_sql and Active Scaffold</title>
		<link>https://iridescenturchin.wordpress.com/2008/02/21/interaction-between-finder_sql-and-active-scaffold/</link>
					<comments>https://iridescenturchin.wordpress.com/2008/02/21/interaction-between-finder_sql-and-active-scaffold/#respond</comments>
		
		<dc:creator><![CDATA[Steve Hayes]]></dc:creator>
		<pubDate>Thu, 21 Feb 2008 03:19:38 +0000</pubDate>
				<category><![CDATA[rails]]></category>
		<guid isPermaLink="false">http://iridescenturchin.wordpress.com/?p=86</guid>

					<description><![CDATA[I came across an interesting interaction in Rails that depended on two things that I didn&#8217;t know (of course, that list is infinite). The two things were: Active Record ignores finder_sql when you do an eager load of an association (though I can&#8217;t find a definitive reference for this, it is the observed behaviour); Active [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I came across an interesting interaction in Rails that depended on two things that I didn&#8217;t know (of course, that list is infinite). The two things were:</p>
<ol>
<li>Active Record ignores finder_sql when you do an eager load of an association (though I can&#8217;t find a definitive reference for this, it is the observed behaviour);
<li><a href="http://activescaffold.com">Active Scaffold</a> uses eager loading by default
</ol>
<p>I didn&#8217;t have any specs that explicitly tested that my model could eagerly load its associations, but everything else seemed to be working, so I was surprised that Active Scaffold was unhappy. The solution was to tell Active Scaffold not to use eager loading on that particular association, following the instructions in the <a href="http://activescaffold.com/tutorials/faq">FAQ</a> under &#8220;my database is choking&#8221; (which kind of describes what was happening to me, if the choking was fatal).</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iridescenturchin.wordpress.com/2008/02/21/interaction-between-finder_sql-and-active-scaffold/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">86</post-id>
		<media:content url="https://2.gravatar.com/avatar/8017d041d07431a5579406a022040e69f685ca12636894c9eda8f384623d6b14?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Steve Hayes</media:title>
		</media:content>
	</item>
		<item>
		<title>Need a Rails-savvy, Java tainted, agile bigot?</title>
		<link>https://iridescenturchin.wordpress.com/2008/02/21/need-a-rails-savvy-java-tainted-agile-bigot/</link>
					<comments>https://iridescenturchin.wordpress.com/2008/02/21/need-a-rails-savvy-java-tainted-agile-bigot/#respond</comments>
		
		<dc:creator><![CDATA[Steve Hayes]]></dc:creator>
		<pubDate>Wed, 20 Feb 2008 21:12:41 +0000</pubDate>
				<category><![CDATA[professional]]></category>
		<guid isPermaLink="false">http://iridescenturchin.wordpress.com/?p=85</guid>

					<description><![CDATA[My involvement in a project has finished unexpectedly early, so I find myself available for a new gig without anything in the pipe &#8211; which is unusual for me. If you have anything that you think I could help with, especially short- or part-time, drop me a line (steve at cogentconsulting dot com dot au).]]></description>
										<content:encoded><![CDATA[<p>My involvement in a project has finished unexpectedly early, so I find myself available for a new gig without anything in the pipe &#8211; which is unusual for me. If you have anything that you think I could help with, especially short- or part-time, drop me a line (steve at cogentconsulting dot com dot au).</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iridescenturchin.wordpress.com/2008/02/21/need-a-rails-savvy-java-tainted-agile-bigot/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">85</post-id>
		<media:content url="https://2.gravatar.com/avatar/8017d041d07431a5579406a022040e69f685ca12636894c9eda8f384623d6b14?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Steve Hayes</media:title>
		</media:content>
	</item>
		<item>
		<title>Rspec View specs and integrate_views</title>
		<link>https://iridescenturchin.wordpress.com/2008/02/19/rspec-view-specs-and-integrate_views/</link>
					<comments>https://iridescenturchin.wordpress.com/2008/02/19/rspec-view-specs-and-integrate_views/#comments</comments>
		
		<dc:creator><![CDATA[Steve Hayes]]></dc:creator>
		<pubDate>Tue, 19 Feb 2008 05:47:45 +0000</pubDate>
				<category><![CDATA[agile]]></category>
		<category><![CDATA[rails]]></category>
		<guid isPermaLink="false">http://iridescenturchin.wordpress.com/?p=84</guid>

					<description><![CDATA[We&#8217;ve recently had the pleasure of having Craig Ambrose working on a project for us, and as you&#8217;d expect when you bring someone new into the team, we&#8217;ve been doing some storming. One of the topics that comes up repeatedly within development teams I&#8217;m familiar with, including ours, is how fanatically we should adhere to [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>We&#8217;ve recently had the pleasure of having <a href="http://www.craigambrose.com/">Craig Ambrose</a> working on a project for us, and as you&#8217;d expect when you bring someone new into the team, we&#8217;ve been doing some <a href="http://en.wikipedia.org/wiki/Forming-storming-norming-performing">storming</a>. One of the topics that comes up repeatedly within development teams I&#8217;m familiar with, including ours, is how fanatically we should adhere to clear separation of unit and integration testing.</p>
<p>I&#8217;m fairly laissez faire about the issue. I&#8217;m quite happy to write tests for Rails models that actually invoke ActiveRecord and interact with the database. I&#8217;ll also happily set up a network of associated objects in the database rather than mock out everything except the class under test, though I do have some ill-defined limit that makes me uncomfortable.</p>
<p>I&#8217;m more strict about controller tests &#8211; I want the controller itself to be wafer thin, and I&#8217;ll generally only test that the controller sets the right instance variables (along with flash notices etc). The tests end up being fairly small, don&#8217;t touch the view at all, and I think even the evangelical TDD folk would call them unit tests.</p>
<p>However, Craig rightly points out a couple of problems with this. I&#8217;m typically working with server side functionality (if I had to say what I was best out, I&#8217;d initially claim domain modelling), so I write crap view code and I rarely write tests for it (someone&#8217;s just going to come along and rewrite it to be presentable anyway). It&#8217;s a fairly pathetic defence of my laziness, but anecdotally it seems lots of people don&#8217;t write view specs. So there&#8217;s a whole area of my application that&#8217;s not tested very well.</p>
<p>Craig also points out that one of the biggest sources of defects for him is that his controller doesn&#8217;t set up what the view expects (or you can express if from the opposite perspective if you prefer) &#8211; the failure occurs during the interaction between the controller and the view. These sorts of failures are quite difficult to find with unit tests alone, and probably won&#8217;t get picked up by distinct controller specs and view specs.</p>
<p>We could write separate integration specs, but RSpec gives a simple way to catch at least the most egregious of these problems. Unit testing purists might object, but the laissez faire&#8217;sts won&#8217;t mind. Put &#8220;integrate_views&#8221; into your descriptions. When integrate_views is specified, RSpec renders the real view rather than mocking out the rendering, and if objects are missing or badly misconfigured you&#8217;ll get a rendering exception.</p>
<p>I remembered the integrate_views option from earlier versions of RSpec &#8211; it&#8217;s not particularly conspicuous in the current version&#8217;s documentation, but it can be very useful.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iridescenturchin.wordpress.com/2008/02/19/rspec-view-specs-and-integrate_views/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">84</post-id>
		<media:content url="https://2.gravatar.com/avatar/8017d041d07431a5579406a022040e69f685ca12636894c9eda8f384623d6b14?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Steve Hayes</media:title>
		</media:content>
	</item>
	</channel>
</rss>
