How to exploit websites that include user input in their CSS
Unsanitized user input in CSS can enable exploitation in web apps, and CSS input sanitization is harder than HTML sanitization.
A Theme Switcher
Implementing an inverted night-mode look with a few lines of CSS keeps image colors intact while changing the page appearance.
Bundler 2 will rename Gemfile and Gemfile.lock
Bundler 2.0 renames Gemfile to gems.rb and Gemfile.lock to gems.locked, with old filenames supported until Bundler 3.0.
Association to polymorphic model does not determine inverse_of automatically
Nested polymorphic associations can fail to save because Rails does not infer the inverse automatically; setting :inverse_of on the parent relation fixes the validation error.
How to enable the Thinkpad microphone mute key on Ubuntu 16.04
ThinkPad microphone mute key stopped working on Ubuntu 16.04 after an upgrade. Binding the ACPI event to amixer restores hardware mute control.
Rails: render a template that accepts a block by using the layout option of render
Reuse a form partial with a customizable submit section by rendering it as a layout and yielding the form object into a block.
How to change the class in FactoryBot traits
FactoryBot traits cannot use :class; a nested factory or initialize_with can build the desired subtype instead.
Import Excel files without running into memory limitations
Reading large XLSX files can exhaust memory when every cell becomes a Ruby object. Stream-based parsers like Roo and Creek avoid loading the full spreadsheet at once.
Ubuntu MATE: Fixing ALT + TAB being really slow
ALT+TAB in Ubuntu MATE can become unusably slow because the application switcher renders live thumbnails for each window. Disabling thumbnails or software compositing restores fast switching.
Sentry: How to get a list of events that is programmatically processable
Programmatic access to the latest issue events in Sentry is available as a JSON list through the events API endpoint.
Postgres: How to force database sessions to terminate
PG::ObjectInUse blocks dropping or resetting a PostgreSQL database when other sessions stay connected. Find the backend PID and terminate the process when needed.
How to pair a Bose Quiet Comfort 35 with your Ubuntu computer
Bluetooth on Ubuntu can pair with Bose QC35 but still lack audio output; disabling low-energy mode and enabling the PulseAudio Bluetooth module restores sound.
JavaScript bookmarklet to click an element and copy its text contents
Click any page element to capture its text or input value, highlight the target, and copy the cleaned content through a browser prompt.
Custom Ruby method Enumerable#count_by (use for quick statistics)
Quick statistics on collections often need grouping, counting, and sorting. Enumerable#count_by combines them for flexible Ruby-based frequency counts beyond database columns.
Async/Await Will Make Your Code Simpler
Async JavaScript can become long and deeply nested when promises are handled awkwardly; async/await offers a cleaner syntax for readable asynchronous code.
JavaScript: How to query the state of a Promise
Native promises do not expose their current state, which makes state checks in unit tests awkward; a promiseState helper can distinguish pending, fulfilled, and rejected promises.
Vagrant: create entry for box in .ssh/config
Passwordless SSH access to a Vagrant box from any directory by adding vagrant ssh-config output to ~/.ssh/config.
How to install a current version of git to your Ubuntu machine
Ubuntu ships an older git release by default; adding the Git Core PPA and installing from apt provides a newer version.
Understanding Scope in Ruby
Ruby scope determines which variables, constants, and methods are visible at a given point, helping prevent confusion about what can be accessed in different contexts.
JavaScript: Polyfill native Promise API with jQuery Deferreds
Small Promise polyfill for jQuery projects, trading native API compatibility for tiny size and jQuery Deferred performance limits.
murdho/rack-cargo: Batch requests for Rack APIs
Single /batch requests reduce API round trips and let later calls reuse earlier results through named placeholders.
travisliu/traim: Resource-oriented microframework for RESTful APIs
Build a RESTful API for ActiveRecord models with very little code. Traim emits a Rack application that can run standalone or inside Rails, but the 1:1 resource model can become limiting.
Deleting stale Paperclip attachment styles from the server
Unused Paperclip image style files can accumulate on the server after style changes, wasting storage and cluttering attachment directories.
ActiveRecord: How to use ActiveRecord standalone within a Ruby script
Run ActiveRecord without Rails in a tiny Ruby script to reproduce bugs or test associations with an in-memory SQLite database.