Archive for the ‘tips’ Category.

“Fail to create pixmap with Tk_GetPixmap in ImgPhotoInstanceSetSize” – A Matplotlib WinXP Nightmare

Those of you Python programmers out there on Windows boxes who use the wonderful library matplotlib / pylab to render your charts and graphs have probably run into this before:

Fail to create pixmap with Tk_GetPixmap in ImgPhotoInstanceSetSize

It’s not immediately clear just why matplotlib generates this error.  I’m guessing by the namespace that it uses Tk under the hood.  Okay.  And apparently Tk has issues on Windows XP and earlier (not sure about later versions of Windows) where it eventually runs afoul of either a memory leak or a bitmap handle reference limitation … or something. Information is kind of sketchy.

And what’s worse, the results of this bug are disastrous.  It doesn’t stacktrace.  It simply crashes Python with the message to stderr:

This application has requested the Runtime to terminate it in an unusual way.

Please contact the application’s support team for more information.

Loverly.

But fear not!  There’s actually a simple solution.  Don’t import matplotlib globally.  Import it locally instead.  This causes whatever limitation gets exceeded to be reset because the module gets unloaded once it goes out of reference.  And if your code somehow generates so many charts in one function that even that isn’t enough to fix your matplotlib woes, then take it one step further and reload the library using the reload statement.

Yes, it really is that simple.

Though it’d be awfully nice if matplotlib (or Tk) were to just fix this problem in the first place.  As of the time of writing this bug is still in matplotlib up to version 0.99.1.

Unlocking The Power Of The Panasonic SH-PD10 Universal iPod Dock

For reasons that I won’t bother explaining, we’re collecting a pile of these Panasonic SH-PD10 Universal iPod Docks.  ( Part No. TNM2AX0011 / Part No. RGN2935 )  And the question becomes, what to do with them?

Panasonic SH-PD10 Universal Dock For iPod

Panasonic SH-PD10 Universal Dock For iPod

Well I don’t have an iPod (nor do I want one as my cellphone plays music just fine), but it seems like everyone else does, including a few coworkers.  So the question became … can we do anything with these docks?

The answer is … probably!

Okay, so the connector on the end of the cable looks to be some kind of proprietary Panasonic thing.  Unless you want to order repair parts for a TV or stereo from them to get the slot for this connector, I just say cut it off at the head and splice what you need into place.  For that reason, I’m not even going to bother trying to figure out the pin numbers for the cables.  Sorry.  Though if someone else has them, I’d be happy if you left a comment with that information.

So wires, wires, wires.  I took the dock apart.  There’s really not much to it.  It feels heavy only because of a metal plate in the bottom that makes it heavy.  Actually, the device is pretty devoid of anything interesting.  It’s just a small PCB with the iPod dock port and a bunch of little resistors.  Unfortunately none of the wires lead directly to the iPod dock port, nor does the PCB lend itself well to tracing.  It was most disappointing really.  So I’m left more guessing what the wires are based on color and position.  Though if one of my coworkers decides to test things, a blog update may provide more definitive answers.  Likewise, if you decide to test things, please give your feedback on what I got right and anything I got wrong.

(That said though, if you really want to unlock the power of your iPod in a custom-made dock, this thing would come in pretty handy.  It wouldn’t be hard at all to solder your own wires to the iPod port on this dock and do whatever you like.  Taking the dock itself apart is very easy.  Just remove the rubber feet, unscrew the phillips-heads under each, and then pry apart as it also snaps together.)

Now, on to the cables:

Yellow – Composite Video

Violet – Component Video Y

Blue – Component Video U (Pb)

Green – Component Video V (Pr)

Black (the small one) – Video Ground

White (the small one) – Left Out

Red – Right Out

White (the large one) – 3.3V or 5V Power (500 mA MAX)  (And yes, it supposedly can be either as the iPod will accept both voltages.)

Black (the large one) – 3.3V or 5V Ground (Also looks to be the audio ground, but looks could be deceiving.  My guess would be use the video ground if this doesn’t work.)

Orange – Serial Rx

Gray – Serial Tx

Brown – Serial Ground

Yes, there are two white cables and two black cables.  (In fact on the inside of the device there are three black cables, one of which connects to the cable’s ground.)  The thicker two cables are the device’s power.

Now, what can you do with this?  Well, likely, not much with the serial communication lines.  That’s intended for devices that actually connect to the iPod to do cool things.  If you’re splicing up one of these cables, chances are you haven’t programmed whatever you’re using it for to communicate to your iPod.  So you can probably skip those.

The video and audio cables however would be quite handy to connect to a TV, a stereo, a car, whatever.  Goodness knows what wicked little things you’ll do with them.  ;)

And the power I’d imagine you can skip if you don’t mind the iPod using up its battery.  Otherwise it shouldn’t be hard to find a cheap cell phone charger that puts out 5v DC.  Connect that up and your iPod should not only be powered by the dock, but even be recharged when sitting in it.

So How Do You Identify A Jasper Xbox 360 When You Go To Buy A New Xbox?

I commented before on how the new Jasper Xbox 360 uses less power thusly generates less heat, and therefore is theoretically less prone to the infamous Red Ring of Death that so many Xbox 360 owners have suffered.  (It’s also been said to have a quieter DVD drive.)  But the big question is, how do you know which one on the shelf is a Jasper?

According to scuttlebutt there are a couple of ways:

Way 1: The last five digits of the serial number indicate the release date.  The serial number format is xxxxxxxYWWLL where Y is the year, WW is the week of that year, and LL is the lot number.  You don’t need to worry the numbers before the last five of the serial, or about the lot number, but you do want to make sure that the year is 2008 (which would be an 8 ) and the week would be a 33 … or higher, obviously.  Anything newer than that release date should, theoretically, be a Jasper.  I’ve seen pictures of year 8, week 44 and that was definitely a Jasper.

Way 2: A lot more definitive is simply to check the power ratings.  It uses less power, which makes it super-easy to spot!  On the box itself is a clear window where you can see the serial number on the actual Xbox 360.    If you look to the very leftmost in that clear window you’ll also see the 12V power rating of the power supply that the Xbox 360 has installed, followed by the 5V rating.  (Note, you can’t actually see the 12V … part of it, but you can see the amperage for the 12V.)  An amperage rating of 12,1A means you’ve got a Jasper.  (Consequently, an amperage of 14,2A is a Falcon … which is almost as good.  And an amperage of 16,5A is a Zephyr which you really just want to skip.)

So as you happily hunt for a new Xbox 360 this Christmas, remember one important thing: Look at the back before you pull it off the shelf!  If you can get it, you want a Jasper and its theoretically fewer RRoDs.  And with these two simple tips, you can make sure you get one!

Protect Your Toys!

So how many of you out there have a nice big widescreen LCD TV? With a DVR, DVD, or Blu-Ray player? With an XBox 360, or a Playstation 3, or a Wii? With surround sound?

And how much did you spend on all of that shiny hardware?

And how much would it suck if just suddenly one day “ZAP!” a power surge kills them all?

Uh huh. It’d suck.

So how many of you then have your goodies plugged straight in to this?

Just your plain old ordinary unprotected outlet.

But the circuit breaker will surely protect your investments in entertainment … right?

Wrong!

The circuit breaker protects your house from fire. It won’t save your life. And it certainly won’t save the life of your toys.

Now some of you are no doubt feeling smug. Because you know that you have your toys plugged in to one of these:

Slightly better, a surge protector.

Well, okay. That might do. Or it might not. It’s still designed around the same concept, to cut power as soon as something surges. But will it catch it in time? That’s debatable. Mainly debatable because there have been plenty of incidents that have gone each way. Which, for your shiny shiny is not great odds.

In fact, your odds with a surge protector are pretty much about as good as your odds with a related device, a ground fault circuit interrupt outlet like this:

Nice.  A gfci (ground fault circuit interrupt) outlet.

The GFCI is a little bit more sensitive than a circuit breaker. It works fast. Fast enough to save your life. Possibly fast enough to save your electronics. It’s why kitchens and bathrooms have them. Have you ever thought of installing one for your TV? Well, no. Of course not. Because we have surge protectors.

But, okay, still … these are systems that at best respond to a major catastrophe. There’s still something far better. Welcome to the wonderful world of:

The almighty of them all, the UPS or Uninterruptible Power Supply.

The UPS

-aka-

The Uninterruptible Power Supply

What is it? It’s a surge protector like device, but far better. It carries internal batteries that kick in whenever there’s a power loss. And if you buy a top-notch design you can even get one with AVR (Automatic Voltage Regulation), which is to say that it has electronics that actually smooth out any tiny surges in the voltage, raising or lowering them to exactly the right voltage so that your electronics never have to suffer or strain with an imperfect power line.

Not only is a UPS the best tool you can buy to protect your investment, but it’s also great to have for people who suffer brown-outs. You know, those little temporary blips of power outages that are over so quickly it only caused your lights to dim for a moment … but also caused all of your clocks to reset and goodness knows what else? Yeah, those. Any electronics on a UPS when one of those hits won’t even know anything happened.

In fact, if the power goes, the batteries in these can give you minutes of juice to tide you over or let you finish what you were doing and turn everything off safely.

When push comes to “ZAP!“, which would you rather have your toys plugged in to? You’ve already spent how much on them? What’s another fifty to make sure you don’t lose them?

And they’re great for computers too!

THIS Is How Packaging Is Done!

A few days ago in Newegg Sucks! It’s Official, Newegg Has Gone Rotten! I complained about how Newegg rather badly packaged my order for shipping and I was lucky to A) still have all of my items in the box and B) have none of the items damaged, even though they went Freddy Krueger on one of the items. Clearly this is how not to package items.

Well let me give you a completely opposite experience. I ordered a largish item from Amazon.com not long ago. It took a while to get here because I had it shipped by “Free Super Saver Shipping”. Now, in spite of going with free shipping, this item was in its manufacturer’s box (in perfect condition, in a box that just perfectly fit the manufacturer’s box – presumably to protect it, and then in the actual shipping box with protective packaging. The latter two boxes were both considerably thicker and stronger than Newegg’s flimsy box. And so my item was protected quite well from the rigors of shipping. (Especially UPS. I don’t know why UPS seems to play hacky-sack with boxes, but I swear they must.)

Now this was a purchase from Amazon directly. These days so many Amazon products are delivered from third parties. But this one was from Amazon. Obviously third party experiences will vary. I’m not saying all Amazon purchases will be packaged well. But the ones directly from Amazon seem to be handled exceedingly well.

And so, there we have it. Some companies today (like Amazon) still know how to package a product for shipping. And some companies (like Newegg) couldn’t properly package if lives depended on it.

Amazon is good.

Newegg sucks.

It’s as simple as that.

It’s really a shame that Amazon doesn’t sell computer parts like Newegg does, or just based on their quality of packaging alone I’d be tempted to do all of my business with them.