Docker Compose Env Vars

TIL that docker compose knows when environment variables have changed, and intelligently recreates containers on up if so. Also, environment variables do not get updated to what’s in the .env file on a restart.
Read more →

Pi4midi

I promised my daughter Lila that I’d get this USB-MIDI keyboard controller working, which I had been talking about doing for some weeks, but which has become more pertinent, given that we are going to be homeschooling, and music is part of our curriculum. Anyway, here are notes on how I got MIDI sound working on a Pi4 2GB with my Nektar IMPACT iX61 MIDI controller: Setup Install base raspberry OS apt install qsynth Start jackd with the seq module so the MIDI keyboard works (from http://slackermedia.
Read more →

Thermostat

Notes for how I go about setting up my Pi-Zero-W-based thermostat, since I keep having to reflash the SD card due to a poor power supply (I know, the right one is cheap… yes yes). Get Pi latest Raspberry Pi OS Lite Change passwd Go into sudo raspi-config change hostname to thermostat enable wifi enable SSH reboot ssh-keygen add pub key to github git clone git@github.com:hoffmanc/heater.git cd heater sudo .
Read more →

Brightness

I tried to help a colleague to get their brightness hotkeys working on Ubuntu using the i3wm. I had googled and implemented a solution for it, but then forgot what I did. So, here it is, for the sake of Future Chris. This solution is applicable to the lenovo t470p and t480 at least. place this script in /etc/acpi/brightness.sh: #!/bin/bash current_brightness=cat /sys/class/backlight/intel_backlight/brightness max_brightness=cat /sys/class/backlight/intel_backlight/max_brightness if [ $1 == "up" ] then new_brightness=$(($current_brightness + 100)) [ $new_brightness -gt $max_brightness ] && new_brightness=$max_brightness else new_brightness=$(($current_brightness - 100)) [ $new_brightness -lt 0 ] && new_brightness=0 fi echo $new_brightness > /sys/class/backlight/intel_backlight/brightness and these under /etc/acpi/events:
Read more →

Splice

A couple of days ago I learned about the javascript method splice for arrays, which allows one to delete and replace elements of an array in one call. I’ve been using the immutable.js implementation of this method, and I’ve been quite pleased with how easy it is to e.g., move an element. For example, given this List: const ary = List(['a','b','c','d']) If I want to move ‘b’ to in between ‘c’ and ’d’, I would do the following:
Read more →

Ignore Revs

TIL that git version 2.23+ allows one to specify commits to ignore during a git blame. This is useful when there are commits that touched a lot of stuff but only changed formatting. I was able to update my version of git on ubuntu by adding the git core ppa, apt updating and installing. sudo add-apt-repository ppa:git-core/ppa Since I use tpope’s vim-fugitive to do blaming, I wanted not to have to specify the –ignore-rev flag every time I use this command, so I did the following:
Read more →

Amps

Today I learned that the little DC adapter I was trying to use to power a ODROID C1 was insufficient, at least when it came to spinning up a GUI. I have this old Lenovo power adapter that is pushing 20V, so I’m looking into stepping down that voltage somehow to 5V. I tried to use a potentiometer to achieve this purpose, which likely belies my electronics knowledge - in short, it didn’t work.
Read more →

Saturn

Today Lila and I saw Saturn through her telescope! We could clearly make out it’s four moons and rings! I think this is the first time either of us have seen something so cool in a telescope (her being nine, so less unusual). Now I feel compelled to learn some amateur astronomy. And build a rocket.
Read more →

Front Matter

Today I learned how to add some tags to these articles, with the hope that I can use them to conditionally syndicate these posts to twitter, linkedin, etc. I believe being able to generate an RSS feed for a script to use for syndication involves digging more deeply into taxonomies; specifically, making sure I am using a theme that supports rss templates for them, or adding my own? UPDATE - after publishing this article, I see a syndications/twitter folder that has exactly what I need for a script to sync this blog with, in this case, twitter!
Read more →

QRCode

Chris, I am a QRCode. Remember my name, god damnit!
Read more →

useEffect style

I was able to modify the width of a stubborn react-admin component dynamically, using another DOM element as a reference point, and it was actually pretty clean! Here’s a stripped-down version: MyComponent = () => { [width, setWidth] = useState() useEffect(() => { const main = document.querySelector('main'); if (!main) { return; } setWidth(main.getBoundingClientRect().width - 50); }); render <StubbornComponent style={{width}}/> } I would’ve preferred a pure-CSS solution, but this seems to be working and the code is temporary (well, moreso than usual, hopefully)
Read more →

Gohang

To make a go program hang until terminated, you can use this line: <-make(chan struct{}) Why would you want to do this? In our case we have a blue/green setup that and docker compose set to restart: always, so if the server reboots both the blue and green containers get spun up at the same time. Now we check to see which one is supposed to be active, and if a container doesn’t match, it executes this hang - otherwise docker will see the 0 exit code and constantly try restarting the container.
Read more →

House

This weekend I learned a bit about what goes into putting a house together. The biggest take away was that making sure all the pieces are square and level is critical, and saves a lot of time down the road. For instance: there were two mud sills, or sill plates, on the foundation walls. The original plan was to shim the second course of sill so that it was totally level all the way around the foundation.
Read more →

Unmarshal

Do not rely on the fact that go unmarshaled json without error into your type - it may just have ignored all the json and instantiated an empty variable.
Read more →

git add --edit

TIL that I can use git add –edit during an interactive rebase to do things like move a file from a go package (created in that commit) to an existing package; this reduces the scope of the regex substitution to avoid changing unrelated code.
Read more →