Matching elements on complex web pages with Webrat

XPath matchers can be combined with CSS-selector matchers. This is really useful if not, for example, the content of an element should be matched but the element itself like in the following example. Here a form is used to display data as default value in its input elements. This can be the case in web applications in which data should be edited easily without additional clicks.

Enable soft tabs in Vim

Tabs in Vim can be replaced with spaces for consistent indentation across files and platforms, with permanent or temporary settings.

Dump a two-dimensional array to an Excel .xls spreadsheet

Ruby code exports a two-dimensional array to an Excel .xls file with a single method call, with the first row used as a bold header. spreadsheet is required and XLS sheets are limited to 65,535 rows.

Using StaticMatic for static pages

Build static pages with Rails-like comforts such as HAML, SASS, helpers and partials, then compile everything to plain HTML and CSS.

Find records created within a timespan

created_within adds a scope for records created between two timestamps and works on ActiveRecord chains, even when other tables are joined.

Gem Versioning and Bundler: Doing it Right

Running Ruby executables without bundle exec can silently use the wrong gems and break on other machines. Using bundle exec keeps executions tied to the bundle.

Git: How to automatically stage deleted files for commit

Deleted files are not staged by git add .; git add -u updates tracked files and records removals for commit.

Defining host aliases in your SSH config

SSH host aliases in ~/.ssh/config make hard-to-remember servers easier to reach and let you use names instead of raw IP addresses.

How to employ and run your tests with parallel_tests to speed up test execution

Parallel test execution can cut long Cucumber, RSpec, or Test::Unit runs by splitting work across CPU cores with parallel_tests and separate test databases.

Salvage a VirtualBox machine you forgot to export

Recover a copied VirtualBox VM after moving its files without export. Reattach the existing vdi disk to a new machine instead of recreating the whole system.

Move Window Buttons Back to the Right in Ubuntu 10.04 / 10.10

Ubuntu 10.04 and 10.10 place window controls on the left by default. gconftool-2 restores the minimize, maximize, and close buttons to the right.

Script to create and copy a production dump to your project root

Creates a production database dump for a chosen Capistrano stage, copies it into the project tmp directory, and can optionally load it into the local development database.

Releasing geordi

geordi bundles handy makandra note scripts into one gem for production database dumps, remote gem installs, and running rake tasks across environments.

IE7 not properly redrawing elements with position: relative

Internet Explorer 7 can misplace nested position: relative elements after DOM changes, leaving elements redrawn in the wrong spot. JavaScript repaint hacks or overflow: hidden may help.

Faker is now I18n aware, ships with unicorns

Faker now reads strings from locale files, which can trigger confusing translation missing errors when locale data is incomplete.

Before installing the Curb gem

Curb requires libcurl3-dev to compile and install successfully on systems using apt-get.

Updating a gem created with Bundler

Releasing a Bundler-based gem needs a version bump, a tagged commit, and a RubyGems push; rake release handles the packaging and publication.

ActiveSupport::StringInquirer

Wrapping a string in this class gives you a prettier way to test for equality.

Test that a number or money amount is shown with Cucumber

Reliable Cucumber checks for displayed numbers and monetary amounts prevent false positives from partial matches and accept spaces or nonbreaking spaces before units.

Setting up FreeBSD as Virtual Machine in VMware

FreeBSD in VMware needs manual setup for installation, VMware Tools, and display resolution. Missing sources under /usr/src can block screen size configuration.

Don't call #node on a Capybara element

Capybara elements become driver-specific when #node is used, breaking code that should work across Rack::Test and Selenium. Prefer the driver-neutral Capybara API for searches and interactions.

Rails 3.1: Release candidate

Asset pipeline, HTTP streaming, jQuery as default framework, auto-reversable migrations, identity map for ActiveRecord.

Ruby 1.8.x support will be dropped with or after Rails 4.

Automatically build the Passenger Apache module, without interactively asking for user input.

Automated installation of the Passenger Apache module avoids interactive prompts and enables non-interactive builds with passenger-install-apache2-module --auto.