How to fix: Corrupt special characters in ZIPs on Linux

ZIP files from Windows users can corrupt umlauts and other non-Latin1 filenames on Linux because of CP850 encoding. unzip -O CP850 handles these archives correctly.

Chrome bug: Wrong stacking order when transitioning composited elements

Chrome can render composited slider elements in the wrong stacking order during CSS transitions, causing overlapping content to appear above neighboring elements until motion ends.

Haml: Generating a unique selector for an element

Haml can derive stable CSS classes and IDs from Ruby objects, making elements easy to target from JavaScript or Unpoly updates.

Haml: Prefixing a group of attributes

Prefix several HTML attributes at once in Haml by nesting them in a hash with {} syntax; () attribute syntax does not support grouped prefixes.

3 ways to run Spring (the Rails app preloader) and how to disable it

Rails commands can start Spring unexpectedly, and DISABLE_SPRING disables it only for non-explicit invocations. Different launch paths affect console and rake behavior.

Debugging Webpacker config

Webpacker configuration can be hard to inspect when builds misbehave; dumping the environment, using browser or Node debugging, and emitting warnings help reveal the active webpack settings.

Introduction to Google Tag Manager (for web developers who know Google Analytics)

Configuring analytics without code changes keeps tracking flexible, but GTM adds complexity and security risk. Tags, triggers, and variables centralize event and pageview tracking.

Rails: Flagging all cookies as secure-only to pass a security audit

Secure cookies are often required by audits even when a Rails app already uses HTTPS and HSTS. A middleware can add the Secure flag to server-set cookies automatically.

JavaScript “Stale Practices” | benmccormick.org

ES5-era JavaScript best practices have stale alternatives in modern code, and older patterns can become outdated as the language evolves quickly.

Make a local copy of an S3 bucket

Backup or mirror an Amazon S3 bucket to a local directory with s3cmd, using a dry run before the full sync.

Fix for Ruby 1.8.7 installation error

Ruby 1.8.7 installation with ruby-build can fail on some machines with a math.c compiler error. Installing ruby-1.8.7-p374 avoids the issue.

Heads up: Rails offers two similar means for text truncation

Rails has both truncate helper and String#truncate; the helper is preferred for block support and safer HTML handling, especially with escape: false.

Using the Ruby block shortcut with arguments

Passing arguments to Ruby’s block shorthand makes map(&:method) usable for nested lookup and JSON extraction without full block syntax.

Ruby: All Errno::ERROR constants inherit from SystemCallError

Network calls can fail with many Errno:: exceptions; rescuing SystemCallError groups them under one base class and simplifies error handling.

Cucumber steps to travel through time with Timecop

Cucumber step definitions for Timecop provide date and time travel in tests, including relative shifts into the past or future; Selenium browser time needs timemachine.js.

Rails' Insecure Defaults - Code Climate Blog

Rails has solid built-in protection, but some default behaviors remain risky in Rails 3 and parts of Rails 4. Security gaps can still leave apps exposed.

CSS: Using interaction media detection to disable hover styles for devices that have no hover

Touch devices can trigger sticky or accidental hover states, especially when hover changes the DOM. @media (hover) and @media not all and (hover) help keep hover-only styling off devices that cannot hover.

Logic in media queries

Media queries can express basic logic for viewport ranges and device capabilities using and, commas, and not all and syntax.

Beware: Don't name a controller action "cookies"

Naming a controller action cookies can override ActionController cookie access and break unrelated requests, causing redirects or storage failures.

ActiveRecord::Store: migrate data in store

Migrate hashed settings stored in a single column by renaming keys safely in an ActiveRecord::Migration, using the store's coder and an embedded model.

Rails: Disabling logging entirely

Rails logs can be silenced completely in a specific environment by replacing the logger with Logger.new('/dev/null').

Capistrano + Rails: Tagging production deploys

Production releases can be linked to Git history by tagging the deployed revision automatically with Capistrano.

Capistrano + Rails: Automatically skipping asset compilation when assets have not changed

Rails deployments can spend minutes precompiling assets; Capistrano can skip that work automatically when the code and asset files have not changed.

Fixing authentication in legacy applications

Legacy authentication setups often miss SSL, cookie, CSRF, and session-fixation protections, leaving logins and browser-stored data easy to compromise.