"Address already in use" with autossh

autossh can fail with “Address already in use” when the tunnel port or monitoring ports are occupied by another process.

Defining custom errors in Ruby

Custom exception classes in Ruby can be defined with Class.new(StandardError) and referenced as namespaced constants.

How to install a frozen version of Firefox for your Selenium tests

Firefox updates can break Selenium and Cucumber tests; a separate unchanging browser copy avoids auto-updates, profile clashes, and window reuse.

Capistrano: Different usernames for each server

Capistrano deployments to multiple servers can fail when each host needs a different login; putting the username in the server definition avoids a global set :user setting.

Compose a regular expression from other RegExp objects

Build a Regexp from existing Regexp objects with interpolation, but backreferences like \1 can point to the wrong capture group after concatenation.

Turn off SSL for scenarios with Selenium

Selenium on WEBrick fails on HTTPS pages because the server does not speak SSL. Disabling SSL only for those scenarios avoids Cucumber browser test failures.

Machinist's #make breaks on has_many associations when defining method `empty?`

Custom empty? on a has_many model can break Machinist collection building, creating records with the wrong foreign key. Use explicit association assignment instead.

Select an unknown option with Capybara

Selecting a dropdown value without knowing the available options helps in tests where only a valid choice is needed. Capybara can read an option from the list and select it by text.

dbconsole in Rails 3 requires the environment as the first argument

Rails 3 dbconsole misreads -p test and opens the development database unless the environment is passed first.

Backup your Mac to an encrypted local hard drive

Time Machine local backups can be encrypted by using an encrypted external volume instead of a disk image. Sparsebundle images are not recognized for local drives.

xdissent/ievms - GitHub

Run multiple Internet Explorer versions in separate VirtualBox VMs on Linux or OS X for website testing without Microsoft VirtualPC.

When Balsamiq Mockups won't let you load an image file

Image import can fail in Balsamiq Mockups when a file with the same name already exists in the project folder, blocking the load.

How to accept or deny JavaScript confirmation dialogs in Capybara/Selenium

JavaScript confirmation dialogs in Capybara/Selenium can block tests or auto-dismiss unexpectedly. Direct alert handling restores accept, dismiss, and text access.

ActiveRecord 3+ auto-converts times to UTC by default. Hilarity ensues.

Rails 3 auto-converts ActiveRecord times to UTC by default, which can break code using Time.now or Time.parse; local time and non-aware attributes restore the older behavior.

Rendering a custom 404 page in Rails 2

Custom handling for missing records in Rails 2 can render a branded 404 page instead of a generic exception when ActiveRecord::RecordNotFound occurs.

mojombo/grit - GitHub

Ruby library for object-oriented read and write access to Git repositories.

Let a Rails 3 application make a request to itself

Rails 3 can issue internal HTTP requests through the Rack interface, useful for Cucumber features and testing app responses without a browser.

When Rails no longer renders changes in view templates or Sass stylesheets

Cached pages in development can prevent Rails from rendering updated view templates or Sass stylesheets, especially when stale files remain in public/.

Rails 3.1.0 has been released!

Rails 3.1 adds jQuery by default, streaming responses, role-based attr_accessible, prepared statements, and simpler migrations.

Web Upd8: Ubuntu / Linux blog

Daily Ubuntu, Linux and GNOME news with practical HOWTOs for users who want updates and troubleshooting help.

Ruby: Convert a time string to your local time zone

Parsing a time string with a time zone converts it to local time automatically; Time.parse needs time or tzinfo to be available.

Windows 7: Open terminal from Explorer

Open a cmd prompt directly in the current Explorer folder using a built-in Windows 7 shortcut from the context menu.

Fix: "undefined method `bytesize' for #<Array>"

WEBrick can mask Rails startup failures with undefined method bytesize for #<Array>, hiding the real cause until logs are checked or another server is used.

Use different code for Rails 2 and Rails 3

Reusable Ruby code can need different behavior across Rails 2 and Rails 3+. Version checks let code branch cleanly for compatibility.