How to provoke Selenium focus issues in parallel test processes

As attachments to this card you will find a Cucumber feature and supplementing step definition that you can use to provoke Selenium focus issues that only occur when two focus-sensitive Selenium scenarios run at the same time (probably with parallel_tests). This can help you to detect and fix flickering integration tests.

The attached feature works by going to your root_path and focusing a random form element every 5…

Analyse TCP/UDP traffic with netcat

Sometimes you want to see what data you get through a TCP or UDP connection.
For example, you want to know how a HTTP Request look like.

It's very easy with netcat.

Example to listen on port 80 and the output gets to stdout.

sudo nc -kl 80

It's also possible write it into a file:

sudo nc -kl 80 > output.txt

If you use Ports higher than 1000 you don't need to be root (sudo).

Custom bash autocompletion

The bash offers control over the behavior of autocompletion.

The most primitive example is this (just run it in your bash; if you want it available everywhere, put the complete ... line into your .bashrc):

> complete -W "list of all words for an automatic completion" command_to_be_completed
> command_to_be_completed a<TAB>
all an automatic

With complete you define how the specified command shall be completed. For basic needs, -W (as in "word list") should be enough, but you may also specify a function, a glob patte…

How to find out the currently focused DOM element with JavaScript

This works in all relevant browsers:


You can use this in your Selenium steps, for example, to assert that a form field is or is not focused.

Debugging Apache's mod_rewrite

Debugging .htaccess is hell, and RewriteRules in particular if they are not working as expected. But fear not! RewriteLog will help you out. \
Add this to your vhost's configuration:

RewriteLog "/tmp/rewrite.log"
RewriteLogLevel 9

After that, restart your Apache httpd and tail the above logfile.

When you are done and all is well: remember to remove those entries again, or set the log level to 0, to switch off rewrite logging.

External content

CSS that lets your alarm bells ring

Harry Roberts, a youngster from the UK, wrote a comprehensive article telling you how to smell CSS rot early.


  • Undoing styles
  • Magic numbers
  • Qualified selectors
  • Dangerous selectors
  • Reactive !important

… and more.

Simple memory information widget for the Xfce panel (or anywhere else where you can run a shell command)

I was unsatisfied with the existing memory status applets for the Xfce panel, so I wrote a little shell script that shows me just the information I need. Now I use it via a "Generic Monitor" panel applet.

Put this at some place like ~/bin/memory-info and chmod +x it:

meminfo=`free -m | grep 'Mem:'`

used=`echo $meminfo | cut -d" " -f3`
total=`echo $meminfo | cut -d" " -f2`
cached=`echo $meminfo | cut -d" " -f7`

really_used=`expr $used - $cached`

echo "Memory usage: $really_used / $total (Cached: ...

Git: Add all changes

A nice way to stage absolutely all changes (edits, additions, deletions):

git add --all

Performance analysis of MySQL's FULLTEXT indexes and LIKE queries for full text search

When searching for text in a MySQL table, you have two choices:

  • The LIKE operator
  • FULLTEXT indexes (which currently only work on MyISAM tables, but will one day work on InnoDB tables. The workaround right now is to extract your search text to a separate MyISAM table, so your main table can remain InnoDB.)

I always wondered how those two methods would scale as the number of records incr…

Render Sass stylesheets dynamically

If - for whatever reason - you have to render stylesheets dynamically, the following snippet might be of help. It emulates what "sprockets" would to when precompiling your assets, and give your stylesheets access to all the regular bells and whistles (like asset_path, proper @imports etc):

class DynamicStylesheetsController < ApplicationController

def show
  path = File.join(Rails.root, logical_path)
  template =
  environment = ...
External content

5 APIs that will transform the Web in 2013

Over the next year, there are a number of technologies coming down the pipeline that have the potential to radically transform how we use and develop for the Web.

Hack: Detect DOM node insertions using plain CSS

David Walsh from Mozilla shows how to fire 'DOM changed' events from CSS. No need for JS to observe DOM mutation events or check the DOM manually – simply put: no deprecated API, no retarding loops.

With the CSS in place you add a listener for your custom 'DOM changed' event and that's it!

Git: Twelve Curated Tips And Workflows From The Trenches

This article contains:

  • Making ‘git diff’ wrap long lines
  • Set a global proxy
  • Clone only a specific branch
  • Diff file against remote branch
  • List all deleted files in the repository
  • Search for a string in all revisions of entire git history
  • Apply a patch from another (unrelated) local repository
  • Making a more recent branch the new master
  • Adding an initial empty commit to a branch to allow full rebase
  • Zero a branch to do something radically different
External content

How to package a non-Ruby file into a gem

Great solution in a GitHub issue.

How to test if an element has scrollbars with JavaScript (Cucumber step inside)

The basic idea is pretty simple: an element's height is accessible via the offsetHeight property, its drawn height via scrollHeight – if they are not the same, the browser shows scrollbars.

var hasScrollbars = element.scrollHeight != element.offsetHeight;

So, in order to say something like…

Then the element "#dialog_content" should not have scrollbars

… you can use this step (only for Selenium scenarios):

Then /^the element "([^\"]+)" should( not)? have scrollbars$/ do |selector, no_scrollbars|

Cronjobs: "Craken" is dead, long live "Whenever"

Our old solution for cronjobs, the "craken" plugin, is no longer maintained and does not work on Rails 3.2+.

We will instead use the whenever gem.

"Whenever" works just like "craken", by putting your rake tasks into the server's cron table. Everything seems to work just like we need it.

Installation for new projects

  1. Add "whenever" to your Gemfile:

     group :deploy do
       gem 'whenever'
  2. Add it to your config/deploy.rb:

Firefox makes an OPTIONS request you don't expect

If some AJAX functionality does not work, but you see Firefox making an OPTIONS request, the reasons is most likely this:

You're accidently trying to talk to a different domain (or switching from http to https), and Firefox tries to find out if that is okay, according to the "Cross-Origin Resource Sharing" standard.

navy gem: Hide empty navigation bars

navy 0.5.1+ gives empty navigation containers a CSS class .navy-empty which you can hide via

    display: none
3222 cards