RSSAmplifier

Blog

Will Richardson

Computers, photography, and related matters.

willhbr.netRSS feed ↗20 posts

Latest posts

Type-Checking SQL Queries With Crystal Macros

The aim of the game here is to use as few macros as possible. I could just have one macro that parses an SQL query, but the fun here is to use the Crystal type system to check the query for us, similar to how I used the type system to implement dependency injection . I’ll be avoiding macros, but I’ll be using macro methods heavily, as they let you introspect on the types of variables. The API…

Backups With Restic

Every year on March 31st I have a sense of minor guilt, anxiety, and sheepishness. It’s World Backup Day and I don’t have good backups. The purpose of the day is to serve as a reminder to check that your backup system is functioning, that you can restore from your backups, and that all your data is included in the backup system. It’s not like I don’t have backups of my data, it’s just they’re not…

All Buttons Could Be Action Buttons

My iPhone 15 Pro has four physical buttons. The two volume buttons, the sleep/wake button, and the Action Button, that replaced the silence switch in the iPhone 15 generation above the volume buttons. Since I never took my phone out of silent mode, I was a big fan of the swap to the action button, which I have used as a camera shortcut since getting the phone. The iPhone 15 Pro was the only phone…

Language Models for Programming

The other day I wrote about the new tools that developers are using to get work done. Another topic I see discussed is different language models as part of the development process. I like to use and think about different programming languages. So I thought it would be interesting to go through some of the neat features in different languages that I’ve used, and how that changes your mental model…

From Vim to Helix

The last year seems to have been the biggest change in developer tools ever. If you’re reading the discourse you can’t go more than 5 minutes without seeing someone talking about their new development environment, new ways of editing code, and the huge productivity gains the tools they use are affording them. A recurring theme of these posts is that anyone who doesn’t pick up the very latest tools…

Language Servers in Containers

The purpose of my container-management tool pod is to make it easier to do development and deployment using containers, specifically with Podman. Read more about why I wrote it and what it does . Recently I’ve been trying out the Helix editor in place of Vim (more on that once I’ve been using it some more). The standout feature of Helix for me is first-class Language Server Protocol (LSP) support.…

Async Programming Is Just @Inject Time

All I really wanted to do was learn a little bit more about different models for error handling, but then I kept seeing “effects” and “effect systems” mentioned, and after reading about Koka and Effekt I think I’ve been converted. I want effects now. So here’s what I wished I could have read a few weeks ago. To start with, you need to remember that functions don’t exist. They’re made up. They’re a…

Ruby Scripting Utilities

I think I’m pretty good at shell scripting: I quote my variables, I know the difference between $@ and $* , I know about checking that variables are set with the ? suffix. I’ve spent a lot of time messing around with shell scripts, but I always feel like the script that I write is almost always dictated by what’s easy or possible to do in the shell. The main reason I did this was for a…

Building Dependency Injection with Crystal Macros

When I first came across dependency injection I was a sceptic. Surely we could just create objects the normal way instead of worrying about modules and bindings? Eventually though I realised how you’re actually just generating the boilerplate code that you’d need to pass the dependencies around manually, and writing that code yourself is a huge waste of time. I then wondered how hard it would be…

Why Containers?

There seems to be a recurring sentiment that pops up every now and again on Mastodon: “this project looks interesting, but the installation instructions say to use Docker, so I’m not interested anymore”. Now I totally understand the sentiment. If I came across a project and the instructions said to install it I’d need Nix , I would also do a quick 180. However, I’ve been using containers for…

Upgrading to Jekyll 4.4

This all started as I was getting confused about how syntax highlighting broke on my website, and my confusion as to what GitHub could have possibly done to break it. As it turns out they didn’t do anything, but the idea of moving to an actions-based website seemed less daunting. Originally GitHub Pages only supported one way of building a website, which was with Jekyll and a fixed set of plugins.…

Help I'm Stuck in a Photo Management Factory and I Can't Get Out

I feel obliged to include a photo, since this post is about photography. In 2019 I got into this whole photography business and used my iPad for photo editing in Photomator . This went pretty well until I started to shoot raw photos instead of JPEGs, and quickly ran into the meagre 250GB internal storage limit of the iPad. At the time I wrote about how limitations of the iPad make using it as an…

My Website Broke and You Won't Believe Why

When I published my last post I did my usual quick check on the real website, just to make sure it had published, and find the obligatory mistakes that only appear once it’s public. I quickly noticed that the XML code block didn’t have any syntax highlighting, just a plain unstyled <code> section. My site uses Rouge for syntax highlighting, which I think is the default for GitHub Pages sites that…

Add a Signature to Your Website

Nothing says “sophisticated and refined” like putting your signature at the bottom of your blog posts. However if you don’t do it right, you might end up with pixellated garbage, and that’s not refined at all. I’ve just done this (have a look at the bottom of this post) and there are a few tricks to get this working nicely. First thing is to get a signature. I didn’t want to use the unintelligable…

Programming With tmux for Beginners

Last week I gave a short talk on my adventures doing weird things with tmux. It went well, so I decided to record the slides with voiceover: It’s very high level, the code snippets are simplified for readability, and I don’t go into much detail on the process of working this all out, but I think it’s a nice introduction to the whole project. Of course you can read more about: Writing the Brainfuck…

Why Do Containers on Alpine Forget My Tailnet?

Earlier this year I wrote about how I’d swapped my home “production” server over to use Alpine Linux . Overall it’s gone well, I swapped the VPS that runs NZ Topomap of the Day ( read more about that ) to Alpine in June, and my script that sets up an Alpine install has made this straightforward. This weekend I swapped the hardware that I was using for the home “production” server to be a little…

More Commands in the JJ Toolbox

It’s been almost two years since I started using JJ regularly, and almost 18 months since I wrote some tips on how to use it . That post was really just the result of me reading the docs (which at the time were much sparser than they are now) and working out how to manage remotes properly. That was a long time ago, and I’ve had more time to settle into a rhythm and realise what works for me and…

Hot ECR Reloading in Your Area

Everyone knows that ECR—the templating system built into the Crystal standard library—works at compile time, which makes it as efficient as writing to an IO manually. This is unlike other templating formats (usually in interpreted languages) like ERB (embedded Ruby) that parse and evaluate the template at runtime. This has the advantage of being able to change the template contents without…

HTML-Safe ECR Templates

After writing my last post I wondered if I could improve ECR to avoid the need to call HTML.escape explicitly when adding values to the template. This turned out to be much easier than I expected. ECR (Embedded Crystal) is the compile-time templating system included in the Crystal standard library . The syntax is based on ERB (Embedded Ruby), but the template is processed at compile time in a…

Tracking Down Progressively-Enhanceable APIs

Something that I’m a big fan of is APIs that can be easily modified and hacked with . It’s frustrating to have to write fully production-ready code when you actually want to just prototype something, and so I’m happy when there’s an API that it’s easy to use, which then progresses into a more full-featured API. In Crystal an example of this is File.read . If you want to get the entire contents of…