Category Archives: fun

When Tinkers Attack

Hey, you in the mood for an electronics-heavy, hardware hacking post? Who cares, my blog my rules. Anyway: lotta words and science and eventually pictures, I promise, but it’s nerds all the way down from here.

Okay, I gotta at least sum up the background of this post: I’ve been playing around with a device called a Photon, made by a company called Particle. It’s a tiny little microcontroller device that seriously blurs the line between the “programmable ICs” I played with a decade ago and, well, computers. It’s the size of my thumb, costs less than $20, and its killer feature is an onboard Wi-Fi radio. They’re at Go buy one, I’ll wait.*

* Disclaimer: While I have received a free Photon from a friend who works at Particle, I also bought a handful of them on my own, and Particle probably doesn’t want me writing a review for them anyway, honest or otherwise, and in fact are no doubt reading this with an increasing sense of dread. (Plus I bricked the free one right out of the gate. I’m just saying.) My opinion, which is possibly biased, is that you should buy a bunch of them. They’re awesome.

So with all that summed up, I can now move on to the problem I’ve had all week with it: I want to drive a super-bright LED module with my Photon. Seems pretty straightforward, right? With my Teensy USB (another cool product, go buy some of them, too!) I could just push current out to the red, blue or green pins of the LED module and it would light up. It is worth noting that the Teensy was a current-bearing** beast. It could shovel 80mA of current out of each pin at 5V without even getting warm. Well, without getting hot. Well, without burning the house down at any rate–look, the point is this module will take a full watt of power and the Teensy could deliver it easily.

** ampiferous? Heh. Shut up that’s an awesome word right there

Enter the Photon.

This thing is unrelentingly awesome, I won’t hear a word otherwise. One of the great features is that it runs on a super-low power budget. It runs on 3.3V (even though it will accept 5V). This means I can plug it straight into USB (5V) and it runs just fine. But those pins only spit out 3.3V. And to make matters worse, it’ll only give 25mA per pin and 125mA overall. It has a lot of love to give, but not a lot of power: 82.5mW per pin means that even with a pin driving each LED separately, it puts out less than a quarter of a watt.

But wait! My LED module has tiny little load switching transistors on it! You plug the board into 5V and ground, and then you just signal which LED you want to light up. All the drive power comes directly from the power rail, not the microcontroller… less than a tenth of a watt, in fact! Yay!

So how come, when I hook it up, the LEDs barely glow? Where my photons at, Photon?

It’s not the Photon. It’s the module. The LED module is a Sparkfun 11588 Tri-Color Breakout. This is a fun little kit you assemble yourself, and more importantly everything is easily understandable as you build it. In order to drive the LEDs, you build a circuit that is very easy to follow and understand: you drive a little current into the base of the transistor, and the collector responds by pulling down big current from the 5V power supply and dumping it through a resistor and the LED before returning to ground. More current means more light. It’s simple, it’s straightforward, it’s comprehensible.

It’s also not the best design for many applications. It was great for what it did, mind you; it just doesn’t adapt well to changing requirements. This circuit has what is called “High-Side Drive”, meaning the transistor (which “drives” the circuit) is connected to the 5V side. If we took the transistor out and moved it down next to the ground side, it would be called “Low-Side Drive”.

Why does this matter? Well… okay, TL;DR it just does and if you don’t want a longer explanation skip to the next paragraph. The longer explanation is this: I don’t actually know. Man, I sure hope you skipped this part. What I think is happening is that with 3.3V on the base and 5V on the collector, a 1.7V volt drop is created across the Collector-Base junction (Vcb for you electronics nerds), artificially limiting the output from the transistor. Normally a transistor can be thought of as an entirely current-based device, but in this case the transistor is forced to throttle the flow all the way back until a 1.7V drop is maintained from the 5V rail down to the 3.3V signal.

Now, there are a few ways you could fix this problem. The first is to alt-tab over to Adafruit and buy a 3.3V to 5V signal converting chip. They’re like $1.50, no biggie. You’d pay more in shipping than you would for the hardware, though, and if you’re like me–and this example you are–you’re gonna throw ton of other in your cart, so that chip is going to set you back closer to $50.

A second option is to dig around in the garage for some old reed relays you have lying around in an old junk parts drawer full of electronics components. You have one of those, right? Hey, me too! So you wire up the Photon to open and close the relays, and the relays switch the 5V supply directly to the signal pins on the module. Check it out:

Oh, wait, sorry. I said it was bright. (Fun fact: I have never seen my cell phone create an internal reflection like this before.) Here, let me turn it off.

There we go. Now this circuit works and all, but it still leaves something to be desired. I can switch the relays on and off, but that’s all I can do: turn the lights on–all the way on–or all the way off.

You can dim LEDs from a digital circuit if you turn it off and back on really fast. You shut it off and then back on before the eye can see the flicker. Do this over and over really fast, and it looks like the LED is getting darker. This trick is called pulse width modulation, or PWM. But to trick the eye, you gotta send these pulses out super fast, and those poor little relays have no chance of keeping up: they contain actual, physical, mechanical switches that are controlled by magnets. (No, I don’t know how magnets work. Yes, I am Mormon. NO, I really don’t know how magnets work. Please stop asking.) The point is, because they’re mechanical devices, they can’t switch on and off faster than you can see. We need a way to switch them on and off electronically.

A third option is to call your friend Kevin (you have a friend named Kevin, right?) who is really good with tools and insanely good at electronics (MY friend Kevin is, too–this is getting weird). He’ll tell you that you can use a 74HCT240 CMOS/TTL buffer, which is a chip that looks exactly like the one you were gonna get from Adafruit, and does exactly the same thing, but has been around for years and years–certainly long before 3.3V computing ever existed. More importantly, he can come to your house on Saturday and bring you one of these chips out of his electronics parts bin.

Cool! So you’ve got a free part coming, now you just have to wait…

Yeah, me either. Time for a fourth option. Let’s head back out to the garage. Do you have a can of solid-state relays left over from when you were manufacturing audio cutout boards for vibration control computers? No? Thank goodness, that would have been way too freaky. Anyway, I DO, so I went ahead and grabbed some.

Just one problem. They’re left over from building computer parts, parts which I built in this millennium. That’s a problem because computers nowadays use all SMT stuff: surface-mount technology. When I used these SSRs, I would etch a flat circuit board, hold the chip where it was supposed to go, then wash hot solder over the feet to make it stick to the copper. Those little feet have big flat pads on them so they can stick, and that means they don’t have the spiky pokey feet I need to jam them into my prototyping breadboard. If only I had some way of attacking wires to the SMT pads.

So, anyway, last night I sort of crafted an unholy abomination of electronics.

(That’s option four: “craft an unholy abomination”.)

The SMT chips need a flat board to stick do, and the prototyping board needs wires or leads. So how about a board with wires on it? This is a real thing you can get professionally, called a breakout board. I don’t have one, but I do have a lot of parts…

I grabbed an unetched circuit board and cut it down to size. I don’t have any etchant, but that’s okay. There are plenty of… decidedly mechanical… ways of removing material. Marked off the little SMT pads, and started scratching a channel before I realized I needed to be taking pictures of what is no doubt going to become a triumphant abomination.

I ditched the knife and got out my handy dandy Dremel tool and the tiniest burr head I could find for it.

Okay, time to slap some solder on there. It’s been 10 years since I’ve held a soldering iron, and all I can say for this solder job is that I did not, at any point, try to hold the iron by the burny ouchy end.

Okay, halfway home. Now it’s time to give this little breakout board some legs that can go into my prototyping board…

If you’re looking at this and jumping up and down and shrieking “SOLDER IS NOT GLUE” you probably need to work on your impulse control. You’re not wrong, mind you, but dude. Settle down. People are staring.

I’m not gonna lie, soldering is NOT like riding a bicycle. Shaky hands, cold joints, poor temperature control, good times. Here’s the finished product in all its lumpy abominationy glory:

I bent the legs under and then down, so that the legs could squeeze the circuit board because solder is not glue I get it shut up already.

And there we go. Just about ready to plug straight into a circuit board!

Oh, but one last step before we plug it in. Solder is not glue, but you know what IS a good glue?

Actual glue.

And now, the moment of truth! I’m so excited! I take it to my breadboard and plug it in, and…

…nothing. No circuit, no blinking, no flickering, no joy. Completely dead. The above picture was taken between blinks on the little Photon board, so you can’t tell that it is turned on and trying to drive the LED board.

I checked the circuit very carefully for continuity faults before plugging it in, so what could OHHHH MAN.

Fun fact about CMOS chips, which these SSRs are made out of: If you handle them without static protection, especially in a dry house in Utah in October, you will fry them.

See? NOT like riding a bicycle at all.



LOL! No seriously, LOL. This was a lot of fun. Not every story has to end with an epic win to have a happy ending. In this case, I got some practice soldering, and got to remember that there’s a fair bit of skill involved there. The whole time I was soldering the smell of the rosin flux burning off the iron transported me back to my teens, where I spent hundreds of hours hunched over a crappy little Radio Shack 5W iron, putting together (and tearing apart) radios, amplifiers, oscillators, power supplies… any number of crazy projects, just for the fun of doing it. I’m happy I did it and will always treasure OH OF COURSE I GOT IT WORKING BECAUSE YES AN EPIC WIN IS REQUIRED IN THIS INSTANCE.

Let’s talk about option five. I sort of hinted at it accidentally when I was describing the problem earlier. So the original SparkFun design is flawed because it is high-side driven. If we could somehow change this circuit to be switched from the low side… well, ground is zero volts, whether your circuit is 5V or 3.3V. If we can ground one circuit, we can ground any circuit.

I don’t have a schematic drawing of a Low-Side Drive circuit, but if you look at the circuit at the top of this post, the circuit you want can be created by turning it upside down. The 5V comes in and hits the LED, then goes through the resistor, then through the transistor, and out to ground. Heck, I don’t even have to change the circuit board!

Well, okay, not the board itself anyway… readers familiar with electronics will realize that you can’t just run electricity backwards through a diode. That’s, like, a diode’s entire job in electronics, to keep you from doing just that.

So I desoldered the diodes, flipped them around backwards, and soldered them back in.

Transistor? Same problem: current won’t flow up the emitter and out the collector. Same solution: desolder, flip them 180°***, put them back in.

*** That’s 82.2°C in metric

This was a lot harder to do than it sounds. Fortunately, I never had a lot of money for electronics, so I always got most of my parts by scavenging existing circuitry. Here’s a #ProTip for you: remove the component before you remove the solder. You can jam the iron in so that all of the solder joints melt at once, and the parts slips out easily before taking heat damage. Then you can mop the solder out of the joints with a solder sucker or desoldering braid.

Here’s what the module looks like with diodes and transistors reversed:

You can’t really tell with the LEDs, but the transistors have their flat sides facing backwards from the little white outline on the circuit board.

Another fun fact is now I have to remember to always hook VCC and GND up backwards. There is something so perversely satisfying about that. It warms the filthy cockles of my gross disgusting heart.

And now, the question: does it work?

Well, at full power it looks about like the first photo of the board way back at the top of this post. But what if we tell the Photon to drive each LED at a different amount of power? Well… now that’s a different story:

Pay more attention to the bar graphs than the numbers; A5 and A3 have different PWM timers, and for some reason one goes to 256 and the other to 4096. (A5 might actually be a true DAC, I’m not sure. But A3 is definitely PWM.)

So… there you have it. High-side drive is a pain, low-side drive is awesome. Ground is ground is ground. and if your circuit has HSD, you need to use LSD to see all the pretty colors.

You heard me.

Risking Regret

Just north of Moab, Utah, a sandstone fin called The Lion’s Back rises about three hundred feet above the blowsand of the desert floor. It’s closed to the public now, because the public can’t be allowed to have nice things, but it used to be a famous Jeep trail. If you are a fan of scary youtube videos, you’ve probably seen the famous crash that happened there years ago (don’t worry, no one was hurt died). But back in the 1980’s, before the Jeepers really discovered it, it was just a big rock up behind the city dump.

When I was 14 I jumped off the top of it.


You Wait What, Off The What of the What Now?

Oh, relax. I had a rope. I even had responsible adult supervision! Well, I had adult supervision at any rate.

My mom was pretty overprotective of me, and when my friend Kenn called and said “A big group of boys and girls from scouts and church are going rappelling today, do you want to come?” I was very excited but also pretty sure I wouldn’t be allowed to go. I remember asking my parents, and my mother making her “worried disapproval” face. But then Dad turned to her and said,

“If you don’t let him go now, when will you?”

Two hours later I was up past the dump near Lion’s Back learning how to rappel.

They chose a small fin next to Lion’s Back and set up practice stations for us. The first jump was maybe five feet high: just high enough to learn how to lean back into the harness. The next was ten or twelve feet: here we learned to work our way down the face. The final station was thirty feet high, enough to get a couple really good bounces off the rock as you came down the rope.

We had arrived in late afternoon, and there were enough of us there that by the time I had tried all three rappelling stations, the sun was starting to set. I figured that was the end of the day, and that it had been a lot of fun. I was really happy I’d come, and I really didn’t see what Mom had to worry about.

“All right,” hollered Kim, our rappelling instructor. “We’re running out of light, so anybody that wants to jump Lion’s Back, we’re going right now.”

Maybe Mom Was Right

I turned around from the tiny fin we had been practicing on. The Lion’s Back went straight up in front of me over 300 feet. I had a sudden attack of vertigo and I wasn’t even looking down. I remember thinking, “I’ll let the other kids go, and if it looks okay, then maybe I’ll try it.”

I think a bunch of us were thinking the same thing, and had the same looks on our faces, because Kim then said “It’s a half-hour hike to the top, and we only got time for one jump, so if you ain’t coming right now, you ain’t coming.”

I knew this was my one chance. I looked at the cliff again. So high, so impossibly, terribly high. The only thing a rational human could do from up there was fall instantly to their death. I mean, obviously. I sighed, and decided not to go, and looked down at my feet.

But then something happened. A tiny little voice in the back of my head piped up and said,

“If you don’t do this right now, you will regret not doing this for the rest. of. your. life.”

I looked back up at the cliff. Yep, still terrifying. But I looked over at Kim and said “I’m coming.”

Fear Is Intense, But Regret Is Forever

By the time we got to the top and anchored our rope, the sun was low over the horizon, starting to turn the desert flame red. Being the chivalrous young men that we were, we let the girls jump first. It was a long drop, and it took each person maybe ten minutes to get down the rope and the next person to get hooked in. By the time the boys could go, the sun was starting to dip beneath the horizon, bathing us in dusk. I was about third from the last, so as jump after jump happened in front of me, dusk came and went, and night settled upon us.

Remember, this was when Moab was a boom town gone bust: there was no light pollution. There was no moonlight to jump by because it was very close to New Moon, but just by starlight alone I could see for miles and miles, the once-red sandstone fins now blue and black but still clearly visible, marching off into the high desert as far as the eye could see.

I figured I could maybe just not jump and hike back down. Since it was dark and all, obviously I wouldn’t be expected to jump. But still that voice told me, convincingly, of the lifetime of regret I would have if I chickened out.

Kim had been bantering with us the whole time, making jokes about how it was such a lovely night for some rappelling, that sort of thing. And suddenly it was my turn. Kim could tell I was terrified, and was about to back out. He smiled kindly, and said in his soft cowboy drawl, “David, me’n your dad used to work at Rio together. We was on the mine rescue team together, and I took him rappelling, too. We’ve jumped some pretty crazy stuff, me’n your dad. But he ain’t never done a night jump. If you tell him you walked back down the trail with me, he’ll understand.”

He could have appealed to my pride, told me how jealous my dad would be if I jumped. He could have urged me to jump, pressuring me a dozen different ways. But all he did was show me what the choice to give up looked like, and reassure me that it would be okay. And it’s taken me nearly thirty years to figure out just how wise his words were: he put the full weight of the decision and the consequences on me, and took the fear away from the decision itself. This was exactly what I needed.

“I’ll never forgive myself,” I said as I straddled the rope.

Kim grinned from ear to ear as he started the safety check. “You’re right,” he said to me quietly. “You never would have. But now… here you are instead.”

Owning Choices Is The Only Way To Own Consequences

The rappelling rig was a friction-stop rig, which meant that to stop, all you had to do was pull down on the loose end of the rope. Unfortunately, this meant that for a stick-thin, 100-pound teenage boy, just the weight of 300 feet of rope hanging down from me was enough to lock up the rig. Kim laughed. “You’re literally gonna have to haul the rope up and pull yourself down the first twenty or thirty feet. It’s okay. Just start walking backwards, and remember not to sit down, just lean back.”

I hauled up on the rope, and it started letting me inch backwards over the edge. For the first twenty feet or so the slickrock curved away, and I was unable to resist the urge to keep my torso vertical. My descent became more and more difficult as my body slowly bent into a sitting position. Above me and now out of sight atop the fin, Kim called down: “David! Lean back!”

I leaned back.

Imagine for a minute that you are not leaning against a mountain, but standing on a wide, flat sandstone floor. Behind you, hundreds of feet away, the desert floor rises like a wall. People are walking around on the wall and if you could turn around, all you would see is the tops of their heads. But you can’t turn around. You can only stand there, hanging in free space, staring at what is directly in front of you:


The stars went on forever. The Milky Way blazed as brightly across the sky as I’ve ever seen. Outside the band marking our galaxy, blue-white dots pierced the utter blackness. And in the gaps between those stars, the inky void of space went on and on to eternity.

There was no up or down to it, just infinite thereness, right in front of me. I stared, openmouthed, at the night sky I had looked at thousands of times already… but somehow, never, ever, actually seen. It spread out before me with a beauty that still, thirty years later, takes my breath away.

And Owning Bad Consequences Is Easier When You Owned The Choice

The sound of a titanium anchor piton snapping is very distinct. To this very day, that single, sharp Tink!, so quiet yet somehow louder than a rifle shot, followed by the gentle feeling of weightlessness as the sandstone began to fly up past my feet, will always be a thing that never actually happened because gotcha.

In reality, I rappelled down Lion’s Back in fine form, had a blast, and formed a memory that will burn bright in my mind until I die (or get Alzheimer’s as karmic retribution for the previous paragraph). That day I swore to never back away from a choice if it would leave me with a lifetime of regret.

And I’ve had to own a lot of consequences as a result. I’ve made bad decisions. I’ve made bad calls. I’ve made bad estimates, done the wrong work, shipped the wrong product at the wrong time to the wrong people. I have permanently screwed up the lives of a few people. I have deeply hurt many others. And I have offended so many people that I’ve lost count. All because I made a choice and took a risk that didn’t work out. And you know what? I don’t feel good about any of those consequences.

But I don’t feel ashamed of the choices. I made the best call I could at the time with the knowledge and abilities I had. Don’t get me wrong–sometimes it takes me a long time to forgive myself when I say or do something hurtful or ignorant or blithe or just plain dumb. But it’s so much easier than forgiving myself for not making a choice and choosing to own it.

Of course I’m only talking about the bad choices I’ve made here. I’ve made lots of good ones, too, and owning the choice is the reason I don’t feel guilty or ashamed that I get to have the nice consequences. There are lots of great things that happen to me on accident, and sometimes I even feel good about them. But sometimes I was just in the right place at the right time with the right skin color or nationality or gender. I can accept those and appreciate those and be grateful for those, but I can’t really own those. And that’s what I’m talking about here: the kinds of choices you can own, and owning them, and owning the risk of choosing–regardless of which side of the choice you took. That’s how you own the consequences.

You Never Regret Taking The Risk

I want to clarify that sometimes the risk is to take the safe path instead of the path everyone expects you to take. I’m not talking about being reckless, or risking more than you can afford, or making a decision before you need to without gathering the information that you need. That’s knowingly making the wrong decision, and there’s no prize for that. That’s stupid at best, and evil at worst. When I say “taking the risk” I mean studying out the odds, calculating the costs of failure, and deciding if the decision is important enough to get wrong.

So you know the kind of risk I mean. The kind where you have the information you need, you know what success could look like, and you know what failure could look like, and you know exactly what living another day without choosing looks like. That decision. THAT risk.

I have never regretted taking that risk, success or fail.

Of course I don’t mean I’ve never regretted a bad decision. But having the chance to make that decision, and thinking I had enough of the right data, and then making the choice–taking the risk–to the best of my ability? Never. Not once. I’ve never cared for the question “what would you do if you knew you couldn’t fail?” It doesn’t motivate me because I can’t know that I can or cannot fail. But Brené Brown rephrased that question into something so much more beautiful that I now keep it on a post-it on my monitor: “What’s worth doing even if I fail?”

That’s the kind of risk I’m talking about here.

I just tried to think of the dumbest risk I’ve ever taken and I ended up spending over an hour writing and deleting and starting over with just the things I’ve failed at this month. I could be the poster child for failure. Not just because I’ve failed so much, so hard and so often, but because I would also look hilarious on that poster.

So What’s With All This Regret And Risk Stuff?

Dumb choices are not the enemy. Big risks are not the enemy. Crazy failures are not the enemy.

Paralysis is the real enemy here.

If you have a choice in front of you, and you don’t want to make it, there’s a hundred things I could say to you. I could remind you that every day you don’t decide, you slide closer to being stuck with the default choice. I could point out that success would be just so awesome. I could say that you miss 100% of the shots you don’t take.

But I’m not going to. I want you to look at that choice, and look at that failure. Just look for a moment. Look at walking down that mountain instead of jumping off of it. And remember: We’ll understand. Stop being afraid of that walk. If you can own that side of the choice, you’re halfway to owning the decision, and owning the risk.

And if it’s a risk that makes sense–I remind you again that I jumped off with a rope–maybe you can let yourself own that, too.

You might regret the consequences. But you’ll never regret taking the risk.

What’s worth doing even if you fail?

How long will you regret it if you don’t even try?


P.S. I’m still writing the Job Replacement Guide, and this post was definitely inspired by my recent research. If there was one thing I could magically place in the book, it would be something that would wave a magic wand and help you get out of your paralysis. Whether you need to network with people you’re afraid of or ask a potential employer to negotiate your salary when you’re currently unemployed, or just put “I enjoy creating abominations of nature” in the interests section of your resumé (join the mailing right now if you want to hear the true story behind that quote, by the way, because it’s a story too good to not include in the book and I’m telling it on the mailing list today or tomorrow.)


The Job Replacement Guide

Learn how to replace your job with a better one in record time. Whether you’re unemployed, hate your job, or just wonder what you could accomplish at work if you were utterly fearless, this guide will give you the confidence that comes from being “unemployment-proof”.

Coming Soon!
Click here to sign up for the mailing list to get updates, advance content, and a discount on launch day.

New Candidate For Most Surreal Email I Have Ever Written

Before you read this, some necessary background.

First, This may come as a surprise to some of you who read my blog, especially those of you with particularly low reading comprehension, but I like to joke around, and tease people in a good-natured way and generally have a good time.

Second, lately I’ve been having a series of Very Serious conversations with a good friend, and one of the things that came up is that I use self-hypnosis to explore my subconscious and understand myself better. She replied that she had tried hypnosis but it just didn’t work for her; she felt like she was imagining everything instead of letting go and letting things happen.

Third, this is a perfectly normal place for many people to start with hypnosis, and all it takes to get through it is the ability to listen to your body’s physical sensations.

Fourth, because our conversations were Very Serious I have changed her real name. Let’s call her Jen instead.

Fifth, as I wrote this, I started to make a silly joke… and it sort of spiraled out of control. However, in comedy there is such a thing as commitment to the joke, so I stayed with it, all the way down into the ground. In flames. On an orphanage.

And Sixth, FOR THE RECORD, AGAIN FOR YOU FOLKS WITH POOR READING COMPREHENSION, Jen is a wonderful friend and I would never say anything to hurt her. This email was a joke, and she took it the right way, and she laughed.

Oh, and Seventh: Trigger Warning: This post contains ascii-art drawings of penises and making fun of quadriplegics. And ninjas. I mean it has ninjas in it, not that I’m making fun of them. Just the quadriplegics. They don’t fight back as much.

On 11/14/2013 05:23 PM, Jen wrote:
OK, we totally need to find some time to hang out so I can pick your
brain about how you discover these things.

This sounds really interesting.

Absolutely! You’ll be happy to hear that it all started where you’re at now: with me being unable to make hypnosis work, and when I did, it felt like I was just making everything up.

The bad news is that I’ve been working at it for over 20 years.

The good news is that I didn’t know how to really practice at things until this year, and I STILL don’t know how to practice at THIS.

The first time you do it, it will either shock you or completely underwhelm you, because there’s nothing to it–you’re already doing it, all the time. And I mean ALL the time. It’s like breathing, or nervously bouncing your foot. If you have a functioning Peripheral Nervous System, you can do this. It’s either happening to you right this second or you’ve had a sudden attack of quadriplegia.

JEN! IF YOU HAVE HAD A SUDDEN ATTACK OF QUADRIPLEGIA, TRY TO ROLL YOUR FACE OVER TO THE REPLY BUTTON! IT WILL SEND ME A BLANK EMAIL BUT I’LL KNOW YOU ARE SIGNALING ME TO oh what am I doing, you’re face down in the keyboard you can’t see the screen it’s not like typing at you in caps is going to help. I mean how stupid am I feeling right now, right? I’m all “TRY TO ROLL YOUR FACE” and you’re just lying there with one eyeball on the P key and your nose mashing the space bar. Geez I feel so dumb.

So… now what. Um.

Huh. This is suddenly kind of awkward.

Okay, so. I am wracking my brain right now trying to think what combination of pixels I could type up that would shine on the top of your head and help you with whatever is going on, but to be honest I don’t even really know what’s going on. I don’t know if you’re having a stroke, or an extremely rapid onset of Friedrich’s ataxia, if you’re just having the world’s calmest epileptic fit. I’m going to level with you, some of this is speculation, I don’t have a lot of information to work with here.

OOH! It could be ninjas! One shuto-uchi (“knife hand”) strike to the C2 vertebra and down you’d go, plus you’d never have seen it coming, because ninjas. This would also explain why you were just sitting there reading this email before it happened, instead of preparing for–I know, I know, “don’t blame the victim” and all that, but there’s a reason I try to teach people to maintain a minimum level of situational awareness. Oh man, I shouldn’t have said that, you’re probably already blaming yourself anyway. It’s probably hard for you to accept this right now, but, if it WAS ninjas, there’s nothing you could have done. I know you’re probably kicking yourself right now. Well, I mean you WOULD be if you could move your legs–aw geez that was probably insensitive of me. Wait, can I say “insensitive” or is that too close to “insensate”? GAH it’s like a spiderweb of tripwires with you and your political correctness! I don’t even know how to talk to you anymore, Jen–again presuming, falsely, that we’re talking and you’re not just lying there blowing snot bubbles into that little groove at the bottom of the space bar–it’s like you’re a complete stranger now, and ALL I AM TRYING TO DO HERE IS HELP YOU, WHY CAN’T YOU SEE THIS aside from the fact that you cannot, in fact, see any of this, as previously stated in an earlier interjective clause in this very sentence. I don’t even remember where I was going with this.

OH! Ninjas! That was it. Here’s the thing: it’s probably just ONE ninja. They don’t actually travel in packs or anything, except at like anime conventions, and even then they’re not actual real ninjas, they’re just dorky teenagers dressing up like, I don’t know, Scorpion or Sub-Zero from Mortal Kombat and stuff. Actually, now that I think about it, the chances of your ninja being a REAL ninja are statistically pretty minimal–except wait, C2 vertebra fracture.


Okay. Jen, I know you can’t see this, but try to be brave. I don’t want to alarm you any more than you already are, but… it’s probably a real ninja.

All right, look–crap, I did it again, sorry. You’re getting a big ol’ eyeful of that P key and I’m telling you to “look”. Geesh. I don’t–wait, don’t you wear contacts? Oh MAN that has gotta suck! I mean, you suddenly lose sensation to 95% of your entire body all at once and the part that can still feel has to start hurting? Ha! Sorry, sorry, I shouldn’t laugh. It’s just that I’ve never really been sure what the actual definition of irony was, and I was just thinking that this is probably pretty close, and–

Sorry, I’m sorry. Appropriate conversation, I get it. I’m pontificating about wordplay and you’re lying there, terrified, with a probably-real ninja assassin in your apartment and spit puddling around your cheek. It’s not like you’re wondering if AppleCare covers the damage if the trackpad shorts out from your saliva. It doesn’t, by the way. Cover the damage, I mean. Just in case you WERE wondering. Which would be pretty odd, actually. And not just a little hypocritical, given the whole “appropriateness” discussion, if you ask me. Which you didn’t, given the whole “keyboard face” thing–sorry to keep bringing that up but it’s really sort of the elephant in the room here–and anyway now I’m starting to wonder why I can’t seem to go more than two paragraphs without it feeling like we’re having an argument. Am I projecting? I feel like I could be projecting. It’s possible. I am going through some issues right now. Okay, tell you what: let’s assume that yes, I *AM* projecting. Let’s just go on that, from here, clean slate, start over. Okay? Okay. Starting over. I’ll go first.

I forgive you.

Well what else am I going to start with, it’s not like we can pretend that words haven’t been said here! I’m just trying to make you see–and YES I realize that was an inappropriate word, but that’s starting to become just a bit too convenient a deflection, young lady, we ALL KNOW that you’re face down in your laptop, we GET IT, the whole paralysis thing, it was big news when we first heard about it but at some point you are just going to have to pick yourself up, sorry, haul yourself up by your bootstraps, again sorry, though maybe you’ve got a friend who would go boot shopping for you and put them on your feet for you so you would have actual, literal bootstraps, and then I guess maybe your friend could sort of tug on them for you, because maybe you gave her a head-nod or an eye-blink or whatever, I don’t know how this stuff works, she’s your friend so I’m sure you could work out some kind of signal given time, but my point is that sooner or later you are going to have to stand on your own two feet. Sorry.

Look (sorry) these are just figures of speech, it’s not like I’m standing (sorry) around trying to think up inappropriate knee-slappers (sorry) to say to my suddenly-and-inexplicably quadriplegic friend to be hurtful! It’s not like I am TRYING to cut you down (sorry) or kick (sorry) you in the teeth (sorr–wait, that one would actually work), if you could just meet me halfway on this, I would try to do better, I really would, Jen, I would try so hard.

But nothing is ever good enough for you, is it? Is it? You don’t have to say anything. We both know I’m right. Well here’s something you DON’T know: I have HAD IT. I am DONE. I tried to give you my friendship and you sure took it, but you couldn’t give back, could you. You just had to go and make everything about you, you, YOU. Well HERE’S something that’s about me, me, ME: ALL MY FINGERS STILL WORK YOU AWFUL HARPY! I HOPE YOU ENJOY STARING AT YOUR KEYBOARD AND I HOPE YOUR TRACKPAD TASTES LIKE GROSS SWEATY PALMS! Look at me! My legs both work! I’m not the one drooling into my keyboard! I’m not the one who is going to be discovered by EMTs tomorrow morning with my laptop open, AND I’M NOT THE ONE WHO’S GOING TO HAVE TO EXPLAIN TO THEM WHY I’M LOOKING AT AN EMAIL FULL OF ASCII-ART PENISES!!!




P.S. If you are not in fact paralyzed from the neck down please stop reading 17 paragraphs ago

P.P.S. The penises count as one paragraph

Final note for you blog readers: If you use Ruby, you can generate your own page full of ascii-art penises with the ‘dicks’ gem. Just type ‘gem install dicks’ and then ‘dicks -n 30’ and bam, your face will be full of cocks. As it were.

Luck Is Not A Factor

Once Upon A Time, A Nonsequitur

“You can observe a lot just by watching.” — Yogi Berra

Late in 2006 I was sitting in Rodney Bliss’ office for our weekly investor debriefing. Rodney was the President of the company; as the Director of Technology I reported to him. In theory, Rodney ran the company and I ran the development team. In practice, the investor would change our priorities and expand the scope of the project every week and it was all we could do to keep up. Rodney had just returned from meeting with the investor, and we were going over the new list of features so that we could prioritize dependencies. And then he casually told me of another request that our investor had made.

“He wants me to put together a list of all our expenditures, from payroll to soda pop–”

“Aw, CRAP!” I interrupted.


“You’re going to get fired!”

“What…? No I’m not!” Rodney actually laughed. I just stared at him in horror. I couldn’t believe he couldn’t see it. It was so clear.

“Rodney, I’m not joking. You’ve got 2 months at best; less if he’s smart. Based on the way things have gone this year, I’m guessing right at about six weeks.”

“Dave, calm down. I am not going to get fired.”

Six weeks later, almost to the day, Rodney got called in for his exit interview.

Rippling Grass Is Always Caused By Wind Except When It’s Tigers

The thing was, I knew Rodney was going to get fired, but I didn’t know how I knew. It was a very chaotic time for all of us, and there was no one significant indicator that I could point out, but sitting in that office, I could see all these tiny little details suddenly adding up to a starkly clear pattern. I’d worked for half a dozen clients in as many years, and based on all of my experiences joining and leaving companies, this request from our investor was… odd. Not just odd, but totally out of keeping with his character and with the way he had behaved towards us all that year. All of these things added up instantly in my gut, if not my head, and what was odd suddenly became ominous. Our investor had always respected Rodney’s autonomy, and aside from some ineffable “leadershippy things” that Rodney did, budgetary discretion was the only thing Rodney actually did… at least on paper. And now the investor was taking that function over. I knew–knew–Rodney was going to get fired, just as soon as our investor put all the pieces together.

It took me seven years to figure out how I figured all that out. It was just last weekend, in fact. Rodney and I were arguing good-naturedly–we’ve stayed friends over the years–about a blog post he’d just written, titled And Sometimes You Just Get Lucky. Go read that post; I’ll wait. It’s a lot of fun to read and most importantly, Rodney is wrong and I can’t resist the temptation to point that out. Especially because it’s the kind of wrong where I get to point out how awesome Rodney really is.

Luck Is Not A Factor

For those of you who didn’t go read his post–for shame!–the TL;DR is that Rodney got lucky debugging a computer problem. He sat down and typed a few commands, and noticed something out of the ordinary. To everyone else in the room, it was ordinary–just a very large amount of free disk space. But Rodney was one of the first SWAT engineers at WordPerfect, and had been steeping himself in the engineering lore of the company for years. He just happened to know that Shell.exe counted up free disk space when it started up. He just happened to know that computers at that time were occasionally experiencing growing pains, where the size of the place in memory for storing numbers was turning out to be too small–like the number of free bytes on disk, in an era where people still carried floppy disks that held less than 2 megabytes, but now you actually could have entire gigabytes(!!!) of disk space lying around–even, in this case, the 2.147 gigabytes needed to overflow a signed 32-bit integer. And lastly, but most definitely not least, he just happened to know the name and phone number of the guy at WordPerfect who wrote Shell.exe in the first place.

Rodney says he got lucky. Rodney is wrong. He was no more lucky that day than I was at guessing he was about to get fired. A hundred tiny factors, measured in our brains against a hundred past experiences, and suddenly we knew that particular ripple in the grass was a tiger.

Cool Story Bro, But So What?

Well, for starters, Bro, start looking at the grass. Unless you’re down with getting eaten by a tiger. That’s very eco of you, man. I mean, hardcore. I can, like, totally respect that.

No, the thing is, if this isn’t luck, then maybe this is a force we can harness for good. Or at least maybe luck is something we can measure. You know, with science and stuff. Or something. Richard Wiseman set out to do just that, measuring the skills and abilities of people who considered themselves lucky against people who considered themselves unlucky. One of the tests he gave was to ask participants to count the number of images in a newspaper:

"I gave both lucky and unlucky people a newspaper, and asked them to look through it and tell me how many photographs were inside. On average, the unlucky people took about two minutes to count the photographs, whereas the lucky people took just seconds. Why? Because the second page of the newspaper contained the message: "Stop counting. There are 43 photographs in this newspaper." This message took up half of the page and was written in type that was more than 2in high. It was staring everyone straight in the face, but the unlucky people tended to miss it and the lucky people tended to spot it."

You can read Wiseman’s entire article here. It’s fascinating. He even changed the message to say “Stop counting and tell the experimenter you have seen this and win £250.” There was no change in the survey results–except that now the lucky people were going home £250 richer.

I don’t want to steal Wiseman’s thunder, but his bottom line is that lucky people relax more, and tend to be more open to noticing things even while they are focusing on accomplishing a task.

No Seriously, So What?

Dude, seriously. You need to relax. No, I mean literally. That’s the whole point of Wiseman’s article.

I read his article a long time ago–It’s ten years old now–and I’ve been fascinated with the kinds of pattern recognition our brains are constantly doing. I began to notice more and more that I was spotting tigers in the grass in the weirdest of places. I began to notice much more subtle tigers. I began to spot tigers from much further away with less and less data. When I called Rodney’s termination, I knew the investor personally and had a lot of information about him personally. Turns out that was mostly noise; the “tell” is an executive with insufficient personnel knowledge asking for a budget spreadsheet. Earlier this year, a manager at one of my clients commented offhand that he had to prepare a budget breakdown for an executive that nobody on the team had ever heard of. I sighed, and smiled wistfully, and told him that it had been nice working with him. When he asked me what I meant, I shrugged and said “that executive is going to have all of the contractors fired. In my experience, it takes”–waaaiit for iiiit–“about six weeks.” This time I was watching the calendar carefully, and I called it exactly to the day.

Okay, So Spidey Senses Are Neat, But Can You Use Them In Anger?


Specifically, the question I am putting in your mouth here is whether or not you can use this pattern recognition skill actively and aggressively, not just defensively. The answer is most definitely yes.

You can use it to hunt tigers.

A couple years ago I was working at a company that handled some sensitive data. I’m used to playing things fast and loose, by which I mean empowering team members and requiring them to be responsible. Unfortunately, we had a sysadmin who didn’t want anybody touching anything for fear of accidentally exposing our production data. He knew his stuff and I respected him, but our approaches to development were worlds apart when I first came on board, and part of us working out our kinks was having some splendid arguments about silly little things like “being able to do my job” and such. You know, trivia.

I remember we had a problem on our production database server that was just beyond bizarre. We had a fairly intensive query that we had been optimizing. A typical query returning a few hundred records would take 10 seconds, which we optimized and got down to half a second. The worst-case queries would return 10 or 20,000 records and would take 90 seconds or more. We optimized those and got them down to 2 seconds. Things looked really good. Except… well, every thirty minutes or so, the queries would take 30 seconds to run. It didn’t matter if they were worst-case queries, or typical ones, or a mixture; the database would just go away for 30 seconds and all the queries would wait before suddenly coming back all at once.

What I desperately wanted to do was log into the production server and watch it run. I knew our sysadmin was absolutely freaked out by the very thought of this because, well, I asked him, and he absolutely freaked out. So I checked everything I could in the code again. Then double-checked. Then triple-checked. The code was fine. There HAD to be something weird going on on the server.

Our sysadmin wasn’t totally unreasonable, he just absolutely refused to compromise the safety of our data. This is a good trait to have in a sysadmin! But it was early days for us working together, and we hadn’t quite learned how to do it. Work together, I mean. He kept asking me, “Tell me what you want to know about the server, and I’ll tell you.” And I kept responding by holding up my hands and saying “I don’t know. I’ll know it when I see it, but I won’t know it until I see it.”

Months later we would work out how to work together effectively, but at that point in time it literally took the intervention of a Vice President to work things out. The proposed solution was laughably simple. To the sysadmin, he said “do you see any reason Dave can’t watch over your shoulder and tell you what to type? He never touches the keyboard, and you have veto power over him looking into sensitive data.”

The sysadmin grumbled that this would be okay, but that he was sure it would be a total waste of time.

We sat down–well, he sat down. I was literally forbidden to be within arm’s length of the desk. I asked him to start looking around the server. Logfiles, running processes, network I/O, database load. As we were looking at running processes, I noticed that the database was running a reverse DNS lookup on an inbound query. I also knew that, for security purposes, none of our webservers had reverse DNS lookups enabled.

“Hey, how long is the timeout if reverse DNS fails?”

The sysadmin stared at the screen for a long moment. I couldn’t tell if he was embarrassed, or angry, but I could see that we had just seen what we’d come to see, and he was piecing together all of the implications in his head.

Finally, all the implications came together and he said, all at once: “Thirty seconds, there’s the query delay. And when it fails, it caches for 30 minutes, so there’s the problem frequency. And reverse DNS shouldn’t even be enabled on the database. Hang on, let me turn it off.”

Total elapsed time, from the time I walked out of the VP’s office with the sysadmin, to the time I returned to tell him we had found and fixed the bug?

Four minutes.

Wow. Can You Ever Use It Defensively And Offensively At The Same Time?

In theory, yes. In practice I’ve only ever seen it done once.

Here’s the theory: if you see that ripple in the grass a long, long way off, but you can’t change your course, you know a tiger attack is coming. Tigers rely on the element of surprise, but you have time to prepare. How much time depends on how far away you saw the ripple. So you try to pick where you’ll make your stand, and you try to bolster your defenses, and when it becomes clear that you can’t avoid the tiger, you… relax and let it happen. As the blur of black and orange streaks up at you from the grass, you can learn a lot about a tiger in a few milliseconds if your life depends on it, and in those milliseconds, you can discover that tigers are often quite surprised by having their ambush turned into a deft counterattack.

That’s the theory, anyway. In practice… well, remember the first story I told, about Rodney? I called the ripple six weeks before the tiger attack. Rodney didn’t believe me at first, but as the weeks went by, other signs began to become clear. I don’t remember what finally convinced him–I think there was a planning meeting on the calendar, and I told Rodney that if I was right, the investor would cancel it, because it made no sense to waste time making plans with somebody you’re going to fire. Sure enough, the investor canceled the meeting at the last minute for “personal reasons”. More importantly, after a year of working with the investor, we knew he was very organized, and always moved appointments instead of canceling them. This time, the investor didn’t set a date to reschedule. When Rodney asked when would be a good time to reschedule, the investor said “let’s talk about that after next week.”

“Next week” was six weeks after I’d said he had about six weeks left.

Rodney went to his weekly meeting with the investor, calm and ready for another normal day of meetings, but also on the lookout for anything out of the ordinary. And there it was: this time there was an extra person in the room–the CFO. Rodney knew from corporate experience that he was there to be a witness… and that meant that this was going to be his exit interview. He sat down, and they sprang what they thought was going to be an ambush.

As the blur of black and orange streaks up at you from the grass, you can learn a lot about a tiger in a few milliseconds if your life depends on it…

I don’t know what happened in that room that day, but Rodney walked out of there smiling, and still very much the President of the company. Oh, they still wanted him gone, but instead of kicking him to the curb as planned, they ended up timidly asking him what terms he would like for them to come to some sort of arrangement regarding that…?

Rodney met the tiger… and then the tiger met Rodney.

But… that part of the story isn’t my story to tell. Which is why I sat him down and made him promise to tell the story on his blog someday soon.

“Dave, calm down. I am not going to get fired.”

Huh. I guess he was right.

James Edward Gray: Associative Arrays and Ruby Hashes

Yesterday I put out a little screencast showing some ways of Creating Ruby Hashes. James Edward Gray II pinged me on Twitter and basically said “Great screencast! Ooh, but you forgot this! Ooh, and this! And this!” and so of course there was nothing to do for it but invite him to do a pairing screencast with me.

This video is a bit of a weird hybrid. You get 7 minutes of podcall, then 18 minutes of screencast, then another 12 minutes of podcall. James shows off some of the “hot new awesomeness” of Ruby 1.9, and then points out that this awesomeness has been around for a couple of years and nobody’s using it, in spite of it having been in the current Pickaxe for nearly as long. Along the way we talk about regular expressions, testing dogma, and the importance of never squashing creativity in the open source community. All in all, an incredibly fun time for me. James threatened to come back and do another one with me on regular expressions, and I’m mentioning it here in writing so that everybody knows I plan on taking him up on that offer.

No podcast, because half of it is us typing into a shared screen session. But here’s the video. You may need to watch it on Vimeo or download it to see the font clearly.

Associative Arrays with James Edward Gray II from David Brady on Vimeo.

Monkeypatching and the Open-Closed Principle

Ah, the Open-Closed Principle. In static languages like C++ and Java, classes by default are Closed-Closed. In dynamic languages like JavaScript and Ruby, they are Open-Open. In Java you have to add design pattern ceremony in order to open for classes for extension; in Ruby you have to exercise discipline in order to keep them closed for modification. Yesterday Pat Maddox and I spent 80 minutes kicking the can around talking about Monkeypatching versus the Open-Closed Principle. Along the way, we talked about everything from Rebecca Black to RSpec, from Cognitive Load to watching my cat try to claw open my office window.

We’re Starting a Podcast!

Pat and I are gonna start doing this regularly. And we need a cool name for our podcast! Help us out! The giver of the winning suggestion will get something cool. Not sure what yet, but I promise it will be something cool.

But for now, just watch the rest of this post’s space for the video. Because I’m embedding it in 3… 2…

Monkeypatching and the Open-Closed Principle from David Brady on Vimeo.

I Accidentally Spoke at MWRC 2011

I found out the night before the conference that one more speaker had canceled than the conference had backup speakers in reserve. I found this out because I was rooming with the conference organizer, Mike Moore, and BOY did he call in the favor of not asking me to split the hotel cost!

So, I spoke for about half an hour about Monkeypatching Your Brain. All while dressed in a Hilton Hotel bathrobe:

Photo by Jeremy Nicoll of Smashing Shots

It’s currently up at, here: I am the second speaker, about 38 minutes in. It’s the livestream from the conference and I don’t know how long the link will be valid. Confreaks is in the process of making “proper” videos of the conference. I’ll post a link once those are up.

TourBus 2: The Tourbusening

I’m speaking at Utah Open Source Conference! I will use up 55 minutes of your remaining lifetime talking about web load testing.

I am, of course, going to dust off TourBus. It was such a simple app that there wasn’t really anything to show off at MWRC 2009 and I am pleased to say that there still isn’t!

But you could help change that. Check out TourBus on GitHub, or better yet fork it and dig in.

Some features I hope to add in the next month:

  1. AMF support (testing Flex apps, anyone?)
  2. Proxy logging (tour the website yourself in a browser, then playback your browser session)
  3. Better (read: ANY) specs!
  4. Rails plugin, complete with generators and rake tasks
  5. Reporting and statistical analysis

Seriously, what’s not to like? Get in there and get forking!

P.S. For those of you watching the MWRC 2009 video and wondering, “Will I ever get the chance to see those ridiculous sideburns in person?” the answer is oh my goodness yes.

Sudoku: Math Is Hard, Let’s Go Shopping

I’ve been researching others’ techniques for generating sudoku puzzles, and I have come to the conclusion that nobody actually knows how to do it.

Seriously, if you Google for “generating sudoku puzzles”, most of the methods boil down to “randomly throw numbers at the board and see if it’s a sudoku”. Oh, there’s some cleverness you can do to try to intelligently preserve the randomness of a partially-complete sudoku puzzle (like not randomly putting a 9 into a column that already has one) but at the end of the day all of the solutions basically amount to bogosort.

I promised yesterday that I’d reveal the identity board math. I had planned a big reveal here with lots of mathy explanationing, but the math just isn’t that exotic. There’s a trick to it, but that’s about it. Here’s the math:

A Sudoku board of dimension n is n2xn2 digits, and has nxn sectors, each with n2 digits. Let’s write a function to find the number at position x, y on the board. The whole trick to my F(x,y) math is simply this: the numbers in every sector other than (0,0) are rotations or shifts of the numbers in sector (0,0).

Make sense? Here. The numbers in sector(0,0) are simply the digits 1..n2, arranged in a grid, so that’s easy:

F(x,y): y*n+x

And the math for every other sector is simply a selection into sector 0, 0. Specifically, for F(x,y) outside of sector (0,0), choose the F(x’,y’) IN sector 0,0 such that

x’ = ((x+y/n)%n

y’ = ((y+x/n)%n

So at the end of the day the whole function looks like this in ruby:

def idfx(x, y, n)
  if x<n && y<n
    idfx( ((x+y/n)%n, ((y+x/n)%n )

I should point out that I am operating under the belief that a sudoku puzzle is like a Rubik’s Cube: that a set of transformations can be performed on a valid puzzle that leave the puzzle changed but always valid, and that you can turn any sudoku puzzle into any other sudoku puzzle via these transformations. If I am right, I can take my identity puzzle board and shuffle it using these transformations, and just like scrambling a Rubik’s Cube I will be left with a unique and interesting puzzle that is, most importantly, still valid.

I have proven the first half of my assumption–there are transformations that will change a sudoku without affecting its validity. What I haven’t proven is the second half. I cannot yet transform puzzles arbitrarily. It may not be possible at all, but right now I’m simply hoping that I don’t know enough transformations yet.