Tag Archive: Work

Generating random user_ids

December 28, 2007 10:10 am Published by 1 Comment

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.

Farewell, Priceline

May 5, 2006 4:53 am Published by

After four different positions in three different groups and two cities in the past seven years, this its my last day working for Priceline.com. I’ve had an excellent time working here. The people are friendly and excited, and we occupy an interesting place between tiny startup and mega-corporation, which allows us to do some interesting and cutting-edge stuff.

I’m sad to be leaving, but I’m excited about my new gig at Texterity, as well as the prospects of owning a condo in Southie and just generally moving to the Boston area. May is exciting!

Sun Ray and Palm syncing

September 23, 2005 1:06 pm Published by

Recently, Sun released version 3.1 of the Sun Ray Server Software. It now has Linux support for USB devices connected to the thin clients. Instead of being kernel-level, this support is user-level — in the form of a modified libusb. Unfortunately, roughly 97% of applications expect kernel devices, and thus lack support for libusb. Luckily, pilot-link belongs to the minority. The following are my (roughly chronological) notes on getting a Palm (in the form of an old Handspring Visor) to sync with my Sun Ray.

  • You’ll need to have libusb 0.1.8 or newer installed. For reference, RHEL3 doesn’t have a new enough version; I needed to find a non-standard RPM.
  • Get the latest version of pilot-link from http://www.pilot-link.org/. I used 0.12.0-pre4. You’ll almost certainly need to compile it, since even if your distro has a package for it, it probably won’t be compiled with libusb support.
  • Be sure to add the –enable-libusb flag when you run configure for pilot-link. (I assume the reader knows how to compile and install stuff under Linux)
  • When you run commands that you want to use the Sun Ray libusb support, you need to run them with the LD_PRELOAD environment variable to include “/opt/SUNWut/lib/libusbut.so.1”.
  • I’m not sure what most of the executables that pilot-link installs do, but I know the important one is pilot-xfer. This command line works for me: bin/pilot-xfer --port usb: -s $HOME/.pilot-link
    This command will fail unless you have the Palm already trying to sync. You’ll also need to run it as root, although the pilot-link guys say they’re working on a fix for that.

I’m still on the hunt for something that will allow me to access data on a USB thumb drive.

Google job

September 6, 2005 6:39 pm Published by

I just got an email from an HR person at Google. It was really personalized, not just a form letter, saying that I might fit in well with their Server Engineering team. And from the description of the job, I think I would. I had to tell him that I didn’t know where I’d be a year from now, but I might contact him in March.

Oh, even better, he told me how he came across me: my goddamn contributions to fucking Wikipedia.

RHCE

September 3, 2005 11:07 am Published by

Yesterday, I passed my Red Hat Certified Engineer exam with flying colors. I’m willing to call it a legitimate certification. The entire test was hands-on troubleshooting (“Here’s a machine that won’t boot. Fix it”) and installation and configuration (“Here’s bare metal, and a four page description of how we want the machine setup. Go”). It’s very indicative of the kind of work I do on a daily basis, so it’s far more useful than a multiple-choice test would have been.