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.

IRB: last return value

IRB and the Rails console store the previous command result in _, making it easy to reuse a forgotten value without rerunning the expression.

ImageMagick: How to auto-crop and/or resize an image into a box

ImageMagick can remove transparent borders and fit images into a fixed box without distortion. -trim, -resize, and -extent preserve aspect ratio and center the result.

RSpec's hash_including matcher does not support nesting

hash_including cannot match nested hashes reliably; use nested matchers such as include or another hash_including for partial hash checks.

Know what makes your browser pant

Changing CSS properties can trigger different amounts of browser work, affecting performance when styles are updated.

ActiveRecord::RecordNotFound errors allow you to query the :name and :id of the model that could not be found

ActiveRecord::RecordNotFound carries model and id, making it possible to report missing records without exposing internal query details.

Rails: wrap_parameters for your API

Rails can nest flat JSON request bodies under a root key so strong parameters work like form submissions and stray keys such as format stop interfering.