Ongardie

Trying Nushell

I've been trying out Nushell again lately. I blogged in 2021 about how command-not-found is slow to build an index of which commands are provided by which Debian packages. I created an alternative Posix shell script that performs well without an index. Now, I ported this script to Nushell. I found it interesting to compare the differences.

Comparison

The two versions are here. Both rely heavily on regular expressions. The Posix shell version is about 10 lines and 250 characters longer. Part of this is additional logic to use ripgrep with LZ4 when available, yet fall back to some default that works otherwise:

Running Virtual Machines on Linux

Virtual machines are useful for running other operating systems within your computer and for testing and sandboxing system-level software. This post is about running VMs locally on Linux: how to get a usable disk image and how to connect to it over SSH. It's not as trivial as it sounds.

The VM ecosystem has evolved over the last decades. QEMU/KVM is still the easiest way to get started on Linux, but many of the ecosystem's projects are designed for running cloud services rather than for desktop or casual server use. This post aims to provide simple instructions for running VMs without installing large software stacks. It covers running VMs with and without cloud-init and libvirt.

Website Updates (2024)

I did a bunch of more updates to this website, including adding a dark mode. Most of the other changes are either invisible or barely noticeable. That's OK. My several visitors will appreciate them. Or at least I'll appreciate them.

Dark mode and syntax highlighting

I added a dark mode using CSS, with prefers-color-scheme (widely availabe as of 2020). I switched syntax highlighting (using Pygments) from inline styles to CSS classes, which use different theme colors for light and dark modes. This change will cause the RSS feed to not have syntax highlighting (since RSS readers shouldn't interpret CSS classes), whereas before some RSS readers may have allowed the style elements. I think RSS feeds aren't supposed to be styled, so that's probably OK.

Command Not Found

On Debian/Ubuntu, command-not-found tells you what package to install when you try to run a program you don't have. I find this helpful, but it takes a long time to maintain its index for lookups. This post tells the meandering story of how I first optimized command-not-found, then replaced it with a script that doesn't use an index at all.

update-command-not-found is slow

I noticed recently that apt update stalls on my computer after fetching new data:

Website Updates (2020)

The code for this website has been running without any major updates since 2009. Back then, I wrote it as a Python 2 program using FastCGI, served originally by lighttpd and more recently by Caddy.

I recently overhauled the code to run as a static site generator. This makes it easier to run locally, feels better from a security perspective, and actually simplifies the code in a few ways:

  • When serving individual requests, you need to figure out what page the request is asking for. With generating an entire site, you just loop through all the possible pages.
  • When serving individual requests, you need to load in only the relevant data for those requests. When generating an entire site, you can just load the input data once at startup.
  • When serving individual requests, you need to recover gracefully from errors. When generating an entire site, you can just let any exceptions propogate to crashing the program and have the user fix the problem and rerun.

One thing I gave up in switching to a static site generator was the page trail. Before, the history of where you've been on this site was tracked with a session cookie and displayed just under the title bar. I somehow felt that was an important feature in the early 2000s, but that sort of navigation is better suited to browser history today.