Never miss a beat

Join my newsletter.

The Archives

Golang: What is a receiver function?

Published: 6/30/2019

Classes aren’t really a thing in go, so you cant have instance methods ( like Java or similar ), however, you may have noticed some functions in Go that appear to be instance methods. These are Go’s receiver functions . The way they work is quite simple. If you have a struct like so: You could write a function that takes the struct in as a parameter. For example: Go’s receiver function However, Go gives us the ability to specify that getDatabaseRoot is a function that belongs to that Struct…

Generating HTML from a List in Elm

Published: 6/27/2019

Elm is a fantastic language for building web applications. It provides a rich DSL for writing HTML that functions in a similar way to JSX (but still quite different). Overall, I enjoy writing it, however, I often forget how to generate HTML from a list of data in Elm. Indeed, the problem is not that difficult, and once you approach it from a functional mindset, it’s easy to see how it works. A simple, yet somewhat contrived example, can be found below: You’ll notice a couple of things: Our Model…

Prompt the user for a rune at the terminal in Go

Published: 6/13/2019

I’ve been spending a lot of my spare time working on a Go project called Deckard . It’s a command line interface (or CLI) for handling database schema changes. Recently, I found myself wanting to prompt the user for a rune before running a command in that CLI. Why would I do this? Deckard handles schema changes via the migrations pattern . This consists of having an up migration and a down migration. The up migration might be to add a new table or alter a column, while a down migration…

Your application should not be responsible for Database Migrations.

Published: 6/9/2019

Classic database/schema migration patterns are a nightmare for modern systems. As Software Engineers push for a more distributed ecosystem, one is tempted to ask: “Why should the code that manages one system, live with the application code of another system?” “But Brad, this is really convenient”. I agree that it is really convenient when you’re working with a monolithic system that runs on one server. However, you start to run into issues regarding responsibility when you encounter scalability…

List Processes by Memory Usage in Linux

Published: 5/9/2019

I recently was running into an issue where a Systemd service was crashing due to an out of memory error. I was pretty sure that my project wasn’t taking up too much memory, but I wasn’t certain what was. Thankfully, with the use of some command-line wizardry, I was able to find out that Hyper (the terminal app) was using almost 3gb of memory! We have two commands here, each with their own man page should you want to learn more. The first command is ps which displays information about all…

What Is Gradle Scan?

Published: 4/17/2019

A Gradle scan is a build scan that provides insights into how your build ran and why it did what it did. Once you’ve generated a scan, you can share that with other members of your team (or anyone who may help diagnose issues) via a URL. Here’s a sample scan ! Creating a Gradle Scan Creating a Gradle scan is extremely easy! In your existing gradle project simply run ./gradlew build --scan or gradle build --scan if you’re not using the gradle wrapper. You’ll be prompted to accept the Gradle…