<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:series="http://organizeseries.com/"
	>

<channel>
	<title>MettaProgramming</title>
	<atom:link href="http://mettadore.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mettadore.com</link>
	<description>Thoughts on Software and Technology</description>
	<lastBuildDate>Wed, 24 Apr 2013 05:58:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Comments Provided by Google+</title>
		<link>http://mettadore.com/analysis/comments-provided-by-google/</link>
		<comments>http://mettadore.com/analysis/comments-provided-by-google/#comments</comments>
		<pubDate>Wed, 24 Apr 2013 05:52:17 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Miscellany]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://mettadore.com/?p=1081</guid>
		<description><![CDATA[Comments have been turned off on my blogs for months, and I&#8217;ve been happy with the result. Gone were both the SPAM comments and the less than useful comments. There is a full discussion of my reasoning in a Google+ post, should anyone be interested. Recently, I learned that one could add embedded Google+ Comments [...]]]></description>
				<content:encoded><![CDATA[<p>Comments have been turned off on my blogs for months, and I&#8217;ve been happy with the result. Gone were both the SPAM comments and the less than useful comments. There is a <a href="https://plus.google.com/110521673329066426447/posts/JmBPoDBbYMw">full discussion of my reasoning in a Google+ post</a>, should anyone be interested.</p>
<p>Recently, I learned that one could <a href="http://browsingthenet.blogspot.in/2013/04/google-plus-comments-on-any-website.html">add embedded Google+ Comments on any page</a>. Naturally, this appeals to me since I send my users to G+ to comment anyway. This provides a nice comment system in the place that I want it, embedded right into my blog posts.</p>
<p>It&#8217;s simple, a wee bit of code:</p>
<pre class="brush: xml; title: ; notranslate">
&amp;lt;div id=&amp;quot;comments&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;// &amp;lt;![CDATA[
gapi.comments.render('comments', {
    href: window.location,
    width: '624',
    first_party_property: 'BLOGGER',
    view_type: 'FILTERED_POSTMOD'
});
// ]]&amp;gt;&amp;lt;/script&amp;gt;
</pre>
<p>Added using the <a href="http://wordpress.org/extend/plugins/post-ender/">Post Ender</a> plugin, and we&#8217;re in business. Now, <em>encouraging</em> people to comment in Google+ is automatic, and I <em>still</em> have no SPAM worries.</p>
]]></content:encoded>
			<wfw:commentRss>http://mettadore.com/analysis/comments-provided-by-google/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using RSpec With Mixed Random and Ordered Tests</title>
		<link>http://mettadore.com/analysis/using-rspec-with-mixed-random-and-ordered-tests/</link>
		<comments>http://mettadore.com/analysis/using-rspec-with-mixed-random-and-ordered-tests/#comments</comments>
		<pubDate>Wed, 24 Oct 2012 03:06:44 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Miscellany]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://mettadore.com/?p=1072</guid>
		<description><![CDATA[I prefer to have my RSpec tests ordered randomly to ensure we have condition independent code. Back in July, RSpec 2.11 was released, which added support for the &#8211;order argument on the commandline. Now you can add &#8220;&#8211;order rand&#8221; to your .rspec file and have all your tests run at random. But what if you [...]]]></description>
				<content:encoded><![CDATA[<p>I prefer to have my RSpec tests ordered randomly to ensure we have condition independent code. Back in July, <a href="http://blog.davidchelimsky.net/category/rspec/">RSpec 2.11 was released</a>, which added support for the &#8211;order argument on the commandline. Now you can add &#8220;&#8211;order rand&#8221; to your .rspec file and have all your tests run at random.</p>
<p>But what if you want some tests run in order? Easy, run your specs with &#8216;rspec spec/path/to/spec &#8211;order default&#8217;.</p>
<p>Love it.</p>
<h2>Continuous Integration Gotchas</h2>
<p>There&#8217;s a gotcha though. What if you are– as I am– using a continuous integration server. I want <em>most</em> of my tests to run in random order, but I want <em>some</em> of them to run top down in the file. That&#8217;s because we have some pretty specific algorithm and analytics code that depends on the system changing over time, and we use the <a href="https://github.com/travisjeffery/timecop">Timecop gem</a> to <em>watch</em> that change over time.</p>
<p>Sometimes, it pays to have specs that are dependent on the state of other specs.</p>
<p>We want our tests to run on the CI server in random order, but if they do, the ordered specs will fail. This is an issue– one that, it turns out, <a href="https://github.com/rspec/rspec-core/issues/547">others have had</a>.</p>
<h2>Defining <em>Some</em> Specs To Run In Order</h2>
<p>It turns out that rspec-core had <a href="https://github.com/rspec/rspec-core/pull/548#issuecomment-3466544">a very interesting pull request</a> about 10 months ago. One that adds support for defining, file-by-file, the order of rspec groups and examples. I haven&#8217;t seen any documentation on it, so assume it&#8217;ll come out in version 2.12, but there are <a href="https://github.com/rspec/rspec-core/blob/d79960bb6ebf63d005c2ed8d74f5a8f31bcc8e3b/spec/command_line/order_spec.rb#L113">some interesting specs</a> showing how it works.</p>
<h3>Ordered Specs In A Single File</h3>
<p>Let&#8217;s assume you want to run all of your specs randomly except one file. Let&#8217;s call that file &#8220;ordered_specs.rb&#8221;:</p>
<pre class="brush: ruby; title: ; notranslate">
require 'spec_helper'

describe Trove do
  RSpec.configure do |config|
    config.order_groups_and_examples do |list|
      list.sort_by { |item| item.description }
    end
  end

  describe &quot;Day 2&quot; do
    specify(&quot;PM&quot;) {}
    specify(&quot;AM&quot;) {}
  end
  describe &quot;Day 3&quot; do
    specify(&quot;AM&quot;) {}
    specify(&quot;PM&quot;) {}
  end
  describe &quot;Day 1&quot; do
    specify(&quot;AM&quot;) {}
    specify(&quot;PM&quot;) {}
  end

end
</pre>
<p>As you can see, we are calling the configure method and telling it to order the groups and examples in this spec file. Given this, the output when run is:</p>
<pre class="brush: bash; title: ; notranslate">
john@patience:~/QStream/qstream
$ rspec spec/trove/ordered_spec.rb

Trove
  Day 1
    AM
.    PM
.  Day 2
    AM
.    PM
.  Day 3
    AM
.    PM
.

Finished in 9.23 seconds
6 examples, 0 failures

Finished in 9.23 seconds
6 examples, 0 failures

Randomized with seed 9386


Randomized with seed 9386

john@patience:~/QStream/qstream
$ 
</pre>
<p>As you can see, the spec was ordered by the description, even though we&#8217;re running with &#8220;&#8211;order rand&#8221; in the .rspec file.</p>
<p>Now, I can have all my specs go to my continuous integration server and get run at random, but have the few tests that look at algorithm and analytics as a whole run in order! </p>
<p>Love. This. Stuff.</p>
<h2>How Do I Get It?</h2>
<p>I&#8217;m not sure this functionality is gemmed up yet, so to get it, I&#8217;ve loaded the current HEAD ref in my gemfile:</p>
<pre class="brush: ruby; title: ; notranslate">
 gem 'rspec-core', git: &quot;git://github.com/rspec/rspec-core.git&quot;, ref: &quot;5d28318b51bf212c215ba1392fb24cc5a52dbe06&quot;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://mettadore.com/analysis/using-rspec-with-mixed-random-and-ordered-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Turning issues into pull requests</title>
		<link>http://mettadore.com/analysis/turning-issues-into-pull-requests/</link>
		<comments>http://mettadore.com/analysis/turning-issues-into-pull-requests/#comments</comments>
		<pubDate>Mon, 27 Aug 2012 11:58:34 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Miscellany]]></category>

		<guid isPermaLink="false">http://mettadore.com/?p=1062</guid>
		<description><![CDATA[For the past several months, I&#8217;ve been using a nice feature that I&#8217;ve recently found out that many others don&#8217;t know about, so thought I&#8217;d draft it up.1 You have an issue in Github, so you do some work, then you issue a pull request to fix that issue. In Github, that means you actually [...]]]></description>
				<content:encoded><![CDATA[<p>For the past several months, I&#8217;ve been using a nice feature that I&#8217;ve recently found out that many others don&#8217;t know about, so thought I&#8217;d draft it up.<sup><a href="http://mettadore.com/analysis/turning-issues-into-pull-requests/#footnote_0_1062" id="identifier_0_1062" class="footnote-link footnote-identifier-link" title="realizing, of course, that this is old news to many&ndash; as usual">1</a></sup></p>
<p>You have an issue in Github, so you do some work, then you issue a pull request to fix that issue. In Github, that means you actually have two issues in your issue list, the original issue, and the pull request. Well, did you know that you can easily <em>turn the issue <strong>into</strong> a pull request?</em> And it&#8217;s easy.</p>
<p>The secret is using the <a href="https://github.com/defunkt/hub">Hub gem</a>. After that&#8217;s installed, &#8216;<a href="https://github.com/defunkt/hub#git-pull-request">git pull-request</a>&#8216; is a commandline option.</p>
<p>Assume I &#8216;cucumber&#8217; branch, cleaning up the &#8216;we&#8217;re in a pickle!&#8217; issue, which happens to be issue #39. It&#8217;s easy to turn &#8220;issue 39&#8243; into &#8220;pull request 39&#8243; by doing</p>
<pre class="brush: ruby; title: ; notranslate">
git checkout -b fix-the-pickle-issue
git commit -m &quot;Make some changes&quot;
git push origin fix-the-pickle-issue
git pull-request -i 39 -b cucumber -h fix-the-pickle-issue
</pre>
<p>If you&#8217;re working on different accounts/origins, you can use fully referenced names:</p>
<pre class="brush: ruby; title: ; notranslate">
git checkout -b fix-the-pickle-issue
git commit -m &quot;Make some changes&quot;
git push origin fix-the-pickle-issue
git pull-request -i 39 -b johnmetta:cucumber -h mettadore:fix-the-pickle-issue
</pre>
<p>The pull request is created on Github, and automatically linked to the issue, turning it from &#8220;issue 39&#8243; to &#8220;pull request 39&#8243;. Of course, you can always close the pull request from the commandline by merging</p>
<pre class="brush: ruby; title: ; notranslate">
git checkout cucumber
git merge pull-test
git commit -m &quot;merge&quot;
git push
</pre>
<p>The pull request is then closed on Github.</p>
<ol class="footnotes"><li id="footnote_0_1062" class="footnote">realizing, of course, that this is old news to many– as usual</li></ol>]]></content:encoded>
			<wfw:commentRss>http://mettadore.com/analysis/turning-issues-into-pull-requests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Heroku, UTF-8, and DATABASE_URL</title>
		<link>http://mettadore.com/analysis/heroku-utf-8-and-uri-specifications/</link>
		<comments>http://mettadore.com/analysis/heroku-utf-8-and-uri-specifications/#comments</comments>
		<pubDate>Tue, 10 Jul 2012 18:55:58 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Miscellany]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://mettadore.com/?p=1053</guid>
		<description><![CDATA[Recently, I&#8217;ve been fighting with Ruby 1.9 and encoding in a Rails 3.1 app that we&#8217;re running on Heroku. The strange thing is that encoding was working fine on any local system we would try, but would break on Heroku while rendering views with the error ActionView::Template::Error (incompatible character encoding: ASCII-8BIT and UTF-8) There are [...]]]></description>
				<content:encoded><![CDATA[<p>Recently, I&#8217;ve been fighting with Ruby 1.9 and encoding in a Rails 3.1 app that we&#8217;re running on Heroku. The strange thing is that encoding was working fine on any local system we would try, but would break on Heroku while rendering views with the error</p>
<pre>ActionView::Template::Error (incompatible character encoding: ASCII-8BIT and UTF-8)</pre>
<p>There are suggestions sprinkled all around the web on how to deal with Ruby 1.9 and character encoding.<sup><a href="http://mettadore.com/analysis/heroku-utf-8-and-uri-specifications/#footnote_0_1053" id="identifier_0_1053" class="footnote-link footnote-identifier-link" title="The most detailed being the post by Yehuda on the topic">1</a></sup> Do a quick Google search and you see everything from &#8220;revert to Ruby 1.8 until <em>they</em><sup><a href="http://mettadore.com/analysis/heroku-utf-8-and-uri-specifications/#footnote_1_1053" id="identifier_1_1053" class="footnote-link footnote-identifier-link" title="whoever &ldquo;they&rdquo; are">2</a></sup> fix Ruby&#8221; to &#8220;Add &#8216;encoding: utf-8&#8242; to the top of every file you&#8217;ve ever seen.&#8221; In the beginning of this all, I thought I at least understood encoding. By the end, after trying litterally everything I could find to fix the problem, I started to think it was all magic.</p>
<p>Here&#8217;s the deal: We&#8217;re using an RDS database plugin on Heroku, so the actual <em>database</em> is the same regardless of what system you&#8217;re on. Moreover, I was using the same database for production and development environments. Despite this, the app had encoding errors on Heroku and not on any local system.</p>
<p>We changed the LANG environment variable, the encoding settings for Rails, for Ruby. Everything. Nothing I did changed the encoding of things on Heroku. Nothing.</p>
<h3>The MYSQL2 Gem</h3>
<p>Many things I saw said to use the mysql2 gem. That was actually one of the first steps we took. Unfortunately, Heroku didn&#8217;t seem to support the mysql2 gem. If you had that gem anywhere in the production environment, the deployment would fail with a gem error. So, we had the mysql gem in production and mysql2 in development:</p>
<pre>group :production do
  gem "mysql"
  ...
end
group :development do
  gem "mysql2"
  ...
end</pre>
<p>Despite this, in our database.yml file we were using</p>
<pre>production:
 adapter: mysql2
 encoding: utf8</pre>
<p>This didn&#8217;t seem to cause any problems, no errors or warnings, so I figured Heroku must be honoring it. Wrong. I&#8217;d fire up the local console, grab something from the database, and see &lt;#Encoding: UTF-8&gt;, then I&#8217;d fire up the Heroku console and see &lt;#Encoding: ASCII-8BIT&gt; for the same object.</p>
<p>The clue came when I changed the adapter to just &#8216;mysql&#8217; and then started the app locally in production mode. Suddenly, I saw the encoding as ASCII-8BIT on my local system too. Somehow, on the local system, despite &#8216;mysql&#8217; two being set in the Gemfile, &#8216;mysql2&#8242; was being used because of the database.yml file. However, the reverse was true on Heroku.</p>
<p>WTH?</p>
<h3>The database URI forces a gem, not a protocol?</h3>
<div>Long story short, Heroku *does* support mysql2, but they don&#8217;t actually let you know that.</div>
<div><a href="http://mettadore.com/files/2012/07/Screen-Shot-2012-07-10-at-10.18.41-AM.png"><img class="alignright size-medium wp-image-1054" title="Screen Shot 2012-07-10 at 10.18.41 AM" src="http://mettadore.com/files/2012/07/Screen-Shot-2012-07-10-at-10.18.41-AM-300x167.png" alt="" width="300" height="167" /></a></div>
<p>When you use the RDS plugin on Heroku, you add the URI to your account info. This is done on the Heroku site using a dialog box, which contains a very helpful bit of text describing the format of the database location as:</p>
<pre>mysql://user:pass@rdshostname.amazonaws.com/databasename</pre>
<p>Now, when reading this, one would naturally assume that the &#8216;mysql://&#8217; part of this URI is designating that you want to use MySQL to access this database. As opposed to, say &#8216;postgres://&#8217; or something.</p>
<p>One however, would be quite wrong.</p>
<p>It turns out that the format is not as described, but rather:</p>
<pre>gemname://user:pass@rdshostname.amazonaws.com/databasename</pre>
<p>Surprised? Yeah, me too. Suddenly, I can use the &#8216;mysql2&#8242; gem in production if I use a database location of:</p>
<pre>mysql2://user:pass@rdshostname.amazonaws.com/databasename</pre>
<h3>Doc, no doc</h3>
<p>Now, I love Heroku, so I&#8217;ll give them the benefit of the doubt here. I&#8217;m sure someone thought it was very clever to use the &lt;schema&gt; portion of the URI to allow for changing of the gem. And sure, it is. But come on, folks, &#8220;The format is&#8221; when describing a URI is meaningful.</p>
<p><a href="http://mettadore.com/files/2012/07/heroku_mysql.png"><img class="alignright size-medium wp-image-1055" title="heroku_mysql" src="http://mettadore.com/files/2012/07/heroku_mysql-300x87.png" alt="" width="300" height="87" /></a>Interestingly, clicking on that little question mark brings you to <a href="https://devcenter.heroku.com/articles/amazon_rds">a documentation page</a> where &#8216;mysql://&#8217; and &#8216;mysql2://&#8217; seem to be used interchangeably, with no notes as to the consequences. If you were following this documentation, you&#8217;d be instructed to migrate your data using the &#8216;mysql&#8217; gem, then you&#8217;d be instructed to <em>use</em> the database using the &#8216;mysql2&#8242; gem. This would probably cause some confusion when suddenly your deployment fails telling you that your Gemfile is broken.</p>
<h3>Coda</h3>
<p>Moral of the story: If you&#8217;re on Heroku, and getting encoding errors that you can&#8217;t find with an external database, look well at the URI of your database and ensure that Heroku is actually using the gem you think it is. Unfortunate as hell that a URI set on their web app would break stuff you put in your code, but there you are.</p>
<ol class="footnotes"><li id="footnote_0_1053" class="footnote">The most detailed being the post by <a href="http://yehudakatz.com/2010/05/05/ruby-1-9-encodings-a-primer-and-the-solution-for-rails/">Yehuda</a> on the topic</li><li id="footnote_1_1053" class="footnote">whoever &#8220;they&#8221; are</li></ol>]]></content:encoded>
			<wfw:commentRss>http://mettadore.com/analysis/heroku-utf-8-and-uri-specifications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Server specific banner using RMagic gem</title>
		<link>http://mettadore.com/analysis/server-specific-banner-using-rmagic-gem/</link>
		<comments>http://mettadore.com/analysis/server-specific-banner-using-rmagic-gem/#comments</comments>
		<pubDate>Tue, 22 May 2012 16:26:36 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Miscellany]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://mettadore.com/?p=1035</guid>
		<description><![CDATA[So, I have a complicated Rails project. I have a local server, a remote dev server, a remote staging server, and a production server. Recently, I had a situation where the dev server was shunting traffic to the production server and I didn&#8217;t catch it. What the hell?! Why aren&#8217;t my changes showing up?! So, [...]]]></description>
				<content:encoded><![CDATA[<p>So, I have a complicated Rails project. I have a local server, a remote dev server, a remote staging server, and a production server. Recently, I had a situation where the dev server was shunting traffic to the production server and I didn&#8217;t catch it.</p>
<blockquote><p>What the hell?! Why aren&#8217;t my changes showing up?!</p></blockquote>
<p>So, I made a banner that said &#8220;Dev Server.&#8221; That was pretty useful, but then I thought it would be nice to have the banner specific for the server.</p>
<p>So I came up with this helper method:</p>
<pre class="brush: ruby; title: ; notranslate">
  def dev_banner
    filename = &quot;#{ENV['QSTREAM_SERVER_TYPE']}_server_banner.png&quot;
    banner_path = &quot;public/images/#{filename}&quot;
    server_type = ENV['QSTREAM_SERVER_TYPE']

    unless File.exists? banner_path
      img = Magick::ImageList.new(&quot;public/images/dev_banner_background.png&quot;)
      img.background_color = &quot;none&quot;
      gc = Magick::Draw.new

      img.annotate(gc, 0,0,15,130, &quot;| #{server_type} Server |&quot;) do
        self.pointsize = 13
        self.rotation = -45
        self.kerning = 1
        self.stroke = &quot;#dfdfdf&quot;
        self.fill = &quot;#dfdfdf&quot;
      end

      picture = img.flatten_images
      picture.background_color = &quot;none&quot;
      picture.write(banner_path)
    end
    filename
  end
</pre>
<p><a href="http://mettadore.com/files/2012/05/dev_banner_background.png"><img class="alignright size-full wp-image-1037" title="dev_banner_background" src="http://mettadore.com/files/2012/05/dev_banner_background.png" alt="" width="180" height="180" /></a>This method uses the RMagick gem. It takes the dev_banner_background.png file– a banner with a transparent border (see right)– and annotates it with the string &#8220;| <code>&lt;name&gt;</code> Server |&#8221; where <code>&lt;name&gt;</code> is a string set in a local environment variable, in this case QSTREAM_SERVER_TYPE.<sup><a href="http://mettadore.com/analysis/server-specific-banner-using-rmagic-gem/#footnote_0_1035" id="identifier_0_1035" class="footnote-link footnote-identifier-link" title="It&rsquo;s totally possible as well to create multiple banners of different colors, and set those in environment variables (or generate multiple banners on the fly), but I didn&rsquo;t need that much complexity.">1</a></sup></p>
<p>I have a dev_banner.css file with the following styling:</p>
<pre class="brush: css; title: ; notranslate">
#right-corner {
    position: fixed; /* Make sure you can align it exactly */
    cursor: pointer; /* Change the cursor on mouse over */
    top: 0px; /* Change to 100px to put it under a 100px banner */
    left: 0px; /* Change to 100px to put it left of a 100px right-side bar */
    z-index: 99999; /* make sure it is the top element always */
}
</pre>
<p>and then I have an application.rb file with the following:</p>
<pre class="brush: ruby; title: ; notranslate">
%head
...
  - if @server_type.present?
    = stylesheet_link_tag 'dev_banner.css'
...
%body
  - if @server_type.present?
    %a#right-corner{:href=&gt;&quot;#&quot;, :target=&gt;&quot;_blank&quot;}
      =image_tag dev_banner
</pre>
<p>It&#8217;s a link because I originally thought of making it able to flip over and show server-specific details on a mouse click.</p>
<p>Because I thought I might change the banner based on other localized information, @server_type is a variable set in the ApplicationController:</p>
<pre class="brush: ruby; title: ; notranslate">
  ...
  before_filter { @server_type = ENV[&quot;QSTREAM_SERVER_TYPE&quot;]}
  ...
</pre>
<p>This allows me to set an environment variable on any server I&#8217;ve loaded, and have a banner specific to that server auto-generated– with nothing showing on the production server.</p>
<p>Given this, it&#8217;s easy to see how you could add information to the banner based on the local system. Just a few simple lines of code. Unless it gets a lot more complex, it seemed unnecessary to make it a gem.</p>
<ol class="footnotes"><li id="footnote_0_1035" class="footnote">It&#8217;s totally possible as well to create multiple banners of different colors, and set those in environment variables (or generate multiple banners on the fly), but I didn&#8217;t need that much complexity.</li></ol>]]></content:encoded>
			<wfw:commentRss>http://mettadore.com/analysis/server-specific-banner-using-rmagic-gem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bundle update &#8220;killed:&#8221; Watch those log files in your gems!</title>
		<link>http://mettadore.com/ruby/bundle-update-killed-watch-those-log-files-in-your-gems/</link>
		<comments>http://mettadore.com/ruby/bundle-update-killed-watch-those-log-files-in-your-gems/#comments</comments>
		<pubDate>Mon, 09 Apr 2012 19:11:59 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://mettadore.com/?p=1028</guid>
		<description><![CDATA[Today was supposed to be a normal day. A simple pull-request merge, an automated Jenkins build, and then a database migration. What followed instead was a search for the cause of a build failure– or, rather, the cause of a ruby gem that was causing the build failure. The Problem The only hint I had [...]]]></description>
				<content:encoded><![CDATA[<p>Today was supposed to be a normal day. A simple pull-request merge, an automated Jenkins build, and then a database migration.</p>
<p>What followed instead was a search for the cause of a build failure– or, rather, the cause of a ruby gem that was <em>causing</em> the build failure.</p>
<h3>The Problem</h3>
<p>The only hint I had to go on was this message in my Jenkins console:</p>
<pre class="brush: bash; title: ; notranslate">
Installing acts_permissive (0.3.2) /tmp/hudson7424891008093103684.sh: line 5: 12423 
Killed 
bundle
Build step 'Execute shell' marked build as failure
</pre>
<p>It couldn&#8217;t install the gem? Why? To the console:</p>
<pre class="brush: bash; title: ; notranslate">
jenkins@li128-183:~/workspace/musicstand
$ bundle update acts_permissive
Fetching source index for http://rubygems.org/
Using rake (0.9.2.2) 
Using RedCloth (4.2.9) 
...

NoMemoryError: failed to allocate memory
An error occured while installing acts_permissive (0.3.2), and Bundler cannot continue.
Make sure that `gem install acts_permissive -v '0.3.2'` succeeds before bundling.
</pre>
<p>What the what? Sadly, trying it manually was no help:</p>
<pre class="brush: bash; title: ; notranslate">
jenkins@li128-183:~/workspace/musicstand
$ gem install acts_permissive -v '0.3.2'
Killed
</pre>
<p>That&#8217;s it. Nothing else.</p>
<h3>The Investigation</h3>
<p>Luckily<sup><a href="http://mettadore.com/ruby/bundle-update-killed-watch-those-log-files-in-your-gems/#footnote_0_1028" id="identifier_0_1028" class="footnote-link footnote-identifier-link" title="or, unluckily, as the case may be">1</a></sup> I am the writer of the Gem in question. <a href="http://rubygems.org/gems/acts_permissive">ActsPermissive</a> is an instance-specific permissions system based on &#8220;circles of trust&#8221; (a bit like Google+ circles).</p>
<p>I went to my dev folder for the gem and explored it. Nothing seemed out of the ordinary. So I created a new gemset and ran &#8220;bundle install&#8221; forcing an installation of acts_permissive. It installed fine; however, I did notice that Bundler seemed to &#8220;pause&#8221; while installing it. On a hunch, I went to look at what the size of the .gem file was.</p>
<h3>The Solution</h3>
<p>Embarrassing as it is, the .gem file weighed in at a whopping 23M. That&#8217;s just ridiculous for a few text files! Further investigation showed me that my development directory was a full Gig! What the what?</p>
<p>Log files.</p>
<p>Without thinking, I was including the spec/dummy rails application, which contains a log directory, and log/test.log was nearly a gigabyte in size! Consequently, that was all getting packaged up, and then this 1G gem was trying to be compressed on the server and borking because of failed memory!</p>
<p>Lazy, John!</p>
<p>I had the normal &#8220;s.test_files = Dir["spec/**/*"] line in my gemspec, but need to exclude some files. The &#8220;test_files&#8221; attribute is an array, thus, I added the following lines to my .gemspec:</p>
<pre class="brush: ruby; title: ; notranslate">
  s.test_files = Dir[&quot;spec/**/*&quot;]
  s.test_files.delete(&quot;spec/dummy/log&quot;)
  s.test_files.delete(&quot;spec/dummy/log/development.log&quot;)
  s.test_files.delete(&quot;spec/dummy/log/test.log&quot;)
</pre>
<p>This dropped the .gem file back to a few kilobytes, which is all it should ever be. </p>
<h3>Coda</h3>
<p>It took a bit of detective work, but the &#8220;bundle update &#8216;killed&#8217;&#8221; problem was a crisis averted. This would&#8217;ve been grueling to troubleshoot if I didn&#8217;t own the acts_permissive gem. However, in the interest of helping others, it can be pretty easy to at least rule this problem out if your &#8216;gem install&#8217; or &#8216;bundle update&#8217; fails mysteriously. Grab the .gem file from RubyGems and check the size. If it&#8217;s crazy huge like acts_permissive was, then you might just be filling up RAM when it&#8217;s extracted.</p>
<ol class="footnotes"><li id="footnote_0_1028" class="footnote">or, unluckily, as the case may be</li></ol>]]></content:encoded>
			<wfw:commentRss>http://mettadore.com/ruby/bundle-update-killed-watch-those-log-files-in-your-gems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Trolling, Sexism, and Dealing with Disappointment</title>
		<link>http://mettadore.com/analysis/trolling-sexism-and-dealing-with-disappointment/</link>
		<comments>http://mettadore.com/analysis/trolling-sexism-and-dealing-with-disappointment/#comments</comments>
		<pubDate>Fri, 23 Mar 2012 19:53:50 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Miscellany]]></category>

		<guid isPermaLink="false">http://mettadore.com/?p=1015</guid>
		<description><![CDATA[This past week has been one is extreme disappointment for me as I survey the landscape of my beloved profession. From Portland&#8217;s own Postgres genius Selena Deckelman getting hazed on IRC to the incredibly immature sexism of Sqoot listing women as &#8220;a feature&#8221; of a hackathon I&#8217;ve just been feeling really depressed that there is [...]]]></description>
				<content:encoded><![CDATA[<p>This past week has been one is extreme disappointment for me as I survey the landscape of my beloved profession. From Portland&#8217;s own Postgres genius <a href="https://twitter.com/#!/selenamarie/status/182841043786543105">Selena Deckelman</a> getting hazed on IRC to the incredibly immature sexism of <a href="http://www.readwriteweb.com/enterprise/2012/03/how-casual-sexism-put-sqoot-in.php">Sqoot listing women as &#8220;a feature&#8221; of a hackathon</a> I&#8217;ve just been feeling really depressed that there is this scale of stupidity toward our fellow programmers– our fellow people– in a field where, at one time, we&#8217;ve all known what it&#8217;s like to feel out of place and unaccepted.</p>
<p>Sqoot is just a light on what&#8217;s seemingly rampant in a field where I just assume there are awesome women doing awesome things. How much of this stupidity am I unaware of? How much do I add to it. Does it really make us feel better to treat other people like shit?</p>
<h3>Sexism At Hydrasi</h3>
<div id="attachment_1017" class="wp-caption alignleft" style="width: 181px"><a href="http://mettadore.com/files/2012/03/Screen-Shot-2012-03-23-at-12.16.15-PM.png"><img class="size-full wp-image-1017" title="Screen Shot 2012-03-23 at 12.16.15 PM" src="http://mettadore.com/files/2012/03/Screen-Shot-2012-03-23-at-12.16.15-PM.png" alt="" width="171" height="171" /></a><p class="wp-caption-text">Kerridra and SI1138, Hydrasi&#39;s lovable mascots</p></div>
<p>It strikes me as somewhat odd that I am a man, in an really male dominated field, in a male dominated world, who&#8217;d write about this. I mean, what do I know? Just as with white people who don&#8217;t see things that every person of color takes for granted, I&#8217;m sure there are a great many things than I just blindly ignore in my happy placement of gender-based privilege. In fact, I know there are.</p>
<p>Recently, we were having some graphic design work done for Hydrasi.<sup><a href="http://mettadore.com/analysis/trolling-sexism-and-dealing-with-disappointment/#footnote_0_1015" id="identifier_0_1015" class="footnote-link footnote-identifier-link" title="These images are secret, don&rsquo;t tell anyone you saw them!">1</a></sup> Hydrasi has a lot of inside jokes based on our name<sup><a href="http://mettadore.com/analysis/trolling-sexism-and-dealing-with-disappointment/#footnote_1_1015" id="identifier_1_1015" class="footnote-link footnote-identifier-link" title="Oh no, it broke! It&rsquo;s Brokedrasi!">2</a></sup> and our mascots, one of which is a Sasquatch and one is a cute, blue robot.<sup><a href="http://mettadore.com/analysis/trolling-sexism-and-dealing-with-disappointment/#footnote_2_1015" id="identifier_2_1015" class="footnote-link footnote-identifier-link" title="The Star Wars connection here is obvious, but there are others we play with as well">3</a></sup></p>
<p>The short story is that there are tiers of service, and for the top &#8220;enterprise&#8221; tier we were trying to make yet another cultural reference joke that could have gone bad.</p>
<p>For every tier, we have a different image. The free tier shows our Sasquatch, Kerridra, holding a pitchfork, the next tier– the lowest paid tier– shows Kerridra with his robotic companion SI1138. The idea, of course, is that you get more robots, more power, with higher subscription rates.</p>
<div id="attachment_1018" class="wp-caption alignright" style="width: 310px"><a href="http://mettadore.com/files/2012/03/Screen-Shot-2012-03-23-at-12.09.35-PM.png"><img class="size-medium wp-image-1018 " title="Screen Shot 2012-03-23 at 12.09.35 PM" src="http://mettadore.com/files/2012/03/Screen-Shot-2012-03-23-at-12.09.35-PM-300x81.png" alt="" width="300" height="81" /></a><p class="wp-caption-text">Attempt at referencing Madmen</p></div>
<p>At the top tier, the enterprise tier, I thought it would be fun to have a reference to the TV show Madmen, where rich advertising executives have martini parties and red-headed secretaries wear mini skirts. My thought here was not &#8220;focus on red-headed chics in mini-skirts&#8221; but rather on &#8220;At the enterprise level, we take care of everything for you so you can sit back and drink a martini.&#8221; Here&#8217;s the first rough cut of that design.</p>
<div id="attachment_1023" class="wp-caption alignleft" style="width: 310px"><a href="http://mettadore.com/files/2012/03/Screen-Shot-2012-03-23-at-12.27.57-PM.png"><img class="size-medium wp-image-1023" title="Screen Shot 2012-03-23 at 12.27.57 PM" src="http://mettadore.com/files/2012/03/Screen-Shot-2012-03-23-at-12.27.57-PM-300x79.png" alt="" width="300" height="79" /></a><p class="wp-caption-text">The final version. You get a computing rack, NOT a secretary</p></div>
<p>Again, the idea was to have something immediately identifiable as from the show Madmen, but we looked at it and felt that it came off as sexist, pointless, and sort of missing the point of what it means to be at the upper level of service. In the end we axed my Madmen idea and went with another reference, this one not to a cultural reference, but to service. We put a rack of servers behind Kerridra and decided to say &#8220;You are getting people, robots, and servers&#8221; instead of &#8220;You can get a hot red-head.&#8221;</p>
<h3>Mindless Sexism</h3>
<p>There&#8217;s a large part of me that&#8217;s embarrassed at the whole idea. I mean, I was just trying to go for a funny pop-culture reference in the same way as we have Star Wars references and WALL-E references. In the end, we recognized it as a misplaced, and overly sexist image, and decided to pull it before it ever went anywhere, but how many things like this don&#8217;t get pulled?</p>
<p>I guess the take away is that we did sit down, and make a conscious decision to axe that train of thought because if it&#8217;s overtones. We thought about it, we decided. That&#8217;s sort of what worries me. How much do we– all of us– throw out there because we <em>don&#8217;t </em>think about it. How much is just simply cultural privilege that we swim in like water?</p>
<h3>Seeking The Positive</h3>
<p>This week kind of got me down, both because of the shitty nature of the way things are, and because of my worry (as my wife and I watch her belly grow and I, at least, hope for two daughters) that I add to it as much as anyone.</p>
<p>I guess one thing to look toward positively is a responses to everything this week. Responses like Selena&#8217;s. She chose not to battle, but to, almost quietly, Storify the interaction and then ask for feedback (http://bit.ly/GW1XT7). This was an incredibly mature and awesome way to handle a troll (Cheers to you, Selena, for so much restraint and thoughtfulness). And there was a lot of outrage about Sqoot&#8217;s mindless objectification of women, including <a href="http://blog.tommorris.org/post/19778985050/newsflash-sexism-in-geek-communities-demeans-everybody">posts like this by Tom Morris</a>. There&#8217;s a lot of outrage and a lot of people, not only women, saying &#8220;Why is it this way? It doesn&#8217;t have to be, and you need to stop perpetuating it!&#8221; That&#8217;s positive.</p>
<p>For what it&#8217;s worth, Sqoot apologized with a &#8220;<a href="http://blog.sqoot.com/we-can-do-better-an-apology-from-sqoot">we can do better</a>&#8221; post. This made me feel worse instead of better because it just seemed way too late and seemed to radiate insincerity. The only thing I could think of while reading that was an image of Steve Carrell from The Office, spouting an apology speech which had all of the right words that he knew other people would want him to say.</p>
<h3>Coda</h3>
<p>Overall, it&#8217;s been a disappointing week in Tech. I&#8217;m trying to see the positive. Good, strong, well-reasoned responses to stupidity and sexism. That should make me feel good. But the fact that there&#8217;s such a culture of &#8220;brogramming&#8221; makes me feel sad. I hope we can change that, but I&#8217;d really expected it to have been changed by now, so am not sure how much faith I have in me and my fellow <em>man</em>.</p>
<ol class="footnotes"><li id="footnote_0_1015" class="footnote">These images are secret, don&#8217;t tell anyone you saw them!</li><li id="footnote_1_1015" class="footnote">Oh no, it broke! It&#8217;s Brokedrasi!</li><li id="footnote_2_1015" class="footnote">The Star Wars connection here is obvious, but there are others we play with as well</li></ol>]]></content:encoded>
			<wfw:commentRss>http://mettadore.com/analysis/trolling-sexism-and-dealing-with-disappointment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Redis-backed acts_as_follower gem</title>
		<link>http://mettadore.com/ruby/a-redis-backed-acts_as_follower-gem/</link>
		<comments>http://mettadore.com/ruby/a-redis-backed-acts_as_follower-gem/#comments</comments>
		<pubDate>Mon, 12 Mar 2012 16:23:01 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://mettadore.com/?p=1009</guid>
		<description><![CDATA[This entry is part 1 of 1 in the series Redis GemsI usually start blog-based introductions to gems and libraries that I write with a narrative. Lately, however, I&#8217;ve been getting busier keeping up with the work I need to do for clients and that I need to do for my startup. So I&#8217;ll leave [...]]]></description>
				<content:encoded><![CDATA[<div class="seriesmeta">This entry is part 1 of 1 in the series <a href="http://mettadore.com/series/redis-gems/" class="series-168" title="Redis Gems">Redis Gems</a></div><p>I usually start blog-based introductions to gems and libraries that I write with a narrative. Lately, however, I&#8217;ve been getting busier keeping up with the work I need to do for clients and that I need to do for my startup. So I&#8217;ll leave the narrative to a minimum, a very short question.</p>
<p>You love the acts_as_follower gem, right? Sure, everyone does. Wouldn&#8217;t it be better if it was based in Redis? Sure, of course it would.</p>
<p>This weekend I found the great <a href="https://github.com/agoragames/amico">Amico gem</a>, a low-level Ruby gem for Redis backed followers, and I decided to create <a href="https://github.com/mettadore/acts_as_amico">Acts_as_Amico</a>, a Rails injectable gem that uses that back-end ability, so now you can have a followers gem that is completely in Redis right in your Rails app.</p>
<p>The code has full-ish, but ever expanding, documentation on the Github page, but here&#8217;s a quick rundown</p>
<h3>ActiveRecord Objects</h3>
<pre class="brush: ruby; title: ; notranslate">
class User &lt; ActiveRecord::Base
 acts_as_amico
end

usera = User.create
userb = user.create

usera.follow! userb
=&gt; nil

usera.following? userb
 =&gt; true
</pre>
<h3>Advanced Usage</h3>
<pre class="brush: plain; title: ; notranslate">
class Admin &lt; ActiveRecord::Base
  acts_as_amico :amico_key =&gt; :name
  validates_uniqueness_of :name  # -&gt; do this or be sorry
  validates_presence_of :name # -&gt; this too, you've been warned
end

usera = User.create

puts usera.id
 =&gt; 18

admin = Admin.create :name =&gt; &quot;frank&quot;

usera.follow! admin
 =&gt; nil

admin.follow! usera
 =&gt; [1, 1]

admin.followers
 =&gt; [&quot;18&quot;]

usera.followers
 =&gt; [&quot;frank&quot;]
</pre>
<h3>ActiveResource Objects</h3>
<pre class="brush: ruby; title: ; notranslate">
class RestObject &lt; ActiveResource::Base
  self.site = &quot;http://mettadore.com/junk&quot;
  acts_as_amico :amico_key =&gt; :title
end

usera = User.create

rest_object = RestObject.find(123)

rest_object.title
 =&gt; &quot;Bread and Circus&quot;

usera.follow! rest_object

usera.following? rest_object
 =&gt; true

usera.following
 =&gt; [&quot;Bread and Circus&quot;]
</pre>
<h3>Issues</h3>
<p>I have every expectation that there will be problems and bugs. If you find one, please don&#8217;t hesitate to <a href="https://github.com/mettadore/acts_as_amico/issues">file an issue if</a> you&#8217;re on Github, or <a href="http://johnmetta.com/+">send me a message on Google+</a> if you&#8217;re not.</p>
]]></content:encoded>
			<wfw:commentRss>http://mettadore.com/ruby/a-redis-backed-acts_as_follower-gem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<series:name><![CDATA[Redis Gems]]></series:name>
	</item>
		<item>
		<title>Rails: SQL Injection over Configuration</title>
		<link>http://mettadore.com/analysis/rails-sql-injection-over-configuration/</link>
		<comments>http://mettadore.com/analysis/rails-sql-injection-over-configuration/#comments</comments>
		<pubDate>Mon, 05 Mar 2012 17:59:50 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Miscellany]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[convention]]></category>
		<category><![CDATA[Github]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SQL injection]]></category>

		<guid isPermaLink="false">http://mettadore.com/?p=991</guid>
		<description><![CDATA[It was an interesting weekend for the Github team, the Rails core team, and lots of Rails users who worked at all through the weekend. There are a lot of details about the weekend to discuss, but my main discussion point is one of philosophy and intention of the Rails project. We&#8217;ll get to that [...]]]></description>
				<content:encoded><![CDATA[<p>It was an interesting weekend for the Github team, the Rails core team, and lots of Rails users who worked at all through the weekend. There are a lot of details about the weekend to discuss, but my main discussion point is one of philosophy and intention of the Rails project. We&#8217;ll get to that towards the end. First, a bit of background.</p>
<h3>Hacking Github</h3>
<p>This weekend, a Github user named <a href="https://github.com/homakov">Egor Homakov</a> hacked Github in such a way that allowed him to <a href="https://github.com/rails/rails/commit/b83965785db1eec019edf1fc272b1aa393e6dc57">commit directly to the Rails core</a> project. Since Homakov is not a Rails team member, this is a really big deal.</p>
<p>Since this happened, there&#8217;s been a lot of talk about the Rails core being fundamentally insecure. In fact, <a href="https://github.com/rails/rails/issues/5239">Homakov has been harping on this for at least 1000 years</a>. A few days ago he filed an issue about a <a href="https://github.com/rails/rails/issues/5228">mass assignment vulnerability</a> in the Rails core, and later he illustrated this vulnerability by filing an <a href="https://github.com/rails/rails/issues/5239">issue report from the future</a>. He was illustrating that you can inject attributes into a Rails model with an HTTP request.</p>
<p>So, when no-one took him seriously, he took the next step. He created HTTP PUT requests adding his SSH key to a Rails core user id, then <a href="https://github.com/rails/rails/commit/b83965785db1eec019edf1fc272b1aa393e6dc57">pushed a commit directly to Rails core</a>.</p>
<h3>How to Hack Rails</h3>
<p>It turns out that Rails apps, by default, are easy to hack. Peter Nixey wrote a very detailed post about <a href="https://gist.github.com/1978249">how Homakov hacked Github and the one line of code that could have prevented it</a>, so if you want the full details, read there. The summary is much shorter.</p>
<p>Let&#8217;s create a simple User model which has two attributes, <code>name</code> and <code>role</code>. By default, every attribute of every model can be modified by using <code>update_attributes</code>. We all know this, and we&#8217;ve known it for a while. What it means is that any User, even if they don&#8217;t have permission, can update their own role. Imagine if I log in to our example app and submit a PUT request to the UsersController with the package <code>{'params': {'id': 23, 'role': 'superadmin'} }</code>. By default, the app will accept this and update the user with the new role.</p>
<p>This is exactly what Homakov did. He sent an HTTP request to Github and used update_attributes to change the Github database. All of this could, he argued, be prevented by adding attr_accessor to the User model.</p>
<h3>Rails: Convention over <del>Configuration</del> Security</h3>
<p>Now, the philosophical point I want to make about this is that the Rails core team seems to be ignoring their own mantra. All of us know that Rails adheres strongly to the <a href="http://en.wikipedia.org/wiki/Convention_over_configuration">Convention over Configuration</a> design pattern. It&#8217;s a pattern that Rails users are taught from day one. In fact, it&#8217;s embedded in the framework&#8217;s <em>name</em>.<sup><a href="http://mettadore.com/analysis/rails-sql-injection-over-configuration/#footnote_0_991" id="identifier_0_991" class="footnote-link footnote-identifier-link" title="Look, just stay on these rails and you&rsquo;ll move fast. We&rsquo;re not responsible for what happens if you go over there">1</a></sup></p>
<p>One of the outcomes of Convention over Configuration is that sensible defaults should be, well, sensible. The Rails core team feel strongly that attr_accessor should not be a default<sup><a href="http://mettadore.com/analysis/rails-sql-injection-over-configuration/#footnote_1_991" id="identifier_1_991" class="footnote-link footnote-identifier-link" title="Incidentally, I don&rsquo;t either, but you can set this as the default by using ActiveRecord::Base.send(:attr_accessible, nil), but this causes all sorts of problems">2</a></sup> and that security is the responsibility of the app developer. I agree that security is our responsibility, but disagree that the dominant Rails design-pattern-come-mantra supports this.</p>
<p>It&#8217;s almost as if no-one wants to say &#8220;Yeah, we should really take care of this.&#8221; Everyone is saying &#8220;You know, <em>you</em> should really take care of this.&#8221;</p>
<h3>Stop the world! We&#8217;ve found a SQL injection</h3>
<p>There&#8217;s a term that makes all software developers give pause: &#8220;SQL Injection.&#8221; It&#8217;s a phrase that keeps us lying awake at night, and gives us nightmares when we finally fall asleep. The idea that someone, using nothing more than a web browser, can change our database willy nilly. It&#8217;s a terrifying thought.</p>
<p>I can&#8217;t help but take an initial read of all the hubbub and think that we&#8217;re not giving it the importance that it&#8217;s due. Everyone sees a headline saying Rails has a &#8216;mass assignment vulnerability&#8217; and says to themselves &#8216;I should probably look into that at some point.&#8217; It&#8217;s too vague, to uncertain. To unemotional.<sup><a href="http://mettadore.com/analysis/rails-sql-injection-over-configuration/#footnote_2_991" id="identifier_2_991" class="footnote-link footnote-identifier-link" title="In fact, to be honest, that&rsquo;s how I was reading it.">3</a></sup></p>
<p>I have to assume that everyone would be treating this differently if we called it what it is. Imagine your thoughts (and actions) if you read a different headline, something like &#8220;Rails apps prone to SQL injection by default&#8221;</p>
<p>Don&#8217;t you think you&#8217;d get something done? You should, because that&#8217;s what we&#8217;re talking about. This is a path to SQL injection, full stop.</p>
<h3>Who owns this issue</h3>
<p>I love Ruby on Rails. Like Python, Scala, Node.js, and a host of other technologies that we have at our disposal, Ruby&#8217;s web framework makes being a developer both powerful and fun. There&#8217;s so much we can do– and so much we can do <em>very quickly</em>. But there&#8217;s a cost to pay. Convention over Configuration is a good thing, but we can&#8217;t expect people to learn fast, develop fast– create fast– if we don&#8217;t respect the logical outcome of that philosophy.</p>
<p>That outcome is this: We, Rails developers, understand that we are responsible for our security; however, we also <em>believe</em> in you, the Rails core team. We trust you. We believe it when you tell us to follow &#8220;Convention over Configuration,&#8221; and so we naturally believe that the defaults you give us will be a safe, or at least not horribly, dangerously wrong. We, all of us– developers and Rails core team both– can&#8217;t have it both ways. We are telling ourselves to follow Convention over Configuration, but we&#8217;re also telling ourselves that SQL Injection is <em>a viable convention</em>, thus, that we have <em>security as a configuration</em>.</p>
<p>Now, personally, I don&#8217;t believe that attr_accessor belongs in the model– or at least that security from view-based actions belongs in the model. Rails is an MVC framework, and therefore I don&#8217;t like forcing myself to define my <em>model</em> based on actions in the <em>view</em>. I don&#8217;t want my view owning control of my model that way. I think the controller should manage these permissions and there are <a href="http://jonathanleighton.com/articles/2011/mass-assignment-security-shouldnt-happen-in-the-model/">others who feel the same</a>. In fact <a href="https://gist.github.com/1974187">Yehuda Katz argues this as well</a>.</p>
<p>Still, the overall question remains: How can we reconcile the mantra of Convention over Configuration if we support the standard of dangerous insecurity by convention?</p>
<ol class="footnotes"><li id="footnote_0_991" class="footnote">Look, just stay on these rails and you&#8217;ll move fast. We&#8217;re not responsible for what happens if you go over there</li><li id="footnote_1_991" class="footnote">Incidentally, I don&#8217;t either, but you can set this as the default by using <code>ActiveRecord::Base.send(:attr_accessible, nil)</code>, but this causes all sorts of problems</li><li id="footnote_2_991" class="footnote">In fact, to be honest, that&#8217;s how I was reading it.</li></ol>]]></content:encoded>
			<wfw:commentRss>http://mettadore.com/analysis/rails-sql-injection-over-configuration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Web App Went Live Today</title>
		<link>http://mettadore.com/analysis/a-web-app-went-live-today/</link>
		<comments>http://mettadore.com/analysis/a-web-app-went-live-today/#comments</comments>
		<pubDate>Mon, 13 Feb 2012 21:25:26 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Miscellany]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://mettadore.com/?p=967</guid>
		<description><![CDATA[A new web app went live today, and I shed a tear. The Power of Good Questions Some history. Years ago, I was starting to question my decision to become a hydrologist. Not because I hated hydrology, I did– and still do– deeply love it, but because I couldn&#8217;t find a job. Since I&#8217;d been [...]]]></description>
				<content:encoded><![CDATA[<p>A new web app went live today, and I shed a tear.</p>
<h3>The Power of Good Questions</h3>
<p>Some history.</p>
<p>Years ago, I was starting to question my decision to become a hydrologist. Not because I hated hydrology, I did– and still do– deeply love it, but because I couldn&#8217;t find a job. Since I&#8217;d been a programmer for 20+ years (indeed, I programmed all the way through 10 years in the sciences), I decided to see what options were out there in that field.</p>
<p>So I interviewed for this software development company. I was nervous because I hadn&#8217;t actually <em>worked</em> as a programmer in a long time. My title had been &#8220;researcher&#8221; and &#8220;scientist&#8221; for a decade. Even though I&#8217;d been programming that entire time, I was nervous about being labeled as a &#8220;wannabe.&#8221;</p>
<p>My interviewer saw through that nervousness right away and immediately started asking me questions that were not the basic &#8220;do you actually know programming&#8221; but were much more geared toward &#8220;what do you think of this subtle programming construct.&#8221;  It was, without a doubt, the best interview experience I ever had, and made me respect the interviewer and want to work with him even if not at this job– which I didn&#8217;t even get.</p>
<p>I never forgot that interview.</p>
<h3>What Goes Around</h3>
<p>Fast forward a few years, and last year I happened to see that same interviewer at the coffee shop. He said that he&#8217;d just left his last job and was looking for work. That, to me, was a wide open door. Finally, a chance to work with this guy!</p>
<p>&#8220;Really,&#8221; I said, &#8220;It&#8217;s not much, but I&#8217;ve got some Ruby work I could use some help with for my company if you&#8217;re interested&#8221;</p>
<p>&#8220;I don&#8217;t know Ruby, I&#8217;ve been learning a little bit, but I can&#8217;t do work in it.&#8221;</p>
<p>&#8220;Tell you what, work with me. I&#8217;ll help you learn Ruby while you do small bits of work on my site. Fair trade?&#8221;</p>
<p>As I suspected from this now barely remembered interview so long ago, he was a sharp tack and things progressed fast enough that he never even did any work on my site. Rather, I took another contract that was a wee bit too big for me, and brought him on as a sub. And so, finally, I was working with this guy, and helping him learn Ruby, and getting him <em>paid</em> to do it.</p>
<h3>A Favor, Returned</h3>
<p>A couple months later, I got contacted by another company who wanted me to create a web app. I was just too busy, so I brought this fellow to the first meeting. My response was, basically, &#8220;I&#8217;m too busy to do this, but I can speak from experience that this fellow here is a good candidate. I&#8217;ll let you take it from here.&#8221; And I walked away. Now, here we are, a couple months after that, and <a href="http://mylunchin.com">MyLunchIn.com</a> has launched for our local restaurant Nora&#8217;s Table. It&#8217;s another Rails app that he created, start to finish, entirely free of my involvement.</p>
<p>I don&#8217;t know I started to cry when I placed my first lunch order today. I didn&#8217;t create that site, and honestly, I didn&#8217;t teach this guy Ruby– I just happened to be around while he was teaching himself. But it still feels good.</p>
<p>All those years ago, I was a scientist scared that I wouldn&#8217;t be accepted by &#8220;serious&#8221; developers and I was. It feels good to think that I brought some happiness back to that person, a favor returned. It just feels like this new website is part of a rising tide that floats all of our boats when we work together, when we look out for each other. When we remember a good conversation.</p>
<p>I&#8217;m on my way now to pick up my first ever lunch ordered on this new site. It&#8217;ll be the best tasting lunch I&#8217;ve had in a while.</p>
]]></content:encoded>
			<wfw:commentRss>http://mettadore.com/analysis/a-web-app-went-live-today/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
