Writing Ruby Scripts That Respect Pipelines

Ruby CLI scripts can break pipe chains when they ignore stdin, stdout, or exit codes. Careful stream handling keeps them composable in shell workflows.

How to deal with MethodNotAllowed errors

ActionController::MethodNotAllowed errors often come from reloads or broken JavaScript links, and can be handled by redirecting back or to a fallback URL with a flash message.

Make Less interpret the escape codes in a logfile

less can leave Rails logfile escape sequences unreadable; less -R preserves ANSI colors and other control codes while browsing logs.

Vendor-prefixed CSS Property Overview

Vendor-prefixed CSS properties support browser-specific features but can complicate cross-browser styling and maintenance.

Managing Rails locale files with i18n-tasks

i18n-tasks helps keep Rails locale files complete by finding missing and unused translation keys and reducing manual YAML bookkeeping.

Re-enable submit buttons disabled by the :disable_with option

Rails submit buttons with :disable_with can stay disabled after back navigation, leaving forms unusable until they are re-enabled on page unload.

Change image scaling algorithms with CSS

Non-standard CSS image scaling controls affect browser resampling and edge smoothness, but results are browser-specific and best avoided unless the target browser is certain.

Useful script to collect downloads from several sites

Keeps lecture documents and other downloadable files collected from multiple web pages without manual checking, using a configurable URL and CSS selector.

How to fix: "500 Internal Server Error" after adding Rack::Bug

Passenger and Apache can return 500 errors after adding Rack::Bug when the middleware is referenced as a string instead of loaded with require 'rack/bug'.

Request a gzipped response from a web server using Wget

Application servers often compress responses with gzip, but Wget downloads the uncompressed version unless Accept-Encoding: gzip is sent.

Embed Google Analytics code for some environments only

Google Analytics should run only in production to avoid polluting visitor statistics. Rails environment checks can gate the tracking snippet.

davetron5000/methadone - GitHub

Ruby framework for building command-line apps with parameter handling, utility classes, and Cucumber support for CLI testing.

How to fix "unknown role" errors in Capistrano recipes

Capistrano multistage recipes can fail with unknown role errors when a task targets a missing server group. Registering the role and skipping the task when no servers match prevents the failure.

Pick a random element from an array in Ruby

Choose one array element at random in Ruby with sample; weighted_sample can bias the result toward specific values.

Caching may break relative paths in your merged stylesheet

Stylesheet caching can merge files from different folders and leave relative image paths pointing to the wrong location, so images work locally but fail on the server.

Scenario outlines in Cucumber

Template-based examples reduce repetition in behavior-driven tests and make repetitive cases easier to maintain.

ERB templates and comments

Whitespace before # in ERB Ruby comments can produce unexpected HTML output; <%# ... %> and newline-indented comments avoid the problem.

Git instaweb

Git includes a built-in browser-based repository viewer for local inspection; git instaweb starts a temporary web server, with Apache or lighttpd support.

Graticule computes NULL distance for some records (and how to fix that)

Spherical distance queries in Graticule can return NULL because MySQL rounding pushes ACOS outside its valid range. Clamping the value to [-1, 1] prevents the zero-distance edge case.

Sequel: The Database Toolkit for Ruby

A lightweight database toolkit for Ruby bridges the gap between ActiveRecord and raw SQL when full ORM features are unnecessary.

DataMapper Retrospective

Two major projects started with DataMapper and later moved to a different ORM, raising questions about the framework’s long-term fit and maintainability.

Bulk-change multiple table rows in a migration

Multiple column changes in a migration can trigger repeated SQL and slow large tables; change_table can bundle them into one ALTER TABLE statement.

Rails ERD – Entity-Relationship Diagrams for Rails

Generate visual database relationship maps from Rails ActiveRecord models for easier schema understanding and documentation.

Ubuntu 11.10: Playing sound over front and back panel (or headphones and speakers) at once

Front and back audio outputs can stop playing together when jack sensing or auto mute disables one panel. alsamixer can turn off the behavior.