Matt Hackmann

MattHackmann

The thoughts and goings-on of some programmer dude.

チャレンジ

I doubt that title's even gonna render correctly...

Let's not beat around the bush, here: this blog has been a fucking ghost town for quite some time now. Last year was quiet, but the only thing I've written at all this year is an out-of-nowhere post about a frog watering contraption. Kind of sad, really. It's not that I don't have anything to write about, necessarily, but can't quite figure out the "correct" way to write it. One thing leads to another, and that generally lead to nothing in the end.

That brings us to here. At the suggestion of my dearest mother, we'll be doing one of those post-a-day challenges for the month of November. She's started off by writing about how she's slowly becoming an evening alcoholic (I kid, I kid), but I'm not sure where to begin.

2016 has been a rather strange year, for sure. It might actually be one of my busiest on record, but it doesn't really feel like I've accomplished anything. Here's a bulleted list of things that may or may not become posts later:

  • Spent a couple weekends in snowy Tahoe with friends
  • Threw not one, but two little parties at my apartment
  • Quit LinkedIn
  • Visited Japan
  • Started working at Twitch
  • Quit working at Twitch
  • Meandered around in unemployment for a while
  • Started working at LinkedIn again
  • Made a road trip to Seattle, visiting friends and family along the way
  • Housed a friend and colleague from work for a week
  • Various other ancillary things

The work nonsense is certainly the "low hanging fruit" of this blog escapade, so I'll probably start on that tomorrow.

In the meantime, this is a post with words that hasn't really said anything in particular. Good thing this is a quantity and not quality challenge!

The Automated Warner Waterer

youtube video

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

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

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.

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 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

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

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

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:

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:

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.