<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[JasonGarber.com]]></title>
  <link href="http://jasongarber.com/atom.xml" rel="self"/>
  <link href="http://jasongarber.com/"/>
  <updated>2012-02-20T00:17:34+00:00</updated>
  <id>http://jasongarber.com/</id>
  <author>
    <name><![CDATA[Jason Garber]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[Ruby recruitment solution: Hire an expert to train developers you already have and like]]></title>
    <link href="http://jasongarber.com/blog/2012/03/20/rails-recruitment-solution-hire-an-expert-to-train-an-employee-you-already-like/"/>
    <updated>2012-03-20T08:08:00+00:00</updated>
    <id>http://jasongarber.com/blog/2012/03/20/rails-recruitment-solution-hire-an-expert-to-train-an-employee-you-already-like</id>
    <content type="html"><![CDATA[<p>Like most well-qualified Ruby developers, recruiters and hiring managers contact me frequently about their open web developer positions. The secret is out that you&#8217;ll get more bang for your buck with Ruby on Rails than the Java and .<span class="caps">NET</span> web frameworks, so small and large companies alike are clamoring for experienced Ruby developers. I read a year or more ago that there&#8217;s a shortage of at least 1,500 Ruby developers in the United States alone. That number has probably doubled or tripled by now. Everyone faces the same frustration: top Ruby talent is hard to come by.</p>
<p><!--more--></p>
<p>This works out well for someone like me who started with Ruby in 2005, when Rails was in its infancy. I have nearly seven years of experience with Rails, ten years of writing web applications, and 15 years of <span class="caps">HTML</span>, <span class="caps">CSS</span>, and Javascript. You can find workers aplenty who list Rails on their résumé but have really only dipped a toe in the water, which doesn&#8217;t cut it. There&#8217;s definitely a &#8220;Ruby way&#8221; and you can tell just by looking at someone&#8217;s code to what degree they get it. Even without looking at code samples, when I look through candidates on oDesk or eLance, I can safely assume the ones who title themselves things like &#8220;Senior Ruby/<span class="caps">PHP</span>/Java/Drupal/Coldfusion developer&#8221; are not competent Rubyists&#8212;probably not competent anythingists. I pass over candidates if they so much as mention <span class="caps">PHP</span> in their description.</p>
<h2>Why is Ruby expertise so important?</h2>
<p>Isn&#8217;t one of Ruby&#8217;s selling points that it&#8217;s easy to learn? Yes, but if you&#8217;re building anything that&#8217;s critical to your business, costs a significant amount, and that you want to have lasting value, <strong>you&#8217;d better build it right</strong>&#8212;not unlike constructing a new building. A good engineer is aware of a wide variety of resources (be it concrete and steel or full-text search and currency conversion libraries) and has worked with them enough to know their strengths and limitations. A good engineer builds things efficiently and follows convention. A good engineer has solved thousands of problems in this domain before, so when new ones appear, they know where to start looking. There&#8217;s no substitute for experience. A developer who has been in the Ruby trenches longer will have better solutions and come up with them more efficiently.</p>
<h3>These are the experts; They&#8217;re not interested.</h3>
<p>You can fairly easily find Ruby experts by:</p>
<ul>
	<li>looking for the authors of <a href="http://workingwithrails.com/browse/rubygems/usage">popular and mature open-source Ruby projects</a>,</li>
	<li>tracking down the leaders of local Ruby meetups,</li>
	<li>checking out who speaks at Ruby conferences, and</li>
	<li>investigating who writes books for the Ruby community.</li>
</ul>
<p>Chances are, they&#8217;re unavailable, prohibitively expensive, and not interested in your job.</p>
<h3>But they <em>can</em> be persuaded</h3>
<p>What experts <strong>can&#8217;t resist</strong>, especially in the fanatical Ruby community, is <strong>proselytizing</strong>&#8212;disseminating information and winning others over to their side. They&#8217;re much more likely to take a gig that involves training other smart developers who just haven&#8217;t &#8220;seen the light&#8221; than they are to just take the job themselves.</p>
<p><strong>If you already have developers that you like, hire an expert to train them on Ruby.</strong> That doesn&#8217;t mean three months of classes in the conference room. Experts like hands-on work and seeing that things are done right. That&#8217;s how they got to be the experts, after all! Put them on pair programming and code reviews to transfer their Ruby expertise to your best people. Develop Rubyists from within. You can always hire more Javaheads.</p>
<h2>Ending up with talented, loyal Ruby developers and a successful project</h2>
<p>Hire one or two Ruby experts to start your new project, apprentice your best developers, and after two or three months, taper off their involvement. They&#8217;ll have started the project with the right tools, set the standard for what good Ruby code looks like, solved the initial design problems, and equipped your developers to carry on. The project won&#8217;t be done&#8212;you might not even have a beta version deployed&#8212;but hopefully the project will be on-track for a solid finish and there will be good feelings all around.</p>
<p>Speaking for myself, I love the initial design phase, love watching others catch the Ruby bug, and love leveraging collaboration to produce more than I could alone. Oh&#8212;and I like being in charge, getting paid well, and moving on when the novelty has worn off!</p>
<p>So, recruiters, no more whining about how you can&#8217;t acquire top Ruby talent. It&#8217;s there and it&#8217;s available if you&#8217;re using the right bait. We&#8217;re not interested in full-time $120k + benefits because a.) we can probably do better freelancing, b.) who wants to work full-time?, and c.) <em>it&#8217;s not about the money!</em></p>
<p>The company hired you to hire developers, but what they really need is successful projects. (The old selling drills vs. selling holes analogy.) Sell them on needing to invest in expertise, but say you&#8217;ll save them money by apprenticing existing developers and they&#8217;ll think you&#8217;re brilliant. (You don&#8217;t need to tell them where the idea came from!) You really are brilliant, because guess who gets to find the replacement for their Javahead-turned-Ruybist&#8230;</p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Benchmarking Ruby String Conversion]]></title>
    <link href="http://jasongarber.com/blog/2012/01/24/benchmarking-ruby-string-conversion/"/>
    <updated>2012-01-24T11:14:00+00:00</updated>
    <id>http://jasongarber.com/blog/2012/01/24/benchmarking-ruby-string-conversion</id>
    <content type="html"><![CDATA[<p>I have a class (<code>Parslet::Slice</code>, to be precise) that inherits from String but needs to be converted back to a string. Which is faster, <code>String#to_s</code> or <code>String()</code>? My hunch is the latter, but I can find out for sure in about a minute:</p>
<p><!--more--></p>
<div><script src='https://gist.github.com/1670877.js?file='></script><br />
<noscript><pre><code>#!/usr/bin/env ruby
require 'benchmark'

TIMES_TO_REPEAT = 10_000_000

class SpecialString &amp;lt; String; end

Benchmark.bmbm do|b|
  b.report(&amp;quot;''.to_s&amp;quot;) do
    str = ''
    TIMES_TO_REPEAT.times { str.to_s }
  end
  
  b.report('&amp;quot;&amp;quot;.to_s') do
    str = &amp;quot;&amp;quot;
    TIMES_TO_REPEAT.times { str.to_s }
  end
  
  b.report(&amp;quot;String(str)&amp;quot;) do
    str = SpecialString.new(&amp;quot;&amp;quot;)
    TIMES_TO_REPEAT.times { String(str) }
  end

  b.report(&amp;quot;str.to_s&amp;quot;) do
    str = SpecialString.new(&amp;quot;&amp;quot;)
    TIMES_TO_REPEAT.times { str.to_s }
  end
end</code></pre></noscript></div>
<p>With Ruby 1.9:</p>
<p><div class='bogus-wrapper'><notextile><figure class='code'><figcaption><span>Results </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>ruby which_string_coercion_is_faster.rb ↵
</span><span class='line'>Rehearsal -----------------------------------------------
</span><span class='line'>''.to_s       0.970000   0.000000   0.970000 (  0.968759)
</span><span class='line'>"".to_s       0.960000   0.000000   0.960000 (  0.960182)
</span><span class='line'>String(str)   0.920000   0.000000   0.920000 (  0.920623)
</span><span class='line'>str.to_s      2.250000   0.010000   2.260000 (  2.249877)
</span><span class='line'>-------------------------------------- total: 5.110000sec
</span><span class='line'>
</span><span class='line'>                  user     system      total        real
</span><span class='line'>''.to_s       0.930000   0.000000   0.930000 (  0.931371)
</span><span class='line'>"".to_s       0.940000   0.000000   0.940000 (  0.934964)
</span><span class='line'>String(str)   0.910000   0.000000   0.910000 (  0.913435)
</span><span class='line'>str.to_s      2.250000   0.010000   2.260000 (  2.252326)</span></code></pre></td></tr></table></div></figure></div></notextile></p>
<p>Similar results on 1.8:</p>
<p><div class='bogus-wrapper'><notextile><figure class='code'><figcaption><span>Results </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>Rehearsal -----------------------------------------------
</span><span class='line'>''.to_s       1.470000   0.000000   1.470000 (  1.475513)
</span><span class='line'>"".to_s       1.540000   0.000000   1.540000 (  1.540667)
</span><span class='line'>String(str)   1.510000   0.000000   1.510000 (  1.509818)
</span><span class='line'>str.to_s      2.710000   0.000000   2.710000 (  2.713870)
</span><span class='line'>-------------------------------------- total: 7.230000sec
</span><span class='line'>
</span><span class='line'>                  user     system      total        real
</span><span class='line'>''.to_s       1.500000   0.000000   1.500000 (  1.497413)
</span><span class='line'>"".to_s       1.520000   0.000000   1.520000 (  1.512449)
</span><span class='line'>String(str)   1.540000   0.000000   1.540000 (  1.536261)
</span><span class='line'>str.to_s      2.690000   0.000000   2.690000 (  2.700433)</span></code></pre></td></tr></table></div></figure></div></notextile></p>]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Deploying Octopress to Heroku with a custom buildpack]]></title>
    <link href="http://jasongarber.com/blog/2012/01/10/deploying-octopress-to-heroku-with-a-custom-buildpack/"/>
    <updated>2012-01-10T16:00:00+00:00</updated>
    <id>http://jasongarber.com/blog/2012/01/10/deploying-octopress-to-heroku-with-a-custom-buildpack</id>
    <content type="html"><![CDATA[<p>I&#8217;ve had apps on Heroku since 2009, but over the last year or so I&#8217;ve been deploying apps there more and more. With the advent of the Cedar stack, there&#8217;s less and less you can&#8217;t do. Compared to provisioning a virtual server, even with the help of <a href="https://github.com/railsmachine/moonshine">moonshine</a>, you can&#8217;t beat <code>heroku create --stack cedar</code>: <strong>boom</strong>, you have a live site with backups, logging, release management and the running of migrations and asset compilation on deploy. In just another few minutes, you can have <span class="caps">SSL</span>, rotating database backups, NewRelic, HopToad, cron, <span class="caps">DNS</span>, monitoring, and myriad other addons.</p>
<p>When I switched my blog from Radiant <span class="caps">CMS</span> to Octopress, I wanted to keep the site on Heroku. It&#8217;s free under normal scenarios and if I ever get on HackerNews or Reddit, I just have to scale up my web processes and pay a bit to keep the site responsive. If I were to be so fortunate,  I wouldn&#8217;t have to scramble to set up load balancing on Linode or even wait while my slice resized. Yay cloud!</p>
<p>The <a href="http://octopress.org/docs/deploying/heroku/">standard method for deploying Octopress to Heroku</a> involves generating your site, checking in the generated contents (within the <code>public/</code> folder), and deploying to Heroku. As <a href="http://www.mwmanning.com/2011/11/29/Run-Your-Jekyll-Site-On-Heroku.html">Matthew Manning noted</a>, neither having to check in generated content nor having it generated on-the-fly is ideal. We really need to hook into Heroku&#8217;s build phase.</p>
<p>The Cedar stack lets you provide a buildpack for generating the app. It&#8217;s how the stack can support Node.js, Python, <span class="caps">PHP</span>, etc. I forked Manning&#8217;s buildpack and customized it for Octopress. Here&#8217;s what you need to do to deploy your Octopress site to Heroku:</p>
<p><!--more--></p>
<h2>Get your repository ready for Heroku</h2>
<p>Heroku needs to see the <code>plugins</code>, <code>sass</code>, and <code>source</code> directories, but they&#8217;re left out of the Heroku application slug unless you remove them from <code>.slugignore</code>.</p>
<pre><code>echo '' &gt; .slugignore</code></pre>
<h2>Fix Pygments</h2>
<p>Pygments won&#8217;t work on Heroku&#8212;or at least I haven&#8217;t found a way&#8212;so let&#8217;s switch to a Pygments <span class="caps">API</span> hosted on Heroku.</p>
<p>First, remove <code>pygments.rb</code> from the Gemfile. You&#8217;ll then need to patch <code>plugins/pygments_code.rb</code>, removing the require at the top and adding an <span class="caps">API</span> call instead of the Pygments library call in two places.</p>
<p><div class='bogus-wrapper'><notextile><figure class='code'><figcaption><span>Changes to plugins/pygments_code.rb (pygmentize.diff) </span></figcaption>
 <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
</pre></td><td class='code'><pre><code class='diff'><span class='line'><span class="gu">@@ -1,7 +1,9 @@</span>
</span><span class='line'><span class="gd">-require &#39;pygments&#39;</span>
</span><span class='line'><span class="gi">+require &#39;net/http&#39;</span>
</span><span class='line'><span class="gi">+require &#39;uri&#39;</span>
</span><span class='line'> require &#39;fileutils&#39;
</span><span class='line'> require &#39;digest/md5&#39;
</span><span class='line'>
</span><span class='line'><span class="gi">+PYGMENTIZE_URL = URI.parse(&#39;http://pygmentize.herokuapp.com/&#39;)</span>
</span><span class='line'> PYGMENTS_CACHE_DIR = File.expand_path(&#39;../../.pygments-cache&#39;, __FILE__)
</span><span class='line'> FileUtils.mkdir_p(PYGMENTS_CACHE_DIR)
</span><span class='line'>
</span><span class='line'><span class="gu">@@ -21,11 +23,11 @@ module HighlightCode</span>
</span><span class='line'>       if File.exist?(path)
</span><span class='line'>         highlighted_code = File.read(path)
</span><span class='line'>       else
</span><span class='line'><span class="gd">-        highlighted_code = Pygments.highlight(code, :lexer =&gt; lang, :formatter =&gt; &#39;html&#39;, :options =&gt; {:encoding =&gt; &#39;ut</span>
</span><span class='line'><span class="gi">+        highlighted_code = Net::HTTP.post_form(PYGMENTIZE_URL, {&#39;lang&#39;=&gt;lang, &#39;code&#39;=&gt;code}).body</span>
</span><span class='line'>         File.open(path, &#39;w&#39;) {|f| f.print(highlighted_code) }
</span><span class='line'>       end
</span><span class='line'>     else
</span><span class='line'><span class="gd">-      highlighted_code = Pygments.highlight(code, :lexer =&gt; lang, :formatter =&gt; &#39;html&#39;, :options =&gt; {:encoding =&gt; &#39;utf-</span>
</span><span class='line'><span class="gi">+      highlighted_code = Net::HTTP.post_form(PYGMENTIZE_URL, {&#39;lang&#39;=&gt;lang, &#39;code&#39;=&gt;code}).body</span>
</span><span class='line'>     end
</span><span class='line'>     highlighted_code
</span><span class='line'>   end
</span></code></pre></td></tr></table></div></figure></div></notextile></p>
<h2>Rearrange your Gemfile</h2>
<p>When Jekyll builds your site, it needs the gems in the development group, but it&#8217;s assumed you&#8217;re generating your site before deploying, so you won&#8217;t need them in production. Since we&#8217;re pushing the generation step to Heroku and it uses <code>bundle install --without development:test</code>, it won&#8217;t have the gems it needs in the build phase. We&#8217;ll need to pull everything but <code>rb-fsevent</code> out into the default group.</p>
<p>Also add <code>gem 'heroku'</code> inside the development group. If you like, you can add <code>gem 'thin'</code> to use thin for your server instead of WEBrick.</p>
<p>Your Gemfile should now look like this:</p>
<p><div class='bogus-wrapper'><notextile><figure class='code'><figcaption><span>Rearranged Gemfile (Gemfile.rb) </span></figcaption>
 <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
</pre></td><td class='code'><pre><code class='rb'><span class='line'><span class="n">source</span> <span class="s2">&quot;http://rubygems.org&quot;</span>
</span><span class='line'>
</span><span class='line'><span class="n">gem</span> <span class="s1">&#39;rake&#39;</span>
</span><span class='line'><span class="n">gem</span> <span class="s1">&#39;rack&#39;</span>
</span><span class='line'><span class="n">gem</span> <span class="s1">&#39;jekyll&#39;</span>
</span><span class='line'><span class="n">gem</span> <span class="s1">&#39;rdiscount&#39;</span>
</span><span class='line'><span class="n">gem</span> <span class="s1">&#39;RedCloth&#39;</span>
</span><span class='line'><span class="n">gem</span> <span class="s1">&#39;haml&#39;</span><span class="p">,</span> <span class="s1">&#39;&gt;= 3.1&#39;</span>
</span><span class='line'><span class="n">gem</span> <span class="s1">&#39;compass&#39;</span><span class="p">,</span> <span class="s1">&#39;&gt;= 0.11&#39;</span>
</span><span class='line'><span class="n">gem</span> <span class="s1">&#39;rubypants&#39;</span>
</span><span class='line'><span class="n">gem</span> <span class="s1">&#39;stringex&#39;</span>
</span><span class='line'><span class="n">gem</span> <span class="s1">&#39;liquid&#39;</span><span class="p">,</span> <span class="s1">&#39;2.2.2&#39;</span>
</span><span class='line'><span class="n">gem</span> <span class="s1">&#39;sinatra&#39;</span><span class="p">,</span> <span class="s1">&#39;1.2.6&#39;</span>
</span><span class='line'><span class="n">gem</span> <span class="s1">&#39;thin&#39;</span>
</span><span class='line'>
</span><span class='line'><span class="n">group</span> <span class="ss">:development</span> <span class="k">do</span>
</span><span class='line'>  <span class="n">gem</span> <span class="s1">&#39;rb-fsevent&#39;</span>
</span><span class='line'>  <span class="n">gem</span> <span class="s1">&#39;heroku&#39;</span>
</span><span class='line'><span class="k">end</span>
</span></code></pre></td></tr></table></div></figure></div></notextile></p>
<h2>Create the app on Heroku</h2>
<pre><code>heroku create --stack cedar --buildpack git://github.com/jgarber/heroku-buildpack-ruby-octopress.git
git push heroku master</code></pre>
<p>The site should build cleanly and should work at the app <span class="caps">URL</span> given. If not, look at the build output when you pushed to Heroku and also check <code>heroku logs</code>.</p>
<p>Let me know in the comments if it worked for you and feel free to fork the buildpack.</p>
<hr />
<h3 style="vertical-align:middle;">Update: Plain Jekyll supported by the buildpack as well.</h3>
<p><a href="https://github.com/matschaffer">Mat Schaffer</a> added support for vanilla Jekyll sites as well. Very elegantly done.</p>]]></content>
  </entry>
  
</feed>

