Use Capybara on any HTML fragment or page
Capybara matchers can be applied to standalone HTML fragments or strings, not only full pages, making fragment assertions easier in test suites.
Zip files with Ruby
Create ZIP archives in Ruby with zipruby; add existing files, string buffers, and directories using Ruby bindings for libzip.
Downloading files from Ruby on Rails
Serving files as downloads in Ruby on Rails uses send_file; it returns the file directly and overrides the normal render response.
Vim: Scroll up/down, keeping your cursor in its row
Keep the cursor on its row while scrolling a Vim buffer, avoiding jumps to the top or bottom of the screen. Default keys move the viewport by a line or half screen.
Thunderbird Addon: Message Archive Options
Sets Thunderbird archive folder date formatting and folder granularity for year and month subfolders, and can modify the A shortcut with Shift, Control, or Alt.
Hide your Selenium browser window with a VNC server
Run Selenium tests in a hidden X session with vncserver, keeping the browser accessible for inspection without adding a gem.
Passenger booting Rails 3 application in wrong environment
Passenger can start a Rails app in the wrong environment unless Apache is configured with the correct RailsEnv or RackEnv setting.
Firefox 3.6 truncates long tables when printing
Firefox 3.6 print output cuts off long tables, often due to CSS floats, overflow rules, or nearby h1 and caption tags.
How to look at hidden X screens
Hidden X displays can be inspected by taking a screenshot of the active display, including Xvfb-backed sessions used for headless tests.
simple_format helper for Javascript
Rough JavaScript equivalent of Rails simple_format for turning plain text into HTML paragraphs and line breaks. Whitespace preservation is not included.
Resque: Work off queues manually
Manual queue processing in Resque specs avoids relying on an external worker while keeping behavior close to real job execution.
Resque: Clearance authentication for dashboard
Resque dashboard access can bypass ApplicationController filters in Rails 3, so a Rack middleware can protect it with Clearance and a remember token.
How to hide your selenium browser window with "headless"
Selenium browser windows can steal focus during Cucumber acceptance tests; headless with xvfb keeps them hidden while running Selenium WebDriver through Capybara.
A few hints when upgrading to Ruby 1.9
Ruby 1.9 upgrades in Rails apps often fail because of gem incompatibilities, lambda arity issues, and encoding mismatches between files, strings, and databases.
Change file permissions with Ruby
File.chmod sets Unix file permissions in Ruby, where the leading zero matters for octal mode values.
Delete a Clearance session after some time of inactivity
Inactive users are logged out after a period without requests, using Clearance cookie expiration and a per-request refresh to keep active sessions alive.
Rails 3: Sending tempfiles for download
Temporary downloads can fail in Rails 3 when send_file triggers X-Sendfile and the web server cannot read files under /tmp. Using an allowed temp directory avoids 404 errors.
How to type accented characters on keyboard layouts without dead keys
Typing accented letters on dead-key-free keyboard layouts is still possible with a configured Compose key and the right compose combinations.
Rails 3: Make "link_to :remote => true" replace HTML elements with jQuery
Rails 3 remote links can replace page content with returned HTML, restoring the Rails 2 link_to_remote update behavior through jQuery and rails-ujs.
Fix for: Your Firefox profile cannot be loaded. It may be missing or inaccessible.
Selenium and Launchy can trigger Firefox profile errors when Launchy opens pages through the active browser. Setting LAUNCHY_BROWSER and BROWSER to Chrome or another browser avoids the conflict.
RSpec 2.6 supports "any_instance" now
any_instance stubbing and expectations now work in RSpec 2.6, enabling should_receive and stub on instances created inside code.
Failtale
Exception tracking service for any platform with a Rails notifier and REST API, useful as a free alternative to Hoptoad/Airbrake for custom error reporting.
Hex color codes for the CGA palette
Hex values for the 16-color CGA palette used on Color Graphics Adapter displays in the 1980s.
Virtual attributes for date fields
Virtual date attributes in forms arrive as strings, so Rails does not auto-cast them like database columns. A custom accessor can coerce them to Date objects or nil.