|Saturday, 19 January 2002, 11:02 pm
I use to program for fun, but I don’t have time (or enough concentration) to write anything substantial any more. It’s still fun to hack out one-liners from time to time though.
The other day I decided to keep track of my Amazon.com sales rank on the front page of Leoville. To do this I’d have to write a program in perl that the web server could call using CGI, the common gateway interface. The program would return the rank which the web server would embed into my page.
The first iteration of the program was pretty simple, thanks to a perl library called LWP. The library provides built-in routines to access web pages. Using the LWP routine “get” I can fetch the contents of the Amazon.com page, then use Perl’s built-in text search features to extract the ranking.
I wrote the program in a few minutes:
# access Amazon web page
# find sales rank
$webpagetext =~ /(Sales Rank: )(d+)/;
# output sales rank
print "Content-type: text/htmlnn"; # this text is required for CGI output
If you’re not familiar with perl a few things might need explanation. All the real work is done in the line…
$webpagetext =~ /(Sales Rank: )(d+)/;
In English this would read something like: search the contents of $webpagetext for the text “Sales Rank: ” followed by one or more digits.
The parentheses in the phrase
(Sales Rank: ) (d+) tell Perl to group the results. Perl assigns the value in the first group to the variable $1, the second group to $2, etc. I’ll use $2 later to output the rank.
Finally I print the results to the console. CGI routes the output back to the web server which inserts it into the web page that called it.
I use Apache’s server-side includes (SSI) to call the perl program and embed the results of the program. On my system that means putting the line:
into the web page. When the web server sees it, it calls ranking.pl and sticks the result into the page at that point.
So far, so good. I could run the program locally and it worked fine, but it wouldn’t work on my server. Turns out the LWP module was never installed. I wasn’t sure how to get around that until I installed Movable Type. This blog software uses several modules that aren’t part of my web host’s perl installation. But I learned I could put the needed modules in a directory on the web host and tell your program to look for them there. Thus adding the line:
use lib "/cgi-bin/mt/extlib/";
at the beginning of the program and storing the LWP::Simple module in the extlib directory, fixed the problem, and version 1.0 of my program was up and running. Worked great, too, until my book fell below 999 in ranking. Amazon displays larger ranks with commas, and my program didn’t consider that. I changed the search to include commas by substituting the regular expression
$webpagetext =~ /(Sales Rank: )([0-9,]+)/;
and it was working again.
Incidentally, I work in perl on both Windows and Macintosh. On Windows, I use an excellent shareware editor from DZSoft. On Mac OS X I use BBEdit from Barebones Software. Both really speed up the development cycle by letting you run the program from within the editor, with built-in FTP uploading, and a perl reference.
No program is ever done, and neither was this one. Next time, how I extended it to keep track of the peak scores. (And maybe one of you perl experts can help me with a bug that’s really been buggin me.)
|Saturday, 19 January 2002, 6:10 pm
Before I go on, I want to point out that Yoshi volunteered for this. He really wanted to do it. He did a lot of research to assure himself it was safe, and we performed the experiment in a controlled environment with a highly trained expert from the Taser corporation. Don’t try this at home – you can really hurt yourself. Tasers are not toys!
Click the thumbnail for a full size picture…
This won’t hurt a bit
Afterwards Yoshi made copies of the video tape and sent it to all his friends. Wow.
They’re trying to talk me into doing this for sweeps in April. Um. I don’t think so.
|Thursday, 17 January 2002, 10:58 pm
Bulletin: We’re going to have a taser on the show tonight. Yoshi has agreed to take a hit for the show. And it’s not even sweeps week!
Tonight on the Screen Savers, 7p Eastern, 6p Central.
|Saturday, 12 January 2002, 6:55 pm
Two trade shows in three days. Wow.
It started Wednesday with MacWorld Expo. As mentioned here in an earlier post, I led a panel with Apple’s Ken Bereskin on Mac OS X Secrets. The panel went very well with a full house of about 200 people. We got to about half our tips in 90 minutes. Since we didn’t have a handout of all the tips, I made the mistake of promising that I would put them up on the web. So I’ll be spending some time doing that this weekend. And you’ll probably be seeing many of the tips on The Screen Savers eventually. There were some really cool ones.
We also covered a few key applications we really liked. Ken introduced me to a little utility for OS X (originally written for NextStep, OS X’s grandpappy) called LaunchBar. LaunchBar gives you access to any program, file, URL, or e-mail address on your computer in just a couple of keystrokes. Your hands never leave the keyboard. Command-Space starts the program then you enter the first few letters of the name of the item you want to open. LaunchBar narrows the options down as you type. It’s the most efficient way of working with a computer I’ve ever seen. I wish there were a version for Windows. Wouldn’t be too hard to write. Hint, hint.
I didn’t get much time at MacWorld Expo, but it was obvious that the new Macs, a revitalized Apple, and OS X have really awakened the Mac world. This show was noticeably more exciting than any in the past five years. More importantly for the company, Apple is winning converts for the first time in a long time with slick looking products like the new iMac, leading edge technology like the DVD-RW Superdrive, and, finally, competitive prices. OS X is UNIX with a pretty face ‘ and power users love it.
On Thursday I flew to Las Vegas to catch the last two days of the Consumer Electronics Show, CES. CES is starting to eclipse Comdex as the most important technology show of the year. It was huge this year, filling the one million square foot Las Vegas Convention center with 15,000 new products. I was struck this year by how digital tech is changing consumer electronics.
This year, as last, TechTV sponsored the Best of CES awards. There was quite a battle over the Best of Show award with the judges evenly split over the HipTop cell phone/PDA from Danger and the Moxi Media Center.
The HipTop is the size of a deck of playing cards and combines a GSM cell phone, GPRS data for web surfing and e-mail and a full elegant PDA with a keyboard and flip up screen. You can synch the PDA with the web over the GRPS link. It even comes with a tiny camera for sending still pictures over the network. One of the big cell phone providers will offer the HipTop this Spring for around $200. Only AT&T, Cingular, and Voicestream offer GSM in the US, and only AT&T offers both GSM and GPRS so my guess is that their deal is with AT&T Wireless, but Danger’s not saying. The judges awarded the runner-up prize to Danger, but it was a tough call.
The Best of CES winner was the Moxi Media Center. And rightly so. It combines all the functionality of a Tivo with a DVD player and CD ripper. You can store a ton of TV and music on the 80 GB hard drive, and best of all, with the little wireless remote units you can watch video or listen to your MP3s anywhere in the house. Moxi uses the new 802.11a wireless networking that can do 20-30 mbits per second. Echostar will offer Moxis for the DISH network (and presumably DirecTV if the sale goes through) by the end of the year.
All I can say is that I plan to buy both the HipTop and Moxi when they’re available later this year. Very cool.
|Tuesday, 8 January 2002, 3:54 pm
Tags: CES, MacWorld Expo, Regis
Talk about hitting the ground running. Wednesday I’m doing a presentation on Mac OS X secrets at MacWorld Expo and I’ve been spending the last few days frantically trying to find some. Secrets, that is. The pressure’s on because this presentation is for the ProTrack – meaning I can’t just show them cool Command key combos. Fortunately, there are lots of UNIX hacks I can do. Did you know the emacs text editor has Eliza built-in? Hit Shift-Esc then enter “k doctor” and confess your troubles. The doctor is in.
Then Thursday morning I’m flying to Las Vegas to host the Best of CES awards for TechTV. I’ll be doing feeds from Vegas for The Screen Savers and various other media outlets, too. It’s going to be hectic, because I have to find a dozen or so really cool products to bring to New York City the following week for Live with Regis and Kelly. That’s right, unbelievably, they’ve already asked me back, less than a month after my last appearance. Regis is going to get really sick of me, I just know it.
TechTV PR wanted more and better plugs on the show, so they’ve had some sweaters made up for me with the TechTV logo on them to wear on the show. That way if Regis forgets to mention TechTV it’s ok. Jeez. I might as well be wearing an orange blazer with a TechTV patch. Just kidding guys. Really.
I’m flying to NYC after the show on Monday, rehearsing Tuesday, doing Live on Wednesday, then flying right back for TSS that night.
I need a vacation already.
|Monday, 7 January 2002, 5:18 am
Time Canada seems to have jumped the gun on Apple’s big announcement tomorrow. It’s an LCD iMac that “looks like a sunflower.”
Author, Josh Quittner, says…
The new iMac, which Time took for an exclusive test run recently and which will be unveiled at the annual Macworld convention in San Francisco this week, could be just the thing. Like many PCs today, the new iMac is built around a flat-panel display. But instead of taking up precious desk space like a typical flat monitor, the iMac’s screen floats in the air, attached to a jointed, chrome-pipe neck. It’s also rimmed by a “halo,” a translucent plastic frame that makes you want to pull it toward you-or push it out of the way. Jonathan Ive, chief of Apple’s ID lab, says he designed it so that you would want to touch it, want to “violate the sacred plane of the monitor.” The chrome neck is articulated and bends while maintaining the angle of the screen; it connects to the computer, an improbably small hemisphere at 26.4 cm in diameter-somewhat bigger than a halved cantaloupe. The machine bears an uncanny resemblance to Luxo Jr.-the fun-loving, computer-animated swing-arm lamp that starred in a short film by Pixar, the fabled computer-animation studio that Jobs runs. (Pixar creative chief John Lasseter has also made the first new iMac ad.) “It looks a little cheeky,” says Ive. It looks alive.
According to Time, the new iMac starts at $1200. The top of the line model is priced at $1800 with a G4 and DVD-R. (Are these Canadian bucks? Unclear.) I’m reserving judgement until I see one, but it sounds like Apple might have found a worthy successor to the original iMac. Clearly Time Magazine thinks so – they’re making it their cover story this week.
|Sunday, 6 January 2002, 10:49 pm
I’ve added a nice new feature to the blog – thanks to Ben and Mena at Movable Type. If you want you can have new entries e-mailed to you directly just enter your address into the form at the bottom of this page. As always, I promise I won’t sell or use your address in any way except to mail you the blog entires.
Unless I hear an uproar to the contrary, I’ll also start sending new entries to the members of the Laporte Report mailing list. So if you’re signed up there no need to sign up below. Goodness knows the mailing list needs some new content from time to time.
|Saturday, 5 January 2002, 5:50 pm
Apple OS Product Manager, Ken Bereskin, and I will be delivering a talk at this week’s MacWorld Expo. It’s called Everything You Always Wanted to Know About Mac OS X But Were Too Afraid to Ask. I didn’t name it. If you’re going to MacWorld in San Francisco, stop by Wednesday, 12:30-2p, Room 133 in Moscone Center.
Expo hype is hotter than usual this year. Apple’s website is fanning the flames with headlines like “count on being blown away” and “lust factor 10.” But no one knows what they’ll be announcing. Speculation ranges from the likely LCD iMac to the far-fetched iWalk, a palm like PDA with working handwriting recognition. SpyMac pulled the iWalk video yesterday, probably at Apple’s request. I do expect Apple will announce some sort of consumer electronics device.
Undoubtedly Steve Jobs will make the announcement on Monday with the usual, “oh, one more thing” at the end of his keynote . I’ll be there – even though I’ll have to get in line pretty early for the 9am talk. I’ve also been invited to the a press reception afterward. I’d sure like to bring something back for Monday night’s The Screen Savers.
|Saturday, 5 January 2002, 6:29 am
Well I couldn’t resist and spent the last two days redesigning the Blog. I manhandled the elegant little templates Movable Type comes with until they looked just like the old blog. The voting has disappeared, but it’s nicer in other ways.
The archives link is back at the bottom, with month by month and day by day views. I’d like to pretty that up when I get a chance. The calendar feature in the next version of MT should do the trick.
I’ve added single entry view that has a back and next button, so you can go entry by entry reading my original post and the comments that followed. Get there by clicking any post’s title or the Comments link.
I am also categorizing the entries now. I’ll archive by category at some point, as well. For now, there are no categories for the old Greymatter and Blogger posts. I just lumped them all in the 2001 category. At some point I’ll categorize them, too.
There’s an e-mail notification feature, too, but I can’t figure out how to make it available to you on the page. It’s not documented anywhere, but as soon as I can I’ll make it possible for you to receive either new posts in their entirety or an e-mail notification.
As usual, I welcome any input or requests. Thanks for your patience during the transition. Now I know what vacations are for.
Viva Movable Type!
|Thursday, 3 January 2002, 11:00 pm
Eric Raymond, one of the mavens of the Open Source movement has written an excellent web article on how to best get help online.
The best way to ask questions in newsgroups and mailing lists is to pose the question in a way that piques interest, show that you have already done the obvious research, and state the problem clearly. Most of this applies to The Screen Savers, too. I highly recommend reading the article.