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.
CSS: Using the current text color for other color properties
currentColor reuses the current text color for borders and other CSS color values, avoiding duplicated color declarations and keeping states in sync.
How to create a user with all privileges to MariaDB
MariaDB administrative access can be granted to a local user without a password, with unix_socket authentication, or by setting a password.
RubyMine: Scratch files
Temporary scratch files in RubyMine let you quickly edit or transform snippets without touching a project directory, with plugin-based access and keyboard shortcuts.
screenfull.js: Simple wrapper for cross-browser usage of the JavaScript Fullscreen API
Browser fullscreen handling is inconsistent across vendors, forcing boilerplate and event workarounds. screenfull provides a small wrapper for cross-browser fullscreen requests, exit, state, and change events.
Capistrano task to tail remote application logs of multiple servers
Monitor logs across multiple app servers from one terminal and avoid missing per-host errors; LOG selects another file, and terminal line truncation can hide long entries.