Weeknotes 2022 W45: Burn II
The days are getting shorter and shorter, and the sun is so low in the sky that I’m occasionally forced to close the curtains to avoid a glare in my computer screen. I dislike the darkness, but at least I have a SAD lamp to help me out.
That SAD lamp also makes for a rather good light for video calls, too.
SAD in this case means “seasonal affective disorder,” which indeed makes you feel sad. What a name.
Find me on Mastodon: @denis@ruby.social.
I moved from chaos.social to ruby.social, which is much better aligned with the community I spend a lot of time in.
My burn (see Weeknotes 2022 W44: Burn) is healing up nicely.
It’s the worst skin burn I’ve ever had. Folks, don’t operate hot kitchen equipment while half-involved in work things. Lesson learnt.
I still can’t shower (that’s what my GP told me), but fear not! I have found other, reliable ways to keep myself clean. (I did tell my GP that I’d be very smelly the next time I come back. A little joke. Ha ha.)
The new System Preferences System Settings UI on macOS Ventura is bizarre. I’m having a hard time finding what I need there.
The groups in the sidebar are unlabeled, and the icons are so tiny as to be unrecognizable.
The groups also seem arbitrary: One group has “Privacy & Security”, another group has “Touch ID & Password,” and a third group has “Passwords.” Shouldn’t all of these be grouped together?
Automated macOS updates never seem to work for me. I got a notification that a macOS update would be installed automatically overnight, and I left my laptop on. The next morning, though, I woke up to a notification that said “Updates not Installed.”
Come to think of it, automatic software updates have never worked for me — is that supposed to be the case?
I released Nanoc 4.12.11, which brings some sweet performance improvements. You should upgrade.
I wrote a bit of code to determine the brightness of the terminal background color. Behold, for it is mildly cursed:
require 'io/console'
# Query RGB background color
raw = STDIN.raw do |stdin|
print "\e]11;?\a"
stdin.read(25)
end
# Parse
r, g, b = raw
.scan(/[0-9a-f]{4}/)
.map { |part| part.to_i(16) / 65_535.0 }
# Calculate brightness
brightness = Math.sqrt(
(0.299 * (r**2)) +
(0.587 * (g**2)) +
(0.114 * (b**2))
)
puts "Brightness: #{format '%.2f', brightness}"
Some desperately needed explanation:
-
\e]11;?\a
is an xterm control sequence which results in the terminal’s current background color to be written to stdin. -
STDIN.raw
turns on raw IO mode, which is needed to read the previously-written background color from stdin. -
stdin.read(25)
reads the response, which looks like\e]11;rgb:ffff/ffff/ffff\e\\
— exactly 25 bytes long. The threeffff
pieces are the red, green, and blue color components. -
.scan(/[0-9a-f]{4}/)
extracts groups of four consecutive hexadecimal characters. There will be three: one for red, one for green, and one for blue. This is probably not the best way to parse out the color components, but it gets the job done. -
part.to_i(16) / 65_535.0
normalizes the hexadecimal color components to the 0.0–1.0 range. -
Math.sqrt(…)
is how you calculate the brightness of a color. The magic values 0.299, 0.587, and 0.114 are there because green is a lot brighter than red, and red is slightly brighter than blue. Color handling: it’s full of mystery.
With the brightness of the terminal’s background color in hand, you can decide to use foreground colors that properly contrast with the background.
Also: is it not weird how high-depth the terminal color is? That’s 48-bit color, which is ridiculous. It’s a terminal for goodness’ sake, not a high-end photo manipulation program!
Not much progress on the budgeting app prototype. The UI looks a little nicer, at least:
On the backend, I’ve been attempting to write an importer for my ledger files, which are in beancount format.
I am writing a parser for Beancount in Rust, because the existing tooling out there doesn’t parse my files correctly. Also, writing parsers is fun, though doing it in Rust (a language I am not very familiar with) is proving to be quite the challenge.
In Rust, I keep bumping into the issue that enum variants are not types themselves. If I have a Token::Number
token, I can’t have a consume_number
function that returns a Token::Number
(because that is an enum variant, not a type).
The chance is high that I’ll soon drop the work on the budgeting app prototype (again). It’s a ton of work and I don’t have a clear direction.
This week at work, there was an engineering offsite, which I did not join. The medical care for my burn wound would have made that difficult, but the core reason is that I don’t fancy traveling to another country for a few days just to spend most of the time working there anyway. It’s not a holiday, but it is work time dressed up as such — intentionally or not.
Along with that, there is still an ongoing pandemic. I’m limiting my travel to what is strictly necessary.
Not to mention that traveling is exhausting, time-consuming, and stressful.
For the dev
tool I created at work, my plan is still to open source it some time. I rely on it so much that I’m starting to miss it when working on my personal projects.
I wrote about this tool before in Weeknotes 2022 W34: Insomnia, but I did not give an example of a dev
configuration file. It looks a bit like this:
up:
- postgres:
version: 14
- redis
- ruby
- bundler
- rails_db
- node
- npm
- homebrew:
- overmind
- pandoc
serve: overmind start -N
test:
- bundle exec rspec
- bundle exec rubocop
Running dev up
will ensure the right version of Postgres is installed and running (multiple versions are supported), the right version of Ruby, Node, … etc are available, and so on. It sets up relevant environment variables too, like POSTGRES_PORT
, which minimizes the amount of manual configuration.
The dev up
command is idempotent, so you can run it any time and it’ll ensure the development environment is set up properly.
This is entirely inspired by Shopify’s dev
tool. I didn’t have the greatest time at Shopify, but I certainly saw plenty of things there that I needed to replicate, and dev
was one of them.
Entertainment:
-
I picked up Gaston Dorren’s Dutch-language book Zeven Talen In Zeven Dagen (Seven Languages In Seven Days) at the recommendation of my mother. It is a well-written and beautifully designed book!
-
I (finally) finished season 5 of The X-Files.
Links: