Austin Hanson

Read this first

Using() block hell in C#

So the other day I was working on transforming streams for an encryption layer for work. I ended up having some code that looked similar to this:

public async Task SendAsync(byte[] data, Delegate next)
{
    using (var stream = ...)
    {
        using (var encryptStream = ...)
        {
            using (var encodeStream = ...)
            {
                using (var reader = ...)
                {
                    await next(...);
                }
            }
        }
    }
}


public async Task RecieveAsync(byte[] data, Delegate next)
{
    using (var stream = ...)
    {
        using (var decodeStream = ...)
        {
            using (var decryptStream = ...)
            {
                using (var reader = ...)
                {
                    await next(...);
                }
            }
        }
    }
}

Which doesn’t look very great! There’s a nice solution

Continue reading →


Page Up & Page Down with Kilo Editor

I’ve recently started going through this brilliant article on creating your own text editor (read: nano/pico clone). If you’ve never built one this article breaks it down into easy to follow chunks.

If you do go through it, you might notice the same thing I did. Page Up and Page Down doesn’t seem to work right (in Mac OS’ Terminal.app).

If you’re also like me, you might end up googling why those keys don’t work right. Let me break it down for you:

  1. Yes, Terminal.app is capturing the keys
  2. Yes, you can hold Shift while pressing Page Up or Page Down
  3. Page Up and Page Down works in vim

Wait, what? How does it work in vim? Is it actually Terminal.app or is kilo not actually entering the elusive “raw mode”?

Alternate Screen

If you google “terminfo alternate screen” you’ll figure out that terminals have a feature allowing programs to switch to, you guessed it, an alternate screen. This is how vim and

Continue reading →


VSCode, GDB, and Debugging an OS

I’ve been spending some time going through Philipp Oppermann’s amazing blog series, Writing an OS in Rust. Digging into operating systems has been on my todo list for years now and I couldn’t pass up the opportunity when I ran across this series on Hacker News.

Phillip has done a wonderful job in his posts and they’re extremely easy to follow. Unfortunately for me, though, he’s doing his development via Linux so some of the instructions aren’t one-to-one. For instance, cross-compiling libcore for x86-64 on Darwin doesn’t really work and likely won’t for some time. That’s ok though, Vagrant to the rescue.

After you have vagrant up and running, you can drop into ssh (vagrant ssh) and follow along with all of the posts.

If you know me, I really like VSCode. I was a huge fan of Sublime Text because of multi-cursors, and VSCode seems better in almost every way. My development environment

Continue reading →


Python, Files, and Databases

 What’s a Database?

A database is an organized collection of data 1. Data is stored on disk and in memory in a manner that maximizes reading data in complex ways.

 Why a Database?

Databases are extremely good at complex queries. They also excel at managing concurrency, data integrity and redundancy.

 Why Not a Database?

Storing data on a file (referred to as a flat file) is fine. In fact in some situations, storing data in a flat file is better that using a database. In others it’s worse. Flat files shouldn’t be considered verboten but rather just another tool in your tool chest. You wouldn’t use a hammer to tighten a bolt, would you?

Let’s look at a couple examples:

Example 1
Volker is writing a program that interacts with hardware via a serial port. He wants to be able to configure the port and communication settings without having to change his program.

This is a great

Continue reading →


Consistency in Python Development

 Consistency

Consistency is important. Make sure that what you think you’re building is actually what you’re building. If you’re developing and testing in a Window’s environment but are intending to deploy to a Linux environment you’re going to get unexpected results. If you’re using Python 2.7 on your development machine and Python 3 on your production environment you’re not going to have a good day. If you’re using different package and library versions on your development and production environments you’re likely in for trouble.

 Development and Target Platforms

Your development platform is the environment you’re writing and debugging your code in. This might be a Windows machine or it might be a Raspberry Pi that you SSH into.

The target platform is the environment your code is intended to run on when it’s finished often referring to as in production. This might be an Amazon EC2

Continue reading →


Remote Accessing HomeBrew’d MySQL on MacOS

I’ve recently been proof of concepting a new idea for work. It involves local and external access to MySQL servers. While transitioning from local development to a Vagrant VM I discovered the VM couldn’t access my host local MySQL server.

Googling turned up some obvious answers, find my.cnf and remove bind_address = 127.0.0.1. I had installed MySQL using HomeBrew which installed MySQL to /usr/local/Cellar/mysql/5.7.10. My my.cnf configuration file was located in support_files within this directory. Much to my dismay there was no bind_address = 127.0.0.1.

Running sudo lsof -i -n -P | grep mysql within the shell told me MySQL was indeed binding to 127.0.0.1 despite the configuration file. Executing ps aux | grep -i mysqld was more enlightening, telling me the daemon was being passed the bind_address argument directly. This led me to the DBA Exchange post giving me what I needed:

  1. Edit /

Continue reading →


Slinging Mud: “Graceful” reboots in a Go world

I participated in MUDJAM on Itch.io last year around this time, putting together a very simple, low feature deliverable, BerkMud. If the title doesn’t tell you, it was How to Train Your Dragon themed. It wasn’t my first foray into building a mud but I wanted to do something new so I did it in golang which was completely new to me.

A year later, I got to thinking that there was a lot I had still wanted to do with it. One of those things was figuring out how some muds I used to play (DarkCastle) were able to reboot/upgrade the server without killing people’s connections.

Each player in a mud has their own permanent socket connection to the server. This socket is the sole medium from which the entire game is played. Normally when killing a process, all of the open sockets are closed, so rebooting the server to pick up any code changes would force all current players to have to reconnect

Continue reading →


Carsforsale.com - Mobile app

Not a real technical post but still corresponding to something I’ve recently had a hand in (or two, writing roughly 25k lines in two weeks)…

Carsforsale.com released our first incarnation of a consumer facing (for all you car buyers out there) Android application. Check it out!

Continue reading →


Publishing a NuGet JS library

First, this is a condensed version of a well written post that can be found here. I’m posting this as reference for myself and for those of you who just want the nuts and bolts.

I was recently working on an incomplete project that leveraged CKEditor for a WYSIWYG editor. The original developer had pulled in CKEditor via NuGet but was using the Auto Grow plugin and had manually added it. This is fine for development but murders the concept of dependency management. So, I found this post and quickly published an Auto Grow NuGet package.

  1. Download and install the NuGet Package Editor
  2. Open it up, click on “Create a NuGet Package” and fill our the left hand side (click the little edit icon to edit)
  3. Add the files in the directory structure you want them output (using the project root as the base directory)

Note: Step 3 is somewhat tricky
Make sure you first right click and add a “Content”

Continue reading →


Mobile Assets

 Android Assets

Android devices come in all shapes and sizes and display resolutions. This means providing uniform assets across devices is tedious and somewhat complicated.

 DP (Density Pixel)

Google created a special type of unit, dp (density pixel), to make dealing with assets easier.

 How is that easier?

This unit generalizes all various display densities into a single display. What does that mean? It means a 100 dp x 100 dp will display the exact same on any device regardless of the device’s properties. So a 100 ppi device, 200 ppi device, 300 ppi device and 400 ppi device will also display the asset as the same size and same quality.

 How does this magically happen?

It doesn’t

Assets must be created in a very special way to let Android do it’s thing. A designer needs to provide different assets for each generalized density type. What are these generalized density types and why

Continue reading →