External content

An easy demonstration of what Twitter Bootstrap does

Holly Schinsky from Adobe shows some of Bootstrap's capabilities. The combination of explanation, screenshots and source code makes it easy to understand

Howto transfer a single mysql table between several deployment stages

Example task: Multiply the table holidays between several stages.

  1. Open two terminals:

    shell-for stage_1
    shell-for stage_2
  2. Get the stage1 and stage2 MySQL credentials:

    cat /opt/www/
    cat config/database.yml # should do it
  3. Dump the table to a path reachable by the stage2 user (e.g. home):

    mysqldump -h mysql1 -u stage_1_user -p stage_1_database table_name > ~/table_name_dump.mysql # Select certain records using --where "some_id > 666"


Machinist blueprints do not work with a column :display

This didn't work for me. Seems display is already taken in Machinist.

# in spec/support/blueprints.rb
Partner.blueprint do
   display { true }

Git: How to look at the stash

Browsing the git stash is a bit tricky. Here is how to see the changes without applying them:

git command on the console

The following will give you the diff of the topmost stash item:

git stash show -u

But what about other items on the stash?
Well, you can list them like this:

$ git stash list
stash@{0}: WIP on feature/foo
stash@{1}: WIP on feature/bar
stash@{2}: WIP on fix/baz

All those stashed changes have their own reference (like branch names) that you can look at, like `stas…

Using before(:all) in RSpec will cause you lots of trouble unless you know what you are doing

TL;DR Avoid before(:all), use before(:each) instead.

If you do use before(:all), you need to know what you are doing and take care of any cleanup yourself.


Understand this:

  • before(:all) is run when the context/describe block begins,
  • before(:all) is run outside of transactions, so data created here will bleed into other specs
  • before(:each) is run before each spec inside it,

Generally, you'll want a clean setup for each spec so that they are independent of other specs in the same context.


External content

CSS Animations Media Queries

CSS transitions make your responsive websites smoother and more professional. It's easy and already there. Use it!

External content

A jQuery plugin pattern every jQuery plugin should use

Many jQuery plugins suffer from a good plugin architecture. When you write jQuery plugins you should use the plugin pattern described in this article which makes your plugin highly customizable and extensible.

Related article with patterns for namespaced jquery plugins (more detailed)

Asset pipeline may break Javascript for IE (but only on production)

If some of your JavaScripts fail on Internet Explorer, but only in staging or production environments, chances are that JavaScript compression is the culprit.

By default, Rails 3.2 compresses JavaScript with UglifyJS. I have seen a few cases where this actually breaks functioning JavaScript on IE (one example is the CKEditor).

I fixed this by switching to Yahoo's YUI Compressor.

To do this, do the following:

  • replace the uglifier gem with the yui-compressor gem…

Unsaved record disappears when assigning to an association

If this happens to you:

user.avatar =
user.avatar  # => nil

(where avatar is a belongs_to), you probably declared your association incorrectly.

Always do

class User < ActiveRecord::Base
  belongs_to :avatar

and never

class User < ActiveRecord::Base
  belongs_to 'avatar'

Migrating to Spreewald

This describes how to migrate an existing cucumber test suite to Spreewald.

  1. Add the gem
  2. Include spreewald into your cucumber environment by putting
    require 'spreewald/web_steps'
    require 'spreewald/email_steps'
    # …
    or just
    require 'spreewald/all_steps'
    into your support/env.rb.

  3. Look through your step definitions for everything that might be included in Spreewald. Candidates are web_steps, shared_steps, table_steps, `em…

Paperclip: undefined method `to_file' for #<Paperclip::Attachment:0000> (NoMethodError)

to_file has been removed in Paperclip 3.0.1.

Instead of using File to access Paperclip storage objects (like this: you can use


ActionMailer sometimes breaks e-mails with multiple recipients in Rails 2

The ActionMailer in Rails 2 depends on a buggy version of TMail, which sometimes inserts a blank line into the mail header when sending a mail to multiple recipients. This makes the header end prematurely.

The reason why this is not exploding in your face all the time is that when you are relaying your e-mail through an MTA like Exim, it will fix this for you.

Fix for Rails if you don't have an awesome MTA

TMail is no longer maintained. The bug is fixed…

Get rid of WARNING: Nokogiri was built against LibXML version 2.7.7, but has dynamically loaded 2.7.8

Rebuilt the gem with the newer library

gem install --no-rdoc --no-ri nokogiri -- --with-xml2-include=/opt/local/include/libxml2 --with-xml2-lib=/opt/local/lib

If you still get the error, try to uninstall all nokogiri versions with

gem uninstall nokogiri

and install nokogiri again.

Cucumber step to interact with an iframe using Capybara webdriver

Give your iframe a name attribute (i.e. <iframe name="myframe">) and then simply use

When I press "Foo" in the iframe "myframe"
Then I should see "Bar!" in the iframe "myframe"

Step as follows:

Then /^(.*) in the iframe "([^\"]+)"$/ do |step, iframe_name|
  browser = page.driver.browser

exception_notification: Send exception mails in models

You're using exception_notification and want to send exception mails within a model. Here's how.

The ExceptionNotifier class has a method notify_exception for that. Simply pass an exception:


=> #<Mail::Message:77493640, Multipart: false, Headers: <Date: Mon, 24 Sep 2012 13:37:00 +0200>,
<To: ["", ""]>,
<Message-ID: <5060543b3759_212311986a0305e...

How to not leave trailing whitespace (using your editor or Git)

There is no reason to leave trailing whitespace characters in your project's files, so don't add any.

A git diff --check will tell you if there are any and you should not commit when you see them. So go ahead and switch your editor/IDE to automatically remove them for you.
Below are a few instructions on how to get them removed by your favorite IDE or editor.

Note that except for RubyMine, the following changes will remove trailing white-space on all lines, not only those that you changed.
While this should not be a problem if your proje…

Git basics: checkout vs. reset

Today I got a better understanding of how git works, in particular what git checkout and git reset do.

Basic facts

  • A commit holds a certain state of a directory and a pointer to its antecedent commit.
  • A commit is identified by a so-called ref looking something like 7153617ff70e716e229a823cdd205ebb13fa314d.
  • HEAD is a pointer that is always pointing at the commit you are currently working on. Usually, it is pointing to a branch which is pointing to that commit.
  • Branches are nothing but pointers to commits. You are 'on …

How to convert an OpenStruct to a Hash

OpenStruct has no to_hash method – it is called marshal_dump.

hash = { :foo => 23, :bar => 42 }
container =
# => { :bar => 42, :foo => 23 }

You will get the underlying hash table, which in our example is the same as the one we built from:

# => Hash
container.marshal_dump == hash
# => true
3193 cards