Finding ancestors with Capybara
Capybara's #ancestor finder locates parent elements with CSS or XPath, replacing verbose XPath and supporting order: :reverse for the nearest match.
Hints for debugging MySQL InnoDB deadlocks
MySQL InnoDB deadlocks occur when concurrent transactions lock rows in different order, often due to broad queries or missing indexes. SHOW ENGINE INNODB STATUS and the application backtrace help identify the conflicting statements.
You can use graphs in gitlab comments!
GitLab comments support Mermaid diagrams, letting text-based graphs and class diagrams communicate ideas more clearly.
Strict Loading Associations can prevent n+1 queries
Rails 6.1 strict loading prevents lazy association loading and raises errors when unread associations are accessed, helping avoid n+1 queries.
Setup Sidekiq and Redis
Sidekiq needs a Redis connection configured separately for client and server environments. A REDIS_URL constant and startup load path keep staging, production, and test settings consistent.
RSpec: how to prevent the Rails debug page if you want to actually test for 404s
Rails development and test environments often replace real 404s with the debug page, which can hide authorization failures in request specs.
RSpec: ". not_to include" behaves like ".to exclude"
not_to include with multiple values checks each value separately, so one matcher can verify several exclusions at once instead of negating the whole expectation.
A Guide To CSS Debugging
Unexpected CSS layout results often come from a small set of common causes. Systematic debugging helps isolate the issue and prevent recurring styling bugs.
Fix REPL of better_errors page
better_errors can lose its interactive REPL on Ruby 2.5.8; updating binding_of_caller to 0.8.0 or later restores advanced debugging features.
Git shortcut to rebase onto another branch
Interactive Git helper for rebasing a chosen run of commits onto another branch, reducing off-by-one mistakes and manual commit counting.
Disable built-in dragging of text and images
Browser text and image dragging can block custom horizontal scrolling or pointer-based movement. Disabling native drag behavior needs CSS and, in Firefox, JavaScript.
Bash alias to switch between recent branches
Quickly jump between recently used Git branches with a shell alias and fzf, avoiding manual branch names and speeding up context switches.
Large CSS box shadows can bring browsers to a crawl
Large blurred shadows can make scrolling and DOM updates sluggish, especially with fixed or sticky elements. filter: drop-shadow() may render faster with hardware acceleration.
Rails: Removing the cucumber-rails warning when setting cache_classes to false without Spring enabled
cucumber-rails emits a transaction warning in test runs when cache_classes stays false without Spring, affecting parallel execution setups.
Working on the Linux command line: How to use bookmarks for directories
Navigate deeply nested project folders faster by storing directory bookmarks in CDPATH and jumping back with short symlinks.
Working on the Linux command line: How to efficiently navigate up
Frequent upward directory changes in deeply nested trees are slow; shell aliases like .. and ... make jumping to parent folders faster.
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.
Cucumber Factory: How to assign polymorphic associations
Polymorphic associations in Cucumber Factory require named associations; indirect references like owner above fail when the target type is ambiguous.
Bookmarklet to facilitate generating new git branches for PivotalTracker Stories
Create git branch names from PivotalTracker story titles, with initials and optional abbreviations for easier tab completion.
Unobtrusive JavaScript helper to progressively enhance HTML
Attach JavaScript behavior to matching HTML elements as they appear in the DOM, with automatic initialization for dynamic content and cleanup on removal.
Using attribute event handlers with a strict Content Security Policy (CSP)
Inline event handlers and javascript: links are blocked by a strict CSP; script-src-attr hashes can re-enable specific handlers while keeping other inline script disabled.
CSS has a well-supported :empty selector
:empty hides elements only when they have no content, including whitespace. Useful for badges or counters that should disappear when nothing is shown.
SSL/TLS - Typical problems and how to debug them
Common TLS failures can block secure connections and are often hard to diagnose. Typical symptoms point to certificate, protocol, or handshake issues and debugging clues help narrow them down.
RSpec < 2.11: ActiveRecord scopes must be loaded before using the "=~" matcher
ActiveRecord scopes must be converted to arrays before using RSpec =~, or array comparison can fail. match_array and contain_exactly are preferred in RSpec 2.11 and later.