Archive for December, 2007
-
31 Dec 2007Franklin Park
Brian, Shaun, and M in front of a big orange oak in Franklin Park.
Discuss -
31 Dec 2007Fark's headlines are notoriously funny, and the year-end voting always highlights the best of the best.
-
31 Dec 2007Some have made the idiotic suggestion that Firefox be renamed to "Netscape" now that AOL has abandoned the latter.
-
28 Dec 2007Brian K questioned my use of rand(), which lead to a discussion and an investigation into random algorithms. Perl's srand() uses /dev/urandom to seed the PRNG, and it turns out that urandom is really clever.
-
28 Dec 2007
At work, each new user is assigned a totally random alphanumeric 12-character ID. They're random instead of sequential because this is what goes into the user's cookie (and in some cases into URLs) and we didn't want the IDs to be discoverable. Sometimes we need to do what we call a subscriber load and generate thousands (or sometimes many thousands) of IDs at once. The subload process tends to be very slow, and one of my co-workers was tasked with making it faster. While profiling the code, he discovered that a big time sink was the ID generation procedure. After more research, we discovered that it was written in 2004 and had never been modified after the original checkin. It was hundreds of lines long, used all kinds of global variables (Perl hasn't had static variables until 5.10), and involved big math with a magic prime number close to 7012. Worse, it was implemented as a hash function. And it was always passed a salt. And that salt was always random.
We replaced it with this code:
my @chars = ('A' .. 'Z', 'a' .. 'z', '0' .. '9'); sub randid { $rv = ''; for my $i (1 .. 12) { $rv .= $chars[rand(@chars)]; } return $rv; }
It used to generate about 100 IDs per second. Now it can do 175,000 per second.
-
27 Dec 2007Sports broadcasting limitations and blackout rules are idiotic. It's nice to see that in at least this one case, NFL realizes it.
-
25 Dec 2007"Based on my sample size of 2, everyone walking around talking on a cellphone on Xmas is angry." ¶
-
25 Dec 2007
-
25 Dec 2007Enjoying gifts
We made the trip to Maine and back last night to surprise M's family for Christmas Eve. They loved it. We did, too.
-
24 Dec 2007For my less fortunate friends who have to use it.
