Tutorials
Implementing dark mode with Tailwind and Stimulus
Dark mode can be automatic based on system settings or manual based on user action.The preference for dark mode will be based on the prefers-color-scheme: dark media selector and a custom settings in localStorage. If you don’t need a custom switch...
Replacing system tests with unit tests | Everyday Rails
It’s amusing and affirming to me that system testing (in Rails) has been declared a failure. I could’ve told you that years ago! I’ve spent much of the past ten years working with test suites that are slow, brittle, and ultimately uninformative—al...
Testing anti-pattern: accessing private properties - Code with Jason
The point of private properties on an object, like private methods and private instance variables, is so you know what you can safely refactor without having to worry that you’re going to mess up some external client that uses that object.Ruby pro...
A trick for invariant generics in Sorbet – Jake Zimmerman
There’s a neat trick for using generic methods to get around some of the limitations that invariant type members in generic classes carry.The problem I’m trying to solve:Sometimes my generic class (say, Box) needs a type_member (say, Elem) to be i...
Why Ruby’s Timeout is dangerous (and Thread.raise is terrifying)
This is already documented in Timeout: Ruby’s most dangerous API. And normally I don’t like making blanket statements about language features. But I had a bad day at work because of this issue. So today, we’re talking about Timeout! :)First! What ...