How to write good code comments

Comments work best when they explain why code exists, not what it does, and stay close to the relevant code, robust against change.

Heads up: Ruby's Net::HTTP silently retries a failing request

Net::HTTP may retry an idempotent request once after failure, so a timed-out call can take up to twice the configured timeout.

Best Practice: Creating User Accounts Without Sending the Password

Admin-created accounts need secure initial access and immediate password replacement. A temporary secret password plus a forced reset avoids sending credentials directly.

How to avoid ActiveRecord::EnvironmentMismatchError on "rails db:drop"

Rails database tasks can fail with ActiveRecord::EnvironmentMismatchError after restoring a dump from another environment. Updating ar_internal_metadata or disabling the environment check lets rails db:drop proceed.

Event order when clicking on touch devices

Touch interactions on mobile fire mouse events after touchstart and touchend, which can create duplicate handling unless the sequence is canceled.

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.

Capybara: How to find a hidden field by its label

Hidden form inputs are ignored by default in Capybara, causing find_field to fail unless type: :hidden is specified. This helps when tests must wait for JavaScript widgets to populate a field value.

Quick HTML testing with RubyMine

Quickly preview embed code or other HTML in RubyMine without creating a project file by using an HTML scratch file and opening it in a browser.

Letting a DOM element fade into transparency

CSS mask-image creates a fade-out effect by using an alpha mask, letting elements gradually become transparent with gradients or images.

Traversing the DOM tree with jQuery

jQuery traversal methods move a selection through the DOM tree to find descendants, ancestors, parents, children, or matching elements efficiently.

Ruby: How to fetch a remote host's TLS certificate

Fetch a remote server’s TLS certificate in Ruby without sending a full request. The certificate can be inspected, cached as PEM, and reloaded with OpenSSL::X509::Certificate.

Sass partial names must always start with an underscore

Imported Sass files need a leading underscore or they compile into standalone CSS and can fail when they depend on shared variables or mixins.

Inspecting a live Ruby process

Extracting a backtrace from a running Ruby process helps diagnose hangs and crashes without waiting for a restart. gdb can attach live or inspect a core file.

How to use the Capistrano 2 shell to execute commands on servers

Capistrano 2 provides shell and invoke for running tasks or ad hoc commands on deployment targets, with support for individual hosts and roles.

Guide to String Encoding in Ruby

Ruby string encodings can behave unexpectedly and trigger invalid byte sequence errors in UTF-8 when text is handled with the wrong encoding.

How to make a cucumber test work with multiple browser sessions

Capybara multi-session tests support simultaneous users in browser-based chat flows, but session-aware authentication state is needed to avoid conflicts.

Rails: Rest API post-mortem analysis

Rails API backends can be fast and easy to extend, but serializer maintenance, schema drift, documentation limits, and missing rate limits create real operational risks.

How to: Validate dynamic attributes / JSON in ActiveRecord

JSONB columns can hold dynamic attributes in ActiveRecord, but validation and strict defaults are easy to lose. JSON Schema keeps evolving hashes predictable.

Handling duplicate links with Capybara and Cucumber

Duplicate links in Capybara can trigger Ambiguous match errors when any matching link is fine; switching Capybara.match to :first avoids the failure.

Structuring Rails applications: the Modular Monorepo Monolith

Monolithic Rails apps can stay maintainable by splitting code into a monorepo of Rails Engines and gems with explicit component dependencies.

Capybara 'fill_in': Ambiguous match for different input names

Capybara fill_in can raise Capybara::Ambiguous when visible field labels overlap. match: :prefer_exact or a global exact matching strategy avoids substring conflicts.

How to capture a screen-cast on Linux

Tools and settings for making Linux screen recordings with better quality, optional audio, and quick trimming or muting with ffmpeg.

Jasmine: Test that an object is an instance of a given class

Verify that a value was created by a specific constructor in Jasmine with jasmine.any(Klass) instead of direct instance checks.

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.