worklog 12/28

Image

Inaugural work in the new garage workshop! Nothing major, just drilled the jackplate for the marquee, and installed the power connector. I also put another coat of poly on the frame. Looks shiny!

jackplate and power connector

On the 3D printer front, I got the heated bed PCB soldered and installed the endstop switches. Soon!

Tickertweet

When the east coast earthquake hit a little while ago, I found out about it first from a tweet, followed up by an IM from a friend in Brooklyn, followed up 10 minutes or so later by Google News. I thought it would be neat to have a way to call attention to important events. Inspired by old-fashioned ticker tapes, I put together some code to print specified Twitter updates in near-real-time to a thermal printer. More details in the video:

sample of the tweet output

The tweets are fetched using the twitter Ruby gem, rendered into a PBM image with rmagick, and printed via the pbm2lwxl library. I’ll put the code up on github after a little cleanup. As an upgrade, I’m setting up the software to run on a NSLU2 single-board computer, so the printer doesn’t have to be tethered to my desktop. More on that in a bit!

i spell “w3rd” with a three

Saying “hello, abandoned blog” seems kind of stupid when my post ratio is approximately one post every year and a half, so let’s just skip past that. Some notes:

  • I went to Bass Pro Shops today, looking for a suitable holster for my Halloween costume. That store might just be the best reason I’ve found so far for Texas to exist at all. They are incredibly enthusiastic to throw a gun in your hand. No exaggeration; upon approaching the handgun counter, the gentleman behind it said “Well, howdy, tall feller! What can I put in your hand?”

    This is a line that is only appropriate at either gun shops or gay bathhouses.

    I’m actually a pretty big gun fan. I find them technically interesting – you get to hold, in a convenient, handheld package, the cumulative result of several thousand years of applied technological development. Plus, shooting is fun – you have to relax, concentrate, and zone out a bit to shoot well, which is oddly similar to coding…

    Anyway, I looked at a few M1911 pistols. There was a Taurus, which was attractive but cheaply made, and a Sig Sauer, which was far, far nicer. I was hoping to get a look at a Springfield Armory Mil-Spec and Smith and Wesson’s version, but no luck. Both of those are far closer to the original GI version, which strikes me as a good thing – why add rails and gizmos to a fantastic design that has survived since WWI…

  • What’s also fun? Booze. Know where I’m never going to get any again? Dallas Liquor Store, located at 2121 Main St # 102, just past the new Main Street Garden park. When I went in, there were two homeless people sitting on crates INSIDE THE SHOP harassing customers (i.e. me). And the guy working there didn’t seem particularly bothered by this. FAIL.

why i hate apartment living

It’s 12:15 AM. I’m hungry. I’m hungry because I’ve been working on DragonCon stuff for hours, and I’ve forgotten to eat. So I go to toss together some basic subsistence food (pasta, canned sauce, mystery meat from the freezer, and frozen vegetables). Fine. Here’s the problem, though. Last time I cooked, I used some oil. If you cook with oil, some of the oil gets on stuff, like your other stove burners. Normally you don’t give a damn. You can try to clean it off, but no amount of scrubbing will keep the burners from smoking, at least a little bit, when you turn them on. Normally, again, you don’t give a damn. But the smoke detectors in my apartment are so hyper-sensitive that making toast is enough to set them off.

Not burning toast. Making toast. And my toaster’s clean, don’t ask.

So now what I’m doing is, with all the windows open, and with every fan I can find blowing toward them, gently throttling each burner, one at a time, for brief intervals, and hoping that the slight tendrils of smoke generated aren’t enough to start the screeching wail of the alarms. We’re not talking a kitchen full of smoke, here. We’re talking wisps. WISPS! I know it’s an old building and all, but jeez. If the alarms don’t clear in a minute or so, the whole BUILDING’S alarm goes off, the fire department comes out, everybody evacuates. It’s happened five or six times since I’ve been here. Not caused by me, thank goodness.

So I wait, daring the alarms to go off.

And I’m really really hungry, dammit!

never as complicated as I wanted to be

Dear abandoned blog, here are some videos:

This is the video I made at DragonCon last year. I never posted it here. It might give you an idea what a big science fiction convention is about. Or it might give you an idea how weird my friends and I are. Or it might give you some other ideas altogether! Best of luck with that. It’s probably what you’d call “not safe for work”, mostly due to cussin’.

Second, here’s a neat video wherein I play with thermal conduction. It’s just *slightly* more interesting than it sounds.

From E3 today, a teaser trailer from Portal 2:

Something that always blows my mind about Valve games is the excruciating emphasis on storytelling. The *first line* of this trailer tells you a number of things about the game – “It’s been a long time.” GLaDOS, as we all know, is Still Alive – and she sounds dark. Angry. Serious. This is gonna be a helluva game.

Other E3 goodness – a new Kid Icarus! A new StarFox! A new PilotWings for crap’s sake! By any definition, Nintendo killed it in their announcements today. Epic Mickey, alone, might sell me a Wii.

untrustworthy hashes in ruby

I ran into one of those annoying bugs where a couple different things conspired to have an annoying result. We use GMail at the moment as our SMTP server, and we put all sorts of automated notifications through it. GMail has a well-documented 500 message limit – that’s per-account, per-day. Upgrading to Premier bumps that to 2000, but we really don’t need to upgrade everybody on the domain just to get the extended limits for a system account. Ordinarily, we don’t send anywhere near that much email, but a bug that got our asynchronous mail-sending queue a little clogged up led to a glut of mails that needed to go out. Which put us over the limit. Bleh.

We’ll be switching to a sturdier mail provider soon enough, but for the time being, I decided to rig ActionMailer to load-balance between four accounts. So there’s a few different ways you could pull this off.

  • Monkeypatch ActionMailer. I try to avoid patches like this if at all possible.
  • Randomize ActionMailer’s user_name setting before each use. Well, AM’s settings hash is a class global. Changing it every time, especially when others might be poking at it, seems in poor taste.
  • Something else.

“Something else” turned out to be hacking the settings hash itself. Ordinarily, when you set it up, it looks like this:

ActionMailer::Base.delivery_method = :smtp

ActionMailer::Base.smtp_settings = {
   :address => "smtp.gmail.com",
   :port => 587,
   :domain => "mydomain.com",
   :authentication => :plain,
   :user_name => "somebody@mydomain.com"
   :password => "mypassword"
}

Instead, I did:

ActionMailer::Base.delivery_method = :smtp

smtp_settings = {
   :address => "smtp.gmail.com",
   :port => 587,
   :domain => "mydomain.com",
   :authentication => :plain,
   :password => "mypassword"
}

SYSTEM_ACCOUNTS = %w[system@mydomain.com system2@mydomain.com system3@mydomain.com system4@mydomain.com]
ActionMailer::Base.smtp_settings = Hash.new { |h, k| SYSTEM_ACCOUNTS[rand SYSTEM_ACCOUNTS.size] if k == :user_name }.merge!(smtp_settings)

The useful part is the employment of the version of Hash.new that takes a block. If a key lookup fails, the block is invoked, and is passed the hash and the requested key. It’s basically “method_missing” for hashes. So, when ActionMailer looks for :user_name, the block picks a random entry out of the SYSTEM_ACCOUNTS array. For lack of a better name, I called this approach an “untrustworthy” hash – as one generally expects to get the same key-value mapping from a hash every time.

This wouldn’t work in all cases – for example, has_key?(:user_name) would fail. I’ve got a more generic solution in mind, that being an add-on for Hash that lets you insert key/proc pairs as well as key/value pairs. More on that soon.