Matt Hackmann

The Automated Warner Waterer

Posted On

Out of nowhere, a blog post!

I'm currently in possession of my brother's frog whilst he gets his new life set up. I love the little guy (the frog, not my brother), so I'm okay with this. The only downside is that it does keep me attached to my place to care for him (again, the frog) at a time in my life where I can do whatever the hell I want whenever the hell I want.

To that last point, I booked a rather spur of the moment trip to visit good ol' devbus over the long weekend. Now, the frog (who from hereon out will be referred to as "Warner") can live with some neglect, particularly on the food side of things. I'll only be gone four days, which should be fine. Still, he should be kept moist regularly and that's been weighing on my soul.

Enter the Automated Warner Waterer! (Or, "aww" for short)

The Supplies


- One small fountain pump (picked up at Home Depot)

- Some 1/4" tubing

- Plugs for said tubing

- One Raspberry Pi (I used a 3)

- One reused, relay-controlled gangbox

Excluding the Pi and the box which I already had, I spent about $25 for everything. Not too shabby. Oh, and this isn't meant to be a blog-by-blow tutorial. I'm not instructables...

Building It

If you look real closely, you can see Warner

The water pump and tubing stuff came together pretty easily, the stuff that I figured would be difficult. Despite it being drip tubing, I wound up punching some holes as the pump wasn't strong enough to force the water through. Other than that, cake all the way.

So much wires

Setting up the script and such to control it via the Raspberry Pi turned out to be trickier, or the part I figured would be easy. Some stuff I learned:

- The Pi has 5v out, which is great for my relay card. But the GPIO pins are only 3.3v, something my relay card did _not_ like. An NPN transistor fixed this.

- The relays themselves are active when they're pulled low, something I do not recall when messing with them before. Had to do some rewiring so that the pump would be off when the relay is engaged (which is basically all the time when the Pi is on). This of course means that if the Pi loses power, that pump will always be on.

- When running something as a cron job, you don't get the benefits of running with that user's shell. So, when you run node, you need to absolute path to that

The Result

The business end

The way everything is set up now, I can manually water Warner by running the script through SSH, but it's also set to water for fifteen seconds every day at 3PM. In addition to that, it will reboot the Pi at 3:01PM, resetting the GPIO pins and shutting off the pump just in case something went wrong and the script hung with the pump on. MY CODE HAS LIVES IN THE BALANCE.

A pretty good way to spend half a day and it'll make me feel more at ease while I'm away.

The Yearly Time Travel Trip

Posted On

As has now become a yearly tradition, words from my past self to my present day self arrived this 21st of December. Here is what I had to say.

Dear FutureMe,

Here we are once again. We'll skip the pleasantries and get right to the heart.

To be quite honest, I'm a bit apprehensive about how next year is going to go down, at least as far as work goes. Being understaffed and rewriting the entire stack in the time the PMs are allotting is worrisome to be sure. I'm hoping that there will be no long nights (certainly impossible odds), but the realist in my is not optimistic.

I am, however, slightly more optimistic about that trip to Japan with your coworkers. The tickets are soon to be bought as I write this which will essentially seal three people into that deal. How things will play out while there, though, remains a bit shaded to me.

Speaking of Japan, don't really expect anything to come of the 3 month work stint over there, but it would certainly be nice. Oh, and this is of course assuming that you're still at LI, though I can't see any reason why you wouldn't be. That gig, though the honeymoon is over, is still pretty sweet.

On the girlfriend front... sigh... I can't really make any predictions. I've become disillusioned with the effectiveness of online dating as it doesn't pair you up with a person in any natural sort of way. Maybe with that senior promotion (presumably that'll happen sooner rather than later), you'll get some extra confidence and balls and can converse with ladies on a "cold call" type basis.

It seems these letters are getting longer each year I write them, so the wrapping shall begin here.

Oh, you need to bike over 2000 miles next year and get your fat body into shape. Please do that for me.

This is probably the most accurate thing I've written to date. Project Voyager, which I played a marginally large-ish role in for a while (lead web developer for the new "Me" page), was an absolute nightmare to work on, and continues to be in some cases. Any project that has people tossing out the term "PTSD" for those who have abandoned ship is not one that should be praised too heavily. In the initial stages, I did a lot of actual yelling in anger and frustration in trying to keep the expectations sane. During the course of the year, I entered what was probably actually some level of depression. I nearly stopped doing things after work at all, trying to keep what time I wasn't at work to myself just to recover so I could go and face it again the next day or week. In the end, I bailed from the project entirely (in the most hush-hush way I could, except for the long essay I wrote to managers about my thoughts on the mess). I attempted to flee to Facebook, making it all the way through the interview process only to be turned down, so instead just went to a different team which still has me working tangentially on Voyager. It's much calmer and saner overall and I'm slowly beginning to return to "normal", whatever that is.

Japan is a thing that happened, though, with a couple of work friends and myself making a pilgrimage to my home away from America. I'd like to say that this trip was way more successful than the one my brothers and I took. We went to more places, saw more stuff, and ate a larger variety of food. We hung out with the fine folk at the Tokyo LinkedIn office, who are exceptionally good at partying (from karaoke to playing wingman in Ropongi bars). To that last point, I had every opportunity to nail a drunk Japanese chick, but even my level of inebriation did not allow me miss the last train back to our hotel (our flight was the next day). Of course, I came back with all manner of used figures and such to adorn my various shelves.

Yeah, the girlfriend thing continues to elude me. I went on a couple-ish dates this year, but neither I didn't consider to be enough of a personality fit to continue pursuing (or other various circumstances). 2016 is the year I want to turn my lack of love life around (which is the equivalent of saying it'll be the year of the Linux desktop) because I'm getting bummed out watching everybody around me get married and have kids.

Finally, I think I biked six or seven hundred miles this year. Nothing to write home about after the 1800 I biked last year. I'm fatter than ever, but I think I've fleshed out a nice little plan for once the holidays and their gluttonous wiles have played out. Getting into shape will play heavily into the dating thing, methinks.

And with that, I will now go and pen the letter I will be reading and writing about next year.

A Thought

Posted On

I don't like talking about things in the political or socio-economic realm. I abhor it, even. A couple reasons, A) I'm bad at it, B) it requires an emotional component that I don't have enough of. That said, I'm going to make a societal rant.

I of course am going to be speaking of the recent unpleasantness going down in France. I've been quasi-monitoring various threads on reddit and - unsurprisingly - it would seem the collective world's head is turned to look at Islam (or, rather, Muslims) as being the cause. Now, I wouldn't be surprised if extremists who claim to be working in the name of this religion are involved, but that's not why I'm here. Well, I suppose it is. A lot of the sentiment seems to be around the notion that this particular religion is making people do this.

No. No it's not. And the people who claim this are themselves probably hypocrites.

I had an interesting thought as I was grabbing a piece of cheese from the fridge. It's the exact same argument as "video games make those who play them violent". I've written about this before, maybe here, maybe for school, but the answer is: no, of course they don't. A video game, movie, book, or piece of music doesn't make you violent. If you're acting out on things, you were probably pre-disposed to such things already. The exact same idea applies to this notion that a religion will turn somebody violent.

These individuals chose to kill of their own free will. We as humans kind of have that privilege.

In the end it's not video games and it's not religion causing people to cause fucked up mayhem against innocent lives. It's extremely disturbed individuals who will find any reason to validate the horrendous crimes they already want to commit. Intangible concepts don't cause people to kill.

People do that all by themselves.

And it goes without saying that they are acting and representing themselves and themselves only, not the whole. They may represent a subset of people, but simply by being human, they actually represent all people.

So, if you subscribe to the group mindset, does that not make all of us murderers?

Idiocy, Caching, and Reducing Round Trips

Posted On

Over the last few days, I'd been receiving high CPU usage alerts from my host. A tad perplexed, I'd login in, check the graph and logs to see that, indeed, CPU usage was high, but nothing really seemed out of the ordinary. Google Analytics showed that traffic was moderately high, to be expected with a few widely visible brackets going on in /r/anime, but it wasn't anything to raise an eyebrow at. Still, you can't look at the following graph and notice a very predictable period of high activity:

Those peaks would be terrible to bike up

These peaks were actually coinciding with the most prominent bracket updating, bringing with it a fresh wave users every day. By the time I had received the third CPU alert email, I knew something was up and decided to actually take a look. Luckily, I didn't have to look far. The MySQL query graph was showing 1000+ read queries per second, certainly out of ordinary given how aggressive I am about caching.

Suspecting that something might be awry with memcache, but not actually wanting to bounce it, I bugged the cache library with some stats tracking hoping that it would turn up something I had overlooked. Indeed, I know where things are cached, but have never really had a list of just how all of this looks in production. And, true to that, I found something that I had not anticipated: every call to Dal::getById - a method on a class that database models extend - was a cache miss. Every. Single. One. And there were thousands of these, which very quickly explained the high query volume. All of this I found out in about 30 seconds of having that profiling code live, which is good because it also brought the site down and I had to disable it...

With that information, I had a pretty solid lead as to where I needed to be checking for issues: the aforementioned getById method. I was a bit baffled because I knew there should be caching on that, it's one of the two reasons that the method even exists (the other reason being for coding simplicity). So I get in there and take a look. Lo and behold, the cache is checked but nothing was ever actually stored back. Of course, I had to fuck the fix up once before actually resolving it.

Once that was shoved to production, I was greeted with this wonderful little sight:

Down.. down.. down.. ROCK LOBSTER

So, the immediate issue was fixed, but there was still something obviously very wrong if I was individually getting so many singular items by ID. As it turns out, in one of the most looped pieces of code in the entire project, I was making not one but two calls to get an item by ID. The whole output was cache guarded, but on a per user basis. In the case of the popular running bracket, that's over 400 queries per user per page generation. Unacceptable.

So, in one of those cases of code brevity != code speed, I did a heavy refactor to stash all the IDs that needed to be fetched and then make a big batch call later. There are some trade-offs here. There's still room for optimization here, especially if the getById calls are aggressively cached (indeed, the data fetched changes rarely). Or, the data returned from the batched call could be cached in shorter intervals. It still needs to be looped through as it's decorated with user specific data, but that would bring the overhead down to one big-ish hit only every few minutes. Still, with those measures currently in place, the CPU load issue has gone away and the queries per second is generally down in the double digits on average.

The true sign that everything is working, though, was the lack of an email in my inbox this afternoon.


Posted On

Hey, there. It's been quite some time. About two months, I'd reckon. Actually, I'm not even sure that last post counts for much, being that it was entirely technical. The one before it doesn't count either, as it was more of an op-ed piece... I guess? I dunno...

So, what exactly has Matt Hackmann been up to since his last meaningful "life update"? Who wants to know? Certainly, you don't. But, the future me does, so that's enough to validate my want to write this post. The answer to the original question is fairly simple: not a lot. And also, everything. Maybe it's not so simple after all.

The easy answer, really, is work. NDA prevents me from mentioning what exactly is going on, but it's pretty big. Now that I'm a team lead, I'm being challenged in ways that are completely new and foreign to me. Adding to that, I've spent the last month or so on a pretty large portion of this project that affects everybody working on this codebase. All of that landed on Monday and since then, I've been helping people on-board while also crushing any bugs that crop up. I still have a long way to go until all that is all tied up with a neat little bow, but this is probably the most difficult and certainly the most crucial time in the life cycle. I'm hoping to be able to breathe a little bit once this part is done.

In the now, very little happens outside of work. I spend most of my evenings and weekends just trying to mentally recuperate, which primarily consists of naps and lazing around. However, this is coming off of a fair amount of things that happened in the last few months.

Back in March, I moved from my little apartment in Sunnyvale to a slightly less little apartment in San Mateo. The apartment itself is pretty sweet and the location is even better. There are so many places that are now in walking distance, from ramen shops to the train station to friends houses. Due to the above exhaustion, I haven't taken as much advantage of this as I should, but once things ease up, I hope to start sampling some more of the food wares in the area. Inside my apartment, I built a couple of sweet desks to fill the larger space in my room, so I now have a space for computer things and a space for electronics things.


In April, I made another pilgrimage to Japan, this time accompanied by a couple of friends from work. In some regards, I consider this trip to have been more successful than the previous one. I knew better what was going on, and had far, far less fast/conbini food than last time. We also managed to land right in the middle of cherry blossom season which was goddamned gorgeous. Of course, there was plenty of time spent in Akihabara and I came away with many nerdy goods to fill my shelves and to gift to folks. It's hard to believe that it's already been almost two months since I've been back... or that I even went at all.

So, that's a bunch of stuff. I'm actually feeling motivated to work on my LED board project right now, so I guess I'll do that.

Or I'll binge watch a bunch of Forensic Files >_>