Matt Hackmann

MattHackmann

The thoughts and goings-on of some programmer dad.

How I Saved Hundreds of Dollars by Writing Unit Tests

There's so much clickbait hyperbole in that title, it makes me sick. A more accurate title would be "how I saved hundreds of dollars by actually planning my crappy code... and then verifying it through tests". The world doesn't need another article about "test driven development", but I'm writing one that touches on those points anyways.

To quickly catch folks up, I run an image hosting/reverse image search site on the side. As it's gained traction and grown, things like server disk space and bandwidth caps have become very real issues. I get quite a bit of bandwidth per month from my webhost for the price I pay, but not enough disk space to hold all hosted images. On the flip side, AWS provides lots of cheap storage space, but gets super expensive at the amount of data I push over the pipes every month. If the AWS price calculators are to be believed, it'd be on the order of $1500/mo, which is about ten times more than I'm paying currently and would not be sustainable, even with Patreon supplementing the funds. By bringing in an additional server, load balancer, and doing some work to keep fresh content on the app servers and only make requests to AWS on an as-neeeded basis, I managed to have most of the best of both worlds. Everything was great and all was right with the world.

Until it wasn't.

Continue Reading

Setbacks

The last few days have been kinda "meh" on various fronts. Just when I think I'm making or about to make progress on something, WHAM! Something's in my way ruining those plans.

Hakk's Lab Episode 1

The first episode of Hakk's Lab is supposed to be a rebuild of the power/video board on my Famicom (partially because I destroyed the original one). Those screenshots I've been posting of PCBs was supposed to be for that, the idea being I was going to mill the board on my PCB because it seemed the easiest. To that end, I began getting the CNC machine set back up... and then my garage computer died. Replaced the garage computer, updated my CNC to the latest firmware and... it suddenly doesn't know how to move anymore. Do a bunch of googling, fix the issues with the motor direction and things are looking good... except now my Z axis is unable to move more than an inch down. I don't even know where to go next without taking the whole machine apart... well, fuck.

Hakk's Lab Episode 1 - Alternate idea

Itching to just get something out, I dipped into a different episode idea: modding a Super Game Boy to fix the clock speed problem... and that went really well! All the filming got done, the mod itself was pretty much there... and then it didn't work. Okay, cool. Just fix it up and leave that part out of editing. Oh... I just broke one of the pins off of this surface mount chip and now the whole cartridge is basically ruined... well, fuck.

React RFC

This one didn't have any real surprise behind it, but the RFC for React I created the other day was indeed rejected. Not for any fault of mine beyond the idea goes in a difrection that React doesn't want to. A fair point, but now I've got no clean way forward for bringing back the RSS feeds... well, fuck.

Arguably, these are very comfy problems to have, but it's getting annoying having stuff constantly derailing me as I've finally mustered up some resolve to do them. To the Hakk's Lab thing, I decided to go with my initial idea but just etch the PCB in the old-fashioned way with caustic chemicals. Hopefully that goes a bit better.

Writing Down the Mental Paper Trail

As has become typical in my annual performance review, I got dinged for not better documenting my architecture plans for various work things. I can certainly argue that the expectation wasn't necessarily set well or that the work didn't necessarily require the time and effort to write hollow words simply for the sake of a paper trail, but that's not why we're here. The sentiment is certainly not wrong. I have a tendency to refine an idea in my head and then immediately jump into code, either implementing exactly as I figured it'd go, or pivot as needed. As a friend observed, "i think hakk just does shit and sees what sticks and iterates".

I'll admit, there's a time and a place for both mentalities. When working on something large, it's probably better to actually document at a high level the whole notion. We in the industry call this an "RFC", or "request for comments". The idear being that others look at this document and then are able to begin a discussion on potential issues and, in the end, suss out all the pain points before actually speanding time spinning wheels on implementation. It's also a good indicator of the amount of effort a feature will require, a good thing when trying to decide what and what not to work on. This paragraph full of business buzz words basically describes the position I'm finding myself in on my new team. I hate it because I have no confidence in my ability to actually document such things in actual words, but it must be done.

All of that to get to the actual point of this post: trying to bring back the RSS feed. I was happily chuffing along and ran into a major wall: React really does not like doing things that are HTML-like but not actually HTML. That is to say, HTML has a tag called link and it cannot have any children, similar to more frequently used tags like img and input. These are known as empty elements. Now, RSS also specs out a link tag, and it's used for linking to the blog it represents and each individual post item. Unlike its HTML counterpart, the RSS link tag wants... will a link as its child content. And, with React in its current state, this is simply impossible. It's enforcing very strictly the rules of HTML, as well it should.

Now, despite being owned and mostly developed by Facebook, React is an open source project. This means that all the source code is freely available and anybody is allowed to contribute back to it. I pulled down a copy of the code and began setting about figuring out how to allow me to have my cake as well as consume it. As I started zeroing in on the solution and creating that mental plan, I decided to check out the contributing guidelines for React before submitting my pull request. Per that doc, they recommend opening an issue for new features to begin a discussion about what's to be implemented: an RFC.

....sigh. Fiiiiiiine.

Some time was spent ensuring that I adhered to the format they'd laid out, and ensuring that the issue was well described, my reasons for wanting to change made clear and validated with an example, and a thorough explanation left of how I planned on implementing my idea. About thirty minutes later, I had a lovely little proposal written and hit submit... and then I immediately wrote all the damn code (including unit tests) just to see it work.

Overall, I'm pretty pleased with the RFC that I drafted and it felt good being able to articulate what it was I wanted to do and why. I honestly have little faith that I'll get the blessing from the Facebook gods to add this, but if I do, I get my name attached to one of the most used and well liked JavaScript projects ever created (I'd say only jQuery beats React at this).

After that, I guess I can just retire.

March Madness

I missed a few days, sue me.

The reason for that, actually, is because I was up in the mountains of Tahoe on a trip bonding with my new team. This was a great success as I got to meet many people and, more importantly, connect with them. Alcohol does that so, so very well. This trip ticks off yet another thing that has been planned for this month.

Next weekend, I go to Tahoe again, but this time with old friends. One of those is one of the usual ski crew, who is also bringing his kid this time. Joining us is one who's done fewer things since having a kid of his own, so it'll be nice to hang out with him outside the confines of work. Another is visiting in from Las Vegas and will be experiencing true snow for potentially the first time in his life. He's from Hawaii and then lived in Arizona, so the opportunities to experience the wonders of semi-frozen water have been few for him. These are some of the chillest people on the planet and I think a good time shall be had by all.

The week after that, I'm once again spending part of a weekend outside my home base of San Mateo. I'll be joining aforementioned ski fellow on his dream trip to golf at Pebble Beach down in Monterey. Over the last few months, I've come to enjoy golf as both a great opportunity to down some beers and drive buzzed, but also escape the nonsense that is my overactive brain. The sport itself is fine, but I enjoy the things around it vastly more. I'll be spending enough time down there to also do some sight seeing and probably visit the aquarium, which is a thing I've been wanting to do for nigh five years now.

Jumping back to this weekend, it'll be a bit more chill. I'm planning on getting the CNC machine back up and running and (with a bit of luck), getting that first episode of Hakk's Lab in the can. Even if I just get the CNC machine back into a usable state, I'll be happy.

So, yeah... March is shaping up to be kind of busy. I think I'll probably be a bit more chill come April.

In the Vein of

I should stop remembering about this blog thing fifteen minutes before midnight.

As I continue to toil away at the first episode of Hakk's Lab, let's take a moment to look back at the thing that kind of started me down this path. What later unofficially became "Matt Pokes and Prods" started off with this video of me repairing a VRAM address line on an old NES. It's a one shot, so not perfect, but if you're into such things, it has some fun bits of nuggets.

youtube video