petty annoyance of alias_method_chain

So it appears you can’t alias_method_chain []=. Rightly so you’d end up trying to do something like

def []=_with_rescue
alias_method_chain :[]=, :rescue

The resulting method names are of course invalid. So you have to do it longhand

require 'action_dispatch/middleware/cookies'
# action_dispatch/middleware/cookies.rb
module ActionDispatch
  class Cookies
    class SignedCookieJar
      def assign_with_overflow_rescue(name, options)
        assign_without_overflow_rescue(name, options)
      rescue ActionDispatch::Cookies::CookieOverflow => e
        SiteMailer.delay.error(e, key: key, original_options: original_options, encoded_size: options[:value].size)
      alias_method :assign_without_overflow_rescue, :[]=
      alias_method :[]=, :assign_with_overflow_rescue

grab Ruby Objects by object_id

Are you ever frustrated that you cannot just grab objects in the console to see what the hell they are and what methods you can call on them?

2.2.3 :001 > ArticlesController
=> ArticlesController 
2.2.3 :002 > ObjectSpace._id2ref(70289541845000)


It is my aim in 2016 to stop being lazy. It’s all too easy to let your skill set slide, and while I enjoy what I do every day I haven’t explored every language, framework or technology enough to know whether I am missing out on anything I am interested in. So starting from tomorrow morning I’ll be taking a stab a some new projects to advance my skills in probably the following, Python, R, Java / Android app development, Swift for iOS, AngularJS for Desktop Development with Electron, Unity / C#, Corona SDK / Lua, Raspberry Pi PSX Emulation, Arduino development to measure how much our cats are using their cat wheel (no really). Expect the Lab to fill up with guff. Wish me luck or don’t.

Three things that were invaluable today

Quick and dirty database migration on the console

When a database migration failed to roll back properly, stripping one column but not all, we had to put back the original column without changing the migration and re-running. It always feels very dangerous when a multipart migration fails halfway through. So….you can actually call migration commands on ActiveRecord::Migration directly, just be careful to test in development first as accidents can and will happen.

Rails pro >> ActiveRecord::Migration.add_column :somethings, :thing_file_name, :string, before: :thing_file_name
-- add_column(:somethings, :thing_file_name, :string, {:before=>:splash_content_type})
   (4838.6ms)  ALTER TABLE `somethings` ADD `thing_file_name` varchar(255)

Cherry picking changes in a different branch with Git.

I had to give up on a recent branch because refactoring had caused more problems than it intended to solve. Without wanting to start over I was able to pick the files that I cared about individually rather than sifting through and reverting parts of a previous commit.

git checkout feature/somefeature -- config/blah.yml

While I’m there, ever wanted to ditch your local changes in a conflict over the merged in changes from another branch?

git checkout --theirs config/routes.rb

Rails partials as layouts

Ever had a Rails partial and wanted to re-use it in a specific situation but with a small change? A partial can also be used as a layout, it appears a partial can be a layout that takes a block.


= form_for(@dave) do |f|
  = f.text_field :full_name


= render partial: 'dave'

I really want to add an way to to re-use the form and add to it. How about this?


= form_for(@dave) do |f|
  - if block_given?
    = yield
  = f.text_field :full_name


= render layout: 'dave' do

TBG Secret Santa

Another mini-project. A Secret Santa app, Facebook login, address data collection, will then select a suitable Gift Recipient, mark gifts as shipped and reciprocol gifts received.

Hosted on

Mammothfest Facebook Tab / Spotify Playlist

Created just a quick widget, although it did require buying an SSL key in order to host the app through Facebook. The playlist itself was tirelessly compiled by Fox James for the MammothFest 2015 line-up.

<!-- full width 810px -->
<iframe src="" width="810" height="920"></iframe>

<!-- width limited to 560px, width 20px border -->
<iframe src="" width="580" height="920"></iframe>

Just a demo of it in action.
It can be installed via

This really just boils down to using the Spotify embedding as below served via Facebook.

<iframe allowtransparency="true" frameborder="0" height="600" src="" width="520"></iframe>

update embed test

VEVO embedding

Raging Speedhorn PledgeMusic project

Raging Speedhorn are back and looking to do a new album, best way to test if embedding is working I suppose.

The REAL Pixels movie