Update: The conclusions in this post might be invalid. I’ve left the post unchanged but I added a footnote explaining why. I never thought I’d apologize to Comcast, but … sorry I said–in great detail–that your service is bad. It turns out maybe it isn’t? Ok here’s the original post: Since the pandemic, I’ve been […]
Archives for April 2023
The Bash trap command
Bash’s trap command is used to catch and react to signals sent to your shell. It’s similar to an event listener in the browser, or a pubsub topic subscriber. The typical use case is to run some kind of cleanup command when a process terminates, like this: The command above will run cleanup_job when it […]
Dedupe a list in Vim
Tldr: use :sort u Surprisingly often, I find myself needing to dedupe a list, usually when digging through logs. There are many ways to dedupe a list, but Vim might just be the fastest one. Take this list of UUIDs I pulled when investigating a recent issue: From a quick look, I can see that […]
Ruby’s safe navigation operator (&.)
Ruby’s safe navigation operator (&.) is a nil-safe way to chain operations. Let’s say we have a User class, and that class can have first_name and last_name attributes: Without safe navigation, we’d need a more-verbose if check to accomplish the same thing: If you’re familiar with Javascript, ruby’s safe navigation works just like javascript’s optional […]
Golang iota explained
If you’ve worked in Go, you’ve likely seen iota. Here’s how the Go docs explain it: Within a constant declaration, the predeclared identifier iota represents successive untyped integer constants. – The Go Docs That sort of makes sense, but let me put it into plain English. iota is used when declaring a list of constants, […]