Hello!

Mainly notes to myself and writing to think out loud.

All views my own.

Freeing Up Disk Space Used by Docker

Today my computer ran out of disk space. I narrowed it down with this command: du -sh /* 2>/dev/null | sort -rh | head -20 The culprit was this file: $HOME/Library/Container/com.docker.docker/Data/vms/0/data/Docker.raw This command showed that my build cache was using over 200 GB: docker system df -v I cleaned it up using: docker system prune --all

2026-04-22

Finding the single number with XOR

I’ve been drilling on LeetCode recently and ran into a problem which I did not know how to solve while using constant extra space: Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant extra space. Example 1: Input: nums = [2,2,1] Output: 1 Example 2: Input: nums = [4,1,2,1,2] Output: 4 Example 3: ...

2026-02-24

SQL Common Table Expressions

Today I spent some time learning about SQL common table expressions (aka “CTEs”). I already use subqueries, so they were easy to understand. The syntax is very simple: WITH my_cte AS ( SELECT col1, col2, col3 FROM table1 ) SELECT col1, col3 FROM my_cte WHERE ... Here’s a more complex example with two CTEs: WITH my_cte1 AS ( SELECT col1, col2, col3 FROM table1 ), my_cte2 AS ( SELECT col4, col5, col6 FROM table1 ) SELECT my_table.*, my_cte1.col1, my_cte2.col4 FROM my_table JOIN my_cte1 ON my_table.fkey_id1 = my_cte1.col1 JOIN my_cte2 ON my_table.fkey_id4 = my_cte1.col4 WHERE ... In general, I should prefer CTEs over subqueries because: ...

2025-12-18

BASH Process Substitution

Today, I learned about shell process substitution from Bread on Penguin’s latest video. Assume you have two files: $ cat file1 a b c $ cat file2 c b a To see if they are identical when sorted without manually creating your own temporary files, you can: diff <(sort file1) <(sort file2) What is happening here? <() is doing process substitution, which is running the command and then exposing its output as a temporary file. ...

2025-12-16

Sublime Text Arithmetic Command

I’ve been using Sublime Text as my main text editor since August of 2014. I know it pretty well, but occassionally I still learn something new and useful. Today I learned about the Arithmetic command from a video by OdatNurd. Summary of what I learned Variables The following variables are supported: Variable What it does s The literal selected text i The selected text interpreted as a number (0, if interpretation fails) i The index of each selection (0-indexed) Converstions hex(x) // to hex int(x) // to decimal bin(x) // to binary format() is supported format(x, ',') // add comma separators to number, 1234 -> 1,234 format(x, '^80') // center selected text in 80-character column math package is supported math.ceil(x) math.floor(x) TIP: update numbers of an ordered list This is particularly useful; I do this all the time! ...

2025-11-19

SSH Key Best Practices

Today I needed to create a new SSH public/private keypair for work. I wanted to make sure I was following modern best practices for this, so I did some reading online. I found these two articles to be very helpful: SSH Key Best Practices for 2025 – Using ed25519, key rotation, and other best practices SSH Agent Explained Things I learned I didn’t ever think to change the comment at the end of the keyfile. Now I plan to date them, as it suggests. Using the email sub-alias (+) is clever and I’m stealing that. ...

2025-09-10

Treating strings as numbers in Golang

Today I encountered an API which sometimes sends back numbers as strings. Example response: { "age": "30" } That’s annoying, because I wanted my struct in Go to be like this: type Person struct { Age int `json:"age"` } I learned that json struct tags have a string option meant for dealing with exactly this sort of problem: The “string” option signals that a field is stored as JSON inside a JSON-encoded string. It applies only to fields of string, floating point, integer, or boolean types. This extra level of encoding is sometimes used when communicating with JavaScript programs: ...

2025-08-28

Even Easier Git Rebasing

Rebasing your feature branch on main regularly is a good idea. I used to do it like this: # update local copy of main git fetch origin main:main # rebase on local main git rebase main This always felt a litle off because I was worried I’d typo main:main and mess it up. This works just as well and feels much better to me: # update local copy of `origin/main` git fetch # rebase on origin/main git rebase origin/main

2025-08-28

How to add values to an HTTP query string in Go

Here’s how to add key/value pairs to an http.Reqest’s query string in Go: package main import ( "fmt" "net/http" ) func main() { // create a request req, _ := http.NewRequest(http.MethodGet, "http://www.example.com/", nil) // get the current query string from the http.Request values := req.URL.Query() // add or set values values.Set("myKey1", "myVal1") // overwrite! values.Add("myKey1", "myVal2") // append! // add values back to the request req.URL.RawQuery = values.Encode() // query string: mykey1=myVal1&myKey1=myVal2 // print the url fmt.Println(req.URL.String()) } The above program will output: ...

2025-08-26

Binaries on Macos

Path Note /usr/local/bin/ System-wide binaries go here! ~/bin/ My user’s binaries go here!

2025-08-22