Adam Kirk

Adam Kirk
Shower thoughts on programming
TwitterGithubStack OverflowLinkedIn

Running terraform with providers on Apple Silicon

November 25, 2021

If you use custom providers with Terraform, many of the probably won’t work on Apple Silicon. You can work around this using docker. I created a file in my terraform directory called with this in it: Now just use this script in place of the old command like so: It’s probably best to migrate to Terraform Cloud at this point. However, if you’re already on Apple Silicon, the above advice will still…

Loose Coupling

March 29, 2021

Admittedly, I’m not very good at thinking in the abstract, so a lot of terms in our software development culture are hard for me to internalize. One of those terms is “Loose Coupling”. I thought “well… if I need to reference something, I need to! How can I reduce the coupling in my application without reducing the requirements!?” I had an epiphany the other day where I realized that coupling is…

Simple Elixir Decimal Interpreter

March 26, 2021

I needed a way to allow a user to provide an equation that uses variables and then compute that equation with the variables. Elixir to the rescue! Elixir has this awesome Code module where you can pass it a string and it will give you back an AST. Most of the values in these equations will be money, so I needed a way to interpret and compute the equations with Elixir’s Decimal library so that…

Make your monolith last

December 09, 2020

In Martin Fowler’s essay “Microservice Premium” he makes the argument that as the complexity of a system increases, the productivity of a monolith architecture starts out as very productive, but decreases in productivity faster than a service oriented architecture (SOA), until a SOA is more productive than the monolith. Here’s a chart he provides to illustrate: But, come on, when you add all the…

Simple as possible as long as possible

December 04, 2020

The value of simplicity is underated in software development. Recently, a buddy of mine Parker Wightman and I were brainstorming how to bundle some simple javascript for a mobile app he was working on. He could have gone full webpack and spent all day configuring an industry standard js app, but instead we did this in : Boom, it’s done. esbuild is super simple by itself, but the point is we chose…

Trustless voting WIP

December 03, 2020

NOTE: This is a work in progress. I’ve learned since that to make this truly convincing, it has to protect anonimity even better than mail in voting (which doesn’t protect it very much). Our current voting system has the following problems: It’s slow, things have to be counted by hand. Counting by hand makes it error prone. There is always some margin of error. A manual process is easy to attack…

New tech, old problems

December 01, 2020

I did a small survey of some startups that have popped up in the last 20 years. Almost none of them are solving new problems. They are leveraging new tech to solve age old problems. Transportation, hospitality, communication. In fact 90% of them are applications of SOFTWARE to age old problems. There has been an exponential explosion of innovation in the last 40 years and it all points to 2 things…

Crud all the things

October 05, 2020

My argument is simple: All interactions with a resource should be done using the following interface: Anything more specific than this is overly complex, hard to adapt, hard to extend and very hard to understand. Here’s some examples of violations I’ve seen in the wild and we can compare: A graphql endpoint called vs Using the first strategy, we have to include a ton of boilerplate to handle…

Fast feedback pyramid

July 27, 2020

I wrote before about the importance of fast feedback loops and the 5 categories of bugs and today I thought about how this could be represented as a pyramid, much like the Test Pyramid. Toward the bottom are the mistakes we make as programmers most frequently. They are also typically the fastest to catch and correct. Syntax errors happen as soon as you save the file and try to build. It’s even…

Model the real world

July 21, 2020

Requirements creep toward the real world because users live in the real world. Software starts off supporting a subset of what all potential users need. As you expand your market, you add features that support more and more use cases. Your application’s data model more and more accurately represents the real world. If the requirements are to let users post a house for rent, we create a user…

How to handle errors

July 19, 2020

Everything useful a program does can be described as a “side-effect.” A purely functional language that produces no side-effects is also purely and utterly useless. It is these side effects where things go wrong. Any useful operation on a resource your program tries to perform, even if your code has no bugs, could fail for the following reasons that are completely out of your control: The resource…

The 5 categories of bugs

July 16, 2020

Syntax errors Your parser won’t make it past this no matter what language. You get immediate feedback if you haven’t stated something correctly. Linking, reference & type errors Where your code references other code incorrectly. A compiled language, with a linker, won’t compile on this. Javascript, and most dynamic languages, will run just fine and only crash when it tries to execute that…

Learning a new language is hard

July 15, 2020

I doubt many, if any, remember learning their first spoken language. But I bet most remember the frustration of learning a new language. You think about what you want to say, translate it word by word in your head and then say it. It’s slow and tedious. But, if the person doesn’t speak your language, you have to speak their language. I also bet that most people remember learning their first…

The importance of factories

July 04, 2020

I think languages and frameworks should be batteries included. Or, if they are taking a hard stance on minimalism, “blessed” packages for doing all the basic tasks like testing and parsing JSON. One of the things I think languages should have first class support for is factories. We all need to generate example data for testing and seeding. Any time you define a type, you should be able to call a…

Organize by feature not by function

July 03, 2020

Most the software projects I’ve worked on organized code around what they do. All the controllers together, all views together, etc. The directory structure usually looks like this: What? When was the last time you were working on a bunch of controllers across features? Way more often, we work across all the functions of a single feature. Instead, organize your project around features, like this…

Elixir TDD in VSCode

July 01, 2020

Set up a task to run on save that runs your tests in Elixir

Fast feedback loops

July 01, 2020

If you’re a software company, two things count: moving faster and having less bugs than all your competitors. As software engineers, we rarely know if our code is correct without running it. On one extreme, your loops are big where you write code in large chunks and then test the app in the browser. Maybe you push giant commits to CI and (in a typical org) wait 15m for your CI to run to see if…

Whats the fastest way to look up an index in Elixir?

April 15, 2020

Lets create a long list of a million items and look up the 500,000th item Here we can see that looking up an index in a linked list is very slow compared to looking up an index in a map or tuple: So, which is faster? A tuple or a map? A map keyed by index is even faster

Hungarian algorithm in Elixir

January 18, 2020

The Hungarian (also called Munkres) is an assignment algorithm that optimizes for the lowerst total cost. For example, if 5 painters need to be assigned to 5 jobs, each having a cost (driving time + paint cost + time cost), this algorithm will find the optimal assignment with the lowest total cost. One use case of this algorithm is comparing sets of drawings. If set A has 10 drawings and set B has…

Small differences in a wall of text

September 20, 2018

We’ve all ran that test that failed and it dumped two walls of text on you, one as the expected and the other as the reality. Your job is to figure out how the two walls of text are different. An example is testing the content of an email body. Well, I made a helper in Elixir that makes this way easier. It will only print a padded excerpt of the part that is actually different and even show you…

Spectre

January 09, 2018

I spent quite a while trying to understand the Spectre vulnerability. Here’s my attempt to explain it: Let’s say you create an array in javascript with length 4 and in it. And lets say it ends up next to a sensative password in memory belonging to your password manager app. The bytes are mine, I have access to them. If I try to access past it: it will return . In other languages, like C, it’ll…