Archive for May, 2008

Sex and the City Second Hand Review

0

My wife came back from the movie last night, not happy. “It was horrible”. “Depressing”. “Too serious”.

So there you have it. Not good, apparently.

Running Shell Scripts from Python

0

There are about a million different ways to execute an external program from Python. Here’s the right way:


import subprocess

subprocess.call('''zcat %s | tr '\02\03' '\r\n' | ssh %s "hadoop dfs -put - %s"''' %
     (local, DEST, remote), shell=True)

Where what you put inside the call statement is what gets executed in a shell. In this case I used pipes, escaping, etc, just to show a slightly complicated example; you could do something as simple as “ls” instead.

Lots more info in Doug Hellmann’s PyMOTW article.

Multi-Process vs. Multi-Threaded Python Performance

1

Interesting benchmarks in PEP 371 — Addition of the Processing module to the standard library. In short, standard Python threads perform worse than non-threaded in almost every benchmark, while the multi-process Processing module generally does as you’d expect and reduces processing time proportional to the number of processors / cores.

You could argue this just means Python has a crappy thread implementation or that the benchmarks are biased, but it’s interesting. I actually have an occasion for a multi-headed app, so perhaps I’ll give Processing a try.

Via Doug Hellmann.

Write The Damned Email

0

I gave a talk at UCSD a couple of days ago. After the talk several students came up to me asking about how to find internships and full time positions at Yahoo. As it so happened we had our HR folks right there and they got connected up.

I told every one of the students that I spoke with that they should drop me an email; that the best way to find a job you like is to connect with people in industry.

Two days later and not a single email. I remember being the same way as an undegrad, somehow intimidated to connect with others. I remember how surprised I was when I got several offers for an internship I had applied for.

Here’s a clue: if you want a job, ask for it. Make an effort. Write the damned email. The fact is we are hiring as fast as we can get good candidates. The positions are open and available. All you have to do is connect with somebody. And here’s a shocker: dropping your resume into a pile of other resumes is not the best way to get noticed. Talk to somebody.

There’s a strange disconnect here: I’d love to get access to excellent students; there are many positions at Yahoo and I have visibility into lots of other opportunities as well. Students want to find good jobs and internships, and there are plenty of good ones that haven’t found it. But we’re not connecting nearly as well as we could be. Odd.

MMA

1

MMA

I’m really into Mixed Martial Arts these days. Watching that is – I’m as lazy and immobile as ever, and I’m pretty sure my 6 year old could beat my sorry ass.

But it’s always a guilty pleasure. For one thing it feels like mindless gratuitous violence. For another, I’m near the worst shape of my life, sitting on the couch watching instead of doing. And my wife really frowns on it.

Tonight as I was telling my dad about MMA and how much I enjoy it I realized I have a good out: I’m Iranian. Wrestling is huge in Iran – it’s sort of the national sport. Wrestling is a big part of MMA. Therefore, I’m perfectly justified in enjoying MMA. It’s my birthright.

Beyond the basic violence, MMA is one of the most technical combat sports out there. There are so many different skill sets the fighters have to bring to bear, and so many different styles, it’s really a deep sport to watch.

I still remember watching an old Japanese movie about the founding of Judo when I was 8 or 9. It had a huge impact and I always wanted to learn. Somehow I got my hands on a Judo book and practiced with my friend, sometimes using the techniques on unsuspecting classmates. Unfortunately I never took it further.

Perhaps someday I’ll take my useless dilapidated self to a Judo studio and learn something. In the meanwhile, I’ll use my race to assuage my guilt and just watch MMA on TV.

Javascript Array Deferencing?

1

I have an array, say:


var pieces = [2008, 5, 19, 13, 49];

I’d like to create a date based on this; the equivalent of:


new Date( 2008, 5, 19, 13, 49 );

Is there a way to do that in Javascript? Can I dereference the array in my date create call? I’d prefer to avoid eval.

Football

0

Giant

After a lovely day at the Cystic Fibrosis walk, I fell asleep in the toy room.

I briefly skirted the real world to the feeling of my 10 month old grabbing my feet to stand.

Back into sleep, I was having a discussion, watching a movie, and generally experiencing a wonderful dream world.

Then, out of nowhere, a giant stepped on my chest, crushing me back to reality. Half way there the foot shrunk and my partially functioning senses told me the giant was my son and his foot was nestled on my privates as he attempted to scale my legs and torso.

Inexplicably I drifted back towards sleep as my dream world took a strange turn. My son was an explorer on a mountain, a grave look on his face as he peered out to decide which path to take next: climb, or turn back and go around.

He decided to climb.

As I bolted into wakefulness, only to drop into a groaning heap, several women, dressed as reporters and shoving mic’s into my face screamed at me for my stupid decision to go back to sleep.

And that’s how I woke up.

Photo by Jurvetson.

Flickr Capacity Planning Presentation

0

Unfortunately I missed the Web2.0 Expo this year, but I’ve been catching up on slides and presentations. I had John Allspaw’s Capacity Planning For Web Operations open in a tab for several days and finally got to it. Turned out to be much more interesting than I’d anticipated. Slide 9 – “Normal” growth: 4x increase in photo requests/sec. That’s pretty obscene. Slide 43 – diagonal scaling: replacing 67 dual core servers with 18 dual quads results in ~half the load per server. Slide 45: ~70% less power usage, 49U less space. I’d been curious about that last stat (power usage of horizontally scaled servers versus multitude of smaller servers), good to see some real numbers for it.

Kids’ Book Template

2

My 5 year old loves to create “books”, which to date consisted of stapling a few pages together and going to town on them. Lately he’s been interested in “chapter” books with a little more structure: a picture and some text on each page.

He asked for my help in putting one together, so I made a simple template that can be printed out on regular 8×11 paper, folded in half, and stapled to a number of other folded copies to produce a book. Each page has space for a picture, a few lines to write on, and a page number. Here’s the template for your enjoyment, in both pdf and svg.

To assemble: print 5 copies. Put 4 of the copies back into the printer such that you can print on the opposite side, and print 4 more copies on them. The page you saved is the cover, and the rest are the inside pages.

Beautiful Treemaps and Visualization for Javascript

0

Next sign

The Javascript Information Visualization Toolkit looks very good. Look at how beautiful the treemap and hypertree examples are.

Btw, I’m voting Joshua Schachter for best link blog.

How To Dynamically Select Part of a jQuery Call Chain

3

Updated, thanks to Simon Willison:

Say you’d like to pick part of your jQuery call chain dynamically – for example, to removeClass for many elements, but addClass to one special element. Here’s how you do it:


var myfunc = some_condition ? 'addClass' : 'removeClass';
$('#someid').html('something')[myfunc]('some_class');

The first line selects the function name as a string. The second line calls the ‘html’ function (it could be any function; html is just the example in this case), followed by the function with the selected name (addClass or removeClass in this case).

You’d probably use this in the context of a loop, eg:


for (var i=0; i<10; i++) {
    var myfunc = some_condition ? 'addClass' : 'removeClass';
    $('#something'+ i).html('sample text ' + i)[myfunc]('selected');
}

The Wierdness Of Having An Audience

0

Next sign

When I first started blogging I expected no-one would read it. (Well, actually I expected to immediately become an a-list uber-blogger, but…)

Now it appears I have a small group of loyal readers, some of whom I’ve never met in-person before. And they contribute, leave comments, etc. This makes me happy. Thank you guys.

Some of the readers I have met. Hi guys. Some I know very well.

I’m good with all this; I have a mental model of who the likely readers are, and I self-censor to stay within fairly reasonable bounds and keep things cool and happy.

Two weeks ago, however, a series of events blew my mind. Within that single week 3 people that I really never expected to read the blog mentioned it to me, mostly in passing. In fact, to my surprise, I was introduced at a talk I was giving by my blog by-line (”A Cruel and Petty Dictator”).

Now I’m kinda spooked. These folks are clearly not regular readers, but they are a fantastic demonstration of just how accessible and ever-lasting everything you excrete onto the net is. When technophobes, random professional and personal acquaintances, recruiters, and any other dick-or-harry can ask you, apropos nothing, how your weekend trip to Seaworld was, that’s just odd. It puts you at an unusual information disadvantage – you have no idea who this person is, but he knows how many kids you have and what they look like, how you spent your weekend, and which movies you like. Heck, he knows more about you than some of your best friends. He’s FriendFeeded his way to the front.

It’s not that I really care – it’s not like I lead a particularly interesting or exotic life or have too many things to hide – but I’m realizing it leads to further sub-conscious self-censorship. And that sucks. I was much more likely to rant stupidly (one of my favorite hobbies) when I thought 2 close friends would be reading it than now that I know random semi-acquaintances will be.

I think my trouble spot is the semi-acquaintance part. People I know, regular readers, and random strangers, excellent. But people that read up on me just before we meet and spring it on me out of nowhere spook me.

Photo by TCM Hitchhiker.

Handy Javascript Scoping Trick

0

Neat Javascript function scoping trick from Dustin Diaz, master of cool Javascript tricks. His Javascript Video Tutorials were the first time I was exposed to proper Javascript (Justin, do some more!).

Here’s the trick:


var o = 'hello world';

(function() {
  alert(this);
}).call(o);

And why is this neat? Because it lets you avoid the “that = this” funkiness (if you’ve had to do it you know what I’m talking about). Read Justin’s post for actual info.

Google Reader Techno Music Attack?

0

My laptop suddenly and for no apparent reason started playing techno music. I started digging around, closing app and browser window after window until it finally stopped. Turned out to be coming from google reader. I re-opened reader and the music came back. I went thru and marked a bunch of items as read, closed it, re-opened again, and it was gone.

So the source was some post being viewed in reader, but it’s not obvious which post it was. It wasn’t the one I was currently reading; I think reader keeps some number of posts in its buffer so you can go back and forth.

Anyway, interesting behavior. I wonder if reader does anything to sandbox posts from each other? I hadn’t thought about annoyance/attack by RSS before, but I guess it renders to browser so it’s possible.

Coding Efficeny Improvemnt Tip: “Next” File

0

Next sign

I don’t recall where I read this, but I’ve been using it to great effect: as you are about to stop coding, note what your next task should be in a file called NEXT.txt . When you come back to resume coding look at NEXT.txt to get context for where you are and what you need to do.

I’ve found this simple practice reduces the penalty of starting and stopping very significantly.

Photo by Thomas Hawk

The Case For Teaching Calculus Early

1

I remember when I finally had Calculus, my final year of high school. It took a bit of effort to get my head around it, but once I got it I remember the distinct feeling of being pissed off. Pissed off about all the time wasted in Physics class. In Chemistry. And in all the other math classes I’d taken up to that point.

Given calculus I could’ve derived and actually understood all those formulas, instead of just memorizing them. And memorize them I never did – in fact the other time I remember being distinctly pissed off was when I spent the first 30 minutes of the AP Physics exam deriving formulas because I was too stubborn/stupid to memorize them.

Calculus is really not that hard. A good teacher can explain it to an 11 year old. It will take some effort, but it can be done. And once the kid knows calculus, think of how much easier Physics and Chemistry will be.

Anyway, this ramble came about as a result of reading A Gentle Introduction to Learning Calculus.

Son Of A …

0

And that’s all I’m gonna say about that.

Twitter In Microcosm

0

Drama:

Twitter RoR

Tweet Response:

Twitter Still on RoR

Go to Ev’s twitter account, FAIL:

Twitter fail 500

How Do You Design Sites for Blackberry?

1

There’s a lot of info and tooling out there for building iPhone ready apps. But what about good old Blackberry? Are there good tutorials / docs on how to build websites that show well in the Blackberry browser? I get the sense it’s not WML (or is it?)…

What Are You Using for Contact Management?

1

Most of my contacts are in LinkedIn, but you can’t store phones numbers, IM addresses, etc, there. The vast majority of my phone contacts are in my cell phone, but those die every time I kill a phone, which is about every 3-6 months these days. I used to use Yahoo Mail contacts, but since I couldn’t get that contact list to sync with my phone it stopped being useful. GMail contacts are generally fairly useless as well.

So here we go again. New phone, new contact I need to store, where do I put it? Plaxo seems like a reasonable solution, but I remember bad creepy stuff from them a few years ago so I’m hesitant to jump back in with that.

I’m thinking a system where you can express relationships, ala LinkedIn or FaceBook, and contact details are published and maintained by the person you know (as opposed to you) is a good thing. Combine this with the FriendFeed / Venturehacks Recommended model where you can create entries for people that are not on the network yet, and allow syncing with phone or otherwise make it always-available, and you got something good. Also will need the ability to identify contacts as personal, business, etc.

What do you use, and do you like it?