Making minimal updates to DOM trees using morphdom / idiomorph
Replacing DOM fragments with innerHTML wipes state such as form values, scroll position, and custom-element data. morphdom and idiomorph preserve existing nodes by applying minimal changes.
Custom Angular Test Bootstrap
Custom Angular test bootstraps centralize global providers, matchers, and test-wide setup while preserving CLI strict error checking.
Checklist: Using Carrierwave in a Rails project
Checklist for CarrierWave edge cases beyond the default Rails setup: secure URLs, image resizing, metadata handling, file validation, and efficient processing.
Ruby: Do not rescue without specifying exception classes
Bare rescue swallows StandardError and hides typos and other unexpected failures. Rescue only the specific exception you expect so monitoring still catches real bugs.
Jasmine: Cleaning up the DOM after each test
DOM-based Jasmine specs can leak leftover elements into later tests; using a dedicated fixture container cleared after each run keeps test state isolated.
File System Access API: Recursive Directory Traversal
Modern browsers can read selected folders and files with the File System Access API, reducing the need for ZIP upload workarounds when recursive directory handling is enough.
Rails: Adding a unique constraint for a has_one association might be a good default
A unique index on a has_one foreign key lets the database enforce 1:1 relationships and fail fast when application logic creates duplicate rows.
Rails: When to use :inverse_of in has_many, has_one or belongs_to associations
inverse_of lets Rails treat both sides of an association as the same in-memory object, reducing duplicate loads and fixing bi-directional association behavior.
How to update a single gem conservatively
Updating one gem with bundle update can pull in dependency upgrades and break existing code. Bundler --conservative limits changes to the targeted gem and avoids unnecessary transitive updates.
Defining class methods with Modularity traits
Trait parameters require define_singleton_method for class-level behavior; def self.foo works only without parameters, with normal class method visibility caveats.
Sentry Local Logging in Ruby
Local Sentry event logging helps debug error capture and background jobs without sending data to Sentry or affecting production metrics.
Using a virtual column for trigram indexes in PostgreSQL
Trigram indexes provide a lightweight alternative when full-text search becomes too rigid or slow. A virtual column can combine multiple text fields and support indexed LIKE queries.
Simple form examples with bootstrap
Building Bootstrap forms with simple_form reduces repetitive markup and keeps form layouts consistent.
Ruby: A small summary of what return, break and next means for blocks
return, break, and next behave differently in Ruby blocks: one exits the method, one exits the yielding method, and one skips only the current iteration.
Using ActiveRecord with threads might use more database connections than you think
ActiveRecord threads can open one database connection per thread, quickly exhausting server limits. Rails reuses and releases connections automatically, but manual cleanup is sometimes needed.
Unpoly: Passing Data to Compilers
Rails data can be passed to Unpoly compilers through data-* for simple strings and up-data for objects, arrays, and nested values.
Unpoly: Compiler Selector Patterns
Common Unpoly compiler selector strategies for reusable components, one-off view behavior, configurable attributes, and universal element enhancements.
Project management best practices: Budget control
Keeping project estimates aligned with the remaining budget prevents overruns when requirements change and project management overhead shifts.
Careful: `fresh_when last_modified: ...` without an object does not generate an E-Tag
Passing last_modified without an object skips ETag generation, so second-level timestamps can make distinct responses look identical and break cache-related tests.
Firefox cancels any JavaScript events at a fieldset[disabled]
Events from controls inside a disabled fieldset stop bubbling in Firefox, unlike Chrome and IE/Edge, which can break document-level listeners and delegated handlers.
SQL: Fast threshold counts with LIMIT
Large-table COUNT(*) queries can be slow when only a threshold like 100+ matters; a LIMITed subquery stops early and avoids scanning every row.
How to tweak RSpec's truncation behavior
RSpec truncates long inspected values to 200 characters, which can hide the real cause of failing specs. Raising max_formatted_output_length reveals more of the error message.
Matching Unicode characters in a Ruby regexp
Ruby 1.9+ \w and \d stay ASCII-only; Unicode-aware POSIX character classes match letters, digits, and other script-specific characters.
JavaScript: Stopping expensive work in inactive tabs
Pause expensive periodic work when a tab is hidden to save battery and mobile data; document.hidden and visibilitychange let background pages go passive.