Stub a request's IP address in a Cucumber scenario

Force a fixed client IP in Cucumber scenarios when request-dependent code needs predictable behavior.

MySQL: Do not use "WHERE id IN (SELECT ....)"

MySQL subquery filters in WHERE id IN (SELECT ...) can force repeated scans and hurt update performance; a JOIN or preloaded id list is faster.

Linux Performance Analysis in 60,000 Milliseconds

A Linux server with a performance issue needs fast triage in the first minute. Core commands reveal load, memory, CPU, disk, network, and process bottlenecks.

Designing HTML emails

Email client rendering is inconsistent, so HTML messages need table-based layouts, inline styles, and client-specific workarounds to remain readable across major mail apps.

Handy: A regex that validates all valid email addresses (give or take) - Axon Flux // A Ruby on Rails Blog

/^([\w!#$%&'*+-/=?^`{|}~]+.)*[\w!#$%&'*+-/=?^`{|}~]+@((((([a-z0-9]{1}[a-z0-9-]{0,62}[a-z0-9]{1})|[a-z]).)+[a-z]{2,6})|(\d{1,3}.){3}\d{1,3}(:\d{1,5})?)$/i

Alternative to #to_a and Array(...)

Turning arbitrary values into arrays can trigger to_a deprecation warnings and inconsistent nil behavior. Array.wrap or listify provide a safer conversion.

Stub methods on any instance of a class in Rspec 1 and Rspec 2

Stub a method on every instance of a class to control behavior in tests, using stub_any_instance, any_instance.stub, or allow_any_instance_of.

Understanding SQL compatibility modes in MySQL and MariaDB

SQL mode mismatches can break apps after MySQL or MariaDB upgrades by changing strictness, grouping rules, and allowed values.

How to change the order of nested forms being rendered (especially blank forms)

Blank nested forms usually render last; reordering the one-to-many association changes their position and can move the empty form to the top.

SSHKit 1.9.0 failure for Capistrano deploy

Capistrano deploys can crash in sshkit-1.9.0 with NoMethodError in pretty.rb; upgrading SSHKit to 1.21.0 resolves the failure.

IRB's multi-line autocomplete and how to disable it

IRB’s multi-line completion can slow down input and make Backspace unreliable; --nomultiline or IRB.conf[:USE_MULTILINE] = false disables it while keeping Tab completion.

Ruby 2.3.0 has a safe navigation operator

Ruby 2.3.0 adds &. for nil-safe method calls, preventing NoMethodError when receivers can be absent while leaving false behavior unchanged.

How to make Rational#to_s return strings without denominator 1 again

Ruby 1.9+ renders integer-valued Rational objects as 2/1, which can leak into views and date calculations. A small override restores the Ruby 1.8-style integer string output.

Careful with '||=' - it's not 'memoize'

||= does not memoize nil values, so expensive lookups or database queries may run repeatedly when the result is absent. Use defined-instance-variable caching when nil must be cached.

Thread-safe collections in Ruby

Shared data in threaded Ruby code needs protection or immutability; concurrent-ruby offers thread-safe Array and Hash, and Hamster uses immutable collections.

Email validation regex

Ruby email checks can be simplified with URI::MailTo::EMAIL_REGEXP, while stricter web forms often need a top-level domain and looser validation may use Devise's pattern.

There is no real performance difference between "def" and "define_method"

def and define_method have no meaningful performance gap in typical Ruby code; only very short methods show a small difference, while closures can affect garbage collection.

Things to consider when using Travis CI

Fragile CI builds on Travis often fail with Ruby 1.8.7, incompatible Rubygems, or debugger gems in the test bundle.

Bash: How to use colors in your tail output

Coloring tail output makes log levels easier to scan, and ANSI escape codes in sed can highlight INFO and FATAL lines in different colors.

Understanding database cleaning strategies in tests

Test databases need cleanup between examples to keep state isolated; transactions are fastest, while browser-driven tests or MyISAM tables require deletion or truncation.

Limiting CPU and memory resources of Paperclip convert jobs

Paperclip image conversions can spike CPU and memory during heavy uploads. ImageMagick resource limits and nice help reduce contention on Unix systems.

Fix: esbuild assets are missing after capistrano deploy

esbuild output can disappear after a Capistrano deploy when app/builds is not committed, leaving public/assets incomplete. Sprockets may ignore files in unknown paths.

Unpoly 2: Don't try to download files through AJAX requests

AJAX downloads fail because browsers try to render files instead of saving them. Exclude download links from Unpoly link handling and use Content-Disposition: attachment or download.

PostgreSQL: Ordering, NULLs, and indexes

PostgreSQL sorting puts NULL values first or last depending on direction, and matching index order is needed for efficient multi-column queries.