Rails: Have different session secrets for all environments

Using the same Rails session secret in staging and production can let a cookie from one environment authenticate in another. Separate secrets per environment reduce session hijacking risk.

Rails: Send links in emails with the right protocol

ActionMailer defaults to http in email links, which can expose session cookies to SSL-stripping. Set default_url_options or the link protocol to use https where needed.

git: How to always pull with rebase

Keeping git branches linear avoids cluttered merge commits when pulling updates. Setting pull.rebase=true makes git pull rebase by default.

Pimp my IRB

Custom .irbrc files can make irb and the Rails console more useful with extra methods, nicer printing, editor integration, and app-specific prompts.

Virtus: Coercing boolean attributes

Virtus boolean attributes need Virtus::Attribute::Boolean rather than Boolean, because Ruby has no native Boolean class and Virtus will not coerce it correctly.

Bundle capistrano

Capistrano API changes can break deployments with older deploy.rb files; bundling it and using bundle exec helps keep releases working.

Ubuntu: Restart sound services

Broken speaker output on Ubuntu can often be restored by restarting the audio stack with pulseaudio -k and reloading ALSA.

marcandre/backports · GitHub

Backported Ruby 1.8.7–2.0.0 features for older Ruby versions improve compatibility and access to newer core APIs without upgrading the interpreter.

Subscribe to Rails security mailing list without Google account

Subscribe to the Ruby on Rails security mailing list without a Google account by using a direct boxsubscribe URL instead of the web interface.

Clean up application servers when deploying

Frequent deployments fill application servers with old releases, tmp files, and stale compiled assets. Capistrano can automate release and asset cleanup to prevent disk-space exhaustion.

How to remap keys in Ubuntu

Keyboard remapping in Ubuntu lets you change key behavior when layouts or hardware keys are inconvenient. xmodmap can adjust mappings using keycodes from xev.

Redactor WYSIWYG html editor

Lightweight WYSIWYG HTML editing for web apps, with a cleaner interface than TinyMCE or CKEditor and Rails integration.

Launch Gnome disk utility from command line

Launch the GNOME disk utility from the terminal with sudo palimpsest.

Ruby Scripts: Select the Ruby version in the shebang

Use rvm in a script shebang to run Ruby with a specific version instead of the system default.

News flash: Absolute CSS positioning on opposite sides is not a problem

Absolutely positioned boxes can use opposing offsets on both sides in modern browsers; only IE6 and older break this layout.

How to clear cookies in Capybara tests (both Selenium and Rack::Test)

Need to remove cookie data during a Capybara scenario when browser state must reset before the test ends.

How to: Build a "generic observer" widget for the awesome window manager

Periodic command output in an awesome panel can be turned into a widget with a timeout timer and escaped text.

LibreOffice Calc: Reset positions of split dividers

Split panes in LibreOffice Calc can end up in awkward positions; moving the dividers off screen and toggling splitting restores the default layout.

Inherit without Single-Table-Inheritance (STI) in ActiveRecord

ActiveRecord can inherit without STI when no type column exists or inheritance_column is overridden, making form models and presenters possible.

Duplicate a git repository with all branches and tags

Copying a Git repository with every branch and tag requires a bare clone and a mirror push to preserve the full ref set.

How to find out which type of Spec you are

Runtime checks can identify the current RSpec spec type, letting shared setup run only for controller, helper, or request/response-aware examples.

How to find out if you are in Cucumber or in RSpec

Feature and spec code may need different behavior when Rails env is unavailable. Capybara.current_driver can distinguish Cucumber scenarios from RSpec examples.

Do HTTP referers survive a 301 redirect?

HTTP referer headers can persist across a 301 redirect, affecting analytics and referrer-based logic.