Ran into an issue this weekend with httparty, and an API (mapquest) that was sensitive to query parameter order. Specifically, when batch geocoding locations, mapquest expects a query string like: ?location=foo&location=bar&location=baz, and will return geocode results in the order received.

I noticed the issue when an api call for a US city returned a result in Ireland.

Httparty has two methods of encoding query parameters. The default, rails-friendly, way converts

:param => ['bar','baz']



This can be disabled by calling disable_rails_query_string_format, which replaces the default query string normalizer with this proc

  Array(query).map do |key, value|
    if value.nil?
    elsif value.is_a?(Array)
      value.map {|v| "#{key}=#{URI.encode(v.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))}"}
      HashConversions.to_params(key => value)

Different version of ruby (even different 1.8.7 versions) will sort the result of

Array({:key => :value})

differently. A sort was added at the end of the normalizer proc to ensure that the query string is consistent across versions, likely for testing. This works, but has the side effect of also shuffling the order of array value elements.


  • Presort query parameters to avoid surprises,
  • use an alternate proc for query normalization (I just removed the sort entirely in my app),
  • submit request as json (or other format)
  • or wait until it’s fixed upstream.

Httparty pull request can be found here: https://github.com/jnunemaker/httparty/pull/245

Raspberry Pi Paper Cases

Received 3 Raspberry Pi cases as gifts recently, and my wife was kind enough to supply me with these excellent boxes.

Three paper raspberry pi cases

Box template can be found here

Copy Last Git Hash

Show the most recent git commit hash, and copy it to the clipboard:


git rev-parse HEAD | tee xclip -selection c

Windows (mingw/cygwin)

git rev-parse HEAD | tee /dev/clipboard


git rev-parse HEAD | tee pbcopy

Recently discovered Chocolatey, which I’ll be using for basic software installation on new machines.

Chocolatey both suffers and benefits from its community-driven packages. While there are a large number of packages available, especially compared to similar windows tools, several packages I tried are were not functioning and seem abandoned.

My current install script and package lists can be found here.

Octopress Under Windows

When running the setup_github_pages task, the ampersand in … can be escaped with a caret symbol.


@@ -345,7 +345,7 @@ task :setup_github_pages, :repo do |t, args|
   mkdir deploy_dir
   cd "#{deploy_dir}" do
     system "git init"
-    system "echo 'My Octopress Page is coming soon …' > index.html"
+    system "echo 'My Octopress Page is coming soon ^…' > index.html"
     system "git add ."
     system "git commit -m \"Octopress init\""
     system "git branch -m gh-pages" unless branch == 'master'