RSSAmplifier

Blog

integralist

A personal blog about emotions and the human experience.

integralist.co.ukRSS feed ↗103 posts

Latest posts

Managing project tools with Go

There are multiple ways to deal with non-application dependencies (i.e. “tools” that your project needs). 

 go tool 

 As of Go 1.24 (Feb 2025) 

 To add a new tool: 

 go get -tool golang.org/x/lint/golint
go get -tool github.com/mgechev/revive@latest
 

 To run the tool: 

 go tool golint -h
go tool golang.org/x/lint/golint…

Manually install and auto-switch Golang versions

If you work on muliple Go projects, you’ll often find they require
different Go versions. So how do you handle switching between Go versions? 

 You can’t rely on your package manager as it might only provide the latest
version of Go (such as is the case when using Homebrew on macOS) or it might
not provide all prior Go versions (maybe only a subset). Then you have…

Go Concurrency Patterns

Goroutines 

 The go keyword is used to start a goroutine. 

 A goroutine is a lightweight, managed thread used by the Go runtime to run
functions concurrently. 

 Unlike OS threads, which have a fixed stack size (often around 1MB), goroutines
start with a very small stack, around 2KB, and can grow or shrink dynamically as
needed. This makes it possible to run…

Bitwise Operations in Go

In the below Go file we use bitwise operators to manipulate individual flags (on/off switches) in a single integer, where each bit position represents a different status. 

 First we’ll look at the code, and then we’ll explain how it works: 

 package main

import (
 "fmt"
 "strings"
)

// Define bit flags as constants, where each status is…

Programming at the edge with Fastly Compute

So you’ve heard about computing at the edge, and you’ve heard that Fastly 
let’s you run JavaScript, Go, Rust and any other language that compiles to
Wasm at the edge… well, let’s take a look and while we’re at it let’s try and
understand how caching works there too. 

 Getting started 

 OK, first thing you’re going to…

Go Typed Nil

The following code doesn’t do what you might expect: 

 package main

import "fmt"

func main() {
 var i *impl

 fmt.Println("i == nil:", i == nil)
 what(i)
}

type impl struct{}

func (i *impl) do() {}

func what(i interface{ do() }) {
 fmt.Println("i == nil:", i == nil)
}
 

 If you expected the what…

Continuous Integration and Deployment to multiple environments with Terraform Cloud and GitHub Actions

Summary 

 In this post I cover what CI/CD means and how you can achieve it across multiple
different environments (e.g. dev, stage, prod) using the GitHub Actions
platform. The infrastructure is managed using Terraform and the state is
coordinated using Terraform Cloud. 

 I detail specific issues I experienced while implementing CI/CD for a…

The Power of OpenAPI: Simplifying API Design and Documentation

Introduction 

 In the rapidly evolving landscape of software development, creating robust and user-friendly APIs has become essential. One tool that has gained immense popularity for designing, documenting, and testing APIs is OpenAPI. 

 In this comprehensive guide, we’ll explore why OpenAPI is so important, how to write an OpenAPI document, and the key sections you need to…

Beginner's guide to creating a Terraform Provider

You have an API and you want your customers to be able to use that API via Terraform . In this post I’m going to explain how you can write your own Terraform provider to enable your customers to integrate your API into their “infrastructure as code” pipeline. 

 You don’t need an API to be able to follow along, nor am I going to make you write one as part of the…

Rust Smart Pointers

Summary &#xA;&#xA; The five types covered: Box , Rc , Arc , Cell , RefCell . &#xA;&#xA; ℹ️ INFO Not discussed are Mutex<T> and RwLock<T> , &#xA;which provide mutual-exclusion. &#xA;&#xA; &#xA; Box<T> : A pointer type for heap allocation. &#xA; Rc<T> : Single-threaded &lsquo;multiple owners&rsquo; pointer (immutable). &#xA; Arc<T> : Thread-safe &lsquo;multiple owners&rsquo; pointer (immutable).…

New Laptop Configuration (Second Edition)

Introduction &#xA;&#xA; This is the second edition to &ldquo;New Laptop Configuration&rdquo; . &#xA;&#xA; Backup &#xA;&#xA; When moving laptops I will temporarily backup my existing GPG and SSH keys (encrypted) to an external data storage device. &#xA;&#xA; We start by making a directory to hold the files temporarily: &#xA;&#xA; mkdir /tmp/keys&#xA; &#xA;&#xA; Next I start backing up my GPG data:…

Manage multiple versions of the Go programming language

Installing Go &#xA;&#xA; All versions of Go are available to download here: https://go.dev/dl/ &#xA;&#xA; The installation directory will be: /usr/local/go . &#xA;&#xA; Once you have Go installed, you can then use the go command to either install go based tools/binaries or other versions of Go. &#xA;&#xA; 💡 TIP Additionally, you can automate the install via a terminal using the following shell…

Setting up Neovim for Rust and Go development

UPDATE November 2022 &#xA;&#xA; Not long after I wrote this post I had switched from VimScript to using Lua and also making large sets of changes and tweaks to my configuration. The source of truth is: &#xA;&#xA; https://github.com/integralist/nvim (which is a submodule within https://github.com/integralist/dotfiles ) &#xA;&#xA; This post is being kept for posterity, but ultimately I would…

Fix broken Vim Themes

I&rsquo;ve been around the houses on this problem long enough, and after many years of trying various tricks and having them fail I decided to document an actual working solution. &#xA;&#xA; &#xA; Install a terminal that has good colour support (e.g. Alacritty ) &#xA; Install a better Vim (i.e. Neovim ) † &#xA; &#xA;&#xA; ℹ️ INFO † This should still work with standard Vim, but actually Neovim has…

Developer Tools

I don&rsquo;t know who needs to hear this but: &#xA; I love my developer tools . &#xA;&#xA; Core &#xA;&#xA; &#xA; Package Manager : Homebrew &#xA; Terminal : Ghostty &#xA; Code Editor : Neovim &#xA; &#xA;&#xA; History &#xA;&#xA; &#xA; Used stock macOS Terminal.app with tmux &#xA;for 10+ years. &#xA; I tried iTerm2 ,&#xA; Kitty , Alacritty ,&#xA; WesTerm but none really fit well for me. &#xA;…

Go Style Guide

This is my own personal style guide for Go. &#xA;&#xA; Reference Materials &#xA;&#xA; The following reference materials are my &lsquo;go to&rsquo; whenever I&rsquo;m unsure of something (they&rsquo;re mostly official resources). &#xA;&#xA; &#xA; Project structure &#xA; Effective Go &#xA; Code Review Comments &#xA; What&rsquo;s in a name? &#xA; Commit messages &#xA; Comments &#xA; Slice Gotchas…

GitHub Actions

💬 CITE GitHub Actions makes it easy to automate all your software workflows, now with world-class CI/CD. Build, test, and deploy your code right from GitHub. &#xA;&#xA; I&rsquo;ve been using GitHub Actions a lot recently and I&rsquo;ve found it to be immensely flexible and feature rich. I think it&rsquo;s well worth your time learning how to run your CI/CD pipelines via GitHub Actions, and in…

Advanced Vim topics, tips and tricks

I see a lot of posts on Vim &lsquo;tips and tricks&rsquo; and decided I&rsquo;d have a go at putting together my own list of things that don&rsquo;t typically see the light of day, but are super powerful and useful to know about. &#xA;&#xA; ❗ IMPORTANT I want people to realise that they don&rsquo;t need super complex Vim configurations with lots of third-party plugins, and this entire post is…

Rust Ownership, Borrowing, and Lifetimes

I&rsquo;ve been learning Rust recently. This will probably be my third (lazy) attempt to learn the language. The reason I&rsquo;ve failed previously is simply because I had no reason to learn it. &#xA;&#xA; Other than the memory safety aspects, which I like a lot, I don&rsquo;t actually like the design of the language at all (but that&rsquo;s a conversation for another day). &#xA;&#xA; This time…

Reflection in Go

I&rsquo;m going to walk you through how to understand reflection in Go using the reflect package. We&rsquo;ll do this by looking at an open-source package I created called go-flags that utilizes reflection heavily . &#xA;&#xA; The use of reflection is often frowned upon because it side steps the &lsquo;compile time&rsquo; type safety we get in Go. So I&rsquo;ll also explain how we can still ensure…

Tips for Comparing Code Libraries

When writing software you will inevitably need to choose an external code library to assist you with some specific feature or behaviour. &#xA;&#xA; You&rsquo;re also likely to discover that there are many tools available that claim to solve the same problem. So how do you choose which one to use? &#xA;&#xA; You should carefully compare the value of each individual tool that is under consideration,…

Rate Limiting at the CDN Edge

What is Rate Limiting? &#xA;&#xA; Rate Limiting is a technique used to control the rate of requests received. &#xA;&#xA; It exists to help online services to stay up and running even when clients of the service are issuing lots of requests. &#xA;&#xA; Think of an API such as the GitHub API . If they didn&rsquo;t rate limit their clients, then it&rsquo;s very possible a single client could consume…

Git Internals

Introduction &#xA;&#xA; There are many version control systems, but git is undoubtedly the most popular, and regularly used, thanks to online social platforms such as GitHub and GitLab . &#xA;&#xA; Yet, it is a tool that is still vastly misunderstood and feared. In this post I aim to take a look at some of the internal moving parts of git, primarily what&rsquo;s inside the .git directory (inc the…

Python 101: Context Managers

Introduction &#xA;&#xA; In this post I wanted to discuss a relatively simple, but important topic: Context Managers. I want to cover the what, the why and the how. &#xA;&#xA; Summary &#xA;&#xA; &#xA; Content Managers abstract away &lsquo;clean-up&rsquo; logic. &#xA; Define a class with __enter__ / __exit__ methods. &#xA; The __enter__ method is similar to a try block. &#xA; The __exit__ method is…

Python 101: iterators, generators, coroutines

In this post I&rsquo;m going to be talking about what a generator is and how it compares to a coroutine, but to understand these two concepts (generators and coroutines) we&rsquo;ll need to take a step back and understand the underlying concept of an Iterator. &#xA;&#xA; Each section leads onto the next, so it&rsquo;s best to read this post in the order the sections are defined. Unless…

Understanding the purpose of tox.ini

Introduction &#xA;&#xA; I was confused by the Python tool tox for a long time, and was unsure what it was really used for considering lots of different Python packages appeared to rely on tox&rsquo;s configuration file (e.g. tox.ini ). &#xA;&#xA; In this post I&rsquo;m going to briefly explain what the tox tool is, and what a tox.ini configuration file looks like and why that configuration file…

Python Management and Project Dependencies

Introduction &#xA;&#xA; This blog post aims to demonstrate the most practical way to install multiple versions of Python, and of setting up &lsquo;virtual environments&rsquo; for macOS userso &#xA;&#xA; We&rsquo;ll also dig into how to manage our project dependencies (e.g. we&rsquo;ll be discussing the classic Pip and requirements.txt format) + our approach for avoiding newer tools such as Poetry…

Guide to Concurrency in Python with Asyncio

This is a quick guide to Python&rsquo;s asyncio module and is based on Python&#xA;version 3.8. &#xA;&#xA; Introduction &#xA;&#xA; So let&rsquo;s start by addressing the elephant in the room: there are many modules&#xA;provided by the Python standard library for handling&#xA;asynchronous/concurrent/multiprocess code&hellip; &#xA;&#xA; &#xA; _thread &#xA; threading &#xA; multiprocessing &#xA;…

Go Arrays and Slices

I found myself recently trying to recall specific details of how slices work when needing to do something that meant I wanted to not mutate the underlying array data structure of the slice I was working with. &#xA;&#xA; Now the reason for why I wanted to do that isn&rsquo;t important. What&rsquo;s motivating this write-up is my want for a good reference document (not saying the official go blog…

Staying Anonymous

Privacy is becoming more and more important in our modern world. We&rsquo;re constantly tracked and having our movements sold to advertisers. &#xA;&#xA; Even more so our privacy becomes a necessity if we find ourselves doing things that could get us arrested (or even killed), such as being a journalist or a whistleblower. &#xA;&#xA; I am lucky enough to not suffer from such necessity, but wherever…

HTTP Caching Guide

Introduction &#xA;&#xA; Caching is hard. Let&rsquo;s try and understand it a little better. &#xA;&#xA; ℹ️ INFO some sections are purposefully brief. I&rsquo;m not aiming to be a specification document. &#xA;&#xA; Caching at multiple layers &#xA;&#xA; Caching can occur at both a &lsquo;client&rsquo; level and a &lsquo;cache proxy&rsquo; level. &#xA;&#xA; Consider the following request flow…

New Laptop Configuration

Introduction &#xA;&#xA; I&rsquo;m an engineer with a new laptop, which requires setting up with various&#xA;development tools and configuration. This post is my attempt to capture and&#xA;document my process for getting a new dev environment set-up. &#xA;&#xA; I used to try and automate a lot of this with bash scripts, but realised over&#xA;time that things go out of date quite quickly (e.g. OS…

Multiple Branches in Git

Introduction &#xA;&#xA; There are times where you might be working from a particular git branch and need to quickly jump over to a different branch to do some urgent work. &#xA;&#xA; Typically you would need to first git stash anything you were working on (as it&rsquo;s unlikely to be in a state where it can be committed), and then you&rsquo;d have to leave your current branch to create a new…

Algorithms in Python

In this post I&rsquo;ll be demonstrating a few common algorithms using the Python language. I&rsquo;m only covering a very small subset of popular algorithms because otherwise this would become a long and diluted list. &#xA;&#xA; Instead I&rsquo;m going to focus specifically on algorithms that I find useful and are important to know and understand: &#xA;&#xA; &#xA; Sorting &#xA;&#xA; &#xA; Merge…

Remote Working

Introduction &#xA;&#xA; I was asked on twitter recently about how I am able to be successful and impactful at an organization as a remote worker. What follows is a run down of how I work remotely, and how it has changed over the last seven years. &#xA;&#xA; This is not a &ldquo;rules for how you should do remote working&rdquo; but more so a single perspective on the problem of remote working and…

Mocking in Python

Introduction &#xA;&#xA; Mocking resources when writing tests in Python can be confusing if you&rsquo;re unfamiliar with doing such things. In this post I am going to cover various aspects of mocking code, which will hopefully be a useful resource for those who are a bit stuck. &#xA;&#xA; ℹ️ INFO in the code examples I&rsquo;m using pytest , but for the most part that shouldn&rsquo;t matter.…

Calculating Big-O

Introduction &#xA;&#xA; This post includes a condensed version of the information gleened from the excellent interactivepython.org section on algorithm analysis. I strongly recommend you read that if you require more detailed information. &#xA;&#xA; The purpose of this post is simply to restructure and simplify the principles offered so I can use it as a quick reference for future practice.…

Algorithmic Complexity in Python

Introduction &#xA;&#xA; In this post we&rsquo;re going to review some different algorithmic time complexities. Let me begin by clarifying, when I say &lsquo;algorithm&rsquo; I mean: &lsquo;logic written in code&rsquo; and when I say &lsquo;operation&rsquo; I mean: &lsquo;a unit of code was evaluated&rsquo;, and that operation could be something as simple as x + y . &#xA;&#xA; Asymptotic Analysis…

Data Types and Data Structures

In this post we will be looking briefly at, and at a high-level, the various data types and data structures used in designing software systems, and from which specific types of algorithms can subsequently be built upon and optimized for. &#xA;&#xA; There are many data structures, and even the ones that are covered here have many nuances that make it impossible to cover every possible detail. But…

Python Code Design and Dependency Management

Introduction &#xA;&#xA; This post is going to cover a few tools and features I plan on using when writing Python code in 2019. &#xA;&#xA; 💡 TIP † read my post &ldquo; Python Management and Project Dependencies &rdquo;. &#xA;&#xA; Type Hints and Static Analysis &#xA;&#xA; Some languages are weakly typed (JavaScript), some are strongly typed (Python) and some are statically typed (Go, Rust). Being…

Modern JavaScript: Webpack and Babel

Introduction &#xA;&#xA; This post will explain how to set-up and configure the various tooling necessary in order to be able to write cross-compatible modern (ES2015+) JavaScript code. &#xA;&#xA; 💡 TIP if you&rsquo;re unsure of what &lsquo;modern&rsquo; JavaScript looks like, then I&rsquo;ll refer you to these compatibility tables . &#xA;&#xA; The tools we&rsquo;ll be using: &#xA;&#xA; &#xA;…

Engineer to Manager

You&rsquo;re a software engineer with many years of technical experience, and you&rsquo;ve decided you want to kickstart the process of working towards becoming an &lsquo;Engineering Manager&rsquo;. &#xA;&#xA; So what do you need to know? Let&rsquo;s discuss&hellip; &#xA;&#xA; Roles &#xA;&#xA; As a software engineer you have a few different paths available to you for career progression: &#xA;&#xA;…

Interview Techniques

Introduction &#xA;&#xA; This post will explain a little bit about a particular type of interview: an architecture interview. It&rsquo;ll breakdown what it is, why using whiteboards isn&rsquo;t necessarily a bad thing to use in an interview context, as well as understanding a bit about what it is we&rsquo;re looking for from a particular candidate (in this post the information will be related to…

Post Mortems

💡 TIP for those short on time: here&rsquo;s the Post-Mortem Template &#xA;&#xA; What is a post-mortem? &#xA;&#xA; When you have a service outage, or any form of unexpected service disruption, you first resolve the issue and then proceed to discuss what happened, why and how. &#xA;&#xA; The process of discussion is referred to as a &lsquo;post-mortem&rsquo;. &#xA;&#xA; How do we make post-mortems…

OpsBot: Operations Slackbot

So this post is a long time coming. It has been pushed to the forefront by the fact that BuzzFeed recently held its annual &lsquo;Hack Week&rsquo;, and riding on the wind of a massive success I&rsquo;ve had with my hack project this past week&hellip; &#xA;&#xA; 💬 CITE &ldquo;Mark has casually saved the company $60k a year by letting us break away from a commercial dependency without losing any…

Thinking about Interfaces in Go

This post is going to explain the importance of interfaces, and the concept of programming to abstractions (using the Go programming language), by way of a simple example. &#xA;&#xA; While treading what might seem like familiar ground to some readers, this is a fundamental skill to understand because it enables you to design more flexible and maintable services. &#xA;&#xA; Interfaces in Go…

Multigrain Services

It seems most people are either talking about &ldquo;monolith applications&rdquo; or &ldquo;micro services&rdquo;. But recently I&rsquo;ve noticed yet another new buzzword bubbling up across the internet: &ldquo;mini services&rdquo;. &#xA;&#xA; It&rsquo;s worth mentioning that this isn&rsquo;t a post about which pattern is the most appropriate to use, as they&rsquo;re all appropriate to use, when…

Authentication with AWS Cognito

Introduction &#xA;&#xA; In this post I would like to introduce you to the AWS&#xA;Cognito service, and to explain its various&#xA;moving pieces and how they fit together. &#xA;&#xA; If you&rsquo;re interested in a very high-level view of what I was working on, then&#xA; this architecture diagram should give you the basic&#xA;idea. &#xA;&#xA; Effectively I co-designed and implemented a new…

A Guide to Effective 1:1 Meetings

What is a 1:1 ? &#xA;&#xA; A 1:1 (&ldquo;one to one&rdquo;) is a meeting between a manager and a &lsquo;report&rsquo;. &#xA;&#xA; What is a &lsquo;report&rsquo; ? &#xA;&#xA; A &lsquo;report&rsquo; is a member of staff of which the manager is responsible for. Specifically the manager is responsible for that person&rsquo;s happiness at the company and their career progression. &#xA;&#xA; How…

Project Management in Five Minutes

💡 TIP Related information: Project Planning . &#xA;Includes specific documents needed and also an example matrix&#xA;spreadsheet . &#xA;&#xA; Introduction &#xA;&#xA; If you&rsquo;re a technical lead (aka engineering lead, lead developer, etc), then there comes a time where you&rsquo;ll be put in charge of a project. &#xA;&#xA; You may also already be quite familiar with the process (read: red…