How to make select2 use a Bootstrap 4 theme
Select2 can be styled to match Bootstrap 4, using a Bootstrap 4 theme fork and matching Sass imports for consistent dropdown controls.
Capistrano: Doing things on rollback
Capistrano rollback hooks let custom deployment tasks undo side effects after a failed release, including Slack notifications and other deployment-specific actions.
How to make Webpacker compile once for parallel tests, and only if necessary
Compile Webpacker assets once in parallel test runs and skip recompilation when files are unchanged, avoiding duplicate work and Capybara timeouts.
Cucumber: Test that an element is not overshadowed by another element
Detects whether a visible page element is covered by another layer, such as a modal overlay or higher z-index element, using a browser hit test.
Caution: Carrierwave has your file three times (temporarily)
CarrierWave can temporarily keep three copies of an uploaded file, and large uploads may waste time and disk space. Configuring moves instead of copies reduces the duplication.
Ruby: define a class with Struct.new
Struct.new can define lightweight Ruby classes with attributes, comparison, and keyword initialization for data objects that behave more like records than hashes.
How to: Rails cache for individual rspec tests
Rails caching can be enabled for a single RSpec example without changing global test settings. File and memory stores let cache behavior be verified in isolated tests, including parallel runs.
Speed up better_errors
Better Errors can become very slow in development when large objects are inspected and rendered. Limiting huge inspect output improves error-page performance.
Shoulda Matchers: how to test conditional validations
Conditional Rails validations with if: are not covered by Shoulda Matchers; test the model’s behavior by stubbing the predicate and checking presence only when it applies.
RawGit
Serve raw GitHub files with correct Content-Type headers for CDN-style testing or prototyping, but without any uptime guarantee.
MySQL 5.7.5 enables `ONLY_FULL_GROUP_BY` mode per default
ONLY_FULL_GROUP_BY in MySQL 5.7 rejects queries that select non-grouped columns, preventing nondeterministic results and breaking some Rails scopes.
PostgreSQL: How to add/remove/modify array values (and how to replace 1 value with multiple values)
Manipulating PostgreSQL array columns can be awkward: values can be appended, removed, or replaced, with special handling for multi-value substitutions.
Clicking issues with chromedriver
ChromeDriver click targeting can hit the wrong point on an element, causing intercepted or non-clickable errors when overlays or nearby elements overlap.
Rails 5's ApplicationRecord is the place to put generic model logic
Rails 5 model classes inherit from ApplicationRecord, making it the shared home for logic used by all application models instead of patching ActiveRecord::Base.
Capistrano 2: How to deploy a single server
Deploy a single server from a multi-server Capistrano setup by using HOSTFILTER to target one host and skip irrelevant tasks.
Ubuntu: keyring password won't change with user password
Ubuntu keyring passwords can differ from the current user password after later password changes. If the old password is unknown, the affected keyring may need to be deleted in Passwords and Keys (seahorse).
Testing webpages globally (as in "around the globe")
Global website checks reveal DNS propagation issues and location-specific rendering problems before users do.
How to define height of a div as percentage of its variable width
Percentage padding-top can create a responsive box whose height follows its width, useful for keeping background images proportional without fixed heights.
Webmock's hash_including doesn't parse query values to string
hash_including in WebMock v3.0.1 compares query values as strings, so integer expectations fail unless the request matcher uses '1' instead of 1.
Listing all gems on a private gem server
gem list -r --clear-sources -s can inspect gems on a private remote server, useful when Bundler reports a gem in multiple sources.
Standard Gems
Ruby's standard library is being gemified, so components can be updated independently of Ruby and API breaks can be fixed before a full Ruby upgrade.
HTTP/2 push is tougher than I thought - JakeArchibald.com
Browser HTTP/2 push support is inconsistent and can hurt performance instead of improving it, despite a useful model for integrating push with browser APIs.
RSpec: Stubbing a method that takes a block
RSpec stubs for methods that yield blocks need and_yield instead of and_return; multiple yields can be chained, and return values can be combined.
Middleman: Use pretty URLs without doubling requests
Middleman pretty URLs can trigger an extra redirect and second page request; Apache can serve /foo/index.html directly while canonicalizing /foo/.