How I ask GPT-4 to make tiny Python scripts in practice

First get a working script. “Hey GPT-4, write me a ChatGPT script that does .” Manually check over the script and iterate until it’s giving me what I want. “Now wrap the script into a click command-line interface.” I almost always specify to use an --input flag and an --output flag. If the data it’s working with is human-readable, “Make it so that if --input is not specified, it reads data from stdin....

August 22, 2024

The highest personal ROI program I have written so far

It would have to be finstem, a simple command-line program I wrote to reduce Finnish words down to their root form. Finnish is a lot like Latin or Russian in that its words often become lumbering behemoths of rewritten consonants, suffixes upon suffixes, and this makes it hard to look up in a dictionary – that is, until you factor in its very regular orthography and the phenomenal efforts of the Finnish programming industry: finstem is basically a very specialized UI for the OpenOffice spell checker, and I have no shame in admitting that....

July 30, 2024

Language learning treated as breadth-first search

I am, emphatically, not the language learning type. I’ve done enough of it over my life to know this. It’s certainly one of the better hobbies out there: You can do it for free (in principle), you can sink as many hours as you care to into it, and if you get good enough at it you get to reap some unique cultural and economic1 benefits. But there’s a reason I picked up Python when 14 year old me decided he wanted to get ahead in life instead of (say) German....

April 22, 2024

Check my math - NixOS vs the Most Complicated Program on Earth (MCPOE)

Imagine you had the Most Complicated Program On Earth (MCPOE), with 1,000,000 dependencies. Every dependency must be build correctly exactly right or the MCPOE will fail to compile. MCPOE’s 10x dev team chose their packages so that each dependency has only a 1/1,000,000 chance of having something go wrong when you’re installing them - maybe a whitespace character snuck into the wrong build script, maybe solar wind hit the build computer....

April 14, 2024

fd + xargs + bat = quick document review

I’ve been on vacation this week, and part of what I’ve been up to is fixing up the Selkouutiset Archive. Like most of my websites these days, SA is powered by Hugo, which means handling a lot of Markdown documents, which means I opted to use an intermediate Git repo as a submodule to actually store the custom-processed documents. After a few tweaks here and there, I found myself wanting to quickly flip through all of the Markdown documents I had generated for each news day....

February 25, 2024

Getting `fzf` to print the preview pane

fzf is an incredibly useful bit of software, if someone shows you how to use it. There’s a lot more to it than just fuzzy-switching directories and fuzzy-searching you shell history – it also comes with a preview pane that updates on every keystroke. Try 1 echo '' | fzf --preview 'echo {q} {q}' and typing something to see how it works. ({q} is the query you type in at the bottom of the screen....

December 6, 2023

Vagrant lets you wrap VDI images

At work I’m currently experimenting with using Vagrant to automate getting an entire local network of our tiny embedded Linux systems running all on my local box. Alas! One of our devices uses a custom Yocto distribution! But wait, we have scripts to run these as VDI images, and apparently that’s enough for Vagrant to get to work! 1 vagrant package --base my-virtual-machine Further reading materials for future me: Creating a Base Box, and the Box File Format....

December 5, 2023

Git aliases for fun and profit

haskell-kata’s Quickstart now has this neat little ditty at the start: 1 2 git config --local alias.build '!sh -c \'for file in *.hs; do ghc -o "${file%.hs}-bin" "$file"; done\'' git build Git is the gift that keeps on giving. I was on the hunt for a subdirectory-scoped alias, and I just discovered this incredibly flexible way to create new Git subcommands. History: 2 years ago I read through the 1200 page behemoth Haskell Programming from First Principles....

December 3, 2023

Outage postmortem: Why didn't SelkoArchive get today's news?

For some reason, my daily archive of Finland’s “clear news” broadcast didn’t work today. Why not? TL;DR: Just a Git snafu. Quick recap of the archive: There are 3 Git repos: selkouutiset-scrape simply scrapes the HTML https://yle.fi/selkouutiset at 6 PM every day via a Github Action. selkouutiset-scrape-cleaned pulls in scrape and turns it into a stack of translated, properly-named Markdown files, by the magic of shell scripts, systemd timers, and a tiny VM in a datacenter somewhere....

December 1, 2023

One problem with user-scoped `systemd` timers

I’ve discovered one big downside of [putting systemd times into ~/.config/systemd/user/][1]: They stop running when you log out. Two ways around this problem: Bite the bullet, and install the timers into /etc/systemd/. This means giving up chezmoi version control, making the overall system more snowflake-y. I’m not crazy about it. Remote in with tmux, instead of ever logging out, just use C-b d to detach from the session. I’m going with #2....

November 26, 2023