

<rss version="2.0">
  <channel>
    <title>Dblock.org | Code</title>
    <description>technology website</description>
    <link>http://code.dblock.org/</link>
    <language>en-us</language>
    <image>
      <url>http://code.dblock.org/images/blog/blog.gif</url>
      <title>Dblock.org | Code</title>
      <link>http://code.dblock.org/</link>
      <width>72</width>
      <height>49</height>
    </image>
    
      <item>
       <title>Building &amp; Scaling a Test-Driven Culture @ AppNexus (Video)</title>
       <pubDate>Thu, 16 May 2013 15:38:37 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p>I gave a talk last week at AppNexus on building and scaling a test-driven culture.</p>  <p><a href="http://www.youtube.com/watch?v=QvHf94hxzRc">http://www.youtube.com/watch?v=QvHf94hxzRc</a></p>  <p><a href="http://www.youtube.com/watch?v=QvHf94hxzRc"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=551&ShowThumbnail=false" width="240" height="148" /></a></p></stripped></div><div><a href="http://code.dblock.org/building-scaling-a-test-driven-culture-appnexus-video">Read</a></div></html>
         ]]>
       </description>
       <category>teams</category><category>art.sy</category><category>testing</category><category>agile</category>
       <link>http://code.dblock.org/building-scaling-a-test-driven-culture-appnexus-video</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/384</guid>
      </item>
     
      <item>
       <title>Being Helpful with Ruby Exceptions and Error Messages</title>
       <pubDate>Wed, 15 May 2013 01:57:17 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p>We talk a lot about error handling in Ruby. But we rarely talk about raising errors and creating helpful error messages that are actionable. A good error should tell the developer what went wrong and what to do about it.</p>  <p>One library is known for its excellent error messages. Consider a typical validation error from <a href="https://github.com/mongoid/mongoid">Mongoid</a>.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>#&lt;Mongoid::Errors::Validations: </li> <li style="background: #f3f3f3">Problem:</li> <li>  Validation of User failed.</li> <li style="background: #f3f3f3">Summary:</li> <li>  The following errors were found: Password can't be blank</li> <li style="background: #f3f3f3">Resolution:</li> <li>  Try persisting the document with valid data or remove the validations.&gt;</li> </ol> </div> </div> </div>  <p>This error describes the problem, offers a detailed summary and provides a possible resolution!</p>  <p>Lets implement a similar system for the <a href="https://github.com/dblock/ruby-enum/">ruby-enum gem</a> that I <a href="http://code.dblock.org/your-first-ruby-gem">live-coded at NYC.rb</a>.</p>  <p>First, add a dependency on <a href="http://rubygems.org/gems/i18n">i18n</a><em></em> and <em>require "i18n"</em>. Then, create a <em>lib/config/locales</em> folder and an <em>en.yml</em> file in it. English error messages will go there. This file will need to be loaded by our library, specifically in <a href="https://github.com/dblock/ruby-enum/blob/master/lib/ruby-enum.rb">ruby-enum.rb</a>.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>require 'i18n'</li> <li style="background: #f3f3f3">I18n.load_path &lt;&lt; File.join(File.dirname(__FILE__), "config", "locales", "en.yml")</li> </ol> </div> </div> </div>  <p>Error descriptions inside <em>en.yml</em> contain the problem, summary and resolution. The YAML format supports multi-lines with \_\_ and can include values from parameters using the <em>%{name}</em> syntax.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>en:</li> <li style="background: #f3f3f3">  ruby:</li> <li>    enum:</li> <li style="background: #f3f3f3">      errors:</li> <li>        messages:</li> <li style="background: #f3f3f3">          uninitialized_constant:</li> <li>            message: "Uninitialized constant."</li> <li style="background: #f3f3f3">            summary: "The constant %{name}::%{key} has not been defined."</li> <li>            resolution: "The enumerated value could not be found in class %{name}.\n</li> <li style="background: #f3f3f3">            \_Use 'define' to declare it.\n</li> <li>            \_Example:\n</li> <li style="background: #f3f3f3">            \_\_module %{name}\n</li> <li>            \_\_\_include Ruby::Enum\n</li> <li style="background: #f3f3f3">            \_\_\_define %{key}, 'value'\n</li> <li>            \_\_end"</li> </ol> </div> </div> </div>  <p>The base error class, <a href="https://github.com/dblock/ruby-enum/blob/master/lib/ruby-enum/errors/base.rb">Ruby::Enum::Errors::Base</a> takes care of the translation. I stripped the implementation details below – the important parts is the <em>BASE_KEY</em> value for localized error messages and the <em>compose_message</em> method. Get the full implementation <a href="https://github.com/dblock/ruby-enum/blob/master/lib/ruby-enum/errors/base.rb">here</a> and modify it for your project.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>module Ruby</li> <li style="background: #f3f3f3">  module Enum</li> <li>    module Errors</li> <li style="background: #f3f3f3">      class Base &lt; StandardError</li> <li> </li> <li style="background: #f3f3f3">        attr_reader :problem, :summary, :resolution</li> <li> </li> <li style="background: #f3f3f3">        def compose_message(key, attributes = {})</li> <li>          @problem = create_problem(key, attributes)</li> <li style="background: #f3f3f3">          @summary = create_summary(key, attributes)</li> <li>          @resolution = create_resolution(key, attributes)</li> <li style="background: #f3f3f3"> </li> <li>          "\nProblem:\n  #{@problem}" +</li> <li style="background: #f3f3f3">          "\nSummary:\n  #{@summary}" +</li> <li>          "\nResolution:\n  #{@resolution}"</li> <li style="background: #f3f3f3">        end</li> <li> </li> <li style="background: #f3f3f3">        private</li> <li> </li> <li style="background: #f3f3f3">          BASE_KEY = "ruby.enum.errors.messages" #:nodoc:</li> <li> </li> <li style="background: #f3f3f3">          # implementation of create_problem, summary and resolution</li> <li> </li> <li style="background: #f3f3f3">      end</li> <li>    end</li> <li style="background: #f3f3f3">  end</li> <li>end</li> </ol> </div> </div> </div>  <p>Specific errors derive from this class.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>module Ruby</li> <li style="background: #f3f3f3">  module Enum</li> <li>    module Errors</li> <li style="background: #f3f3f3">      class UninitializedConstantError &lt; Base</li> <li>        def initialize(attrs)</li> <li style="background: #f3f3f3">          super(compose_message("uninitialized_constant", attrs))</li> <li>        end</li> <li style="background: #f3f3f3">      end</li> <li>    end</li> <li style="background: #f3f3f3">  end</li> <li>end</li> </ol> </div> </div> </div>  <p>When raising an <em>UninitializedConstantError</em>, pass the values of <em>key</em> and <em>name</em> used in the en.yml file above.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>raise Ruby::Enum::Errors::UninitializedConstantError.new({ </li> <li style="background: #f3f3f3">  :name =&gt; "Class", </li> <li>  :key =&gt; "CONSTANT" </li> <li style="background: #f3f3f3"> })</li> </ol> </div> </div> </div>  <p>Here’s the result.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>1.9.3-p362 :002 &gt; require 'ruby-enum'</li> <li style="background: #f3f3f3"> =&gt; true </li> <li>1.9.3-p362 :003 &gt; raise Ruby::Enum::Errors::UninitializedConstantError.new({</li> <li style="background: #f3f3f3"> :name =&gt; "Class", </li> <li> :key =&gt; "CONSTANT" </li> <li style="background: #f3f3f3">})</li> <li> </li> <li style="background: #f3f3f3">Ruby::Enum::Errors::UninitializedConstantError: </li> <li>Problem:</li> <li style="background: #f3f3f3">  Uninitialized constant.</li> <li>Summary:</li> <li style="background: #f3f3f3">  The constant Class::CONSTANT has not been defined.</li> <li>Resolution:</li> <li style="background: #f3f3f3">  The enumerated value could not be found in class Class.</li> <li>  Use 'define' to declare it.</li> <li style="background: #f3f3f3">  Example:</li> <li>   module Class</li> <li style="background: #f3f3f3">    include Ruby::Enum</li> <li>    define CONSTANT, 'value'</li> <li style="background: #f3f3f3">   end</li> </ol> </div> </div> </div>  <p>Beautiful.</p></stripped></div><div><a href="http://code.dblock.org/being-helpful-with-ruby-exceptions-and-error-messages">Read</a></div></html>
         ]]>
       </description>
       <category>ruby</category><category>open source</category>
       <link>http://code.dblock.org/being-helpful-with-ruby-exceptions-and-error-messages</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/383</guid>
      </item>
     
      <item>
       <title>Your First Ruby Gem</title>
       <pubDate>Wed, 15 May 2013 01:53:08 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p><img style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" src="http://photos1.meetupstatic.com/photos/event/6/5/a/3/global_20906019.jpeg" /></p>  <p>I live-coded a new gem called <a href="https://github.com/dblock/ruby-enum">Ruby::Enum</a> at <a href="http://www.meetup.com/NYC-rb/events/88141492/">NYC.rb</a> on Tuesday. This library adds enum-like functionality to Ruby.</p>  <p>Here’s my checklist for creating a new gem.</p>  <p><strong>Check the Name</strong></p>  <p>Ruby gems are registered with <a href="http://rubygems.org/">Rubygems</a> and managed in your projects using <a href="http://gembundler.com/">Bundler</a>. Search for the new gem name on Rubygems to make sure it's not taken.</p>  <p><strong>Create a Folder</strong></p>  <p>I organize all my code in <em>source</em> and since I often fork code from others to contribute, create a subfolder with the Github username, including mine.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>$ mkdir ~/source/ruby-enum/dblock</li> <li style="background: #f3f3f3">$ cd ~/source/ruby-enum/dblock</li> </ol> </div> </div> </div>  <p><strong></strong></p>  <p><strong>Initialize a Git Repository</strong></p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>$ git init</li> <li style="background: #f3f3f3">Initialized empty Git repository in /home/dblock/source/ruby-enum/dblock/.git/</li> </ol> </div> </div> </div>  <p><strong></strong></p>  <p><strong>Create a Github Repo</strong></p>  <p>Create a new repository on <a href="http://github.com/">Github</a>. </p>  <p><a href="http://code.dblock.org/ShowPicture.aspx?id=547&ShowThumbnail=false"><img title="image" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=548&ShowThumbnail=false" width="343" height="46" /></a></p>  <p>Add it as a remote.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>$ git remote add origin git@github.com:dblock/ruby-enum.git</li> </ol> </div> </div> </div>  <p><strong></strong></p>  <p><strong>Create a Readme</strong></p>  <p>Documentation is written in Markdown. Create and commit a <em>README.md</em>.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>$ git commit -m "Added README."</li> <li style="background: #f3f3f3">[master acc5880] Added README.</li> <li> 1 file changed, 4 insertions(+)</li> <li style="background: #f3f3f3"> create mode 100644 README.md</li> </ol> </div> </div> </div>  <p>Push the README to Github.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>$ git push origin master</li> <li style="background: #f3f3f3">Counting objects: 6, done.</li> <li>Compressing objects: 100% (5/5), done.</li> <li style="background: #f3f3f3">Writing objects: 100% (6/6), 963 bytes, done.</li> <li>Total 6 (delta 0), reused 0 (delta 0)</li> <li style="background: #f3f3f3">To git@github.com:dblock/ruby-enum.git</li> <li> * [new branch]      master -&gt; master</li> </ol> </div> </div> </div>  <p><strong></strong></p>  <p><strong>Add a License</strong></p>  <p>Every project needs a license. I use <a href="https://github.com/dblock/ruby-enum/blob/master/LICENSE.md">the MIT license</a> because it’s short and nobody has time to read licenses. Add a copyright notice to the README, don't forget future contributors.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>Copyright (c) 2013, Daniel Doubrovkine and Contributors. All Rights Reserved.</li> <li style="background: #f3f3f3"> </li> <li>This project is licenced under the [MIT License](LICENSE.md).</li> </ol> </div> </div> </div>  <p><strong></strong></p>  <p><strong>Gemfile</strong></p>  <p>A Gemfile is something that comes with <a href="http://gembundler.com/">Bundler</a> and declares gem dependencies.</p>  <p>Install Bundler.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>$ gem install bundler</li> <li style="background: #f3f3f3">Fetching: bundler-1.3.5.gem (100%)</li> <li>Successfully installed bundler-1.3.5</li> <li style="background: #f3f3f3">1 gem installed</li> <li>Installing ri documentation for bundler-1.3.5...</li> <li style="background: #f3f3f3">Installing RDoc documentation for bundler-1.3.5...</li> </ol> </div> </div> </div>  <p>Create a Gemfile. For now it just says where to get other gems from.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>source "http://rubygems.org"</li> </ol> </div> </div> </div>  <p>Run <em>bundle install</em>.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>$ bundle install</li> <li style="background: #f3f3f3">Resolving dependencies...</li> <li>Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.</li> </ol> </div> </div> </div>  <p><strong></strong></p>  <p><strong>.gitignore</strong></p>  <p>The generated Gemfile.lock should not be included, create a <em>.gitignore</em>.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>Gemfile.lock</li> </ol> </div> </div> </div>  <p><strong></strong></p>  <p><strong>Enum Library</strong></p>  <p>Create <em>lib/ruby-enum.rb </em>and <em>lib/ruby-enum/version.rb</em>.</p>  <p>   </p><div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>require 'ruby-enum/version'</li> </ol> </div> </div> </div>   <p>   </p><div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>module Ruby::Enum</li> <li style="background: #f3f3f3">  VERSION = '0.1.0'</li> <li>end</li> </ol> </div> </div> </div>   <p><strong></strong></p>  <p><strong>Tests</strong></p>  <p>You. Must. Test.</p>  <p>Add RSpec to <em>Gemfile</em>.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>gem "rspec"</li> </ol> </div> </div> </div>  <p>Tests need some setup, specifically to load the code in <em>lib</em>. Create <em>spec/spec_helper.rb</em>.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))</li> <li style="background: #f3f3f3"> </li> <li>require 'rubygems'</li> <li style="background: #f3f3f3">require 'rspec'</li> <li>require 'ruby-enum'</li> </ol> </div> </div> </div>  <p>Create a test in <em>spec/ruby-enum/version.rb</em>.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>require 'spec_helper'</li> <li style="background: #f3f3f3"> </li> <li>describe Ruby::Enum do</li> <li style="background: #f3f3f3">  it "has a version" do</li> <li>    Ruby::Enum::VERSION.should_not be_nil</li> <li style="background: #f3f3f3">  end</li> <li>end</li> </ol> </div> </div> </div>  <p>Add .rspec to pretty-print test output.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>--format documentation</li> <li style="background: #f3f3f3">--color</li> </ol> </div> </div> </div> <strong></strong>  <p><strong></strong></p>  <p><strong>Gem Declaration</strong></p>  <p>A <em>ruby-enum.gemspec</em> is a gem declaration.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>$:.push File.expand_path("../lib", __FILE__)</li> <li style="background: #f3f3f3">require "ruby-enum/version"</li> <li> </li> <li style="background: #f3f3f3">Gem::Specification.new do |s|</li> <li>  s.name = "ruby-enum"</li> <li style="background: #f3f3f3">  s.version = Ruby::Enum::VERSION</li> <li>  s.authors = [ "Daniel Doubrovkine" ]</li> <li style="background: #f3f3f3">  s.email = "dblock@dblock.org"</li> <li>  s.platform = Gem::Platform::RUBY</li> <li style="background: #f3f3f3">  s.required_rubygems_version = '&gt;= 1.3.6'</li> <li>  s.files = `git ls-files`.split("\n")</li> <li style="background: #f3f3f3">  s.require_paths = [ "lib" ]</li> <li>  s.homepage = "http://github.com/dblock/ruby-enum"</li> <li style="background: #f3f3f3">  s.licenses = [ "MIT" ]</li> <li>  s.summary = "Enum-like Behavior for Ruby"</li> <li style="background: #f3f3f3">end</li> </ol> </div> </div> </div>  <p>The declaration can be loaded in <em>Gemfile</em>, so that we can list dependencies in one place. </p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>source "http://rubygems.org"</li> <li style="background: #f3f3f3"> </li> <li>gemspec</li> </ol> </div> </div> </div>  <p>When running under Bundler, the <em>Gemfile</em> will automatically be loaded, which will automatically load the gem specification.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>$ bundle exec irb</li> <li style="background: #f3f3f3">1.9.3-p362 :001 &gt; require 'ruby-enum'</li> <li> =&gt; true </li> <li style="background: #f3f3f3">1.9.3-p362 :002 &gt; Ruby::Enum::VERSION</li> <li> =&gt; "0.1.0"</li> </ol> </div> </div> </div>  <p><strong></strong></p>  <p><strong>Rakefile</strong></p>  <p>Bundler comes with a number of Rake tasks to release a gem. Add Rake to Gemfile.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>gem "rake"</li> </ol> </div> </div> </div>  <p>Create a <em>Rakefile</em>.</p>  <p>   </p><div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>require 'rubygems'</li> <li style="background: #f3f3f3">require 'bundler/gem_tasks'</li> <li> </li> <li style="background: #f3f3f3">Bundler.setup(:default, :development)</li> </ol> </div> </div> </div>   <p>   </p><div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>$ rake -T</li> <li style="background: #f3f3f3">rake build    # Build ruby-enum-0.1.0.gem into the pkg directory.</li> <li>rake install  # Build and install ruby-enum-0.1.0.gem into system gems.</li> <li style="background: #f3f3f3">rake release  # Create tag v0.1.0 and build and push ruby-enum-0.1.0.gem to Rubygems</li> </ol> </div> </div> </div>   <p>   </p><div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>$ rake build</li> <li style="background: #f3f3f3">ruby-enum 0.1.0 built to pkg/ruby-enum-0.1.0.gem.</li> </ol> </div> </div> </div>   <p>Add <em>pkg</em> to <em>.gitignore</em>.</p>  <p><strong></strong></p>  <p><strong>Default Rakefile to Running Tests</strong></p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>require 'rspec/core'</li> <li style="background: #f3f3f3">require 'rspec/core/rake_task'</li> <li> </li> <li style="background: #f3f3f3">RSpec::Core::RakeTask.new(:spec) do |spec|</li> <li>  spec.pattern = FileList['spec/**/*_spec.rb']</li> <li style="background: #f3f3f3">end</li> <li> </li> <li style="background: #f3f3f3">task :default =&gt; :spec</li> </ol> </div> </div> </div>  <p><strong></strong></p>  <p><strong>Travis-CI</strong></p>  <p>Add <em>.travis.yml</em>, register the project on <a href="https://travis-ci.org/">travis-ci.org</a> and add a badge.</p>  <p>   </p><div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>rvm:</li> <li style="background: #f3f3f3">  - 1.8.7</li> <li>  - 1.9.3</li> <li style="background: #f3f3f3">  - 2.0.0</li> <li>  - jruby-19mode</li> <li style="background: #f3f3f3">  - rbx-19mode</li> </ol> </div> </div> </div>   <p>   </p><div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>[![Build Status](https://travis-ci.org/dblock/ruby-enum.png)](https://travis-ci.org/dblock/ruby-enum)</li> </ol> </div> </div> </div>   <p><a href="http://code.dblock.org/ShowPicture.aspx?id=549&ShowThumbnail=false"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=550&ShowThumbnail=false" width="127" height="70" /></a></p>  <p><strong></strong></p>  <p><strong>Enum Library Code</strong></p>  <p>Include <em>ruby-enum/enum</em>. See <a href="https://github.com/dblock/ruby-enum/blob/master/lib/ruby-enum/enum.rb">enum.rb</a> and <a href="https://github.com/dblock/ruby-enum/blob/master/spec/ruby-enum/enum_spec.rb">enum_spec.rb</a> for the implementation.</p>  <p><strong></strong></p>  <p><strong>Changelog</strong></p>  <p>Create a CHANGELOG to list current and future updates.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>### 0.1.0 (5/14/2013)</li> <li style="background: #f3f3f3"> </li> <li>* Initial public release - [@dblock](https://github.com/dblock).</li> </ol> </div> </div> </div>  <p><strong></strong></p>  <p><strong>Contributing</strong></p>  <p>Add a contributing section to README.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>* Fork the project. </li> <li style="background: #f3f3f3">* Make your feature addition or bug fix with tests. </li> <li>* Update CHANGELOG. </li> <li style="background: #f3f3f3">* Send a pull request. Bonus points for topic branches.</li> </ol> </div> </div> </div>  <p><strong></strong></p>  <p><strong>Release the Gem</strong></p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>$ rake release</li> </ol> </div> </div> </div>  <p><strong></strong></p>  <p><strong>Prepare for Next Release</strong></p>  <p>Bump the version, add a <em>Next Release</em> section to CHANGELOG.md.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>### Next Release (TBD)</li> <li style="background: #f3f3f3"> </li> <li>* Your Contribution Here</li> </ol> </div> </div> </div>  <p><strong></strong></p>  <p><strong>Source Code</strong></p>  <p>All source code for the above can be found at <a href="https://github.com/dblock/ruby-enum">https://github.com/dblock/ruby-enum</a>. </p></stripped></div><div><a href="http://code.dblock.org/your-first-ruby-gem">Read</a> | Updated 5/15/2013</div></html>
         ]]>
       </description>
       <category>ruby</category><category>open source</category>
       <link>http://code.dblock.org/your-first-ruby-gem</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/382</guid>
      </item>
     
      <item>
       <title>Grape vs. Poncho</title>
       <pubDate>Sat, 06 Apr 2013 13:19:37 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p>There’re a number of excellent micro-frameworks to author RESTful APIs in Ruby. Let’s take a look at the newcomer, <a href="https://github.com/stripe/poncho">Poncho</a>, from the Stripe team, <a href="https://groups.google.com/forum/?fromgroups=#!topic/ruby-grape/4oEnuDA9e-8">brought up</a> on the Grape mailing list. For those that don’t know me, I’m the maintainer of <a href="https://github.com/intridea/grape">Grape</a> and use it very heavily at <a href="http://artsy.net/">Artsy</a>. I’ll do my best not to be biased.</p>  <p>With Poncho you start by declaring resources that inherit from <em>Poncho::Resource</em>. A resource is a prescriptive way of declaring what parameters to expect and what results to render from the API. In many ways resources are similar to <a href="https://github.com/intridea/grape-entity">Grape’s entities</a>, except that the latter are no longer part of Grape and you can use <a href="https://github.com/apotonick/roar">roar</a>, <a href="https://github.com/nesquena/rabl">rabl</a> or any other framework to render results - you choose. Poncho resources include parameter validation, which makes sense. Personally, language matters, so I would not call values that can be assigned to the resource <em>parameters</em>, but maybe <em>fields</em> or <em>attributes</em>.</p>  <p>You then declare a <em>Poncho::JSONMethod</em>, which inherits from <em>Poncho::Method</em>, which is a piece of middleware. The former is equivalent to a Grape formatter, and the latter is equivalent to the Grape endpoint Rack middleware. You have to override the <em>invoke</em> method and implement your business logic.</p>  <p>How does all this come together? </p>    <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li># poncho</li> <li style="background: #f3f3f3">get "/users", & UsersListMethod</li> </ol> </div> </div> </div>      <p>   </p><div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li># grape</li> <li style="background: #f3f3f3">get "/users" do</li> <li>   ...</li> <li style="background: #f3f3f3">end</li> </ol> </div> </div> </div>     <p>Grape could easily support the Poncho syntax with a few lines of code. Internally it creates a Proc from the body of the block.</p>  <p>I think that Poncho is in the very early days of development and has made some choices that Grape already made a year or two ago and decided undo more recently. Poncho hasn’t dealt with more complicated problems like versioning or content-negotiation, yet. Once it does, poncho contributors will find that infrastructure begins to bloat and will likely split it the same way we split grape and grape-entity. My current view is that the API DSL layer should be providing functionality closer to the HTTP protocol and a separate entities-like library should deal with data representation. That’s because I have strong opinions that a modern API should be a Hypermedia one, but I would not want to impose this on anyone, which is incidentally a similar philosophy that lead to  Webmachine (check out my earlier <a href="http://code.dblock.org/grape-vs-webmachine">Grape vs. Webmachine</a> post).</p>  <p>That said, none of the above is difficult to accomplish.</p>  <p>I would certainly have preferred if Stripe chose Grape as the API DSL and implemented their style of data presenters if they felt strongly about that. But we all want our own micro frameworks, don’t we?</p></stripped></div><div><a href="http://code.dblock.org/grape-vs-poncho">Read</a> | Updated 4/6/2013</div></html>
         ]]>
       </description>
       <category>grape</category><category>ruby</category>
       <link>http://code.dblock.org/grape-vs-poncho</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/381</guid>
      </item>
     
      <item>
       <title>Doctors, Surgery and Open-Source</title>
       <pubDate>Wed, 27 Mar 2013 17:38:39 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p>I visited a friend who lives in a remote, tropical region of the United States. He’s a doctor and a practicing eye surgeon. The island has both the very rich and the extremely poor. It’s known for both the beautiful beaches and gun violence in poorer neighborhoods. There’re no Starbucks for over 50K residents. There’re a few richer patients that have good insurance or pay cash, but the majority are older natives with a large proportion on Medicare. A dozen surgeries or 60 patients a day is considered uneventful. A full night operating in the ER only happened once during our stay. There’re talks about closing the only hospital.</p>  <p>The phone rang in the middle of a dinner with a fellow doctor on the other end of the line, and our side of the conversation went something like this: “It sounds like this patient really needs to be seen by a doctor first thing tomorrow morning, so if she doesn’t have a Medicare coupon for a specialist, we’ll see her for free.” I asked him how that’s even an option? He replied that the money made with so many patients is good enough, and the health of the resident population is so precarious, that it just makes sense to be helpful as much as possible. </p>  <p>I think there’s a valuable lesson to be learned here for everyone writing software, too.</p>  <p>By all accounts we’re paid extremely well and we’re as much in demand as doctors. An even smaller percentage of us are the kind of specialists capable of building the software equivalent of performing eye surgery. Of course, there’s no true comparison with being able to directly affect one’s vision with a surgical instrument and the next website, but how can we use our privileged position to, at least, be more helpful? Here’re a few ideas.</p>  <p>If you can afford it, work for a non-profit. If you’re in NYC, I would start with <a href="http://www.donorschoose.org/careers">DonorsChoose</a>. Their Engineering team is lead by <a href="http://www.linkedin.com/in/oliverhh">a very experienced techie and an amazing guy</a>. They promise you’ll never get rich, but you’ll wake up every day with a purpose and heartwarming “thank you” emails from thousands of children in the public school system around the US.</p>  <p>For the socially-conscious that are looking for a startup experience, check out NYC’s <a href="http://jobs.amicushq.com/">Amicus</a>. We shared an office at GeneralAssembly with their <a href="http://www.linkedin.com/in/sethbannon">founder and CEO</a> and the company has labored relentless helping non-profits be a lot more efficient in their fundraising. This means more money goes to the cause.</p>  <p>Continuing the theme of education, consider <a href="http://neverware.com/">Neverware</a>, which makes old computers run like new and who’s <a href="http://www.inc.com/magazine/20110501/ceo-passions-volunteer-firefighting.html">CEO is a volunteer firefighter</a>.</p>  <p>Don’t work for anyone evil. One way to ensure that is to join a company that encourages, promotes and writes open-source. I try to practice this as much as possible by going the extra mile of creating new open-source projects, contributing to existing ones, answering questions on mailing lists and educating rising technologists without expecting anything in return. Software has eaten the world, so even if you don’t completely side with Richard Stallman’s vision of freedom activism, you could, maybe, compare the little bit of your open-source work you do to an occasional free visit to the doctor.</p></stripped></div><div><a href="http://code.dblock.org/doctors-surgery-and-open-source">Read</a></div></html>
         ]]>
       </description>
       <category>teams</category><category>teaching</category><category>technology</category><category>jobs</category><category>people</category>
       <link>http://code.dblock.org/doctors-surgery-and-open-source</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/380</guid>
      </item>
     
      <item>
       <title>5 Anti-patterns in a College Grad Engineer’s Resume</title>
       <pubDate>Mon, 25 Mar 2013 18:46:12 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p>A resume is what you did, it’s not who you are.</p>  <p>In the past few years I’ve collected dozens of resumes from junior Engineering candidates and have provided written feedback to those who wanted to improve. I found that the vast majority of resumes have similar anti-patterns, repeating mistakes that are a quick turn off for any hiring manager. If you are in school or a soon to be graduating computer science major and don’t want your resume to go to the garbage, read the following 5 anti-patterns.</p>  <p><strong>Objectives Are Too Broad</strong></p>  <p><a href="http://code.dblock.org/ShowPicture.aspx?id=535&ShowThumbnail=false"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=536&ShowThumbnail=false" width="150" height="190" /></a></p>  <p><em>“To obtain a full time position that matches my enthusiasm, constant effort and efficiency.”</em></p>  <p>An objectives paragraph creates unnecessary barriers in hiring you, at best. The above example limits you to full time offers, then just moves some air around. Don’t limit your search to full time positions, especially if you’re trying to relocate. Most companies I know will extend a full time offer if you do an amazing job as an intern. Remove this text and repeat after me: <em>“Seeking a paid internship or full time programming position with an experienced Engineering team.”</em></p>  <p><strong>Github is Your New Resume</strong></p>  <p><em>“I am an open-source contributor </em><em>…”</em></p>  <p><a href="http://code.dblock.org/ShowPicture.aspx?id=537&ShowThumbnail=false"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=538&ShowThumbnail=false" width="451" height="91" /></a></p>  <p>I wrote an article that went viral, <a href="http://code.dblock.org/github-is-your-new-resume">Github is Your New Resume</a>. When evaluating someone’s Github profile, I usually click on <em>Repositories</em> and then <em>Sources</em>. Do you have a project that you have started that has been heavily forked and contributed to? Do you have any activity that’s longer than a year ago or did you just throw some code up there to beef up your resume? Does your contributions graph really look like this?</p>  <p><a href="http://code.dblock.org/ShowPicture.aspx?id=539&ShowThumbnail=false"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=540&ShowThumbnail=false" width="457" height="127" /></a></p>  <p>I don’t expect a junior developer to have any of these things. Displaying a link to an empty Github profile is a terrible idea. Do link to your personal website.</p>  <p><strong>You have Lead, Driven, Managed, Advised or Evangelized</strong></p>  <p><a href="http://code.dblock.org/ShowPicture.aspx?id=541&ShowThumbnail=false"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=542&ShowThumbnail=false" width="240" height="161" /></a></p>  <p><em>“Advised xyz.com founders in technology selection.”</em></p>  <p>It reads like your head can barely squeeze through your chateau’s living room French doors! You are not the project’s lead because you’re the only programmer. You’re not an advisor because your friends started a website and wanted to know which language is cool. Downplay and humble-down every single word on paper. Let your results and references speak for your value, not your resume. Remove every single adjective or verb that isn’t “did”, “implemented” or “built”.</p>  <p><strong>You Have Expert Skills</strong></p>  <p><a href="http://code.dblock.org/ShowPicture.aspx?id=543&ShowThumbnail=false"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=544&ShowThumbnail=false" width="173" height="240" /></a></p>  <p><em>“Expert in C++, Photoshop and Excel.”</em></p>  <p>I recommend removing a list of skills altogether and writing, in tiniest font possible, the technologies used within your work experience.  Should you talk about source control that you have worked with on the resume? My answer is no: make sure to avoid the impedance mismatch between the tools and technologies that you describe. My rule of thumb – delete anything that’s not a programming language.</p>  <p><strong>You Took Many Courses and Excelled in Clubs</strong></p>  <p><a href="http://code.dblock.org/ShowPicture.aspx?id=545&ShowThumbnail=false"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=546&ShowThumbnail=false" width="240" height="163" /></a></p>  <p><em>“2nd Place in the Campus Green Computing Initiative”</em></p>  <p>Most of us who left college many years ago will roll our eyes when you ask about those college years.</p>  <p>I think your resume should demonstrate that you can make an effective transition from college to the workforce, which means leaving as much “college” behind as possible. Being a Teaching Assistant should go into your work experience, but your participation in chess club should be left out. I would also not include a mention of your GPA. And any work experience that you may have should be concise and explain what the project was and what you did within that project.</p>  <p>***</p>  <p>If you like the advice above, and are in college or a recent grad, send me a copy of your resume to dblock[at]dblock[dot]org. I promise to give it 15 minutes and email you a few bullet points of feedback.</p></stripped></div><div><a href="http://code.dblock.org/5-anti-patterns-in-a-college-or-junior-engineers-resume">Read</a> | Updated 3/25/2013</div></html>
         ]]>
       </description>
       <category>teams</category><category>teaching</category><category>learning</category><category>hiring</category><category>people</category>
       <link>http://code.dblock.org/5-anti-patterns-in-a-college-or-junior-engineers-resume</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/379</guid>
      </item>
     
      <item>
       <title>Grape 0.4.0 Released w/ Stricter JSON Format Support &amp; More</title>
       <pubDate>Sun, 17 Mar 2013 18:30:43 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p>I’m very excited to Release Grape 0.4.0 today. Again, thanks to the 10 (!) contributors to this release. </p>  <p>Is this a solid release? You bet. I’ve upgraded our largest API project at <a href="http://artsy.net">artsy.net</a> to Grape 0.4.0 and all of the 1870 API specs have passed.</p>  <p>The complete <a href="https://github.com/intridea/grape/blob/master/CHANGELOG.md">CHANGELOG is here</a>. There’re a few backwards incompatible changes that you might want to check out while you’re upgrading.</p>  <p><strong>JSON and XML Formatter Changes</strong></p>  <p>Until the 0.4.0 release Grape took a pragmatic approach to JSON response and request data. It was also incorrect.</p>  <p>If your API returned a an <em>Object</em>, it was translated to JSON via <em>to_json</em> or a <em>MultiJson.dump</em> call. This worked well for both <em>Hash</em> and <em>Array</em>, meanwhile Grape left objects of type <em>String</em> alone. This friendly method ensured that you could translate an object into a <em>String</em>, skipping all the hard work Grape’s formatter would otherwise have to do. Similarly, Grape tried to be helpful by ignoring any data that couldn’t be parsed into a hash and therefore retrieved via a call to params from a PUT or POST.</p>  <p>I have fixed this in <a href="https://github.com/intridea/grape/commit/6fa8f59e0475f926682168ad4f0bbb2f72df96a3">@6fa8f59</a>, released with Grape 0.4.0, and it’s now possible to return proper JSON representations of <em>NilClass</em> or <em>String</em>, as well as to parse any valid JSON, such as <em>Array</em>. This means that if your API implementation returned a <em>String</em> or a <em>nil</em>, the output will be different.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>get "/" do</li> <li style="background: #f3f3f3">  "example"</li> <li>end</li> <li style="background: #f3f3f3"> </li> <li># Grape 0.3.x</li> <li style="background: #f3f3f3">"example"</li> <li> </li> <li style="background: #f3f3f3"># Grape 0.4.0</li> <li>"\"example\""</li> </ol> </div> </div> </div>   <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>get "/" do</li> <li style="background: #f3f3f3">  nil</li> <li>end</li> <li style="background: #f3f3f3"> </li> <li># Grape 0.3.x</li> <li style="background: #f3f3f3">""</li> <li> </li> <li style="background: #f3f3f3"># Grape 0.4.0</li> <li>"null"</li> </ol> </div> </div> </div>  <p>You can monkey-patch back the old behavior as follows.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>module Grape</li> <li style="background: #f3f3f3">  module Formatter</li> <li>    module Json</li> <li style="background: #f3f3f3">      class &lt;&lt; self</li> <li>        def call(object, env)</li> <li style="background: #f3f3f3">          return object if ! object || object.is_a?(String)</li> <li>          return object.to_json if object.respond_to?(:to_json)</li> <li style="background: #f3f3f3">          raise Grape::Exceptions::InvalidFormatter.new(object.class, 'json')</li> <li>        end</li> <li style="background: #f3f3f3">      end</li> <li>    end</li> <li style="background: #f3f3f3">  end</li> <li>end</li> </ol> </div> </div> </div>  <p>Similar changes apply to the XML formatter.</p>      <p><strong>Reading Input</strong></p>  <p>With the above changes its now possible to read JSON input that’s not a hash. This was reported as a bug in <a href="https://github.com/intridea/grape/issues/347">#347</a>. Hash parameters continue to be merged into <em>params</em>, while everything else is now available in <em>env[‘api.request.body’]</em>, you don’t have to parse <em>env[‘rack.input’]</em> again, a notable performance optimization<em>.</em></p>  <p><strong>Default Log Format</strong></p>  <p>Somewhere in version 0.3.2 the default logger format was inadvertently changed to be something like this.</p>  <div class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>I, [2013-02-27T18:39:20.352350 #85986]  INFO -- : one line</li> <li style="background: #f3f3f3">I, [2013-02-27T18:39:20.363543 #85986]  INFO -- : two lines</li> </ol> </div> </div> </div>  <p>This was a side-effect of requiring all of ActiveSupport, reported and fixed in <a href="https://github.com/intridea/grape/issues/353">#353</a>. The logger is now back to be its undecorated version without all those timestamps, levels or process IDs. </p>  <p>If you want the above behavior, <em>require active_support/all</em>.</p></stripped></div><div><a href="http://code.dblock.org/grape-040-released-w-stricter-json-format-support-more">Read</a></div></html>
         ]]>
       </description>
       <category>rack</category><category>grape</category><category>ruby</category>
       <link>http://code.dblock.org/grape-040-released-w-stricter-json-format-support-more</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/378</guid>
      </item>
     
      <item>
       <title>ResourceLib 1.4 Released</title>
       <pubDate>Sun, 03 Mar 2013 15:44:00 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p><a href="https://github.com/dblock/resourcelib">https://github.com/dblock/resourcelib</a></p>  <p>Download: <a href="http://code.dblock.org/downloads/resourcelib/Vestris.ResourceLib.1.4.zip">http://code.dblock.org/downloads/resourcelib/Vestris.ResourceLib.1.4.zip</a></p>  <ul>   <li><a href="https://github.com/dblock/resourcelib/pull/2">#2</a>: Added VersionResource.FileFlags - <a href="https://github.com/alaendle">@alaendle</a>.</li>    <li>Updated solution to Visual Studio 2010 - <a href="https://github.com/redwyre">@redwyre</a>. </li>    <li>Added NUGet references for NUnit, NUnit.Runners, and MSBuildTasks - <a href="https://github.com/redwyre">@redwyre</a>. </li>    <li>Added more options to build.cmd: code, code_and_test and run_test_only - <a href="https://github.com/redwyre">@redwyre</a>. </li>    <li>Documentation rewritten in markdown - <a href="https://github.com/dblock">@dblock</a>.</li> </ul>  <p>ResourceLib is a framework that enumerates resources and implements both read and write of the file version VS_VERSIONINFO, string resources such as company, copyright and product information, RT_GROUP_ICON and RT_ICON, RT_CURSOR, RT_BITMAP,RT_MENU, RT_DIALOG, RT_STRING, RT_ACCELERATOR, RT_FONT and RT_FONTDIR and RT_MANIFEST resources.</p></stripped></div><div><a href="http://code.dblock.org/resourcelib-14-released">Read</a></div></html>
         ]]>
       </description>
       <category>resourcelib</category><category>open source</category><category>win32</category>
       <link>http://code.dblock.org/resourcelib-14-released</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/377</guid>
      </item>
     
      <item>
       <title>Graduating to Jenkins CI for Ruby-on-Rails Teams - Jenkins User Group in NYC (Video)</title>
       <pubDate>Sat, 02 Mar 2013 13:56:49 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p><a href="http://www.youtube.com/watch?v=LkrI3D8gxw0"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=534&ShowThumbnail=false" width="404" height="247" /></a></p>  <p>My talk from JUG NYC from last summer has finally been uploaded to YouTube!</p>  <p>There’s also a summary with all the links in <a href="http://artsy.github.com/blog/2012/05/27/using-jenkins-for-ruby-and-ruby-on-rails-teams/">this blog post</a> and the <a href="http://www.slideshare.net/dblockdotorg/graduating-to-jenkins-ci-for-rubyonrails-teams">slides here</a>.</p></stripped></div><div><a href="http://code.dblock.org/graduating-to-jenkins-ci-for-ruby-on-rails-teams-jenkins-user-group-in-nyc-video">Read</a> | Updated 3/2/2013</div></html>
         ]]>
       </description>
       <category>speaking</category><category>open source</category>
       <link>http://code.dblock.org/graduating-to-jenkins-ci-for-ruby-on-rails-teams-jenkins-user-group-in-nyc-video</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/376</guid>
      </item>
     
      <item>
       <title>In Defense of Heroku</title>
       <pubDate>Thu, 14 Feb 2013 02:56:22 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p>Le Clash of Booba, Rohff and La Fouine have a new player, RapGenius.</p>  <p><a href="http://code.dblock.org/ShowPicture.aspx?id=529&ShowThumbnail=false"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=530&ShowThumbnail=false" width="313" height="169" /></a></p>  <p>James, who I have met, and who is a super nice guy wrote a post called <a href="http://rapgenius.com/James-somers-herokus-ugly-secret-lyrics">“Heroku’s Ugly Secret”</a>, describing the changes in the Heroku’s routing mesh on the Cedar stack and how much it sucks. It’s a bit sensationalist, and there was some hint on the evil overcharging overlords. It’s the price of getting up there on HN, I guess. I was going to just watch this quietly, but I just can’t.</p>  <p><a href="http://code.dblock.org/ShowPicture.aspx?id=531&ShowThumbnail=false"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=532&ShowThumbnail=false" width="445" height="480" /></a></p>  <p>This is unproductive. This sensational news has been discussed <a href="http://tiwatson.com/blog/2011-2-17-heroku-no-longer-using-a-global-request-queue">here</a> and <a href="https://groups.google.com/forum/?fromgroups=#!msg/heroku/8eOosLC5nrw/Xy2j7GapebIJ">here</a> a year ago. Man, you tore. Them. UP.</p>  <p>Heroku is not an evil organization and it provides an amazing service to millions of applications. It has enabled so much in my world! It has very smart developers that try to be as helpful as they can and, I am sure, do their best to improve the said routing. They don’t always succeed, but they certainly don’t deserve “serious internet beef”, which in Russian we would call “<a href="http://universal_ru_de.academic.ru/184788/%D0%B2%D1%8B%D1%81%D0%BE%D1%81%D0%B0%D0%BD%D0%BD%D1%8B%D0%B9_%D0%B8%D0%B7_%D0%BF%D0%B0%D0%BB%D1%8C%D1%86%D0%B0">полемика высосанная из пальца</a>”.  Lets all get back to making technology a better, more civil place, please.</p></stripped></div><div><a href="http://code.dblock.org/in-defense-of-heroku">Read</a> | Updated 2/14/2013</div></html>
         ]]>
       </description>
       <category>heroku</category>
       <link>http://code.dblock.org/in-defense-of-heroku</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/375</guid>
      </item>
     
      <item>
       <title>Data Corruption Is Most Likely Caused By Your Code And Not Your Database</title>
       <pubDate>Sat, 09 Feb 2013 19:30:22 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p><a href="http://code.dblock.org/ShowPicture.aspx?id=527&ShowThumbnail=false"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=528&ShowThumbnail=false" width="321" height="123" /></a></p>  <p>I am increasingly convinced that those who blame MongoDB for any kind of data corruption are waving hands out of desperation. Every single time I had an issue with data I ended up finding code that I’ve written or code that was written in a library that I used. The hardest bugs involve some kind of concurrent operation, including one I’ve described in a new post on the Artsy Engineering blog: <a href="http://artsy.github.com/blog/2013/02/09/data-corruption-and-concurrent-updates-to-embedded-objects-with-mongoid/">Data Corruption and Concurrent Updates to Embedded Objects w/ MongoDB</a>. Read it, especially if you are using an ODM to manipulate embedded objects.</p>  <p>I also want to point out two magical lines of code that I use all the time.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>Moped.logger = Logger.new($stdout)</li> <li style="background: #f3f3f3">Moped.logger.level = Logger::DEBUG</li> </ol> </div> </div> </div>  <p>Knowing what Mongoid is doing is half the battle.</p></stripped></div><div><a href="http://code.dblock.org/data-corruption-is-most-likely-caused-by-your-code-and-not-your-database">Read</a></div></html>
         ]]>
       </description>
       <category>mongoid</category><category>mongodb</category>
       <link>http://code.dblock.org/data-corruption-is-most-likely-caused-by-your-code-and-not-your-database</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/374</guid>
      </item>
     
      <item>
       <title>Three DevOps Rake Tasks I Use Daily on Heroku with MongoDB</title>
       <pubDate>Sat, 02 Feb 2013 06:21:21 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p><a href="http://code.dblock.org/ShowPicture.aspx?id=525&ShowThumbnail=false"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=526&ShowThumbnail=false" width="133" height="121" /></a></p>  <p>Heroku and MongoDB enable the kind of frictionless devops workflow every mature software organization wants and spends mountains of money on. It begins with a 1-box developer setup in which I can checkout source code and be ready to start development after a <em>bundle install, </em>and continues with a <em>git push</em> to a Heroku staging environment that deploys the application for last minute integration testing  and, finally, production. Each separate Heroku instance has its own configuration and resources. My code also needs sensible defaults for development. For example, <em>mongoid.yml</em> lists <em>localhost:27017</em> as the development database host and <em>ENV['MONGOHQ_HOST_LIST']</em> for production.</p>  <p>However, in true devops, I want to be able to reach into a remote environment programmatically, run commands remotely or connect two environments together, as long as we have access to them. In this post I’ll propose an implementation of three tasks that have become part of the daily routine of one of my projects.</p>  <ol>   <li>Execute a Rake task with local code modifications and the configuration of a production environment.</li>    <li>Open a shell to the primary node of the MongoDB on my development Heroku environment.</li>    <li>Dump a single table from a production database before doing something scary.</li> </ol>  <p>We’ll accomplish the above with help from two new gems: <a href="https://github.com/dblock/mongoid-shell">mongoid-shell</a> and <a href="https://github.com/dblock/heroku-commander">heroku-commander</a>. Add those to your Gemfile in the <em>:development</em> section.</p>  <p>And, please remember, that with great power (and the word “production” in much of what follows) comes a lot of responsibility.</p>  <p><strong>Execute a Rake task with local code modifications and the configuration of a production environment.</strong></p>  <p>This is made possible by <a href="https://github.com/dblock/heroku-commander">heroku-commander</a>. The library wraps the Heroku CLI (intro <a href="http://artsy.github.com/blog/2013/01/31/create-mongodb-command-lines-with-mongo/">here</a>) and will run <em>heroku config –s</em>. It’s now easy to reach out to a Heroku application and retrieve its configuration programmatically without worrying about API keys (by default it will use the Heroku app defined via the “heroku” GIT remote). We will also need a bit of code to apply our application’s naming convention. This lets me change the execution environment to the one of a remote Heroku application, in Ruby.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>module Heroku</li> <li style="background: #f3f3f3">  class Config &lt; Hash</li> <li>    def self.set_env_from!(env)</li> <li style="background: #f3f3f3">      app = case env.to_sym</li> <li>        when :heroku, :development then nil</li> <li style="background: #f3f3f3">        else "app-#{env}"</li> <li>      end</li> <li style="background: #f3f3f3">      require 'heroku-commander'</li> <li>      config = Heroku::Commander.new({ :app =&gt; app }).config</li> <li style="background: #f3f3f3">      config.each do |k, v|</li> <li>        ENV[k] = v</li> <li style="background: #f3f3f3">      end</li> <li>    end</li> <li style="background: #f3f3f3">  end</li> <li>end</li> </ol> </div> </div> </div>  <p>So how do I run a task locally, but configured as <em>production</em>? With the following Rake task.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>namespace :heroku do</li> <li style="background: #f3f3f3">  desc "Load environment vars from Heroku config into ENV."</li> <li>  task :config_from_env do</li> <li style="background: #f3f3f3">    env = ENV['RAILS_ENV'] || Rails.env</li> <li>    raise "RAILS_ENV or Rails.env must be specified" unless env</li> <li style="background: #f3f3f3">    Heroku::Config.set_env_from! env</li> <li>  end</li> <li style="background: #f3f3f3">end</li> </ol> </div> </div> </div>  <p>Run <em>RAILS_ENV=production rake heroku:config_from_env my:task</em>.</p>  <p><strong>Open a shell to the primary node of the MongoDB on my development Heroku environment.</strong></p>  <p>First, figure out the remote MongoDB configuration, then execute the <em>mongo</em> shell command. It’s important to know that the built-in system command doesn’t raise an error when the process returns a non-zero status code. Lets add a <em>system!</em> function that fixes that.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>def system!(cmdline)</li> <li style="background: #f3f3f3">  logger.info("[#{Time.now}] #{cmdline}")</li> <li>  rc = system(cmdline)</li> <li style="background: #f3f3f3">  fail "failed with exit code #{$?.exitstatus}" if (rc.nil? || ! rc || $?.exitstatus != 0)</li> <li>end</li> </ol> </div> </div> </div>  <p>Instead of making MongoDB command lines manually, I’ve used a new gem called <a href="https://github.com/dblock/mongoid-shell">mongoid-shell</a> (intro <a href="http://artsy.github.com/blog/2013/01/31/create-mongodb-command-lines-with-mongo/">here</a>).</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>namespace :db do</li> <li style="background: #f3f3f3">  [ :staging, :production, :heroku ].each do |env|</li> <li>    namespace env do</li> <li style="background: #f3f3f3">      task :shell do</li> <li>        require 'mongoid-shell'</li> <li style="background: #f3f3f3">        Heroku::Config.set_env_from!(env)</li> <li>        config = File.join(Rails.root, "config/mongoid.yml")</li> <li style="background: #f3f3f3">        Mongoid.load! config, env</li> <li>        system! Mongoid::Shell::Commands::Mongo.new.to_s</li> <li style="background: #f3f3f3">      end</li> <li>    end</li> <li style="background: #f3f3f3">  end</li> <li>end</li> </ol> </div> </div> </div>  <p>Run rake <em>db:production:shell</em>.</p>  <p><strong>Dump a single table from a production database before doing something scary.</strong></p>  <p>We all do backups and other important things, daily. But when manipulating production data I want to have the last safeguard with the freshest data from the collection I am about to <strike>drop accidentally</strike> update. Dump a MongoDB collection locally.</p>  <p>   </p><div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>namespace :db do</li> <li style="background: #f3f3f3">  [ :production, :staging, :heroku ].each do |env|</li> <li>    namespace env do</li> <li style="background: #f3f3f3">      task :dump, [ :collections ] =&gt; :environment do |t, args|</li> <li>        require 'mongoid-shell'</li> <li style="background: #f3f3f3">        Heroku::Config.set_env_from!(env)</li> <li>        config = File.join(Rails.root, "config/mongoid.yml")</li> <li style="background: #f3f3f3">        Mongoid.load! config, env</li> <li>        collections = args[:collections].split(/[\s|,]+/)</li> <li style="background: #f3f3f3">        collections.each do |collection|</li> <li>          system! Mongoid::Shell::Commands::Mongodump.new({ collection: collection }).to_s</li> <li style="background: #f3f3f3">        end</li> <li>      end</li> <li style="background: #f3f3f3">    end</li> <li>  end</li> <li style="background: #f3f3f3">end</li> </ol> </div> </div> </div>   <p> </p>  <p><strong>Points</strong></p>  <p>Thanks to <a href="https://twitter.com/joeyAghion">@joeyAghion</a> and <a href="https://twitter.com/fancyremarker">@fancyremarker</a> who are responsible for many of the core concepts above.</p></stripped></div><div><a href="http://code.dblock.org/three-devops-rake-tasks-i-use-daily-on-heroku-with-mongodb">Read</a> | Updated 2/2/2013</div></html>
         ]]>
       </description>
       <category>deployment</category><category>mongoid</category><category>rake</category><category>heroku</category><category>mongodb</category>
       <link>http://code.dblock.org/three-devops-rake-tasks-i-use-daily-on-heroku-with-mongodb</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/373</guid>
      </item>
     
      <item>
       <title>Should you use “Should” in RSpec Examples?</title>
       <pubDate>Thu, 31 Jan 2013 12:55:37 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p>There’re two kinds of developers: those who use <em>should</em> in RSpec examples and those who use present tense. </p>  <p>   </p><div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>describe Fridge do</li> <li style="background: #f3f3f3">  when "plugged in" do</li> <li>    before do</li> <li style="background: #f3f3f3">      subject.plug!</li> <li>    end</li> <li style="background: #f3f3f3">    it "should keep food cold" do</li> <li>      subject.temperature.should be between(35).and(38).degrees</li> <li style="background: #f3f3f3">    end</li> <li>  end</li> <li style="background: #f3f3f3">end</li> </ol> </div> </div> </div>   <p>   </p><div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>describe Fridge do</li> <li style="background: #f3f3f3">  when "plugged in" do</li> <li>    before do</li> <li style="background: #f3f3f3">      subject.plug!</li> <li>    end</li> <li style="background: #f3f3f3">    it "keeps food cold" do</li> <li>      subject.temperature.should be between(35).and(38).degrees</li> <li style="background: #f3f3f3">    end</li> <li>  end</li> <li style="background: #f3f3f3">end</li> </ol> </div> </div> </div>   <p>Should you use <em>should</em>?</p>  <p>My short answer is <strong>no</strong>, you shouldn’t. Write your examples in present tense. Two reasons.</p>  <ul>   <li>BDD often refers to examples as documentation. Imagine that your fridge’s documentation said “when plugged in, it should keep food cold”. IMO it should say “when plugged in, it keeps food cold”.</li>    <li>Using “should” makes the text longer by a few characters. We have over <a href="http://artsy.github.com/blog/2012/05/15/how-to-organize-over-3000-rspec-specs-and-retry-test-failures/">3000 specs in one projects</a>, probably saving a megabyte worth of test descriptions by not using “should”. Shorter is better.</li> </ul>  <p>(<a href="https://twitter.com/mzikherman">@mzikherman</a> has heavily contributed to this thought)</p></stripped></div><div><a href="http://code.dblock.org/should-you-use-should-in-rspec-examples">Read</a></div></html>
         ]]>
       </description>
       <category>rspec</category><category>ruby</category><category>testing</category>
       <link>http://code.dblock.org/should-you-use-should-in-rspec-examples</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/372</guid>
      </item>
     
      <item>
       <title>Hacker News Karma: 666</title>
       <pubDate>Wed, 23 Jan 2013 03:01:28 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p>Pure. Evil.</p>  <p><a href="http://code.dblock.org/ShowPicture.aspx?id=523&ShowThumbnail=false"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=524&ShowThumbnail=false" width="667" height="27" /></a></p></stripped></div><div><a href="http://code.dblock.org/hacker-news-karma-666">Read</a></div></html>
         ]]>
       </description>
       <category>me me</category>
       <link>http://code.dblock.org/hacker-news-karma-666</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/371</guid>
      </item>
     
      <item>
       <title>Why I am Excited About the new Cornell Tech School</title>
       <pubDate>Mon, 21 Jan 2013 20:39:07 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p><a href="http://code.dblock.org/ShowPicture.aspx?id=521&ShowThumbnail=false"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=522&ShowThumbnail=false" width="174" height="71" /></a></p>  <p>New York Times has just published <a href="http://www.nytimes.com/2013/01/22/nyregion/cornell-nyc-tech-will-foster-commerce-amid-education.html?pagewanted=all&_r=1&">“New Cornell Technology School Will Foster Commerce Amid Education”</a>. I am super excited about <a href="http://www.cornell.edu/nyc/">Cornell Tech</a>, and not just because Ariel Kaminer chose to quote me on the modest Artsy partnership with the University :)</p>  <p>In 1994 I lived in Switzerland and was contemplating going to either the University of Geneva or the Polytechnic of Lausanne (EPFL). I was convinced by the former, which offered a much more theoretical education in mathematics with world-wide known professors, had strong ties to the CERN and frequent contacts with some of early Internet legends. I felt strongly about not wanting an education of an applied computer programmer, which I thought as inferior. I imagined UniGE producing scientists and the EPFL, the equivalent of car mechanics. So I spent three painful years sucking at math, finally finishing with a year of trivial computer-related courses, and generally coming out of the experience wanting to put it all behind me.</p>  <p>15 years ago your ability to memorize 4 whiteboards worth of proof for each of the 120 theorems of Algebra II was the ultimate benchmark for computer science students. Today’s measure is your Github public activity, your ability to translate theoretical knowledge into working systems, excellent social and networking skills, clear communication and mad skills of learning and adaptation. Any educational program that can produce well-rounded individuals that can enter the workforce without feeling like they have been hit but a bus is on the right track.</p>  <p>With people like <a href="http://www.cs.cornell.edu/~dph/">Daniel Huttenlocher</a> and <a href="http://www.linkedin.com/in/gregpass">Greg Pass</a> New York’s Cornell Tech is going to succeed at this. I am excited because they are doing all the right things, including partnering with smaller startups and seeking out exciting projects for their students, integrating them with the industry early, right here in my favorite city in the world.</p></stripped></div><div><a href="http://code.dblock.org/why-i-am-excited-about-the-new-cornell-tech-school">Read</a> | Updated 1/23/2013</div></html>
         ]]>
       </description>
       <category>education</category><category>teaching</category><category>technology</category>
       <link>http://code.dblock.org/why-i-am-excited-about-the-new-cornell-tech-school</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/370</guid>
      </item>
     
      <item>
       <title>Open-Source Roundup for Early January 2013</title>
       <pubDate>Mon, 21 Jan 2013 02:44:11 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p>Aside of all the posts about <a href="http://code.dblock.org/help-me-fix-tech-recruiting-become-a-recruiter">recruiting</a> (recruiter spam dropped by 75%, amazing, thank you very much), <a href="http://code.dblock.org/10-things-engineers-and-non-engineers-can-do-to-make-a-website-faster">website performance</a> and the <a href="http://code.dblock.org/treat-every-line-of-code-as-if-its-going-to-be-thrown-away-one-day">importance of source code</a>, I wrote a few posts recently on the <a href="http://artsy.github.com/">Artsy Engineering Blog</a> and made some open-source gem releases and contributions. It feels really good and there’s a whole new week ahead!</p>  <p>I got very excited with getting my hands into em-proxy and writing <a href="http://artsy.github.com/blog/2012/12/13/beat-heroku-60-seconds-application-boot-timeout-with-a-proxy/">Beat Heroku’s 60 Seconds Application Boot Timeout with a Proxy</a> using the <a href="https://github.com/dblock/heroku-forward">heroku-forward</a> gem. I even <a href="https://github.com/igrigorik/em-proxy/pull/31">contributed to em-proxy</a> itself, adding support for unix domain sockets. It’s exciting because em-proxy is written by <a href="mailto:i@igrigorik">@igrigorik</a>, who is one of those impressive people that I still don’t have the pleasure to know personally. The post was accompanied by a more philosophical piece on <a href="http://code.dblock.org/losing-control-to-the-heroku-paas">Losing Control to the Heroku PaaS</a>. Speaking of losing control, I annoyed the crap out of Heroku developers trying to figure out why an application was timing out during <em>bundle install</em> on Heroku, which turned into an already well trafficked blog post on <a href="http://artsy.github.com/blog/2013/01/15/debugging-bundler-issues-with-heroku/">Debugging Bundler Issues on Heroku</a>. Sorry everyone.</p>  <p>Today I released <a href="https://github.com/dblock/mongoid-cached-json">mongoid-cached-json 1.4</a> and <a href="https://github.com/artsy/garner">garner 0.2</a> with some significant performance optimizations for the former, described in <a href="http://artsy.github.com/blog/2013/01/20/improving-performance-of-mongoid-cached-json/">today’s blog post</a>. This was some pretty exciting, although relatively basic CS work, that didn’t always turn out the way you’d expect from performance improvements. My first optimization ran 20% slower than the original – you cannot make assumptions about the runtime characteristics of theoretically better algorithms until you actually benchmark them.</p>  <p><a href="https://github.com/intridea/grape">Grape</a> got a lot of love with the release of 0.2.6 after a ton of formatter-related work and security fixes via <a href="https://github.com/sferik/multi_xml">multi_xml</a> (upgrade!) and I plan to push 3.0 really soon. Generally, Grape is getting much skinnier, faster and lighter: I simplified a lot of internals and entities were taken out into the <a href="https://github.com/agileanimal/grape-entity">grape-entity</a> gem by <a href="https://github.com/agileanimal">@agileanimal</a>.</p>  <p>Last week I released <a href="https://github.com/dblock/guard-rack">guard-rack 1.3.1</a> in which <a href="https://github.com/viking">@viking</a> got rid of .pid files and I finished by making it compatible with all versions of Ruby using the awesome <a href="https://github.com/headius/spoon">spoon</a> gem (solid replacement for not-so-cross-platform <a href="https://github.com/rtomayko/posix-spawn">posix-spawn</a>).</p>  <p>Finally, I posted <a href="http://artsy.net/dblock/post/this-horse-is-a-fantastic-study-of">an amazing study of a horse by George Stubbs on Artsy</a>. You can follow me there for all the art, and for my tech stuff, on <a href="https://twitter.com/dblockdotorg">Twitter</a>.</p></stripped></div><div><a href="http://code.dblock.org/open-source-roundup-for-early-january-2013">Read</a></div></html>
         ]]>
       </description>
       <category>open source</category>
       <link>http://code.dblock.org/open-source-roundup-for-early-january-2013</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/369</guid>
      </item>
     
      <item>
       <title>Help Me Fix Tech Recruiting: Become a Recruiter</title>
       <pubDate>Sat, 12 Jan 2013 16:11:17 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p><a href="http://code.dblock.org/ShowPicture.aspx?id=519&ShowThumbnail=false"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=520&ShowThumbnail=false" width="260" height="380" /></a></p>  <p><font size="1">everything is in your own hands by </font><a href="http://www.lucabogoni.com/"><font size="1">Nele Brönner and Luca Bogoni</font></a></p>  <p>Recruiting is broken and a plethora of startups are attempting to fix it with better mouse traps, in which you, the magical engineering unicorn that everybody wants, continue being a mouse. Trapped. The basic problem is the same: no matter what recruiters tell you, however genuinely helpful they try to be, they don’t have your best interest at heart, except in a single case where you want to maximize your money. More on that in the final words of this post.</p>  <p>To fix the problem we must replace the recruiters that suck by recruiters that don’t, with only the candidate’s best interest in mind. This is not a problem of tools. We must replace recruiters with <em>ourselves</em>.</p>  <p><strong>Building Industry Relationships</strong></p>  <p>Engineering doesn’t happen in a vacuum behind closed doors anymore. Deliberately maintaining long lasting relationships with other technologists is part of your job.</p>  <p>My first contacts were made with people I went to college with or worked with in the 90s. I have great friends in Seattle and San Francisco and amongst those I hung out with after moving to New York ten years ago. I made some amazing connections through open-source coordination work on popular projects such as <a href="https://github.com/twall/jna">JNA</a> or <a href="https://github.com/intridea/grape">Grape</a>.</p>  <p>For me, being deliberate about building industry relationships means that in every conference, event or social function I set myself the objective of meeting and establishing a contact with just one single peer who I respect for technical achievement and who is currently or often be in a hiring manager position. I’ve invited all these people to visit me during work hours, showed them what we’re working on and often bought them coffee at La Colombe around the corner. It’s amazing to brainstorm with these smart technologists, so I get a ton out of it. I’m booked almost every early afternoon for the sole purpose of meeting people.</p>  <p>I don’t want anything from these connections except an opportunity to learn from them and to refer engineers to them.</p>  <p><strong>Opening Your Doors</strong></p>  <p>When I worked at Microsoft my manager used to talk about an “open door policy”. Everyone literally had a small personal office and keeping the door open meant allowing anyone to walk in and talk to you. Today I still keep a wide open virtual door.</p>  <p>I’ve written several blog posts that have gone viral, including <a href="http://www.dblock.org/your-commute-is-killing-you-move-to-new-york">Your Commute is Killing You, Move to New York</a>, followed by  <a href="http://code.dblock.org/moving-to-new-york-a-guide-for-software-engineers">Moving to New York? A Guide for Software Engineers</a> and even a more comical <a href="http://code.dblock.org/sitting-is-killing-you-move-to-new-york">Sitting is Killing You? Move to New York</a>. (You get the idea – move to New York!) Since then I’ve received hundreds of emails and have invited countless engineers to visit me at work. A disproportionate amount of these are talented developers stuck in a cubicle working for the BORG or generally unhappy with their current situation. But more than a new job, they want a first, personal, connection to the New York startup scene. Someone helped me with this a long time ago – I owe it to them to return the favor.</p>  <p>I’ve offered at least 3 personal connections to every one of these engineers visiting me. I’ve directed others to <a href="http://nytm.org/made-in-nyc">NYTM</a> and offered more personal help if cold connections failed. I’ve hooked up people with startup CEOs running tiny teams at GeneralAssemb.ly where we used to have our office and that was my entry in the NYC startup scene, engineering managers that are actively hiring at other NYC startups or other technologists with similar technical interests at large.</p>  <p>I don’t want anything from these referrals except an opportunity to help them. I am very emotionally attached to New York and helping a single engineer helps the NYC tech scene rise.</p>  <p><strong>Becoming a Connector</strong></p>  <p>I am a connector. I take the left hand side of my relationships with hiring technologists and the right hand side of my connections with engineers and make introductions between the two. I don’t necessarily enjoy being part of their conversation and I have no incentive other than helping the two individuals involved. I am a recruiter, the kind you actually want, because I have your interest at heart. I once read an article that said that casual professional acquaintances are much more likely to help you find a new job than your close friends – I am that acquaintance. </p>  <p>If all engineers in a similar position to mine became recruiters, the first reaction of someone looking for a job would not be to post their resume online or update their LinkedIn profile and get spammed. It would be to quietly reach out to 3 people, which would make 9 direct connections, which is plenty to get a good view at what’s going on in your city right now with job opportunities in your industry, line up a few interviews and land your next gig.</p>  <p><strong>Exceptions and Money</strong></p>  <p>So what are actual recruiters good for?</p>  <p>There’s always an exception to the rule. Some engineers just want the best paying job possible, anywhere. They will compromise on the excitement, the interesting project or the view. While I may have your happiness at heart I probably don’t have as much stake in your financial interests. So by all means use a recruiter who will do their best to maximize your money. A good recruiter is like a salesman and will negotiate your pay to get a nice 25% cut of your yearly salary when you get hired. To every connector I recommend establishing a business relationship with a single professional recruiter you have used in the past and that you trust not to screw you or the candidate over. Recommending a good established recruiter to a candidate that wants it is good for our industry. This will force natural selection and help weed bad recruiters out of the system.</p>  <p><strong>For Those That Love Lists</strong></p>  <ol>   <li>Establish a referral network with your peers. </li>    <li>Offer help to those seeking opportunities. </li>    <li>Make connections and help in any way you can. </li> </ol>  <p>It’s obvious. When was the last time you did this? Fixing recruiting is in your own hands.</p></stripped></div><div><a href="http://code.dblock.org/help-me-fix-tech-recruiting-become-a-recruiter">Read</a></div></html>
         ]]>
       </description>
       <category>teams</category><category>recruiters</category><category>hiring</category><category>people</category>
       <link>http://code.dblock.org/help-me-fix-tech-recruiting-become-a-recruiter</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/368</guid>
      </item>
     
      <item>
       <title>10 Things Engineers and Non-Engineers Can Do to Make a Website Faster</title>
       <pubDate>Sun, 23 Dec 2012 18:57:38 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p><a href="http://code.dblock.org/ShowPicture.aspx?id=517&ShowThumbnail=false"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=518&ShowThumbnail=false" width="189" height="181" /></a></p>  <p>An investor, a startup CEO, and an engineer walk into a bar to discuss <a href="http://blog.chriszacharias.com/page-weight-matters">“Page Weight Matters”</a>. They naturally end up talking about their own slow website.</p>  <p align="center">***</p>  <p>The CEO’s friend works in finance. She invested a bit of cash in her friend’s startup. She came home late, made herself dinner and read her personal email (her bank won’t let her do that at work). The website’s newsletter had something interesting, so she clicked. She stared at a white page for a bit, then it finally loaded after 8 seconds. She was already bored and figured it’s not worth it. “Something’s wrong with my internet”, she thought. Google came up instantly, though, so she emailed her CEO friend.</p>  <p>This morning the CEO had to make the difficult decision to invest into a new kind of reticulated spline, the 3-dimensional kind. After looking at the data gathered for the past two weeks by the early prototypes of the 2-dimensional spline, it became clear that users want that other, much more esoteric, 3rd dimension. Tomorrow he’ll gather the team to show them the user data. Also, a friend and early investor emailed him that his website was slow. Going to the website right now on his iPad confirms that, indeed, that 2D spline page takes 4 seconds to show up. Trying again was fast, though. Weird.</p>  <p>The engineer was watching an API response graph that oscillated abnormally with 4 seconds peaks fetching the 2D spline when he received the investor’s email forwarded by the CEO. A large code refactor that enables a much faster 2D spline page rendering finally had a successful build and was now ready to be merged onto the master branch, pending code review. He replied to the CEO’s email with the good news of progress being made before leaving the office.</p>  <p>They all meet at <a href="http://www.yelp.com/biz/tom-and-jerrys-new-york">Tom & Jerry’s</a>. Where else?</p>  <p align="center">***</p>  <p>If you can find yourself in my story, you’re in a good place. You have the CEO doing his job having visions of the future based on the experiences of the past. You have engaged users that want you to succeed and are willing to provide feedback. You have engineers doing their job building new features as fast as they can and fixing issues, including performance, as they are found incrementally. You are in a bar in New York with cheap drinks.</p>  <p>Generally, though, the website is slow, and that’s a problem. What should you do?</p>  <p>The answer, in my opinion, lies in a basic equation. You can focus on performance, but your features won’t move forward. Build more features, and performance will suffer. To have both takes much more time. You want to find the right balance. Here’re 5 ideas for engineers and non-engineers for improving website performance.</p>  <p>For engineers:</p>  <ol>   <li>Observe humans using your product and don’t make excuses, your system is slow until it’s not.</li>    <li>Optimize for simplicity, complex software is very hard to optimize for performance.</li>    <li>Measure your slowest components. As an individual contributor, address one a week.</li>    <li>Discuss alternate solutions to experiences that will perform poorly with the product and design team.</li>    <li>Regularly undertake large projects that address fundamental bottlenecks by your own initiative.</li> </ol>  <p>For non-engineers:</p>  <ol>   <li>Learn about the engineering process and technical debt.</li>    <li>Avoid asking “When is it going to be done?”. Organize features in a backlog rather than milestones with deadlines.</li>    <li>Be helpful, but don’t try to suggest technical or external solutions to performance problems, such as experts or consultants.</li>    <li>Give improvements time and assume that a good engineering team knows what they are doing.</li>    <li>Be constructive when reporting slow parts of the system and avoid broad “it’s too slow” statements.</li> </ol></stripped></div><div><a href="http://code.dblock.org/10-things-engineers-and-non-engineers-can-do-to-make-a-website-faster">Read</a></div></html>
         ]]>
       </description>
       <category>teams</category><category>startups</category><category>performance</category><category>technology</category><category>people</category><category>agile</category>
       <link>http://code.dblock.org/10-things-engineers-and-non-engineers-can-do-to-make-a-website-faster</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/367</guid>
      </item>
     
      <item>
       <title>Treat Every Line of Code as If It&#39;s Going to be Thrown Away One Day</title>
       <pubDate>Fri, 21 Dec 2012 14:11:45 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p><a href="http://backspac.es/"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=516&ShowThumbnail=false" width="260" height="127" /></a></p>  <p>It’s incredible to see talented people succeed at building great things.</p>  <p>I met <a href="https://twitter.com/dmitric">Dmitri</a> through a mentorship program and brainstormed with him during his early prototyping of <a href="https://itunes.apple.com/us/app/id553403814?mt=8&src=af&ign-mpt=uo%3D6">Backspaces</a>. I told him to feel free to ignore most or all of what I said, too. So, needless to say I was pleasantly surprised when he attributed an excellent piece advice to me in <a href="http://arbor.posterous.com/i-just-quit-my-job-now-what">his recent blog post</a><em> – Treat Every Line of Code as If It's Going to be Thrown Away One Day – </em>and put it in the context of programming as an art form.</p>  <p>Many have drawn parallels between software and art, but I think that while programming is most certainly a creative endeavor, most of its output is mastery and technique. A piece of art may live forever and offer new generations an updated perspective in their context, whereas a program is ephemeral by design, and is quickly made obsolete with rapidly advancing technology. And, unlike art, the large part of elegance of a program is perceived at the time of the writing  (replaced by a new, less beautiful and less buggy implementation the next morning). So, how long should code live, anyway?</p>  <p>For a startup, the answer to that question is <em>not long</em>. A true startup is experimenting and looking for a business model. In that context code is more dead weight than intellectual property. The best we can do is not to get attached to it and treat every line of code as if it’s going to be thrown away <strike>one day</strike> tomorrow.</p>  <p>Just this week I deleted a huge and solid piece of functionality that lived for barely three months and took weeks to develop. The complexity of the feature was staggering and the implications of the change reverberated through every part of the system. But I cannot feel bad about it, it has served its purpose and show must go on. We all have to remember that the real goal of software is to empower or entertains an individual, a group, or, in rare cases, society. The editor I am using now is helping me put my thoughts on this blog. The <a href="http://art.sy/">website</a> I work on every day brings art to millions of people. Software makes it possible for an airplane to fly across the ocean to visit your family. It brings planet Mars a bit closer – I hope to visit one day.</p>  <p>Code may be <em>important</em>, but everything else is more <em>valuable</em>.</p></stripped></div><div><a href="http://code.dblock.org/treat-every-line-of-code-as-if-its-going-to-be-thrown-away-one-day">Read</a></div></html>
         ]]>
       </description>
       <category>startups</category><category>technology</category><category>people</category><category>agile</category>
       <link>http://code.dblock.org/treat-every-line-of-code-as-if-its-going-to-be-thrown-away-one-day</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/366</guid>
      </item>
     
      <item>
       <title>Losing Control to the Heroku PaaS</title>
       <pubDate>Fri, 14 Dec 2012 05:09:27 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p><a href="http://code.dblock.org/ShowPicture.aspx?id=514&ShowThumbnail=false"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=515&ShowThumbnail=false" width="156" height="156" /></a></p>  <p>I love Heroku and <a href="http://success.heroku.com/artsy">we have had great success with it</a>. Yet, today, I find myself releasing <a href="http://artsy.github.com/blog/2012/12/13/beat-heroku-60-seconds-application-boot-timeout-with-a-proxy/">heroku-forward</a>, a gem born from frustration, that works around a seemingly simple limitation of the platform - a 60 seconds application boot timeout.</p>  <p>Why did I need to do all that work? How hard can it be for Heroku to raise a timeout limit? The truth is that it’s probably very hard. I don’t know anything about Heroku’s internals, but I bet that there’s some math going on on for resource allocation as well as a system that runs on a 1-minute cycle. Changing a number impacts everything, making some customers happy and others upset, adding risk.</p>  <p>We all make similar design choices that hard-code numbers all the time. I’ve deliberately created a 1:1 relationship between an object and the object’s owner knowing that in some future an object may have multiple owners. I’ve probably saved countless hours of minor pain doing so, but I am about to pay the full price. The entire system must be turned on its head.</p>  <p>Are those two issues comparable? The biggest difference is <em>control</em>. In the Heroku PaaS example, someone else has it. In my domain model, it’s me.  But after years of tinkering with every single layer of hardware and software, I find myself increasingly comfortable delegating control of those areas outside of my domain expertise. I guess it’s called focusing exclusively on your core competencies.</p></stripped></div><div><a href="http://code.dblock.org/losing-control-to-the-heroku-paas">Read</a></div></html>
         ]]>
       </description>
       <category>technology</category><category>heroku</category><category>ruby</category><category>architecture</category>
       <link>http://code.dblock.org/losing-control-to-the-heroku-paas</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/365</guid>
      </item>
     
      <item>
       <title>Migrating from a relational to a NoSQL cloud database?</title>
       <pubDate>Mon, 10 Dec 2012 02:35:04 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p><a href="http://www.techrepublic.com/blog/datacenter/migrating-from-a-relational-to-a-nosql-cloud-database/5904"><img style="display: inline" title="image" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=513&ShowThumbnail=false" width="240" height="60" /></a></p>  <p>I was recently quoted in a <a href="http://www.techrepublic.com/blog/datacenter/migrating-from-a-relational-to-a-nosql-cloud-database/5904">TechRepublic article</a>, making rather sweeping general statements about how the free open-source NoSQL databases are the best thing since both SQL and sliced bread. I think some context may have been lost there, so it’s worth talking about it.</p>  <p>Two years ago I was looking at the Art.sy prototype implemented with MySQL. I found out that it was doing a JOIN to compose the hundreds of genes with their values for each of N artworks at startup time, where N &gt; 10000. That cannot scale, but it’s a dumb problem with many solutions. The best approach I could think of was to choose a store that natively supported a hash-like data structure – therefore I chose MongoDB. Learning how to use it was easy – much easier than even installing Oracle 11g. But even I can argue today that a relational database would have continued to pay dividends by helping me with data integrity, while a NoSQL store required a lot of programming discipline. Do you trust a programmer or the machine? The jury is out.</p>  <p>The article’s conclusion begins with <em>“Foursquare’s and Art.sy’s applications may be somewhat unique." </em>I would want to stop there. Every single application that you’re building is unique and deserves individualized attention to its data. Furthermore, database technology makes giant leaps every year in both SQL and NoSQL spaces - when I started, Heroku didn’t have a <a href="https://postgres.heroku.com/">PostgreSQL</a> offering that can do 1TB storage with a 68GB cache layer and fork-and-follow, and Amazon did not have <a href="http://aws.amazon.com/dynamodb/">DynamoDB</a> that runs off SSDs. Personally, I don’t make such a black and white distinction between SQL and NoSQL anymore – these are powerful tools available to the developers – I choose the best tool for the job in front of me.</p>  <p>PS: we use MongoDB in production and I strongly recommend it, but if you find me talking excitedly about the next big thing in databases today, it’s likely to be <a href="http://www.datomic.com/">Datomic</a>.</p></stripped></div><div><a href="http://code.dblock.org/migrating-from-a-relational-to-a-nosql-cloud-database">Read</a></div></html>
         ]]>
       </description>
       <category>scale</category><category>performance</category><category>technology</category><category>art.sy</category><category>mysql</category><category>mongodb</category><category>databases</category>
       <link>http://code.dblock.org/migrating-from-a-relational-to-a-nosql-cloud-database</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/364</guid>
      </item>
     
      <item>
       <title>Five Ways to Torture Candidates in a Technical Interview</title>
       <pubDate>Sat, 08 Dec 2012 17:19:01 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p>When I joined Microsoft in ‘99 I was taught how to properly interview candidates. I was shown the wheel of competencies, a kind of a wheel of fortune where a color represents the candidate’s technical skill, ability to solve complicated problems or to communicate with their peers. Each  slice included broad interviewing suggestions, which often gave birth to elaborate puzzles. What could possibly be the best way to figure out whether the candidate is capable of thinking out of the box? Ask them why the potholes are round. Can they crank complex working code on a deadline? Ask them to implement a memory allocator in 30 minutes or less in C. </p>  <p>As the interviewee I’ve been given all these problems myself. I hated the puzzles, but I loved the code, even though I failed my share of coding interviews - one that I still remember was for a team within the Windows division, where I was asked to implement “malloc”, which I think went well, and then some other simple string manipulation in C that I totally missed because I didn’t listen to the problem carefully enough. I also bombed an interview at Google because I’m still not capable of doing a power of 2 after 4 years of hardcore college math.</p>  <p>Below are some well-researched and widely practiced techniques of breaking even the best interview candidate.</p>  <p align="center"><strong>***</strong></p>  <p><strong>1. Whiteboarding</strong></p>  <p>Ask an expert C++ level candidate to reverse a string in C.</p>  <p><a href="http://code.dblock.org/ShowPicture.aspx?id=503&ShowThumbnail=false"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=504&ShowThumbnail=false" width="181" height="164" /></a></p>  <p>This is guaranteed to be insulting to someone who has demonstrable success developing software in any relevant technology. It’s the first thing taught in any C class and should take you about 45 seconds. The fact that many just cannot do it is irrelevant, those should never make it past a phone screen. By giving this problem to someone you’re telling them that you don’t trust their resume and that their demonstrable experience is completely irrelevant. It’s a single, efficient blow to their ego.</p>  <p><strong>2. Dehydration, Starvation and Solitary Confinement</strong></p>  <p>Create a system in which the candidate does not have access to food, water or bathroom for extended hours and spends significant lone time in a small, preferably windowless space.</p>  <p><a href="http://code.dblock.org/ShowPicture.aspx?id=505&ShowThumbnail=false"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=506&ShowThumbnail=false" width="179" height="176" /></a></p>  <p>After each 1 hour interview, grab the next interviewer and interrogate the previous interviewer on the strengths and weaknesses of the candidate. There’s a series of canned questions to ask: What did you ask the candidate? What did they answer? How well did they do? What are the areas that they failed at and that need to be drilled further by the next interviewer?</p>  <p>This is a clever management technique that extends the interview schedule by about an hour. The candidate is left in a conference room alone, while observing their incomplete solution for the previous problem on the whiteboard. I’ve never seen a candidate walk out to find a bathroom or a glass of water - they don’t want the next interviewer to come to an empty room. The bladder will speak in the middle of the next round, at which point it’s not polite to ask to take a break either. Lunch will be skipped since everything is running so late and the CEO only has a 2:00-2:01 PM window to meet.</p>  <p><strong>3. Pitchcapping</strong></p>  <p>Ask the candidate to solve a simple problem in a completely different way, until you run out of time.</p>  <p><a href="http://code.dblock.org/ShowPicture.aspx?id=507&ShowThumbnail=false"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=508&ShowThumbnail=false" width="184" height="196" /></a></p>  <p>This is akin to pouring hot pitch on a candidate’s head, letting it cool and then restarting again. It’s theoretically a good exercise if the question is complex, but it’s guaranteed to stump even the best programmer on the fifth “Can you please implement fib(x) in yet another completely different way?” iteration. You’ve succeeded when the candidate gives up and says that there’s just no other reasonable way to do this, at which point you end the interview, shake their hand and walk out.</p>  <p><strong>4. Keelhauling</strong></p>  <p>Lead the candidate to a stopping point where they are drowning in a problem, then maintain them underwater.</p>  <p><a href="http://code.dblock.org/ShowPicture.aspx?id=509&ShowThumbnail=false"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=510&ShowThumbnail=false" width="182" height="184" /></a></p>  <p>Pretend to be helpful. Finally, give them a few minutes to concentrate and solve the problem alone. Have a smoke outside. Come back 15 minutes later to see no real progress. Ask them to explain what they wrote and keep a concerned look. Finally, shoot them with a “this is good, although pretty far from working, and we’re out of time”.</p>  <p><strong>5. Flaying</strong></p>  <p>Ask an executive-level, non-programming interviewee to implement a sort algorithm of their choosing.</p>  <p><a href="http://code.dblock.org/ShowPicture.aspx?id=511&ShowThumbnail=false"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=512&ShowThumbnail=false" width="181" height="175" /></a></p>  <p>Guaranteed to remove any kind of skin that one developed over their 20 year long career. In small companies low rank developers interview their future executive-level bosses. Guide the candidate to talk about how they got started and wait for the story about their small, yet relevant programming experience. Mention with a smile that you’re impressed by their solid CS foundation and that “they must surely be able to implement a sort function with a bit of help, even today”. The candidate will definitely bite. The next step is a whiteboard.</p>  <p>About 10 years ago, one CTO candidate told me that he would walk out of the room if I was actually seriously about asking him to code a sort. He complied though, got sweaty and nervous and finally broke down with the next interrogator after me. His interview was cut short.</p>  <p> </p>  <p align="center">***</p>  <p>In a future post I will talk about great ways to interview people. In the meantime, I would like to apologize to all my past interview detainees and ask you to post your torture stories in the comments!</p></stripped></div><div><a href="http://code.dblock.org/five-ways-to-torture-candidates-in-a-technical-interview">Read</a></div></html>
         ]]>
       </description>
       <category>interviews</category><category>teams</category><category>people</category>
       <link>http://code.dblock.org/five-ways-to-torture-candidates-in-a-technical-interview</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/363</guid>
      </item>
     
      <item>
       <title>Measuring Performance in Grape APIs w/ NewRelic RPM</title>
       <pubDate>Mon, 03 Dec 2012 02:58:53 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p>If you’re not using NewRelic, here’s a pretty picture to convince you to try it out. And <a href="http://artsy.github.com/blog/2012/11/29/measuring-performance-in-grape-apis-with-new-relic/">a blog post on measuring performance in Grape APIs with NewRelic RPM</a> on the Art.sy Engineering blog, with a Grape middleware I rewrote last week.</p>  <p><a href="http://code.dblock.org/ShowPicture.aspx?id=501&ShowThumbnail=false"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=502&ShowThumbnail=false" width="599" height="276" /></a></p></stripped></div><div><a href="http://code.dblock.org/measuring-performance-in-grape-apis-w-newrelic-rpm">Read</a></div></html>
         ]]>
       </description>
       <category>performance</category><category>grape</category><category>ruby</category>
       <link>http://code.dblock.org/measuring-performance-in-grape-apis-w-newrelic-rpm</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/362</guid>
      </item>
     
      <item>
       <title>Debugging “object has no properties” in a MongoDB map/reduce</title>
       <pubDate>Thu, 29 Nov 2012 12:48:12 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p>You got to love debugging JavaScript errors. Here’s one from a MongoDB map/reduce. The operation fails with this:</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>04:39:41  Database command 'mapreduce' failed: (</li> <li style="background: #f3f3f3">    assertion: 'map invoke failed: JS Error: </li> <li>        TypeError: spline has no properties nofile_b:7'; </li> <li style="background: #f3f3f3">    assertionCode: '9014'; </li> <li>    errmsg: 'db assertion failure'; </li> <li style="background: #f3f3f3">    ok: '0.0').</li> </ol> </div> </div> </div>  <p>Examining the MongoDB log we notice that the map/reduce completes to about 70%, so this is caused by some data inside the database. In this case the issue is in the <em>spline</em> object being accessed by the <em>map</em> function. Indeed, the map tries to fetch <em>spline.reticulated</em>, which is hopefully a Boolean value. The error <em>“spline has no properties”</em> is, generally, another way of saying <em>“spline is null”</em>. In my case splines live in an embedded collection inside <em>bones</em>, and aren’t expected to be <em>null</em>, so I need to track down a null <em>spline</em> inside <em>bone.splines</em>.</p>  <p>While we can just look for a null embedded object, more generally, we can find whether a JS object has no properties with <a href="http://stackoverflow.com/questions/3426979/javascript-checking-if-an-object-has-no-properties-or-if-a-map-associative-arra">this isEmpty function from SO</a>. Declare it in the mongodb console (use a 1-liner):</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>function isEmpty(map) { </li> <li style="background: #f3f3f3">    for(var key in map) { </li> <li>        if (map.hasOwnProperty(key)) { </li> <li style="background: #f3f3f3">            return false; </li> <li>        } </li> <li style="background: #f3f3f3">    } </li> <li>    return true; </li> <li style="background: #f3f3f3">}</li> </ol> </div> </div> </div>  <p>Iterate over all bones records.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>db.bones.find().forEach(function(bone) { </li> <li style="background: #f3f3f3">    if (bone.splines) { </li> <li>        bone.splines.forEach(function(spline) { </li> <li style="background: #f3f3f3">            if (isEmpty(spline)) { </li> <li>                printjson(bone); </li> <li style="background: #f3f3f3">            }</li> <li>        }</li> <li style="background: #f3f3f3">    ); </li> <li>}});</li> </ol> </div> </div> </div>  <p>Here’s the culprit, notice the null embedded <em>spline</em>.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>Here's the culprit:</li> <li style="background: #f3f3f3"> </li> <li>{</li> <li style="background: #f3f3f3">    "_id" : ObjectId("507ea06bd646a40002000759"),</li> <li>    "splines" : [</li> <li style="background: #f3f3f3">        {</li> <li>            "_id" : ObjectId("508a6911c6e210000200078c"),</li> <li style="background: #f3f3f3">                        ....</li> <li>        },</li> <li style="background: #f3f3f3">        null</li> <li>    ],</li> </ol> </div> </div> </div>    <p>You can get rid of it in different ways on the mongo console. In this case we have two splines, one to keep and another to erase.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>var bone = db.bones.findOne({ _id: ObjectId("507ea06bd646a40002000759") })</li> <li style="background: #f3f3f3">bone.splines = [ bone.splines[0] ];</li> <li>db.bones.save(a);</li> </ol> </div> </div> </div>  <p>How did we get into having this null record anyway? See <a href="https://jira.mongodb.org/browse/SERVER-831">https://jira.mongodb.org/browse/SERVER-831</a> and <a href="https://github.com/mongoid/mongoid/issues/2545">https://github.com/mongoid/mongoid/issues/2545</a>. </p></stripped></div><div><a href="http://code.dblock.org/debugging-object-has-no-properties-in-a-mongodb-mapreduce">Read</a> | Updated 11/29/2012</div></html>
         ]]>
       </description>
       <category>mongoid</category><category>javascript</category><category>mongodb</category>
       <link>http://code.dblock.org/debugging-object-has-no-properties-in-a-mongodb-mapreduce</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/361</guid>
      </item>
     
      <item>
       <title>TaxCloud: SOAP Service Integration in Ruby</title>
       <pubDate>Tue, 27 Nov 2012 05:54:16 GMT</pubDate>
       <description>
         <![CDATA[
          <!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->
          <!--[if IE 7 ]><html class="ie ie7" lang="en"> <![endif]-->
          <!--[if IE 8 ]><html class="ie ie8" lang="en"> <![endif]-->
          <!--[if (gte IE 9)|!(IE)]><!--><html lang="en"> <!--<![endif]-->
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/base.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/skeleton.css" />
          <link rel="stylesheet" href="http://code.dblock.org/stylesheets/layout.css" />
          <link rel="apple-touch-icon" href="http://code.dblock.org/images/apple-touch-icon.png" />
          <link rel="apple-touch-icon" sizes="72x72" href="http://code.dblock.org/images/apple-touch-icon-72x72.png" />
          <link rel="apple-touch-icon" sizes="114x114" href="http://code.dblock.org/images/apple-touch-icon-114x114.png" />
          <html><div><stripped><p><a href="http://code.dblock.org/ShowPicture.aspx?id=499&ShowThumbnail=false"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://code.dblock.org/ShowPicture.aspx?id=500&ShowThumbnail=false" width="115" height="72" /></a></p>  <p>I’ve been working on the the <a href="https://github.com/drewtempelmeyer/tax_cloud">tax_cloud</a> gem for the past couple of days and am happy to announce version 0.2.0, released today. The gem was started by <a href="https://twitter.com/tempelmeyer/">@tempelmeyer</a> and is now a mature wrapper for the <a href="https://taxcloud.net/default.aspx">TaxCloud US Sales Tax calculation service</a>.</p>  <p>This library is also a nice example of a generic SOAP client wrapper in Ruby. I wanted to point out several successful patterns for this integration, which I cannot take credit for, for the most part.</p>  <p><strong>Error Handling</strong></p>  <p>I borrowed error handling from <a href="https://twitter.com/modetojoy">@modetojoy</a>’s Mongoid. Today someone said: “I had a bug in a spec and Durran told me how to fix it in an error message.” True story. To accomplish this we define a base error that holds the problem, summary and resolution. In tax_cloud’s case this is  <a href="https://github.com/drewtempelmeyer/tax_cloud/blob/master/lib/tax_cloud/errors/tax_cloud_error.rb">TaxCloud::Errors::TaxCloudError</a> paired with <a href="https://github.com/drewtempelmeyer/tax_cloud/blob/master/lib/config/locales/en.yml">config/locales/en.yml</a>, a locale file that does the error formatting. There’re two things to do in order for the error code to find the message: add the locale file to the load path, in <a href="https://github.com/drewtempelmeyer/tax_cloud/blob/master/lib/tax_cloud.rb">tax_cloud.rb</a>, and do a bit of formatting with I18n.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>I18n.load_path &lt;&lt; File.join(File.dirname(__FILE__), "config", "locales", "en.yml")</li> </ol> </div> </div> </div>  <p>   </p><div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>def translate(key, options)</li> <li style="background: #f3f3f3">    ::I18n.translate("#{BASE_KEY}.#{key}", { :locale =&gt; :en }.merge(options)).strip</li> <li>end</li> </ol> </div> </div> </div>   <p>What does an error in tax_cloud look like?</p>  <p>   </p><div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>Problem:</li> <li style="background: #f3f3f3">  Missing configuration.</li> <li>Summary:</li> <li style="background: #f3f3f3">  TaxCloud requires an API login ID and key.</li> <li>Resolution:</li> <li style="background: #f3f3f3">  Create a TaxCloud merchant account at http://www.taxcloud.net. </li> <li>  Add a website to your TaxCloud account. </li> <li style="background: #f3f3f3">  This will generate an API ID and API Key that you will need to use the service. </li> <li>  Configure the TaxCloud gem. For example, add the following to `config/initializers/tax_cloud.rb`.</li> <li style="background: #f3f3f3">  TaxCloud.configure do |config|</li> <li>   config.api_login_id = 'your_tax_cloud_api_login_id'</li> <li style="background: #f3f3f3">   config.api_key = 'your_tax_cloud_api_key'</li> <li>   config.usps_username = 'your_usps_username' # optional</li> <li style="background: #f3f3f3">  end</li> </ol> </div> </div> </div>   <p>Pretty awesome.</p>  <p><strong>Safe SOAP Requests </strong></p>  <p>The tax_cloud gem uses <a href="https://github.com/savonrb/savon">Savon</a> to make SOAP requests. “Savon” is French for “Soap”, which confuses the French speakers like myself trying to explain that SOAP is Savon. Anyway, a client is initialized with its WSDL.</p>  <p>   </p><div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>module TaxCloud #:nodoc:</li> <li style="background: #f3f3f3">  class Client &lt; Savon::Client</li> <li>    def initialize</li> <li style="background: #f3f3f3">      super 'https://api.taxcloud.net/1.0/?wsdl'</li> <li>    end</li> <li style="background: #f3f3f3">  end</li> <li>end</li> </ol> </div> </div> </div>   <p>First, we need to add authentication to every request, which is required by the API. We can override <em>request</em>.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>def request(method, body = {})</li> <li style="background: #f3f3f3">    super method, :body =&gt; body.merge(auth_params)</li> <li>end</li> <li style="background: #f3f3f3"> </li> <li>def auth_params</li> <li style="background: #f3f3f3">{</li> <li>    'apiLoginID' =&gt; TaxCloud.configuration.api_login_id,</li> <li style="background: #f3f3f3">    'apiKey' =&gt; TaxCloud.configuration.api_key</li> <li>}</li> <li style="background: #f3f3f3">end</li> </ol> </div> </div> </div>  <p>Second, we want to handle SOAP errors, and give a detailed explanation for SOAP faults, Mongoid-style. This is your typical block with <em>yield</em>.</p>  <div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>def request(method, body = {})</li> <li style="background: #f3f3f3">  safe do</li> <li>    super method, :body =&gt; body.merge(auth_params)</li> <li style="background: #f3f3f3">  end</li> <li>end</li> <li style="background: #f3f3f3"> </li> <li>def safe &block</li> <li style="background: #f3f3f3">  begin</li> <li>    yield</li> <li style="background: #f3f3f3">  rescue Savon::SOAP::Fault =&gt; e</li> <li>    raise TaxCloud::Errors::SoapError.new(e)</li> <li style="background: #f3f3f3">  end</li> <li>end</li> </ol> </div> </div> </div>  <p>The complete code can be found in <a href="https://github.com/drewtempelmeyer/tax_cloud/blob/master/lib/tax_cloud/client.rb">client.rb</a>. The error itself is parsed in <a href="https://github.com/drewtempelmeyer/tax_cloud/blob/master/lib/tax_cloud/errors/soap_error.rb">soap_error.rb</a> – SOAP faults come in standard format.</p>  <p><strong>Parsing Responses</strong></p>  <p>We will now raise a good-looking exception on SOAP failures, but we still must protect ourselves from unexpected data or successful SOAP requests that return API errors. That possibility is the thing I detest most about SOAP (vs. REST) – it makes programming a client unnecessarily complicated. The TaxCloud service returns a SOAP body with different values in <em>key_response/key_result/response_type</em>, where the key will be the name of the method invoked (eg. <em>ping_response</em>). A bit of meta-programming can make a <a href="https://github.com/drewtempelmeyer/tax_cloud/blob/master/lib/tax_cloud/responses/base.rb">base class</a>, which can parse a response and match an XML path, raising errors where appropriate. It can be subclassed into a <a href="https://github.com/drewtempelmeyer/tax_cloud/blob/master/lib/tax_cloud/responses/generic.rb">generic response type</a> and, finally, into specific declarative implementations such as <a href="https://github.com/drewtempelmeyer/tax_cloud/blob/master/lib/tax_cloud/responses/ping.rb">ping</a> or <a href="https://github.com/drewtempelmeyer/tax_cloud/blob/master/lib/tax_cloud/responses/authorized.rb">authorized</a>.</p>  <p>Most services have a common response pattern, generalizing it yields a very productive framework where adding support for new calls requires very little to no code. And you must never, ever expose to the user that you’re making SOAP requests and return any kind of raw SOAP object. Return domain-specific classes with attributes on success and raise exceptions otherwise.</p>  <p><strong>Testing SOAP Requests</strong></p>  <p>The tax_cloud gem uses <a href="https://github.com/myronmarston/vcr">VCR</a> to test SOAP requests. It’s surprisingly easy: use a cassette (a YAML file), which records it the first time you make a request. Second time around the file contents are used and no HTTP requests are made. You can filter out sensitive keys in the configuration.</p>  <p>   </p><div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li>require 'vcr'</li> <li style="background: #f3f3f3"> </li> <li>VCR.configure do |c|</li> <li style="background: #f3f3f3">  c.cassette_library_dir = 'test/cassettes'</li> <li>  c.hook_into :webmock</li> <li style="background: #f3f3f3">  c.filter_sensitive_data('api-login-id')  { TaxCloud.configuration.api_login_id }</li> <li>  c.filter_sensitive_data('api-key')       { TaxCloud.configuration.api_key }</li> <li style="background: #f3f3f3">  c.filter_sensitive_data('usps-username') { TaxCloud.configuration.usps_username }  </li> <li>end</li> </ol> </div> </div> </div>   <p>   </p><div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" class="wlWriterEditableSmartContent"> <div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"> <div style="background: #fff; overflow: auto"> <ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"> <li> def test_ping_with_invalid_credentials</li> <li style="background: #f3f3f3">  assert_raise TaxCloud::Errors::ApiError do</li> <li>   VCR.use_cassette('ping_with_invalid_credentials') do</li> <li style="background: #f3f3f3">    TaxCloud.client.ping</li> <li>   end</li> <li style="background: #f3f3f3">  end</li> <li> end</li> <li style="background: #f3f3f3"> </li> <li> def test_ping_with_invalid_response</li> <li style="background: #f3f3f3">  e = assert_raise TaxCloud::Errors::UnexpectedSoapResponse do</li> <li>   VCR.use_cassette('ping_with_invalid_response') do</li> <li style="background: #f3f3f3">    TaxCloud.client.ping</li> <li>   end</li> <li style="background: #f3f3f3">  end</li> <li>  assert_equal "Expected a value for `ping_result`.", e.problem</li> <li style="background: #f3f3f3"> end</li> <li> </li> <li style="background: #f3f3f3"> def test_ping</li> <li>  VCR.use_cassette('ping') do</li> <li style="background: #f3f3f3">   response = TaxCloud.client.ping</li> <li>   assert_equal "OK", response</li> <li style="background: #f3f3f3">  end</li> <li> end</li> </ol> </div> </div> </div>     <p>You can see the rest of the tests <a href="https://github.com/drewtempelmeyer/tax_cloud/tree/master/test">here</a>.</p>  <p><strong>Finally</strong></p>  <p>Let me know if you use some of these ideas, post your comments and suggestions and please help improve the tax_cloud gem <a href="https://github.com/drewtempelmeyer/tax_cloud">on Github</a>.</p></stripped></div><div><a href="http://code.dblock.org/taxcloud-soap-service-integration-in-ruby">Read</a></div></html>
         ]]>
       </description>
       <category>ruby</category><category>open source</category><category>testing</category>
       <link>http://code.dblock.org/taxcloud-soap-service-integration-in-ruby</link>
       <guid isPermaLink="false">http://code.dblock.org/Post/360</guid>
      </item>
         
  </channel>
</rss>
