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.

Install the DeaDBeeF music player under Ubuntu Linux

DeaDBeeF is a lightweight music player for Linux users who want an alternative to the default playback app. Installation is available for Ubuntu systems.

Always show all form errors during development

Forms can fail validation without visible feedback when the offending field has no input. A development-only error box keeps all form errors visible without leaving debug markup behind.

Let Webrat make a POST request

Webrat can submit a page request as POST by passing :post to visit, useful when a path must be tested with form-style submission.

Webrat doesn't follow redirect because it considers the url external

Absolute URLs in Rails tests can be treated as external because the host is unknown, breaking redirect handling in Webrat. Use path-only matching or reset Webrat to the local site.

Timecop creates records in the past after calling Timecop.freeze

Timecop 0.3.4 and earlier can create records with timestamps in the past after Timecop.freeze; upgrading to 0.3.5 avoids the bug.

Time#utc, Time#gmt and Time#localtime are destructive methods

Time#utc, Time#gmt and Time#localtime mutate the receiver instead of returning a converted copy, which can cause hidden side effects in shared Time objects.

Convert the colorspace of a PDF from RGB to CMYK under Ubuntu Linux

RGB-to-CMYK PDF conversion usually changes colors because no exact mapping exists; Ghostscript can rewrite the file with CMYK output on Ubuntu Linux.

Rotate a PDF under Ubuntu Linux

Incorrectly oriented PDF pages can be fixed on Ubuntu with pdftk by applying page rotation during output generation.

Fix: Tail says "no space left on device"

tail -f can fail with “no space left on device” when Linux inotify watches are exhausted, often by daemons like Dropbox. Raising fs.inotify.max_user_watches restores file following.

Fix Rubygems warning: Gem.source_index is deprecated, use Specification

Rubygems updates can flood legacy Rails apps with Gem::SourceIndex deprecation warnings. SlimGems or upgrading Rails 2.3.11 to 2.3.12+ reduces the noise.

Who broke the build?

Jenkins build failures trigger an automatic foam missile counter-attack aimed at the developer who broke the build.

Downgrade Firefox 6 to Firefox 5 on Ubuntu

Firefox regression can break Selenium tests after an upgrade; running an older browser is unsupported and may leave the system unstable.

Prevent your Firefox from auto-updating

Freezing Firefox versions for broken Selenium tests is a poor long-term fix because old releases stop receiving security patches. Auto-update can be disabled via about:config, but keeping Firefox current is safer.

An ActiveRecord is invalid, but has no errors

before_validation returning false can make an ActiveRecord object invalid without populating errors, leaving validation failures hard to diagnose.

Distance of time in what you like: days, months, years

Rails’ distance_of_time_in_words can be too imprecise when a fixed unit is needed. A custom helper returns rounded differences in days, months, or years.

Print large PDFs as a poster

Convert a large PDF into tiled pages for printing as a poster using pdfposter; sizing the output can be awkward, but it works for oversized prints.

Best GitHub feature

Repository navigation becomes faster with GitHub’s file-name search shortcut, letting you jump to files immediately instead of scrolling through folders.

Random list of ActiveSupport goodies

Handy ActiveSupport helpers add callbacks, message signing and encryption, ordered options, array wrapping, deep hash merging, whitespace squishing, and zone-aware current time.

How to make a single check box (or image, etc) align vertically

Single inline controls like checkboxes or images can sit top-aligned inside a line-height container when they are alone; adding adjacent inline content or a non-breaking space centers them.

Ruby GetText will eval scripts containing ActiveRecord classes

Ruby-GetText may execute entire files while scanning for ActiveRecord models, so one-off scripts can run during PO rebuilds.