Test that a form field is visible with Cucumber/Capybara

Spreewald now comes with a step that tests if a form field is visible:

Then the "Due date" field should be visible
But the "Author" field should not be visible

The step works by looking up the field for the given label, then checks if that field is hidden via CSS (or Javascript).

It is not currently tested if the label is visible or hidden. For this see: [Check that an element is visible or hidden via CSS with Cucumber/Capybara](…

Consul: Querying a power that might be nil

Consul 0.6.1+ gives your Power class a number of static methods that behave neutrally in case Power.current is nil. This allows you to create authorization-aware models that still work when there is no user at the end of a web browser, e.g. on the console, during tests or during batch processes.

You will often want to access Power.current from another model, to e.g. iterate through the list of accessible users:

class UserReport

  def data
External content


Behave.js is a lightweight library for adding IDE style behaviors to plain text areas, making it much more enjoyable to write code in. Features include:

  • Custom Code/Behavior Fencing
  • Hard and Soft Tabs
  • Auto Open/Close Parenthesis, Brackets, Braces, Double and Single Quotes
  • Auto delete a paired character
  • Overwrite a paired character
  • Multi-line Indentation/Unindentation
  • Automatic Indentation

Autoplay HTML5 audio in Chrome for Android, Mobile Safari in iOS

  • Mobile browser's ignore the autoplay attribute on <audio> and <video> elements. Stupid reasons include saving mobile bandwidth on behalf of the user and/or securing app store sales.
  • Audio and video elements will only play as the result of a user interactions (click, touch).
  • A workaround is to have a "start button" in your application that loads and plays an initial sound.
  • You can now play further sounds without user interaction by changing the source on the same <audio> element.

I tested this on Chrome for Android. The int…

Error: "sylogd: /var/log/authlog : no such file or directory" but the file exists

If you get a message like this:

Jan 21 13:42:38 foobar syslogd: /var/log/authlog : no such file or directory

But you are sure the file exists and it have the correct permissions:

# example for Solaris 9
-rw-r--r-- 1 root sys 8,0K 21. Jan 13:51 /var/log/authlog

Then you perhaps have a trailing whitespace after /var/log/authlog in the /etc/syslog.conf.

Note: Use TAB to separate log components from log file names in Solaris. Because spaces do not work.

Using Apache Benchmark (ab) on sites with authentication

Apache HTTP server benchmarking tool (ab) is a nice tool to test performance on sites delivered by HTTP. If the site you're about to test is placed behind a login, follow these steps to successfully use ab on it.

  1. Open the site to test in the browser of your choice. Do not login yet.
  2. Use developer tools to show all cookies used by the site. (Chrome: Ctrl+Shift+i, open the 'Resources' tab and click on the site below 'Cookies' on the left. Firefox: Right-click on the site, open 'We…

Setting expiry dates for images, JavaScript and CSS

When deploying Rails applications you might have noticed that JS and CSS are not cached by all browsers.

In order to force Apache to add expiry dates to its response, add the attached .htaccess to the public directory. This will add a header such as Expires: Thu, 07 Oct 2010 07:21:45 GMT to the httpd response.

Configuring Apache

Check that you have mod_expires enabled. You need it for the attached .htaccess to work:
sudo a2enmod expires

Configuring Nginx

You can add this:

Consul: Dynamically access and query powers for a given name, model class or record

Consul 0.6.1+ gives you a way to dynamically access and query powers for a given name, model class or record.
A common use case for this are generic helper methods, e.g. a method to display an "edit" link for any given record
if the user is authorized to change that record:

module CrudHelper

  def edit_record_action(record)
    if current_power.include_record?(:updatable, record)
      link_to 'Edit', [:edit, record]


You can find a full list of available …

External content

Prism.js: simple, fast and lightweight syntax highlighting

Prism is a new lightweight, extensible syntax highlighter, built with modern web standards in mind. It’s a spin-off from Dabblet and is tested there daily by thousands.

External content

Phusion Passenger 4 Technology Preview: Out-Of-Band Work – Phusion Corporate BlogPhusion Corporate Blog

The Out-of-Band Work feature allows one to perform arbitrary long-running work outside the request/response cycle without blocking HTTP clients. The primary use case is to run the garbage collector in between cycles so that your requests will finish faster because they will not be interrupted by the garbage collector.

RVM: Get rid of your system Ruby

If you worked with a system Ruby before switching to RVM, this system Ruby will be in your way when you switch between projects with/without RVM.

It's hard to get rid of your system Ruby entirely, but you can tell RVM to just use a given Ruby by default, e.g.:

rvm --default use 1.8.7

You need to re-open existing terminals for the changes to take effect.

Note that this will not actually remove the ruby package from your system, it just isn't used anymore.

Detect effective horizontal pixel width on a mobile device with Javascript

So you want to find out how many horizontal pixels you have available on a mobile device. This is super difficult because:

External content

Amazon Elastic Transcoder

Amazon Elastic Transcoder is video transcoding in the cloud. It is designed to be a highly scalable, easy to use and a cost effective way for developers and businesses to convert (or “transcode”) video files from their source format into versions that will playback on devices like smartphones, tablets and PCs.

This might be a good alternative for services like Panda which charge a large monthly fee just to be available for your encoding requests. Amazon's service bills by usage instead:

A 10 minute sourc…

Memcache: Your cache node may degenerate over time, check your settings

We recently had a problem on a Memcache cluster, where one of the servers showed a significantly worse cache hit rate and a lot more evictions.

It turned out that the only reason was that the server was running for a few months longer than the others. Some investigation showed this to be a known problem with Memcache: Once your cache gets full, it might be "hardwired" for your specific usage patterns. If those change (and you for example start to store larger values), memory is no longer allocated optimally, in extreme cases Memcache might …

External content

Geocoding Strategies - Google Maps API

The attached article outlines considerations when choosing client-side vs. server-side implementations of the Google Geocoding APIs (geocoder, directions, not maps drawing). The main points are:

  • On the server side you only get a fixed daily request quota
  • On the client side the quota is per-client, so basically unlimited
  • When implementing APIs on the server-side, be aware that quota is measured by IP. When hosting in the cloud **you don't always know which other services might…
External content

daylerees/colour-schemes · GitHub

Awesome color schemes for RubyMine, Sublime Text 2 and other editors.

To install the themes into your Rubymine, copy intellij-themes/*.xml from the repository to your local ~/.RubyMine40/config/colors. Then restart RubyMine.


Geordi: run a capistrano task on all stages

Geordi now has a script that runs capistrano with all known deploy targets (i.e. staging, production…).

Use with

geordi capistrano deploy:migrations


geordi capistrano deploy

The abbrevation geordi cap ... works as well.

Git: How to stash with a custom message

If you say git stash, your stashed changes will be identified with an automatically generated message:

$ git stash
Saved working directory and index state WIP on master: 77af0df Merge branch 'production'

While this is okay to temporarily stash away stuff, you may want a better identifier for your changes so you can find them more easily if you stash often.
Of course, there is a way to do it with git:

$ git stash save doing crazy things
Saved working directory and index state On master: doing crazy things

Note that you n…

3267 cards