Managing different SSH Keys for different Hosts is well-understood. Different keys for the same host (e.g., github.com ), based on which GitHub Organization we’re working with, that’s… a bit trickier. But, we have the technology! We’re going to configure our SSH and Git clients to seamlessly switch SSH keys between our personal GitHub Account and our GitHub Enterprise Cloud, EMU Account. You need…
A flaky test is one that fails unpredictably, without a corresponding change in the code under test. These often show up in CI runs where a test unrelated to any change made suddenly fails, and then mysteriously passes when re-run. There are many type and causes of “flakes”. Today I want to talk about flaky tests caused by time precision, and time-order dependence. The specific tools mentioned…
Memory leaks happen. And if you’re here, reading this, I’d bet you’re dealing with one. First things first - are you sure it’s a leak, and not bloat ? Okay, so it’s a leak. Much has been written about various tools for profiling a leak , understanding heap dumps , common causes of leaks , work being done to improve Ruby’s memory layout , and so much more. Ben Sheldon’s recent “ The answer is in…
The Active Support library has always (or, close enough to always ) allowed us to cherry-pick specific extensions/behaviors, to load only strictly needed dependencies. That is, rather than loading the entirety of the library, we can load just the bits and pieces we need. This helps keep the amount of things loaded in memory smaller, and faster by doing less work. It can also aide in understanding…
Rails 7 introduced a new bin/dev wrapper to launch and manage your Rails server, CSS watcher, and JS bundler into a single process, managed by foreman . This is quite handy for running everything with a single command. But what if you’re deploying to Heroku and using the Heroku CLI’s heroku local to run things locally? Or if you’re a fan of one of the other tools that manage processes based on…
Command line tools and shell builtins can offer both a short- and long-form way to specify options. Sometimes these are also called short and long flags, respectively. The upshot is a user experience with two ways to specify the same option. A short and terse way. And a longer, more verbose way. $ curl -HLsS http://stevenharman.net # ⬆ is the same as ⬇ $ curl --head --location --silent…
A “well-behaved” object in Ruby needs to understand the following: What makes two Ruby objects “equal”? And which version of “equal” (there are several in Ruby)? And what makes an object usable as a Hash key? And is that the same thing that makes them Comparable ? Because I can never seem to remember the specifics. And because my searching the Interwebs seems to find related, but not specific…
Over the years I’ve written a few Homebrew formulas and sent the occasional Pull Request to update a formula or two. But I’ve never done any work within Homebrew . I’ve never needed to debug how Homebrew itself worked. Until now. I assumed our typical Ruby debugging tools, like Pry and Pry-Byebug would work. Homebrew is just Ruby, after all. Which is true. But it’s also a bit special, and we can’t…
In Search Of… a Ruby method with the semantics of Enumerable#map and Enumerable#inject . That is, to transform values while also having access to the prior iteration return value. Sounds odd, I know. Given the following “value object” class Snapshot def initialize ( value = 0 ) @value = value end def apply ( new_value ) self . class . new ( @value + new_value ) end end I want to build an array of…
TL,DR; When building an application using Rails, I prefer to keep all my model in app/models/ . I reserve lib/ for those other things - those not-my-domain-things. I’d like to explain the what and why . Rails has a history of co-opting names, as happened when the ActiveRecord library used the active record pattern name. A similar co-opting has happened with the MVC pattern wherein many believe…