Sunday, April 20, 2008

Python logger config thread safety

Yes, the python logger is thread safe, but don't configure it programmatically (i.e. not via config file). Adding handlers to a logger with getLogger().addHandler(handler) does just that - and it will add handlers ad infinitum, even if they are already added.

So if you want to set logger options, in say, a Django file:

import logging.config

Your logging.conf might look like this:






args=("/var/log/django/my.log", "a", 1024*1024)

format=[%(asctime)s] - %(levelname)-8s - "%(message)s" (%(filename)s: %(funcName)s - %(lineno)s)
datefmt=%Y-%m-%d %a %H:%M:%S

Labels: , ,

Monday, February 04, 2008

Linking out of Flash embedded on MySpace, et. al.

Don't get your hopes up - you can't link directly from a Flash object in MySpace (Bebo, Facebook, etc.) or any other profile site that adds allowScriptAccess="never" to your embed code.
But what if you want to create a link in a Flash widget that works when it can (like, on a blog), but display the URL and a "copy to clipboard" button when it can't (on MySpace)? This way, you don't have to force a user to choose between the version that links properly and one that doesn't (risking that the click-through-rate will be lower on the fallback solution.)

Here is the best way to detect the linking limitation, cross-browser:
  1. Make sure your embed code has allowScriptAccess set to "always" (it defaults to "sameDomain"). Be sure this is specified as an object-tag parameter as well as a param-tag name-value pair. MySpace will convert this to "never" properly.
  2. In ActionScript, call"eval", "window.location.href = '[full url]';")
  3. The method only works when allowScriptAccess is "always", otherwise it returns null, so check for that.
  4. If null is in fact returned, implement your fallback strategy (such as the one mentioned above.)
Don't waste your time with shenanigans involving and pop-ups either — some pop-up blockers don't take clicks sent to embedded objects into account when determining whether a was generated from a user-initiated event.

Tuesday, December 04, 2007

Why am I seeing this web site?

The bottom of this search spam / black-hat SEO / domain squatting page raises the question certainly in your mind "Why am I seeing this web site?"

This question is especially important when you consider that this page was linked from an Ad placed in Facebook. The idiot that posted this ad needs to be fired.

Answer: the second "s" in the ad link should not be there.

Labels: , ,

Sunday, November 25, 2007

Hacking The "Is" Status Paradigm

It was short lived, but I suspect a more permanent gift from Mark and the Facebook team in the near future.

Labels: ,

Friday, September 14, 2007

Line Picking and Platinum Cards

A past weekend I was at Bed, Bath, and Beyond in Fashion Valley to buy a new shower curtain. I think it was move-in weekend at the State school in America's Finest City. It was pretty full with freshmen and women that were dressed like they should be at the beach instead of shopping with their parents. Of course, these youngin's avoided being seen with them to maintain their perceived coolness. Because parents can be embarrassing.

Needless to say, I didn't want to hang around. I got my shower curtain and dodged the kids while heading for the exit. Lines everywhere, like most places in San Diego on a Saturday.

When I pick a line to check out in, whether I'm at a retail or grocery store, I have a few selection criteria that I evaluate registers within my line of sight:
  1. Length of line: this is a function of the total number of items yet to be scanned as well as total potential transactions. Shorter lines always win. I have things to do.
  2. Appearance of clerk: I'm shallow, I know, but I'd rather be checked-out by someone who looks like they are having a good day. They are more likely to give me favorable discounts when I'm chatty.
  3. Entertainment factor of last group in line: This is highly variable and subjective, it's impossible to tell ahead of time when someone will do something stupid, hilarious, or objectionable. If you know me, you know about my ability to read people in a short amount of time.
This time, the choice came down to the third criterion. I picked the line with a wannabe-Gothic Hot Topic-clad freshwoman with two seemingly well-to-do parents. They were doing their darnedest to embarrass her, histrionic folk, looking around to see if anyone was witnessing their pain of a daughter that clearly wanted to be somewhere else. In Orange County, these kinds of parents would just give the kid an American Express Platinum Card.

Instead, this pair of nouveau-riches parents decided to show off their plastic Platinum Card. Cheap thrills from the $625 annual fee for two or more cards.

When I complete a transaction, I pull out my non-Platinum card and swipe it or hand it to the cashier. I do not wave it around and loudly ask my significant other, "Should I put this on the Platinum Card??!!" I do not delay in swiping it to make sure everyone in line gets a glimpse at my piece of plastic with magnetic stripe, coveted or not.

At least when you swipe a Platinum Card, you never have to worry about it declining, because it simply doesn't decline. I mean, the ability to afford the $625 annual fee is the paragon of fiscal responsibility and success beyond measure.

So needless to say, when the mother's Platinum Card declined, the only thing keeping me from laughing out loud was the forced seal of my lips. I think they heard the involuntary guttural part of my response so I started looking at the ceiling as if I wasn't paying attention.

"That's a Platinum Card! It isn't supposed to decline!" exclaimed the father, with a tone of indignation to the poor girl behind the counter. "Try it again!"

She did. It declined again. Now the daughter is laughing - either at my visible attempt to avoid cracking up or the fact that people at other registers were now watching the drama unfold.

The father knows best, so he pulls out his own Platinum Card. "It must be something wrong with your reader, try my [emphasis his] Platinum Card," he says, loud enough for everyone paying attention to hear.

She does. It goes through. I smile at the daughter, nonverbally agreeing on how pathetic her parents were.

Clearly still embarrassed, the father continues his rant about the declining of his wife's card.

"There's something wrong with your machine. Look! Both cards have the same number!"

At that point I was about to get instructional about how those things actually work, but decided against. They briskly departed after their failed attempt to save face.

It was my turn at the register. The girl, obviously relieved that her previous customer was gone, scanned my curtain.

"I hope this doesn't decline..." I joke as I hand her my American Express Blue. She smiles while swiping it. Approved. "...Whoa, it went through! And it's not even Platinum!"

She laughs. "Well, unlike them, you actually have the money."

Labels: , , ,

Thursday, April 26, 2007


I should really add more to this blog... any ideas? Does anyone actually read this at this point?

Tuesday, February 27, 2007


So I like to run. A lot. Last Friday I wanted to see what the treadmill display would do if I ran over 99:59 (99 minutes, 59 seconds). It autostarted a "cooldown" at 98:00 and kept counting up. After 99:59 it started back at 0:01 and counted up until 1:00, when it shut down.

Yes, that 10.9 number represents miles.