Plurrrr

week 48, 2022

Functional table-driven tests in Go

There are numerous blog posts about table-driven tests in Go. In this blog post, I want to show a technique we have recently started using in our unit tests. I saw it the first time when my friend Matt Layher introduced it to me at work, and since then, I gradually started using it in places where it's suitable. This technique comes especially handy for large structs with multiple nested fields.

Source: Functional table-driven tests in Go, an article by Fatih Arslan.

Stone of Farewell

Following a brutal civil war, Osten Ard has been crushed under the rule of the two villainous High Kings. A single hope remains: if the rebels can find the three swords of legend - Memory, Sorrow and Thorn - they might be able to bring the Storm King and evil King Elias down.

Once but a humble kitchen-boy, Simon is now Simon Snowlock, dragonslayer and bearer of the mythical sword Thorn. But Simon is more alone than ever before: his friends have been imprisoned and his liege lord, Prince Josua, has been exiled. And the Storm King may also be in possession of one of the swords...

A single chance remains: if Simon can deliver Thorn to Joshua and lead his followers to the Stone of Farewell, the rebels may be able to muster the forces necessary to rise up against Elias and the Storm King. But no one knows where the Stone of Farewell is. Or, indeed, what it is...

In the evening I started in Stone of Farewell, Memory, Sorrow & Thorn Book 2 by Tad Williams.

Solving Rock-Paper-Scissors in Type-level Haskell

Let’s solve part 1 of today’s Advent of Code challenge “Rock Paper Scissors” in type-level Haskell.

Instead of using term-level programming as we usually do, we make Haskell’s type system do the work of calculating the solution. So the solution is be known right after we compile the program, and we do not even need to run the compiled program.

Source: Solving Rock-Paper-Scissors in Type-level Haskell, an article by Abhinav Sarkar.

The Audacity of Piping Curl to Bash

It seems more and more common, at least in the self-hosted community, to provide two methods of installations: Docker or a shell script installer. It seems that many new projects don’t even bother with a native package manager, such as dpkg or rpm, which makes me reluctant to use them.

Many talk about the security implications of piping curl into bash but it has been talked about enough and the solution is usually splitting the process into two steps, fetching the file and then running it. But what really makes me avoid running those scripts is how complicated they are and their audacity of how they treat my system.

Source: The Audacity of Piping Curl to Bash.

The Essential Django Deployment Guide

he world of Django deployment is huge and complicated, but that doesn't mean it has to be for you. In this guide we'll cover the big picture decisions you'll make when deploying your Django application—from choosing a hosting strategy to the nitty-gritty details of where to store your passwords. Hopefully after reading it you'll walk away with a better understanding of how to make these choices, and clear path forwards for your new little corner of the Internet.

Source: The Essential Django Deployment Guide, an article by Cory Zue.

Jurassic World: Dominion (2022)

Four years after the destruction of Isla Nublar, Biosyn operatives attempt to track down Maisie Lockwood, while Dr Ellie Sattler investigates a genetically engineered swarm of giant insects.

In the evening Alice and I watched Jurassic World: Dominion. I think the movie was OK, so I give it a 6 out of 10.

NixOS: On Raspberry Pi 3B

Even a decommissioned Raspberry Pi could have some utility running on the home network. With some time to spare, last weekend seemed like the weekend for building RPi images. To get going quickly it’s possible to download pre-built NixOS SD card images from Hydra. Guaranteed to save me a lot of time, that was naturally not the path I chose. I wanted to build the image and machine configuration myself, because why not1.

Source: NixOS: On Raspberry Pi 3B, an article by Martin Myrseth.

Tutorial: forall in Haskell

forall is something called "type quantifier", and it gives extra meaning to polymorphic type signatures (e.g. :: a, :: a -> b, :: a -> Int, ...).

While normaly forall plays a role of the "universal quantifier", it can also play a role of the "existential quantifier" (depends on the situation).

What does all this mean and how can forall be used in Haskell? Read on to find out!

Source: Tutorial: forall in Haskell, an article by Martin Sosic.

I Came By (2022)

Follows a young graffiti artist who discovers a shocking secret that would put him and the ones closest to him in danger.

In the evening Alice, Esme, and I watched I Came By. I liked the movie and give it a 7 out of 10.

Why I am learning category theory

Category theory is a domain of mathematics that exerts a strange influence over programmers. One thing that can be said for sure about category theory is that it is highly abstract, and its relationship to software engineering is not immediately obvious. I consider myself to be more on the pragmatic side of software engineering, so why did I set out to learn category theory beyond the few concepts popularized by functional programming?

Source: Why I am learning category theory, an article by Manuel Odendahl.

Minimum Viable Git for Trunk-based Development

To get the most out of Git, you must use it the least amount possible when it comes to trunk-based development. Limit the commands you use, keep your feature branch up to date properly, and standardize usage as a team. Individually, you may enjoy the freedom to do whatever you want. But as a team, the price for freedom is paid for in friction.

Source: Minimum Viable Git for Trunk-based Development, an article by Eli Schleifer.

The Best Go framework: no framework?

While writing this blog and leading Go teams for a couple of years, the most common question I heard from beginners was “What framework should I use?”. One of the worst things you can do in Go is follow an approach from other programming languages.

Other languages have established, “default” frameworks. Java has Spring, Python has Django and Flask, Ruby has Rails, C# has ASP.NET, Node has Express, and PHP has Symfony and Laravel. Go is different: there is no default framework.

What’s even more interesting, many suggest you shouldn’t use a framework at all. Are they insane?

Source: The Best Go framework: no framework?, an article by Robert Laszczak.

Two-factor authentication (2FA) in Perl with TOTP algorithm

Two-factor authentication is now essential for a lot of web sites, as it ensures that - even if someone gets your access credentials - he/she cannot login, because a token from your mobile phone is required. Therefor, the hacker should also have access to your phone and to the code to unlock it, which is highly unlikely.

Source: Two-factor authentication (2FA) in Perl with TOTP algorithm (Microsoft or Google Authenticator or others), an article by Michele Beltrame.

A pragmatic approach to shell completion

Now there is a new generation of shells that allow passing structured data through a pipe. This is a major thing and well worth its own article.

One of these is Elvish, a shell written in Go that runs on Linux, BSDs, macOS, and Windows. It is also the shell that managed to make me switch again.

But let's focus on another of its features: filtering of entries during menu completion. And not just the values but the descriptions as well. You will understand later why this is important.

Elvish only has a few completions though so I am back at the same problem I had with Fish. This time however I've got some tools under my belt.

So let's change that...

Source: A pragmatic approach to shell completion.

Color Formats in CSS

CSS has a whole slew of different color formats: hex codes, rgb(), hsl(), lch(), the list goes on!

Which one should we use? It might seem like an inconsequential decision, but there are some pretty important differences between them. And, honestly, I think most of us are prioritizing the wrong things. 😅

Source: Color Formats in CSS - hex, rgb, hsl, lab, an article by Joshua Comeau.