Archive for the 'Hacks' Category

Python: di

Friday, August 24th, 2007

The id() function doesn’t have an inverse1. Now it does.

>>> k = object()
>>> print k
<object object at 0x9a3b8>
>>> id(k)
631736
>>> from di import di
>>> j = di(631736)
>>> j
<object object at 0x9a3b8>
>>> id(j)
631736

Stupid simple module available in my SVN repository.

1 For good reason. An object’s id() is just its address in memory. This hack is effectively exposing a pointer — a fragile, prone to disappear out from under you, nasty, C-ism — into Python. It is like running on marbles with scissors. No stability and potential for loss of precious runtime fluids.

In a debugging context, though, being able to turn an id() back into an object reference allows interrogation of objects where identification of “objects of interest” and the actual interrogation of said objects does not have to happen within a contiguous set of expressions.

Chris says:

I wish people wouldn’t post stuff like this. There is never any case where this is a useful operation - the only time it works is when the object you want to retrieve is still around anyway - and there’s never any reason to store the id of an object instead of the object reference (or a weakref) instead.

People asking how to do this isn’t uncommon, and being able to google for it will just lead people to doing it instead of being told that they need to fix the problem that leads to them wanting to do it instead.

“Never any case”? That is a bit unimaginative and could even be construed as arrogant. The only safe “never” is in the statement “never assume you know everything”.

Sure — if you pass a random number or the id of a no longer existing object to di(), your process is going to crash. Totally true and I have added some emphasis on exactly why this feature is not a part of python, nor should it be.

As for this tool and the dangers therein: So what? Don’t do that. Tools can be misused. If something hurts, don’t do it.

This tool has saved me hours and hours of engineering time, several hundred lines of fairly complex code, and having to make some fairly nasty & intrusive changes to several relatively complex client/server focused codebases. More subtly, it allowed me to vastly reduce memory leaks without having to instrument the code in ways that would have very likely changed the lifespan of objects.

Lame. Python’s weakrefs don’t support weak references to Dictionaries, Lists, Tuples, Strings, or None. Four out of five of these types are very often exactly the kind of thing I need to figure out why there are tons of ‘em floating around that shouldn’t be. Bogus.

Posted in Hacks, Software | 15 Comments »

WWDC ‘07 is in the can!

Tuesday, June 19th, 2007
Gerbera Daisy

WWDC ‘07 is now behind us. A huge thank you to everyone who took a moment to give kudos and criticisms of all the work that we have done in the last year. It was overwhelmingly positive and very much appreciated — a confirmation that we are on the right track.

The Tommy’s runs were an awesome success. Wednesday had two graduations and tons of folks showed up!

I spent the weekend unwinding with a bit of development work on Dave Dribin’s MAME OS X client. Was quite relaxing to work with production tools in a production environment without any deadlines. I ended up adding persistence of audit data across app invocations. If I get a chance, I have some ideas to further improve the app.

Posted in Hacks, Life | 1 Comment »

Cthulhu: Eater of Souls, Roaster of Dogs

Saturday, May 26th, 2007

RoastMyWeenie has a limited number of Cthulhu(/Punisher) roaster’s available for purchase.


Cthulhu: Eater of Souls, Roaster of Dogs

A while ago, I wrote about some pretty funny / cool hot dog roasters sent to me from the folks at roastmyweenie.com.

Work well enough, and pretty amusing, but not exactly practical for even a modest sized cook.

I really wanted a roaster that could hold more than one dog. After thinking about it a bit, dawned on me that some creature with tentacles would be perfect and easy enough to cut on roastmyweenie’s water jet based cutter.

Now, I could have a gone with a squid based design as they will, in fact, eventually rule the living world.

But, nah….

Read the rest of this entry »

Posted in Big Green Egg, Food, Hacks | 31 Comments »

Maker Faire ‘07, Day 2

Tuesday, May 22nd, 2007
SRL's Knife Bot Doing The Knife Dance

On day 2 of the Maker Faire, I spent most of the day hanging out with my pinball machines, answering questions, chatting with the SRL folk as they prepped for their performance later in the day, and enjoying refreshing waves of ozone as the Tesla coil was fired up every hour.

Photo on the left is SRL’s Knife Bot doing the Knife Dance with the two pinball machines in the background. Here is another shot with the SRL Logo, Satan Head and the pinball machines in the background.

I also spent some time wandering about to check out various incredibly cool hacks and events, focusing on stuff I had never seen before.

Heavyweight Class Battlebots

The Robot Fighting League folks built a full sized combat robot arena in the robotics room of the show, completely with bleachers for folks to enjoy the show.

I have seen BattleBots on TV and, sure, it was entertaining. But the robots never really looked that terribly menacing.

The arena had a thick plywood roof and lexan (bulletproof glass) sides. The fighting floor was thick plywood, surrounded by a wall of heavy metal beams.

I.e. the arena was built to contain serious destruction.

In come the ‘bots. Two heavyweight robots (I don’t remember the names) weighing around 220 lbs each. Yes — 220 lbs — only slightly less than me (but more than I should weigh). The bots also looked significantly larger than on TV. Very solid, too.

And then the fighting began.

Holy Crap!! These things move fast. Zero to bat out of hell in a second or two, switching directions, flipping over, and generally raising mayhem in milliseconds. When the bots hit, you could feel it. Not just through the noise of the arena, but as vibration through the concrete floor.

Wow. Damned impressive. There was a moment where one of the bots unleashed a hammer like weapon that hit the lexan. I thought the stuff was going to break.

After the two bouts I saw, they had to have a 20 minute delay to repair the arena. Yes, the robots had actually hit the metal beams so hard as to knock them out of place, ripping screws out in the process.

In this picture, you can actually see that the iron beam wall is bent.

Read the rest of this entry »

Posted in Entertainment, Hacks, Life, Technology | 1 Comment »

Maker Faire ‘07, Day 1

Sunday, May 20th, 2007
Discovering Pinball

Maker Faire day 1 was a huge success.

The pinball machines have been in play constantly. Lots of folks had some great questions, many of whom seemed disappointed that I don’t restore machines for a living.

Lots of kids at the show, pretty much perpetually in awe. It was great to see their faces light up when they played their first game of pinball.

Both machines are holding up really well, even under some serious flippity-flap abuse. The Cyclone has not reset a single time!

Very Big Spark

I’m located in an awesome spot this year (last year was in the same room with the circuit benders which was really incredibly painfully loud). As mentioned before, the SRL crew share the corner with me. Seriously interesting people doing very cool stuff. I spoke with Mark Pauline a bit and he introduced his incredibly cute kid to pinball; the kid is a natural!

A little bit further away is the Tesla Coil installation. Two 12 foot tall tower coils driven by quite the custom power supply and driver circuit. The pictured spark was only about 4 feet in length. When going full blast, the tours will generate sparks that jump across the 10 or 12 foot gap in between. With lots of noise and that tasty ozone smell.

Damned impressive piece of equipment. Even more impressive is that the towers are a scale model of what will eventually be two 122 foot tall towers in the Nevada desert that should be able to generate 300 foot long bolts of lightning.

Even these “small” towers generate one hell of an impression when powered up. You can feel the charge, it is damned loud and the sparks are clearly visible even in the otherwise brightly lit room.

Read the rest of this entry »

Posted in Entertainment, Hacks, Life, Technology | 1 Comment »

Maker Faire: If you can make it and don’t… you lose!!

Saturday, May 19th, 2007
Restored Pinball Machines

Ben and I packed up a couple of pinball machines and headed up to the San Mateo Fairgrounds to add ‘em to the rather amazing collection of stuff on display at the Maker Faire.

Last year was incredible, but this year is going to crush it. Many more exhibitors and exhibits. Lots of small stuff, large stuff, interactive stuff, and just plain amazing stuff.

I am deeply honored to be invited to be a part of the show. While everything about Pinball is quite completely in line with the Maker ethic, it is clear that I need to take this beyond “restoration” and directly into “customization” and “optimization”.

Of course, we setup the Cyclone — the machine that was the subject of the Make article — and then it immediately started reseting during game play. Typical problem of System 11 based Williams machines.

So, we road tripped back south and hit up Halted for a boatload of random parts that might fix the problem. $48 and two slices of the best pizza on the west coast later, we headed back to the Faire to fix the damned machine.

Fingers crossed, it seems like a bit of solder reflow, some replacement diodes and capacitors, and a bit of connector cleaning has stabilized the machine!

We also used the setup day as an opportunity to take a few pictures that simply won’t be possible once the place is packed. And packed it will be. This is going to be one hell of a show.

Ben Fighting Off Robot Overlords!

Our neighbors are SRL: Survival Research Labs; kings of the massive destructo-bot, fire breathing, overwhelming shows. Seriously cool stuff. I had a friend that worked with them back in the late ’80s and I have always wanted to meet the crew.

Now I have. Seriously nice people working on some seriously kick ass ‘bots. Pictured is a knife wielding bot that will happily thrust a knife into styrofoam around an outline of a hand. If you have the guts, you can put your hand in the outline.

That is, if the robot is calibrated. Which it wasn’t. So, Ben volunteered to help calibrate the ‘bot. Looks kinda like he was fighting it off, though.

The SRL crew brought some scary robots. Hundreds and hundreds of pounds of self-mobile steel that often breathes fire.

Can’t wait to see this stuff in action.

Read the rest of this entry »

Posted in Entertainment, Hacks, Life, Technology | 2 Comments »

Muddled Strawberry Cocktail

Saturday, April 21st, 2007

It is strawberry season. Woot! As such, I make a habit of getting big flats of strawberries at the farmer’s market; sample until you find the tastiest berries at the market, then buy too damned many for your family to consume!

Fresh and crisp, they make an excellent addition to pancake batter, milkshakes, salads, and a bunch of other kitchen creations.

Update: Got a better, more precise recipe. And I found a really excellent stainless steel muddler (see picture at right).

  • Grab yourself a handful of berries or other soft sweet fruit; strawberry, blueberries or mangoes.
  • Throw ‘em in a glass and muddle the heck out of ‘em!
  • Squeeze in the juice of one fresh meyer’s lemon or drop in one whole meyer’s lemon ice cube (if you have them — I always have ‘em on hand)
  • Add about a shot and a half to two of a good tequila (100% blue agave tequila, of course)
  • Add several ice cubes
  • Top with some unfiltered apple cider and a splash of cranberry or cran-raspberry juice

Delicious. Fruity. Refreshing.

As long as they aren’t moldy, I take whatever isn’t eaten by the next weekend and purée them with apples and a bit of lemon juice. Take the purée and dry it in a dehydrator or oven on the lowest settings to produce delicious fruit leather (I dry it to “crispy” so it doesn’t rip my crown out).


Posted in Food, Hacks | 1 Comment »

How to turn a whole salmon into fillets.

Sunday, April 8th, 2007
Perfect Fillets

Great salmon is a real treat; delicious tender and juicy meat that is almost difficult to pick up with a fork. It carries flavors well and can be cooked dozens of ways. Poached with citrus and red wine yields a refreshing and light result that couples well with salads or spring vegetables. Hot smoked salmon creates a rich, full bodied, hunk of meat that is almost steak like in its texture and depth of flavor, yet still carrying that wonderful salmon flavor.

The best salmon is wild. No, let me put it more succinctly: Farm raised salmon sucks, bad for you, often laced with tons of food coloring, and just a completely disappointing waste of money.

The one problem is that wild salmon typically carries a premium price. It isn’t uncommon to see wild salmon filets pushing $15 a pound. The more refined the cut, the higher the cost.

However, if you are willing to exercise a bit of knife work, it isn’t hard to breakdown a whole fish into fillets. What cost $15/pound fully processed, can be had — typically much fresher — for well under $10/pound.

In my case, I get my fish from Patrick O’Shea of Mission Fresh Fish. His crew shows up at the Mountain View farmer’s market, but I go to the market on Saturday mornings in Saratoga; no craft vendors, all food.

Patrick was kind enough to show me exactly how to clean a salmon. Whereas I had shredded the meat previously, I can now take a fish apart into perfect fillets in a matter of minutes!

Click on through for a photo tutorial on exactly how to do so…

Read the rest of this entry »

Posted in Food, Hacks | 3 Comments »

Digicams with five second exposures?

Wednesday, March 28th, 2007

On the spark post, K asked:

Are digital cameras with five second exposure times really that common?

It always pays to have lots of cash and expensive gadgets when you’re making all these money-saving Make projects…

Good question. But lots of cash and expensive gadgets are not needed.

Of course, all of the Digital SLR style cameras can do this. Most even have a “bulb” mode where you can manually click the shutter open and closed at will. I usually just stick with a 5 second or 2 second exposure and use my little homebrew remote trigger.

If the $500 or so entry point into the DSLR market is too steep for you (or the cameras are just too damned big), then you can go with any of a number of compact and sub-compact cameras that can do multi-second exposures.

I quickly bopped over to DPReview.com and used their buying guide (link on left nav bar — can’t direct link it due to Ajaxian stupidity) to do a Features Search on:

  • Min Shutter: 30+ seconds
  • Price: < $200
  • Only Current: YES

Thinking that there might be one or two. Wrong. There are at least 10 cameras that match the above. There is even a camera that can do timelapse photos — can be programmed to take a photo every N seconds/minutes — for under $200 that can also do 30 second exposures!!

(BTW: The fun factor payoff and collaborative creativity that all of this has fostered is awesome! Thanks to the Make folks for catalyzing this hack oriented age of enlightenment.)

Posted in Hacks, Photography, Technology | 2 Comments »

‘Cause splosions are cool.

Tuesday, March 27th, 2007
Capacitors are Fun
  • Take a part a disposable camera, desolder the capacitor and rig up a charging circuit.
  • Charge the capacitor
  • Turn off the lights
  • Set your digital camera on a 5 second exposure*
  • Use a bit of metal to discharge capacitor at the focal point of the camera
  • Upload photo to flickr

That is all.

*Digital is key. You want to have zero guilt about wasting a shot or 10 doing silly things. Oh, and get one of them null glass filter thingies that screws onto your lens in front of the front element. Much better to have that shatter when a stray bit o’ something hits the lens than, say, the front element.


Posted in Hacks, Photography, Technology | 12 Comments »