<?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>Ice Kream Koan</title>
	<atom:link href="http://www.icekreamkoan.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.icekreamkoan.com</link>
	<description>Flying and other stuff - Peter Braswell</description>
	<lastBuildDate>Thu, 13 Jan 2011 16:19:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Testing Paperclip and S3 &#8211; A &#8220;back-together&#8221; detour</title>
		<link>http://www.icekreamkoan.com/2011/01/13/testing-paperclip-and-s3-a-back-together-detour/</link>
		<comments>http://www.icekreamkoan.com/2011/01/13/testing-paperclip-and-s3-a-back-together-detour/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 16:19:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.icekreamkoan.com/?p=257</guid>
		<description><![CDATA[Fly-mart.com has been live now since the first of the year, yeah I know the logo sucks &#8211; I&#8217;m working on that!  Traffic has been steadily growing, though the site is still in beta and is not taking payments, I&#8217;ve been very happy so far.  One thing that&#8217;s been heaven&#8217;s sent is HopToad.  Despite being [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a title="Fly-Mart.com Aviation Classifieds" href="http://www.fly-mart.com" target="_blank">Fly-mart.com</a> has been live now since the first of the year, yeah I know the logo sucks &#8211; I&#8217;m working on that!  Traffic has been steadily growing, though the site is still in beta and is not taking payments, I&#8217;ve been very happy so far.  One thing that&#8217;s been heaven&#8217;s sent is <a title="Hop Toad" href="https://www2.hoptoadapp.com/account/new" target="_blank">HopToad</a>.  Despite being diligent with regard to testing, some things slip.  HopToad is right there and in one particular incident, I was busy fixing the code before the customer even had a chance to finish his email to support (me).  Good stuff!</p>
<p>Anyway, one of the issues I ran into early in the project was the inability on <a title="Heroku" href="http://heroku.com/" target="_blank">Heroku&#8217;s app environment</a> to write to the file system. If you&#8217;re using &#8220;paperclip&#8221; &#8211; this is kind of an issue, though it&#8217;s relatively easy to work around,  <a title="Paperclip" href="https://github.com/thoughtbot/paperclip" target="_blank">Paperclip</a> can easily integrate with <a title="Amazon Simple Storeage Service (S3)" href="http://aws.amazon.com/s3/" target="_blank">Amazon S3</a>.  The big problem though came with testing.  For some, still unexplained reason, I was never able to get my Cucumber or RSpec tests to successfully connect to the S3 service, I consistently got a connection exception.  I didn&#8217;t really think this was worth chasing down as ultimately I really didn&#8217;t want the tests to hit S3 directly.  My first thought was to use some sort of web tier mock to trick the code into thinking it was talking to S3.  There were a few examples I found regarding how to get this to work but again I had little luck with my own codebase.  I&#8217;m not sure it was because I choose R3 or some other reason, but again no joy.</p>
<p>I was thinking that what I really wanted was the ability to define different behavior depending on the environment.  For example, production and development I wanted actual S3 calls and for testing I would be perfectly happy to have my Paperclip image files land on the local hard drive.  I had a conversation with a good friend, <a title="Ryan Diagle" href="http://ryandaigle.com/" target="_blank">Ryan Daigle</a> who agreed with the approach and could also offer some code to get me bootstrapped.  What follows is the relevant code with commentary.</p>
<pre>
<h3>Step 1 - Modify your app/model/asset.rb class slightly</h3>
</pre>
<p>The thing to notice is that the normal paperclip code that you&#8217;d expect in your asset class it replace by the &#8220;stores_file_as&#8221; helper.  Most of the paperclip configuration as well as the mechanism to detect the environment and act accordingly has been moved into there.</p>
<pre><code><div id="gist-778066" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="k">class</span> <span class="nc">Asset</span> <span class="o">&lt;</span> <span class="no">ActiveRecord</span><span class="o">::</span><span class="no">Base</span></div><div class='line' id='LC2'>&nbsp;&nbsp;<span class="kp">include</span> <span class="no">Helpers</span><span class="o">::</span><span class="no">AssetStorage</span></div><div class='line' id='LC3'>&nbsp;&nbsp;</div><div class='line' id='LC4'>&nbsp;&nbsp;</div><div class='line' id='LC5'>&nbsp;&nbsp;<span class="n">before_validation</span> <span class="ss">:clear_asset</span></div><div class='line' id='LC6'>&nbsp;&nbsp;<span class="n">belongs_to</span> <span class="ss">:ad</span><span class="p">,</span> <span class="ss">:polymorphic</span> <span class="o">=&gt;</span> <span class="kp">true</span></div><div class='line' id='LC7'>&nbsp;&nbsp;</div><div class='line' id='LC8'>&nbsp;&nbsp;<span class="n">stores_file_as</span> <span class="ss">:image</span><span class="p">,</span></div><div class='line' id='LC9'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="ss">:styles</span> <span class="o">=&gt;</span> <span class="p">{</span><span class="ss">:micro</span> <span class="o">=&gt;</span> <span class="s2">&quot;75x43&quot;</span><span class="p">,</span> <span class="ss">:thumb</span> <span class="o">=&gt;</span> <span class="s2">&quot;128x95&quot;</span><span class="p">,</span> <span class="ss">:medium</span> <span class="o">=&gt;</span> <span class="s2">&quot;300x300&quot;</span><span class="p">,</span> <span class="ss">:large</span> <span class="o">=&gt;</span> <span class="s2">&quot;500x500&quot;</span><span class="p">}</span></div><div class='line' id='LC10'>&nbsp;&nbsp;<span class="n">validates_attachment_presence</span> <span class="ss">:image</span></div><div class='line' id='LC11'>&nbsp;&nbsp;<span class="n">validates_attachment_size</span> <span class="ss">:image</span><span class="p">,</span> <span class="ss">:less_than</span> <span class="o">=&gt;</span> <span class="mi">1</span><span class="o">.</span><span class="n">megabytes</span></div><div class='line' id='LC12'>&nbsp;&nbsp;<span class="n">validates_attachment_content_type</span> <span class="ss">:image</span><span class="p">,</span> <span class="ss">:content_type</span> <span class="o">=&gt;</span> <span class="o">[</span><span class="s1">&#39;image/jpeg&#39;</span><span class="p">,</span> <span class="s1">&#39;image/gif&#39;</span><span class="p">,</span> <span class="s1">&#39;image/png&#39;</span><span class="o">]</span></div><div class='line' id='LC13'>&nbsp;&nbsp;</div><div class='line' id='LC14'>&nbsp;&nbsp;<span class="k">def</span> <span class="nf">delete_asset</span><span class="o">=</span><span class="p">(</span><span class="n">value</span><span class="p">)</span></div><div class='line' id='LC15'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="vi">@delete_asset</span> <span class="o">=</span> <span class="o">!</span><span class="n">value</span><span class="o">.</span><span class="n">to_i</span><span class="o">.</span><span class="n">zero?</span></div><div class='line' id='LC16'>&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC17'>&nbsp;&nbsp;</div><div class='line' id='LC18'>&nbsp;&nbsp;<span class="k">def</span> <span class="nf">delete_asset</span></div><div class='line' id='LC19'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">!!</span><span class="vi">@delete_asset</span></div><div class='line' id='LC20'>&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC21'>&nbsp;&nbsp;</div><div class='line' id='LC22'>&nbsp;&nbsp;<span class="n">alias_method</span> <span class="ss">:delete_asset?</span><span class="p">,</span> <span class="ss">:delete_asset</span></div><div class='line' id='LC23'>&nbsp;&nbsp;</div><div class='line' id='LC24'>&nbsp;&nbsp;<span class="k">def</span> <span class="nf">clear_asset</span></div><div class='line' id='LC25'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nb">self</span><span class="o">.</span><span class="n">image</span> <span class="o">=</span> <span class="kp">nil</span> <span class="k">if</span> <span class="n">delete_asset?</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="n">image</span><span class="o">.</span><span class="n">dirty?</span></div><div class='line' id='LC26'>&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC27'>&nbsp;&nbsp;</div><div class='line' id='LC28'><span class="k">end</span></div><div class='line' id='LC29'><br/></div><div class='line' id='LC30'><span class="c1"># == Schema Information</span></div><div class='line' id='LC31'><span class="c1">#</span></div><div class='line' id='LC32'><span class="c1"># Table name: assets</span></div><div class='line' id='LC33'><span class="c1">#</span></div><div class='line' id='LC34'><span class="c1"># id :integer not null, primary key</span></div><div class='line' id='LC35'><span class="c1"># ad_id :integer</span></div><div class='line' id='LC36'><span class="c1"># created_at :datetime</span></div><div class='line' id='LC37'><span class="c1"># updated_at :datetime</span></div><div class='line' id='LC38'><span class="c1"># image_file_name :string(255)</span></div><div class='line' id='LC39'><span class="c1"># image_content_type :string(255)</span></div><div class='line' id='LC40'><span class="c1"># image_file_size :integer</span></div><div class='line' id='LC41'><span class="c1"># image_updated_at :datetime</span></div><div class='line' id='LC42'><span class="c1">#</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/778066/8ce99613bfdd539cbe63bfc804ccea88d18f0d91/asset.rb" style="float:right;">view raw</a>
            <a href="https://gist.github.com/778066#file_asset.rb" style="float:right;margin-right:10px;color:#666">asset.rb</a>
            <a href="https://gist.github.com/778066">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>
</code>
<h3>Step 2 - Add a app/helper/helpers.rb module</h3>

The idea here is to delegate the heavy lifting of the paperclip configuration to the helper module but more importantly to detect
the environment and configure the appropriate behavior.  In my case, I wanted 'dev' and 'prod' to use the actual S3 environment while
the test environment should use the local file system.  Not only does this keep the charges lower for S3 but has the added benefit
of speeding up the tests.  Alternatively you could externalize the configuration in a DSL but I really didn't see the point.

<div id="gist-778095" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="k">module</span> <span class="nn">Helpers</span></div><div class='line' id='LC2'><br/></div><div class='line' id='LC3'>&nbsp;&nbsp;<span class="c1"># Conventient way to setup filesystem attachment uploading when in dev/testing</span></div><div class='line' id='LC4'>&nbsp;&nbsp;<span class="c1"># and use S3 otherwise</span></div><div class='line' id='LC5'>&nbsp;&nbsp;<span class="k">module</span> <span class="nn">AssetStorage</span></div><div class='line' id='LC6'><br/></div><div class='line' id='LC7'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">def</span> <span class="nc">self</span><span class="o">.</span><span class="nf">included</span><span class="p">(</span><span class="n">within</span><span class="p">)</span></div><div class='line' id='LC8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">within</span><span class="o">.</span><span class="n">class_eval</span> <span class="k">do</span></div><div class='line' id='LC9'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kp">extend</span> <span class="no">ClassMethods</span></div><div class='line' id='LC10'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC11'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC12'><br/></div><div class='line' id='LC13'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">module</span> <span class="nn">ClassMethods</span></div><div class='line' id='LC14'><br/></div><div class='line' id='LC15'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">def</span> <span class="nf">stores_file_as</span><span class="p">(</span><span class="n">asset_type</span><span class="p">,</span> <span class="n">opts</span> <span class="o">=</span> <span class="p">{})</span></div><div class='line' id='LC16'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">filename_interpolation</span> <span class="o">=</span> <span class="n">opts</span><span class="o">[</span><span class="ss">:filename_interpolation</span><span class="o">]</span> <span class="o">||</span> <span class="s1">&#39;:style.:extension&#39;</span></div><div class='line' id='LC17'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">options</span> <span class="o">=</span> <span class="n">use_local_storage?</span> <span class="p">?</span></div><div class='line' id='LC18'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">filesystem_default_options</span><span class="p">(</span><span class="n">filename_interpolation</span><span class="p">)</span> <span class="p">:</span></div><div class='line' id='LC19'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">s3_default_options</span><span class="p">(</span><span class="n">filename_interpolation</span><span class="p">)</span></div><div class='line' id='LC20'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">options</span> <span class="o">=</span> <span class="n">options</span><span class="o">.</span><span class="n">merge</span><span class="p">(</span><span class="n">opts</span><span class="p">)</span></div><div class='line' id='LC21'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">has_attached_file</span> <span class="n">asset_type</span><span class="p">,</span> <span class="n">options</span></div><div class='line' id='LC22'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC23'><br/></div><div class='line' id='LC24'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="kp">private</span></div><div class='line' id='LC25'><br/></div><div class='line' id='LC26'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">def</span> <span class="nf">use_local_storage?</span></div><div class='line' id='LC27'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="vi">@use_local_storage</span> <span class="o">||=</span> <span class="o">!</span><span class="p">(</span><span class="no">Rails</span><span class="o">.</span><span class="n">env</span><span class="o">.</span><span class="n">production?</span> <span class="o">||</span> <span class="no">Rails</span><span class="o">.</span><span class="n">env</span><span class="o">.</span><span class="n">staging?</span><span class="p">)</span></div><div class='line' id='LC28'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC29'><br/></div><div class='line' id='LC30'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">def</span> <span class="nf">s3_default_options</span><span class="p">(</span><span class="n">filename_interpolation</span><span class="p">)</span></div><div class='line' id='LC31'><br/></div><div class='line' id='LC32'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1"># Akamai URL -&gt; origin URL -&gt; Rails env</span></div><div class='line' id='LC33'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1"># N/A -&gt; origin.staticassets.development.theslap.digitaltoniq.com -&gt; development</span></div><div class='line' id='LC34'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1"># staticassets.theslap.digitaltoniq.com -&gt; origin.staticassets.theslap.digitaltoniq.com -&gt; staging</span></div><div class='line' id='LC35'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1"># staticassets.beta.theslap.com -&gt; origin.staticassets.beta.theslap.com -&gt; beta</span></div><div class='line' id='LC36'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1"># staticassets.theslap.com -&gt; origin.staticassets.theslap.com -&gt; production</span></div><div class='line' id='LC37'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC38'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="ss">:storage</span> <span class="o">=&gt;</span> <span class="ss">:s3</span><span class="p">,</span></div><div class='line' id='LC39'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="ss">:s3_credentials</span> <span class="o">=&gt;</span> <span class="s2">&quot;</span><span class="si">#{</span><span class="no">RAILS_ROOT</span><span class="si">}</span><span class="s2">/config/s3.yml&quot;</span><span class="p">,</span></div><div class='line' id='LC40'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="ss">:path</span> <span class="o">=&gt;</span> <span class="s2">&quot;/:style/:filename&quot;</span></div><div class='line' id='LC41'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC42'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC43'><br/></div><div class='line' id='LC44'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">def</span> <span class="nf">filesystem_default_options</span><span class="p">(</span><span class="n">filename_interpolation</span><span class="p">)</span></div><div class='line' id='LC45'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">{</span></div><div class='line' id='LC46'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1">## Add any local file system options you may want here ...</span></div><div class='line' id='LC47'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1"># :url =&gt; &quot;/assets/:class/:slug/#{filename_interpolation}&quot;,</span></div><div class='line' id='LC48'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="c1"># :path =&gt; &quot;:rails_root/public/assets/:class/:slug/#{filename_interpolation}&quot;</span></div><div class='line' id='LC49'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC50'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC51'><br/></div><div class='line' id='LC52'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC53'>&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC54'><span class="k">end</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/778095/85907545eb8a2521983f69946ad615905fa72872/helpers.rb" style="float:right;">view raw</a>
            <a href="https://gist.github.com/778095#file_helpers.rb" style="float:right;margin-right:10px;color:#666">helpers.rb</a>
            <a href="https://gist.github.com/778095">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>


Happy Hacking,
Peter</pre>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.icekreamkoan.com%2F2011%2F01%2F13%2Ftesting-paperclip-and-s3-a-back-together-detour%2F';
  addthis_title  = 'Testing+Paperclip+and+S3+%26%238211%3B+A+%26%238220%3Bback-together%26%238221%3B+detour';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>

<!-- start wp-tags-to-technorati 1.02 -->

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://www.icekreamkoan.com/2011/01/13/testing-paperclip-and-s3-a-back-together-detour/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>We&#8217;re back together! &#8211; resparking the flame (Part 2)</title>
		<link>http://www.icekreamkoan.com/2010/12/14/were-back-together-resparking-the-flame-part-2/</link>
		<comments>http://www.icekreamkoan.com/2010/12/14/were-back-together-resparking-the-flame-part-2/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 17:59:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.icekreamkoan.com/?p=252</guid>
		<description><![CDATA[I figured the first thing that I ought to do it to figure out the answer to the question Rails 2.x or 3? To the initiated, that&#8217;s probably a pretty simple question but for someone like me, coming back after a long &#8220;it&#8217;s not you, it&#8217;s me&#8221; thing, it wasn&#8217;t that easy. First there was [...]]]></description>
			<content:encoded><![CDATA[<p></p><p style="text-align: right;"><a href="http://www.icekreamkoan.com/wp-content/uploads/2010/12/RoRTutorial.jpg"><img class="alignright size-medium wp-image-253" title="Ruby On Rails: Learn by Example by Micheal Hartl" src="http://www.icekreamkoan.com/wp-content/uploads/2010/12/RoRTutorial-300x202.jpg" alt="" width="417" height="300" /></a></p>
<p>I figured the first thing that I ought to do it to figure out the answer to the question Rails 2.x or 3?</p>
<p>To the initiated, that&#8217;s probably a pretty simple question but for someone like me, coming back after a long &#8220;it&#8217;s not you, it&#8217;s me&#8221; thing, it wasn&#8217;t that easy.</p>
<p>First there was the stability question.  R3 is relatively new, which led really to two questions: Is it stable and is there enough documentation out there to get me going?  I didn&#8217;t really dwell on the stability question long.  First off, I know that the Ruby/Rails community (for the most part) are test Zealots.  That and there&#8217;s tons of eyeballs out there on the code also brought me great comfort.  What I wasn&#8217;t sure of though was all the gems and plug-ins.  How much of a departure was R3 from R2.x and how long will it take the ecosystem to catch up.</p>
<p>The documentation question also had nested concerns.  The Rails community is great at producing how-to&#8217;s and tutorials but again, how fast are they to react to the new Rails version?  My normal &#8220;go to&#8221; sources <a href="http://www.peepcode.com" target="_self">peepcode.com</a> and <a href="http://www.railscasts.com">railscasts.com </a>seemed to not quite be there yet, though working on it.</p>
<p>I also wanted some industrial strength goodness that I could tap.  I don&#8217;t think I could take another &#8220;build a blog in 15 minutes&#8221; tutorial.  Though interesting and helpful, many of these resources don&#8217;t really delve into the nitty gritty of a production application and cover deployment, testing and some of the other tips and tricks hard won by seasoned rails developers.</p>
<p>I was lucky enough to come upon Michael Hart&#8217;s excellent Rails 3 tutorial <a title="Ruby on Rails by Example" href="http://railstutorial.org/">&#8220;Ruby on Rails Tutorial: Learn Rails by Example&#8221;</a>.  As it turned out it was almost exactly what I needed.  Though the example used in the book is the often used &#8220;Twitter Clone&#8221;, it was comprehensive enough to be interesting and engaging.  Most valuable though was picking up tips and tricks and helpful plug-ins along the way.  Believe it or not, I had never used git before.  When I&#8217;m not stuck with CVS, I&#8217;m likely using SVN.  Similarly, Hart introduces TDD via <a title="RSpec" href="http://rspec.info">RSpec</a>, <a title="Heroku" href="http://www.heroku.com">Heroku</a>, setting up your environment and of course all the R3 goodness including a vast universe of gems that have proven invaluable.</p>
<p>Up for next week &#8230; I&#8217;ll start researching/brainstorming a workable layout and doing battle with CSS and ERB!</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.icekreamkoan.com%2F2010%2F12%2F14%2Fwere-back-together-resparking-the-flame-part-2%2F';
  addthis_title  = 'We%26%238217%3Bre+back+together%21+%26%238211%3B+resparking+the+flame+%28Part+2%29';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>

<!-- start wp-tags-to-technorati 1.02 -->

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://www.icekreamkoan.com/2010/12/14/were-back-together-resparking-the-flame-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>We&#8217;re back together &#8211; me and Ruby! (Part 1)</title>
		<link>http://www.icekreamkoan.com/2010/12/08/were-back-together-me-and-ruby-part-1/</link>
		<comments>http://www.icekreamkoan.com/2010/12/08/were-back-together-me-and-ruby-part-1/#comments</comments>
		<pubDate>Wed, 08 Dec 2010 14:01:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.icekreamkoan.com/?p=242</guid>
		<description><![CDATA[The Back Story So as an architect for a *big* networking company, I really don&#8217;t write a whole lot of code.  I guess that&#8217;s what happens as our careers move forward.  I&#8217;ve traded my syntax color highlighting and code-completion for bubbles and arrow.   I&#8217;m probably a glutton for punishment but Viso doesn&#8217;t give deprecation [...]]]></description>
			<content:encoded><![CDATA[<p></p><h2>The Back Story <a href="http://www.icekreamkoan.com/wp-content/uploads/2010/12/Flymart.jpg"><img class="alignright size-medium wp-image-250" title="Fly-Mart.com" src="http://www.icekreamkoan.com/wp-content/uploads/2010/12/Flymart-300x225.jpg" alt="" width="300" height="225" /></a></h2>
<p>So as an architect for a *big* networking company, I really don&#8217;t write a whole lot of code.  I guess that&#8217;s what happens as our careers move forward.  I&#8217;ve traded my syntax color highlighting and code-completion for bubbles and arrow.   I&#8217;m probably a glutton for punishment but Viso doesn&#8217;t give deprecation warnings and I miss the challenge of making things work.  If you&#8217;re a developer, you know what I mean.</p>
<p>I&#8217;m also passionate about aviation.  One of the aviation communities most active sites for selling and buying aircraft is a site called <a title="Barnstormers" href="http://www.barnstormers.com" target="_blank">Barnstormers.com</a>.  I know, you&#8217;re asking: &#8220;what does this have to do with Ruby on Rails?&#8221;.  Sit tight amigo, we&#8217;re getting there.  I&#8217;ve been on barnstormers a lot.  It&#8217;s active and I suppose it gets the job done but a more 1990&#8242;s site I couldn&#8217;t imagine.  Web 1.0 is alive and well with a visually busy layout, flashing GIFS and blinking ads.  I&#8217;ve been thinking &#8230; what if somebody manned up and did a really nice web 2.0 Rails, AJAX blah blah blah site.  If anything it would be a good exercise to tackle some real-world programming issues.</p>
<h2>The Challenge</h2>
<p>Could I design, test, build and deploy a soup-to-nuts application in 30 days (give or take, hey I&#8217;ve got a life too you know).  This fits into several personal philosophies of mine: First, don&#8217;t spend a ton of time or money trying to launch a business.  Agile and rapid is not only a good tenant for software but for businesses too.  So off to the whiteboard we go.  I thought it might be fun to do a blogging series detailing this adventure and to document getting back together with an old flame &#8211; ah Ruby&#8230; I missed you!!!</p>
<p>So stay tuned!  In the next installment, I&#8217;ll talk about some resources for initially dusting off my eroded Ruby on Rails skills and how I gingerly navigated the Rails 2.x verses Rails 3.  SPOILER WARNING! !: Rails 3 rocks!</p>
<p>In the meantime, if you want to keep tabs on the launch, please visit the <a title="Fly-Mart.com" href="http://www.fly-mart.com" target="_self">Fly-Mart.com launch page</a>.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.icekreamkoan.com%2F2010%2F12%2F08%2Fwere-back-together-me-and-ruby-part-1%2F';
  addthis_title  = 'We%26%238217%3Bre+back+together+%26%238211%3B+me+and+Ruby%21+%28Part+1%29';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>

<!-- start wp-tags-to-technorati 1.02 -->

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://www.icekreamkoan.com/2010/12/08/were-back-together-me-and-ruby-part-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Shakeout Glastar Flight &#8211; a Movie Short</title>
		<link>http://www.icekreamkoan.com/2010/08/12/shakeout-glastar-flight-a-movie-short/</link>
		<comments>http://www.icekreamkoan.com/2010/08/12/shakeout-glastar-flight-a-movie-short/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 15:45:29 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Aviation]]></category>

		<guid isPermaLink="false">http://www.icekreamkoan.com/?p=233</guid>
		<description><![CDATA[Yeah, Yeah, it&#8217;s been forever since I&#8217;ve posted.  I&#8217;ve been super-busy though&#8230; really!  As some of you may know, I decided to give the Glastar, affectionately known as &#8220;Whistler&#8221; a brain upgrade.  My experience with my Blue Mountain Avionics EFIS was &#8211; how should I put this delicately.. &#8220;mixed&#8221;.  I can&#8217;t be too harsh on [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Yeah, Yeah, it&#8217;s been forever since I&#8217;ve posted.  I&#8217;ve been super-busy though&#8230; really!  As some of you may know, I decided to give the Glastar, affectionately known as &#8220;Whistler&#8221; a brain upgrade.  My experience with my <a href="http://www.bluemountainavionics.com/" target="_blank">Blue Mountain Avionics</a> EFIS was &#8211; how should I put this delicately.. &#8220;mixed&#8221;.  I can&#8217;t be too harsh on the BMA folks though.  They&#8217;re a smart bunch and they&#8217;ve been helpful despite being shuttered as a business for over a year now.  They were definitely fast movers in the market but I don&#8217;t think their cost structure was able to keep up with the market.  That&#8217;s just a guess though &#8211; no insider information! <img src='http://www.icekreamkoan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So  I&#8217;ve wanted to put an autopilot into Whistler for quite a while now.  When I started shopping, I was zeroing in on the <a href="http://www.trioavionics.com/ProPilot.htm" target="_blank">Trio Pro Pilot</a>.  It looks like a solid unit and it&#8217;s gotten good reviews.  One problem though, the price tag.  For about $600 bucks more, I was able to take advantage of the Dynon BMA trade-in program and get the <a href="http://www.dynonavionics.com/" target="_blank">Dynon SkyView</a> plus auto pilot.  GOOD DECISION!  The electronics were easy enough to install.  The mechanical servos, we&#8217;ll that&#8217;s another story and probably another post.  Suffice to say that it was TOUGH!  I&#8217;m happy to report though that the SV sytem has been working flawlessly and after a bit of tweaking, the autopilot is working just great after initially wanting to aggressively bank to capture a track and then &#8220;hunting&#8221; back and forth to try to stay on course.</p>
<p>The following short clip has also been keeping me busy.  I came up with this business idea (<a href="http://www.sky-gadgets.com" target="_blank">sky-gadgets.com</a>) to mix great video footage with product demonstrations and tutorials to form a little online business.  Trouble is that I have no idea how to video tape much less edit so off I go to get some practice.  I bought a small &#8220;lipstick&#8221; camera that I mounted on the Glastar&#8217;s cage and a copy of Final Cut Express.  What follows is a piece of footage that I edited together from along continuous shot filmed from Suffolk, Virginia (SFQ) to my home base in Chesterfield (FCI)</p>
<p><a href="http://www.icekreamkoan.com/2010/08/12/shakeout-glastar-flight-a-movie-short/"><em>Click here to view the embedded video.</em></a></p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.icekreamkoan.com%2F2010%2F08%2F12%2Fshakeout-glastar-flight-a-movie-short%2F';
  addthis_title  = 'Shakeout+Glastar+Flight+%26%238211%3B+a+Movie+Short';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>

<!-- start wp-tags-to-technorati 1.02 -->

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://www.icekreamkoan.com/2010/08/12/shakeout-glastar-flight-a-movie-short/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The Two Categories of Kit Built Aircraft&#8230;</title>
		<link>http://www.icekreamkoan.com/2010/05/20/the-two-categories-of-kit-built-aircraft/</link>
		<comments>http://www.icekreamkoan.com/2010/05/20/the-two-categories-of-kit-built-aircraft/#comments</comments>
		<pubDate>Thu, 20 May 2010 18:14:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.icekreamkoan.com/?p=228</guid>
		<description><![CDATA[&#8220;I&#8217;ve come to realize that there two categories of kit built airplanes: 1) Under construction and NOT flying  2) Under construction AND flying.&#8221; The first long flight of the season is always interesting.  It&#8217;s even more interesting if the flight is following major maintenance which was the situation this year.  At the end of last [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a title="Virginia Festival of Flight" href="http://www.virginiaflyin.org/" target="_self"><img class="alignright size-medium wp-image-229" title="card" src="http://www.icekreamkoan.com/wp-content/uploads/2010/05/card-300x203.jpg" alt="card" width="300" height="203" /></a><em><strong>&#8220;I&#8217;ve come to realize that there two categories of kit built airplanes:  1) Under construction and NOT flying  2) Under construction AND flying.&#8221;</strong></em></p>
<p>The first long flight of the season is always interesting.  It&#8217;s even more interesting if the flight is following major maintenance which was the situation this year.  At the end of last season a friend of mine and I were going to head out on a short cross country.  When I opened the hanger door to start the pre-flight, av-gas fumes flooded my nostrils and made my head feel like floating tissue paper.  Uh oh&#8230;  The rubber tanks that I thought were such a good idea at one time had rebelled for the very last time.  I spent a better part of the winter taking the old bladder tanks out and replacing them with the stock aluminum tanks that originally came with the kit.  Ah, had I known then what I know now!  The assumption that the rubber tanks would give more capacity and be safer in an accident turned out to be false, the more capacity part anyway.  Thankfully I&#8217;ve never tested the crash worthiness (knocking vigorously on wood).</p>
<p>Last Saturday a friend of mine and fellow <a href="http://www.glastar.org/GSAI/Welcome_to_the_Glastar_%26_Sportsman_Association.html" target="_blank">Sportsman</a> builder, Dee Whittington and I did a nice little cross country to shake out the bugs.   Mercifully there were none.   Although a little warm and just a touch bouncy, our trip from Chesterfield to Petersburg to Wakefield to Sufflolk to Chesapeake with stops at both Suffolk and Chesapeake for their open house, proved to be completely uneventful.  Can I fly now, huh, can I can I huh??</p>
<p>This weekend it&#8217;s back to Suffolk for the annual Festival of Flight Fly-in.  It should be fun!  Fly there, drive there or walk there if you have to!</p>
<h2 style="text-align: center;"><strong>!!!! NEWS !!!!</strong></h2>
<p style="text-align: left;"><strong> </strong>I&#8217;ve been corresponding with a fellow daring aviator who successfully flew a Velocity from the United States over to South Africa by way of Iceland, Europe and Egypt to Africa.  James Arestad is his name and I watched is Video Blog in snippets over the course of several days.  Apologies to my employer but I couldn&#8217;t help myself, his story is just too compelling!  I reached out to James and he&#8217;s agreed to do a pod-cast which I&#8217;ll post here as soon as it&#8217;s done.  In the meantime, check out <a title="Velocity Trip to South Africa" href="http://www.youtube.com/user/c152blazer#p/u" target="_self">James&#8217; adventures on YouTube.</a></p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.icekreamkoan.com%2F2010%2F05%2F20%2Fthe-two-categories-of-kit-built-aircraft%2F';
  addthis_title  = 'The+Two+Categories+of+Kit+Built+Aircraft%26%238230%3B';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>

<!-- start wp-tags-to-technorati 1.02 -->

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://www.icekreamkoan.com/2010/05/20/the-two-categories-of-kit-built-aircraft/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Knocking the Rust off My Piloting Skills</title>
		<link>http://www.icekreamkoan.com/2010/04/27/knocking-the-rust-off-my-piloting-skills/</link>
		<comments>http://www.icekreamkoan.com/2010/04/27/knocking-the-rust-off-my-piloting-skills/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 16:06:50 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[experimental aircraft]]></category>
		<category><![CDATA[flying]]></category>
		<category><![CDATA[Glastar]]></category>

		<guid isPermaLink="false">http://www.icekreamkoan.com/?p=219</guid>
		<description><![CDATA[A funny thing happens when you spend 10 years of your life building an airplane: You don&#8217;t fly much.  The other thing that happens is that sooner or latter you actually have to get in the airplane you built and fly it!  Should I worry about the left-over parts I had after I finished?  All [...]]]></description>
			<content:encoded><![CDATA[<p></p><div id="attachment_220" class="wp-caption alignleft" style="width: 300px">
	<img class="size-medium wp-image-220" title="IMG_1429 Peter Braswell and his GlaStar (Medium)" src="http://www.icekreamkoan.com/wp-content/uploads/2010/04/IMG_1429-Peter-Braswell-and-his-GlaStar-Medium-300x225.jpg" alt="Glastar N275PA" width="300" height="225" />
	<p class="wp-caption-text">Glastar N275PA</p>
</div>
<p>A funny thing happens when you spend 10 years of your life building an airplane: You don&#8217;t fly much.  The other thing that happens is that sooner or latter you actually have to get in the airplane you built and fly it!  Should I worry about the left-over parts I had after I finished?  All kidding aside, maintaining your currency is a big deal and not nearly as easy as it seems.  There are two things that are in short supply while you&#8217;re building: money and time.  Two years after I first flew my experimental Glastar I found myself lacking a level confidence having only enough flight experience to be legal,  But am I safe?  Probably, but not in anything but in the best of circumstances.  For this year&#8217;s BFR (bi-annual flight review) I wanted to go back to the basics.  I ended up designing my own BFR that zeroed in on the areas I thought were lacking.</p>
<p>Prior to this &#8220;Design your own BFR&#8221; epiphany, I ran across probably one of the best aviation resources currently on the net.  We heard <a title="Rod Machado" href="http://www.rodmachado.com/" target="_blank">Rod Machado</a> speak at Sun and Fun this year.  His talk was excellent and of course he sprinkled his presentation with his trademark Machado humor humor.  One of the things that Rod suggests in his really excellent book &#8220;<a href="http://www.rodmachado.com/_available_products/plane_talk_book.php" target="_blank">Plane Talk</a>&#8221; is to zero in on the things you&#8217;re most uncomfortable with and design training around it.  A designer BFR was born.</p>
<p>I found a really great <a href="http://newkentaviation.web.officelive.com/default.aspx" target="_self">CFII at New Kent Aviation</a> who agreed to work with me on the aspects of flying that I was most concerned with.  My BFR this year is comprised of a 10 hour block of ground school and instruction that covers the following:</p>
<ul>
<li>Engine failures en-route, in the pattern and during take-off</li>
<li>In flight emergencies such as fires, electrical failures, stuck gear and any other think we can dream up</li>
<li>Night flying and night currency</li>
<li>Complex aircraft check-out</li>
<li>ATC communications, flight following and trips into class &#8216;C&#8217; airspace</li>
</ul>
<p>This seems like basic stuff and it is.  Any Private Pilot student will get all of this and more during their training and will be proficient after their check ride.  After the check ride though a funny thing happens: you start doing the stuff you want at the exclusion of the stuff you should be doing but don&#8217;t have to be doing.  Case in point: VFR flight filing and flight following.  I know that pilots have mixed feelings about filing flight plans but the way I see it, it&#8217;s cheap insurance.  Free insurance actually.  Why not use it?  Why not use everything at your disposal for that matter to make flying safer.  Like Rod says: safe flying is all about controlling and minimizing risk and we have control of more of those factors than we think.</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.icekreamkoan.com%2F2010%2F04%2F27%2Fknocking-the-rust-off-my-piloting-skills%2F';
  addthis_title  = 'Knocking+the+Rust+off+My+Piloting+Skills';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>

<!-- start wp-tags-to-technorati 1.02 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/experimental+aircraft' rel='tag' target='_self'>experimental aircraft</a>, <a class='technorati-link' href='http://technorati.com/tag/flying' rel='tag' target='_self'>flying</a>, <a class='technorati-link' href='http://technorati.com/tag/Glastar' rel='tag' target='_self'>Glastar</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://www.icekreamkoan.com/2010/04/27/knocking-the-rust-off-my-piloting-skills/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML Scraping, Starring: Ruby,  HPRICOT and Firebug</title>
		<link>http://www.icekreamkoan.com/2009/09/09/html-scraping-ruby-starring-hpricot-and-firebug/</link>
		<comments>http://www.icekreamkoan.com/2009/09/09/html-scraping-ruby-starring-hpricot-and-firebug/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 01:10:27 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[hpricot]]></category>
		<category><![CDATA[RoR]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://www.icekreamkoan.com/?p=208</guid>
		<description><![CDATA[I had a really sticky problem.  I&#8217;m building a web 2.0 application that aggregates data from disparate social media sites.  The good news is that MANY sites have really great, REST API&#8217;s while many do not.  My nemesis was Google Blog Search.  Sorry Charlie, no API! What to to? I&#8217;ve burned several nights trying to [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I had a really sticky problem.  I&#8217;m building a web 2.0 application that aggregates data from disparate social media sites.  The good news is that MANY sites have really great, REST API&#8217;s while many do not.  My nemesis was <a href="http://blogsearch.google.com/">Google Blog Search</a>.  Sorry Charlie, no API!</p>
<p>What to to?</p>
<p>I&#8217;ve burned several nights trying to work around this problem with mixed results and very disappointing results.  Plugging away and looking at dozen&#8217;s of different ways to tackle this problem, I finally settled on an approach suggested here by <a href="http://www.igvita.com/2007/02/04/ruby-screen-scraper-in-60-seconds/">igvita.com</a>.  While this got me 90% of the way there, I had to do a bit of twiddling to get it to work properly.</p>
<p>First, the igvita.com article didn&#8217;t explain how to submit data.  No big deal, you can pass the search criteria in on the requesting URL:</p>
<p><code>@url = "http://blogsearch.google.com/blogsearch?hl=en&amp;amp;ie=UTF-8&amp;amp;q=ruby+rails"</code></p>
<p>So far, so good.</p>
<p>The next trick is to use XPATH to locate and snag the piece of data you&#8217;re interested in.  This is where Firebug completely rocks.  If you&#8217;re not using Firebug for web development, you&#8217;re either a glutton for punishment or have been living under a rock for quite a while.  In my particular case, the only piece of data that I was interested was the number of hits on the particular query:</p>
<p style="text-align: center;"><img class="size-full wp-image-215 aligncenter" title="rubyrails-google-blog-search1" src="http://www.icekreamkoan.com/wp-content/uploads/2009/09/rubyrails-google-blog-search1.jpg" alt="rubyrails-google-blog-search1" width="383" height="97" /></p>
<p>The igvita.com article goes into detail regarding how to find the right Xpath by leveraging Firebug.  Firebug pretty slick and the article does a great job explaining how to use it, so I won&#8217;t go into the details here.  The problem is that the HTML needs to be converted to XML before the XPATH will work properly.  Below is the Ruby code in its entirety:</p>
<p><code>require 'rubygems'<br />
require 'open-uri'<br />
require 'hpricot'</code></p>
<p>@url = &#8220;http://blogsearch.google.com/blogsearch?hl=en&amp;ie=UTF-8&amp;q=ruby+rails&#8221;<br />
@response = &#8221;</p>
<p>begin</p>
<p># HPricot RDoc: http://code.whytheluckystiff.net/hpricot/<br />
doc = Hpricot(@response)<br />
xml = Hpricot.XML(open(@url).read)</p>
<p># Retrive number of comments<br />
number_of_hits = (xml/&#8221;/html/body/div[5]/table[3]/tbody/tr/td[2]/font/b[3]&#8220;).inner_html<br />
puts &#8220;Number of hits: #{number_of_hits}&#8221;</p>
<p>rescue Exception =&gt; e<br />
print e, &#8220;n&#8221;<br />
end<br />
</code></p>
<p>Happy hacking,</p>
<p>Peter</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.icekreamkoan.com%2F2009%2F09%2F09%2Fhtml-scraping-ruby-starring-hpricot-and-firebug%2F';
  addthis_title  = 'HTML+Scraping%2C+Starring%3A+Ruby%2C++HPRICOT+and+Firebug';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>

<!-- start wp-tags-to-technorati 1.02 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/hpricot' rel='tag' target='_self'>hpricot</a>, <a class='technorati-link' href='http://technorati.com/tag/RoR' rel='tag' target='_self'>RoR</a>, <a class='technorati-link' href='http://technorati.com/tag/Ruby' rel='tag' target='_self'>Ruby</a>, <a class='technorati-link' href='http://technorati.com/tag/ruby+on+rails' rel='tag' target='_self'>ruby on rails</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://www.icekreamkoan.com/2009/09/09/html-scraping-ruby-starring-hpricot-and-firebug/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Six Things to Keep in Mind when Considering Code Reviews</title>
		<link>http://www.icekreamkoan.com/2009/02/17/six-things-to-keep-in-mind-when-considering-code-reviews/</link>
		<comments>http://www.icekreamkoan.com/2009/02/17/six-things-to-keep-in-mind-when-considering-code-reviews/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 16:27:16 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code Review]]></category>
		<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.icekreamkoan.com/?p=186</guid>
		<description><![CDATA[In general, I'm not a huge fan of code reviews but they can be an effective tool if they're kept in check.  A co-worker asked me to put together some talking points about code reviews, which I did, regarding some of the things I thought would be material to keep in mind for a code review process.  I thought they might be generally useful, so I'm posting them here. ]]></description>
			<content:encoded><![CDATA[<p></p><p>In general, I&#8217;m not a huge fan of code reviews but they can be an effective tool if they&#8217;re kept in check.  A <a title="Cisco" href="http://www.cisco.com" target="_blank">co-worker</a> asked me to put together some talking points about code reviews, which I did, regarding some of the things I thought would be material to keep in mind for a code review process.  I thought they might be generally useful, so I&#8217;m posting them here.</p>
<ol>
<li>In general, I&#8217;m not a big fan of invasive, comprehensive code reviews.  They tend to have diminished value the more comprehensive they are.  I <strong>AM</strong> a fan of spot checks and quick audits concentrated mainly on those developers that maybe unknown quantities, e.g. new contractors, new team members etc.</li>
<li>AUTOMATE whenever and wherever possible. If style standards or code test coverage can be automated (which it can), it should.  Tools like <a title="CheckStyle Tool" href="http://checkstyle.sourceforge.net/" target="_blank">CheckStyle</a> and others are invaluable and are huge time savers.  They also have the benefit of being impersonal.  Nobody gets offended if a tools yells at you.   Before anything&#8217;s done manually, ask &#8220;Can this be automated?&#8221;  Manual review *should be* the exception, not the rule&#8230;</li>
<li>If there are formal code reviews, the purpose and the criteria that is going to be checked should be explicitly stated up-front.  I&#8217;ve seen too many code review sessions spiral into arguments that essentially boil down to &#8220;this is NOT how *I* would have implemented it!&#8221; as opposed to having a constructive discussion that ultimately adds value to the process.</li>
<li>Code efficiency can be a dicey topic.  I&#8217;ve seen a lot of developers spend hours arguing about the efficiency of a piece of code that might run once per day.  A strong moderator that has good mediation skills is important.  The reviewers must be mature enough to know when to pick a fight and when good enough is good enough.</li>
<li>A good process with well defined roles goes a long way to alleviating arguments and maximizing the value of code reviews.  In terms of roles, I would suggest: 1) Moderator 2) Peer 3) Developer who is being checked.   The peer reviews and then the three people get together in a meeting and review the results.  The moderator mediates and keeps the meeting rolling along and notes any action that is required to be taken.  I would suggest a time and scope limited review session.  Around 1-1.5 hours seems to work with follow-up sessions as needed.  Any longer and eyes glaze over and people&#8217;s interest fads&#8230;</li>
<li>Don&#8217;t let perfect get in the way of good enough &#8211; again there has to be a good balance and generally this discretion falls to the moderator, hence the moderator should be somebody who has good facilitator skills.</li>
</ol>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.icekreamkoan.com%2F2009%2F02%2F17%2Fsix-things-to-keep-in-mind-when-considering-code-reviews%2F';
  addthis_title  = 'Six+Things+to+Keep+in+Mind+when+Considering+Code+Reviews';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>

<!-- start wp-tags-to-technorati 1.02 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/Code+Review' rel='tag' target='_self'>Code Review</a>, <a class='technorati-link' href='http://technorati.com/tag/Coding' rel='tag' target='_self'>Coding</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://www.icekreamkoan.com/2009/02/17/six-things-to-keep-in-mind-when-considering-code-reviews/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>2 Minute TIps &#8211; Learn how to set up a Google Alert!</title>
		<link>http://www.icekreamkoan.com/2009/01/23/2-minute-tips-learn-how-to-set-up-a-google-alert/</link>
		<comments>http://www.icekreamkoan.com/2009/01/23/2-minute-tips-learn-how-to-set-up-a-google-alert/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 12:04:37 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.icekreamkoan.com/?p=172</guid>
		<description><![CDATA[This is a bit of an experiement.  I wanted to create a series of "2 Minute Tips" - video screen casts that show how to do something specific in a relatively short amount of time.]]></description>
			<content:encoded><![CDATA[<p></p><p style="text-align: center;">
<p style="text-align: center;"><p><a href="http://www.icekreamkoan.com/2009/01/23/2-minute-tips-learn-how-to-set-up-a-google-alert/"><em>Click here to view the embedded video.</em></a></p></p>
<p style="text-align: left;">This is a bit of an experiement.  I wanted to create a series of &#8220;2 Minute Tips&#8221; &#8211; video screen casts that show how to do something specific in a relatively short amount of time.</p>
<p style="text-align: left;">This week, I&#8217;m doing a screen cast of setting up a <a href="http://www.google.com/alerts" target="_blank">Google Alert</a>.  Google Alerts are a must have if you&#8217;re doing niche marketing, marketing research or other internet related marketing activities.  It&#8217;s a great way to keep an eye on the competition!  Even if you&#8217;re not in the SEO or internet marketing space, you should at LEAST have Google Alert set up on your name.  This will allow you to monitor and track what is being published about you on the web.  You&#8217;ll be surprised where you turn up!  Don&#8217;t be caught off gaurd!  Watch this short video and find out how to set this service up.</p>
<p style="text-align: left;">Enjoy! Peter</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.icekreamkoan.com%2F2009%2F01%2F23%2F2-minute-tips-learn-how-to-set-up-a-google-alert%2F';
  addthis_title  = '2+Minute+TIps+%26%238211%3B+Learn+how+to+set+up+a+Google+Alert%21';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>

<!-- start wp-tags-to-technorati 1.02 -->

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://www.icekreamkoan.com/2009/01/23/2-minute-tips-learn-how-to-set-up-a-google-alert/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Abundance and Gratitude</title>
		<link>http://www.icekreamkoan.com/2009/01/07/abundance-and-gratitude/</link>
		<comments>http://www.icekreamkoan.com/2009/01/07/abundance-and-gratitude/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 14:39:58 +0000</pubDate>
		<dc:creator>peter</dc:creator>
				<category><![CDATA[Everything else]]></category>
		<category><![CDATA[philosopy economics humanity]]></category>

		<guid isPermaLink="false">http://www.icekreamkoan.com/?p=158</guid>
		<description><![CDATA[You can’t escape it.  Each morning when I slide the paper out of it’s plastic baggie or turn on CNN, there it is: the constant drumbeat of bad news.  It rains down on us unmercifully like a torrent.  I catch my optimism waning more than I’d like to admit.  I think doubt is natural when [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://www.icekreamkoan.com/wp-content/uploads/2009/01/istock_000004691158xsmall.jpg"><img class="alignnone size-medium wp-image-162" title="istock_000004691158xsmall" src="http://www.icekreamkoan.com/wp-content/uploads/2009/01/istock_000004691158xsmall-205x300.jpg" alt="" width="205" height="300" /></a></p>
<p>You can’t escape it.  Each morning when I slide the paper out of it’s plastic baggie or turn on CNN, there it is: the constant drumbeat of bad news.  It rains down on us unmercifully like a torrent.  I catch my optimism waning more than I’d like to admit.  I think doubt is natural when all the news seems to be bad.  All this got me thinking about loss and abundance and I felt like writing about it.</p>
<p>I tend to be self examining by nature.  I’m not sure why that it is. I assume everybody self examines but I think we tend to spin and self judge rather than objectively self-examining.  There’s a profound difference.  I’m no exception.  I think that when crisis starts to affect friends and family, it feels like it’s closing it’s grips in on everybody.  I think that is what has me spooked.  In all of my adult life I’ve never gone a pay period without a check.  The only job I ever got fired or let go from was a lousy one selling satellite TV dishes.  I hated that job only slightly less than the previous one which was installing the satellite TV dishes.  The worst thing about the installation gig was crawling into places that hadn’t been crawled in years. Picking at frozen dirt wishing it would cooperate was low on the fun scale also.  The best part was the road trip to the next job because it gave you a chance to warm up a bit in the truck. A decade or so after the manual labor gig, I saw heady days of the dot.com frenzy.  This was a time that you really couldn’t get fired if you wanted.  In fact pay raises were no harder than walking down to the bosses office and casually mentioning the number of headhunters that had called during the day.  With every bubble it seems comes a burst.  The world today seems like it’s waking up to ever more perverse hang-overs.  Collectively we never seem to fully realize that each stroke of luck and good-fortune within it is contained its opposite.  This Taoist concept, try as we might, is inescapable.  What we can control however is the grace and the dignity with which we confront each side of this dichotomy.</p>
<p>Unlike today, I feel as though you could get your head around the dot.com bubble.  Today’s specter, with antagonists such as “credit default swaps” and “mortgage derivatives” seems different, almost too exotic to explain.  It’s also what finance types call a contagion  &#8211; something that isn’t isolated within a given sector or specific market.  No, this seems to be a chain of dominoes that isn’t done toppling over yet.  All this reflecting has gotten me thinking and ultimately led me to read a marvelous book by <a title="Victor Frankl" href="http://http://en.wikipedia.org/wiki/Viktor_Frankl" target="_blank">Victor Frankl</a> entitled <a href="http://www.amazon.com/gp/product/B000KDZAFC?ie=UTF8&amp;tag=icek-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B000KDZAFC" target="_blank">“Man’s Search for Meaning”</a>.  Frankl was a Jewish doctor during WWII.  As unthinkable as it was, Frankl, like six million other Jews were summarily rounded up and put into concentration camps.  Many, who were too sick or too old, were simply executed in the gas chambers and cremated.  Frankl describes in his book where a man’s fate was determined by painfully small and seemingly trivial twists of fate:  a simple wave of an SS Officer’s hand, which rail car you were loaded onto, what day of the week it happened to be.  Depending on an apparent random mix of unrelated circumstances it was either a right to the work camp and a chance at living or a left to the gas chambers.  It was that morbidly simple.</p>
<p>Frankl portrays the concentration camp, Auschwitz in his case, as a character which I found interesting.  As unspeakable as the whole “Final Solution” was, Frankl conveys almost reverence  because it provides him a living laboratory for investigating the true nature of man.  In one notable scene, Frankl and his work crew is marching to the day’s worksite.  Because of the extreme conditions, the malnourishment, the cold and disease, the men in his party were in very poor shape.  So poor in fact, where there constitutions that many could not wear shoes as their feet were too swollen from the edema.  On this particular march, the Jewish prisoners passed a convoy of incarcerated criminals.  The emotion that Frankl conveys is one of envy.  Even though the criminals were captive, they probably enjoyed at least an occasional shower, reasonably clean sheets and mail from home.  The wrongfully imprisoned Jews, many of whom had been men of notable position, had been reduced to nothing but a simple number and subsequently treated with as much respect as a number could commend.  These men had literally had everything taken away without exception.  They were stripped to the point where they were envious of criminals and prisoners.  This is a profound example of stratification and underscores just how dire a situation these people were in.</p>
<p>Where is all of this going?  For me, the lesson is simple.  I believe we must be very careful about what we declare a loss.  I don’t want to sell short what it’s like to loose one’s job and still be faced with a mortgage, car payments and dependents.  What I do want to emphasis is our perception of what it really means to live comfortably and how we choose to face adversity.  I don’t want to stand on any moral high ground and declare that we quit complaining about our material loss and get over it because loss and suffering is as individualized as anything.  It’s a matter of perspective and context.  What I will offer however, is what I believe the core message of Frankl’s book is.  Near the end of the part of the book where Frankl talks about the liberation of the camps, two powerful themes emerge.  One theme is fate and the role it plays in all our lives, amplified of course in the context of the Nazi concentration camps.  Even right up until the end, fate nudged the course of events in polar opposite directions.  Just before the allies liberated Auschwitz the Germans moved most of the prisoners out of camp to what they were calling “staging camps”.  Because of a clerical error, Frankl and a companion didn’t make it on the convoy.  They were extremely upset because the staging camp promised a change of clothes and medical aid from the American Red Cross.  Cold, dirty and in need of medical care, they waited, angry they missed the chance to get out earlier.  Latter they learned that the trucks did stop at an intermediate camp where the prisoners were herded into barracks, locked inside and burned alive by the Nazi SS.</p>
<p>The final lesson for me is a simple one.  Frankl speaks at length about the human condition and what man becomes when stripped to an almost sub-primal level.  During a retrospective of his imprisonment, Frankl suggests that it’s not so much what happens to us, but rather it all boils down to how we react.  As Frankl puts it: “We have a choice as to our way”.  So as we go into the new year and we face unavoidable challenges and quite possibly suffering like this generation hasn’t seen, we should keep this in mind.</p>
<p>PJB</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Fwww.icekreamkoan.com%2F2009%2F01%2F07%2Fabundance-and-gratitude%2F';
  addthis_title  = 'Abundance+and+Gratitude';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>

<!-- start wp-tags-to-technorati 1.02 -->

<p class='technorati-tags'>Technorati Tags: <a class='technorati-link' href='http://technorati.com/tag/philosopy+economics+humanity' rel='tag' target='_self'>philosopy economics humanity</a></p>

<!-- end wp-tags-to-technorati -->
]]></content:encoded>
			<wfw:commentRss>http://www.icekreamkoan.com/2009/01/07/abundance-and-gratitude/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

