| radwin.org -> Michael J. Radwin -> blog -> Geek Cred | Search |
I finally got Ariella's iBook to print to our Brother 1440 printer via the SMC Barricade 7004AWBR print server. Here's what I did:
System Preferences > Set Up Printers...
Add > IP Printing
Printer Type: LPD/LPR
Printer Address: 192.168.2.1
Queue Name: LPT1
Printer Model: Brother HL-1440 series CUPS.gz
I found some other pages on the Net that suggested using "lp" for the Queue Name, but that didn't work. I finally ended up downloading the "How to install a LPR printing port on WinXP" document from the SMC support site, and that told me to use "LPT1" as the queue name instead.
Pics of the new Treo 650 on Engadget.
I want one.
Paul Graham's essay Great Hackers is a good read.
The most compelling statement he made was a rant against cubicles:
If you want to get real work done in an office with cubicles, you have two options: work at home, or come in early or late or on a weekend, when no one else is there. Don't companies realize this is a sign that something is broken? An office environment is supposed to be something you work in, not something you work despite.
I'm not a hacker (not sure I ever was). I'm a manager. But I think Graham's advice applies to me for completely different reasons. I speak very loudly when I'm on the phone (my parents do this too; I think it's genetic) and it's hard to remember to keep my voice down. And if my boss or one of my employees comes by and we need to discuss something sensitive such as a negative performance review or an internal transfer, shouldn't we be able to have that conversation without needing to wander around the floor looking for an open conference room?
I had an office (and a really nice chair) back when I worked at Adobe. I liked it better.
As far as I'm concerned, there's only one way to write C-like code. First of all, you must select sane whitespace defaults in your editor. Here's the one true way to configure Emacs.
(setq default-tab-width 8) (defun one-true-style () (c-set-style "bsd") (setq tab-width 8) (setq c-basic-offset 4) (setq indent-tabs-mode t)) (add-hook 'c-mode-hook 'one-true-style) (add-hook 'objc-mode-hook 'one-true-style) (add-hook 'c++-mode-hook 'one-true-style) (add-hook 'php-mode-hook 'one-true-style)
Other rules of thumb, most of which I picked up from Adobe:
Here's a concrete example:
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
int quux(char *foo, size_t len, const char *bar, int flags)
{
int i, j;
char buf[BUFSIZ], *cp;
if (foo == NULL)
{
errno = EFAULT;
return -1;
}
for (i = 0; i < len; i++)
{
for (j = 0; j < BUFSIZ; j++)
{
/* something here */
}
}
return 0;
}
I've never been a big fan of Hungarian notation for variable prefixes. I do think prefixes have a place; within a library all function names need to be prefixed with some short (3-6 char) name so it's easy to see which APIs you're using. I don't see the point of decorating my variable names like pchFoo. Maybe because it's too distracting to be constantly thinking of the Pacific Coast Highway.
I was cleaning out some boxes from my parents' garage and found a bunch of 1.44MB floppy disks. Most of them were garbage, but I found one of them that contained a dotfiles.tar from October 1993. Here's a few examples of the time-warp material I found inside:
I plan to make a more original plan someday. Login: mradwin Name: Mike-bo Radwin Directory: /thayer/hole-in-the-wall Shell: /vdub/pasta/sauce Last login Mon Sep 27 on ttyp1 from timevortex.cit.brown.edu Plan: I plan to make a more original plan someday.
I think this was funny at one point in time. I've seen many examples of folks who added false finger protocol stuff to their .plan file to make you think that you were reading another entry, and it looks like I was part of the same big Unix inside joke. Apparently I also had an obsession with food; Hole In The Wall was one of my favorite sandwich shops in Providence and the Vee-Dub was the nickname of Verney-Woolley dining hall.
alias time 'telnet tsoft 13' alias bye logout alias b 'exit' alias allps "ps -aux | grep -v root | sort | more" alias nasanews "finger nasanews@space.mit.edu" alias webster "telnet cs.indiana.edu 2627" alias rutgers "telnet 128.6.26.25" alias freenet "telnet hela.ins.cwru.edu" alias readers "telnet 144.13.12.1" alias hytelnet "rlogin access.usask.ca -l hytelnet" alias bahamud "rlogin bahamud.st.hmc.edu" alias ww "ps -au | sort" alias dir "ls -slgFL" alias ls "ls -sF" alias ll "ls -slagFL" alias e jove alias undos 'tr -d "\015"' alias eal ntalk eal@tsunami.berkeley.edu alias emlee ntalk emlee@uclink.berkeley.edu alias rot13 'tr A-Za-z N-ZA-Mn-za-m' alias rn trn -M -hDist -hSend -hFollow -hOrg -hExp -hRef -hLines -hNNTP -hReply alias 43 stty rows 42
Looks like I had a buddy list of exactly two people. And that's what bookmarks/favorites looked like in the pre-Web days.
Newsgroups: tellink.general Subject: c compiler Summary: Expires: Sender: Followup-To: Distribution: local Organization: tellink -- the final frontier Keywords: does cc use SYS V syntax only? because I was trying to compile something that I wrote which conforms to ANSI C standards, using prototypes for functions, and cc choked on it. it also didn't like function(void), something that the wonderful product turbo C++ absolutely loves.
An article I posted to an internal newsgroup of my ISP. Even 10 years ago I was a standards freak.
DBM-style flat files are great, but sometimes it's hard to deal with binary formats. Being able to have data in a textual format can be very handy for transferring between different platforms, modifying in your favorite editor, crunching with standard tools like grep, etc. There are a couple of text-friendly DBM export out there, each with advantages and disadvantages.
Suppose you have a DBM hash that contains two key/value pairs like the following:
one=Hello
two=Goodbye
Good ol' BerkleyDB comes with a utility called db_dump which lets you export a binary database to a text format and then use the equivalent db_load tool to import the data. It's easiest to see your data when you use the -p option. Here's a simple database with two records:
format=print
type=hash
h_nelem=5
db_pagesize=512
HEADER=END
one
Hello
two
Goodbye
db_dump is pretty easy to use as it is, but it becomes a little cumbersome when you've got non-printable characters to display (control characters, newlines, and anything that isn't 7-bit clean). You end up with a dump that looks like this:
Erev Pesach
\d7\a2\d6\b6\d7\a8\d6\b6\d7\91 \d7\a4\d6\bc\d6\b6\d7\a1\d6\b7\d7\97
Tu B'Shvat
\d7\98\d7\95\d6\bc \d7\91\d6\bc\d6\b4\d7\a9\d7\81\d6\b0\d7\91\d6\b8\d7\98
Bamidbar
\d7\91\d6\bc\d6\b0\d7\9e\d6\b4\d7\93\d6\b0\d7\91\d6\bc\d6\b7\d7\a8
You don't lose any information, but it becomes impossible to work with when you've got UTF-8 data and you want to be able to edit it in your favorite Unicode-savvy editor.
Perl hackers are probably familiar with Data::Dumper, which looks like this:
$VAR1 = {
'one' => 'Hello',
'two' => 'Goodbye'
};
Data::Dumper is easier than db_dump to use with your favorite text-centric tools, and it has the advantage that it keeps each key/value pair together on the same line (handy for grep). Unfortunately, it's very Perl-centric; you're intended to load the data by calling eval(). I suppose you could write a parser in C that understood that format pretty easily and you could use it in non-Perl programs.
On one of the mailing lists at work today someone mentioned the cdb constant database format. I took a look at the page and was amused to see the cdbdump record format. It's an interesting alternative to db_dump's format and works nicely with UTF-8.
+3,5:one->Hello
+3,7:two->Goodbye
It's a pretty concise format, and it's totally 8-bit friendly. The key and data may contain any characters, including colons, dashes, newlines, and nulls. As a consequence it's very easy to write generators and parsers for this format, and they're typically very efficient. Like Data::Dumper, it keeps key/value together on the same line.
One disadvantage of the cdbdump format is that it uses explicit integer lengths, so it's not very friendly for editing data in a text editor (every change you make requires that you fixup the beginning of the line).
I'm playing with weblogger.el to see if it's possible to post to MovableType from emacs-21.2.1.
It only sorta works for me, and I had to install a few external dependencies (xml-rpc.el and url.el) to even get the thing running.
Oh well. Not ready for prime time yet I suppose.
I've been seeing more and more bzip2-compressed files these days, and I want to be able to open these files in GNU Emacs without the need to decompress them.
About 10 years ago I copied someone's ~/.emacs file and noticed some mention of a crypt++ module. I asked them what it did and they told me that it allowed them to view *.gz files in an Emacs buffer by doing the decoding on-the-fly. Combined with the built-in support for tar-mode, this is very handy.
I've been using it to browse *.tar.gz and *.tgz files since the emacs-19.34 days, but today I needed to view the source code of php-4.3.4.tar.bz2 and it didn't work.
After a little bit of investigation, it turned out that the ancient version of crypt++.el I've been using for the past decade didn't support bzip2 files. So I went and grabbed the latest version (2.92, released January 2003) and added the following 6 lines to my ~/.emacs file:
(require 'crypt++)
(modify-coding-system-alist 'file "\\.gz\\'" 'no-conversion)
(modify-coding-system-alist 'file "\\.Z\\'" 'no-conversion)
(modify-coding-system-alist 'file "\\.gpg\\'" 'no-conversion)
(modify-coding-system-alist 'file "\\.bz\\'" 'no-conversion)
(modify-coding-system-alist 'file "\\.bz2\\'" 'no-conversion)
Viola! It works!
It turns out that GNU Emacs 20 and later has native support for handling compressed files, so all you really need is this:
(auto-compression-mode t)
But I'm still kinda attached to using crypt++ because I occasionally use the built-in PGP support.
For the most part, blog comments have turned into a distributed link farm for perscription drug and porn websites. Instead of a vibrant community of ideas, about half the comments on my blog are a steady stream of Viagra, Propecia and Phentermine ads.
I've had enough of this crap.
Instead of disabling comments altogether, I have disabled HTML and URL auto-linking. I also updated my Individual Entry Archive template to use this tag instead:
<$MTCommentAuthorLink show_email="0" show_url="0"$>
(Another way to solve this problem is to replace the <$MTCommentAuthorLink$> tag with <$MTCommentAuthor$>.)
Now blog spammers can post to my site all they want (and they probably will continue to do so) but their links will be ineffective. Ha!
It looks like there are a couple of MT plugins (like Bayesian and CloseComments) which try to solve this problem as well.
Moved my blog to a new ISP. Testing 123.
(Hey, that rhymes!)
We bought a Uniden TRU5885-2 5.8 GHz cordless phone yesterday.
For the past couple of years we've been using a 2.4 GHz phone and have been suffering from interference with our 802.11b Wi-Fi home network. Picking up a phone call would sometimes disrupt the wireless Internet connection and our SSH sessions would terminate. When our old phone finally started to show its age (intermittently would fail to get a dialtone), we decided to try something new as a replacement.
Like most 5.8 GHz phones, the Uniden TRU5885-2 is pricier than comparable 2.4 GHz or 900 MHz models. But it's got a much greater range throughout the house, and more importantly, it co-exists with our wireless Internet.
This model in particular has an absurdly large number of features. Aside from standard stuff like Caller ID and an integrated digital answering machine, this model gives you a good-sounding speakerphone in the base, and an extra handset. But wait, there's more! Each handset itself can act as a speakerphone. 3 different speakerphones? Wow.
Sound quality is very crisp. It almost sounds like a wired phone. Plus, each phone has an orange backlight. You'll see an eerie but beautiful glow when you hit any key on the keypad.
The only drawback we've found: you can't use both handsets simultaneously. There's only one base station, and apparently only one handset can speak to it at a time. There's a nifty transfer feature that lets you put the call on hold and pick it up on the other handset, but that's not the same as being able to have two people on the line at the same time (when we're talking to our families, for example).
One week after disaster struck, Glenn (the friendly neighborhood admin for my ISP) has restored my MT database files from backup tape. I'm running again.
A quick post-mortem: what happened to me was similar to what is described here. However, running db_dump -r did not successfully recover the data, which is why I needed to go to tape backup.
Now I need to spend some energy getting the data into MySQL so I don't get burned by this again...
MovableType databases got corrupted yesterday, and now everything has gone to hell. I am editing this file by hand.
Waiting for my ISP to do a tape restore, which means I can't really update the blog until Sunday... :-(
One of my co-workers asked me this week for an easy way to see which files had changed in CVS over the last week. I suggested that rcs2log would be a good first start, but strangely enough he had never heard of it before.
rcs2log is a nifty script that you can use to generate a ChangeLog from CVS. As the name implies, the tool was originally written for RCS files, but it knows how to talk to a CVS server without any modifications needed.
It's distributed as part of GNU emacs as a helper script for the ChangeLog feature (C-x v a), but I've found it really handy to use it directly from the shell to group together CVS commits in an easy-to-read chronological order.
After installing emacs, I simply do this:
cp /usr/local/libexec/emacs/21.2/i386--freebsd/rcs2log $HOME/bin
And then it's available in my $PATH to run from the shell whenever I need it.
rcs2log isn't a complete replacement for other tools. I often use cvs log when I need details about a single file or I need to see down-to-the-second timestamps or symbolic tags. And I really like the multi-colored diffs that ViewCVS and Chora can generate. But rcs2log fills a niche that nothing else does.
I've been a very happy Palm Zire owner since January. It does the two things I need it to do (Calendar and Address Book) really well and has phenomenal battery life. I don't need anything fancier.
Today, on the palm.com webiste, I noticed an advertisement for an Open Box Palm Zire for $49.99. Cool.
I just finished writing up 4 pages of documentation on how to correctly build shared libraries for FreeBSD using Yahoo!'s Makefile macros. The fact that Makefiles are such a black art probably explains the popularity of alternative build systems.
I'm sure a bunch of these ideas will be covered in Theodore Ts'o's Designing and Creating Great Shared Libraries talk in a few weeks, but I wanted to write down a couple of key points before I forget:
Syntax error on line 68 of /usr/local/etc/apache/httpd.conf: /usr/local/libexec/apache/mod_yscript.so: Undefined symbol "Bar__3FooiPCc"
Now I've gotta go hire a tech writer to clean up by doc.
Nullsoft (the Winamp people) today released WASTE, a secure, mesh-network IM/chat/file-transfer system. Looks kinda cool. They even GPL'd the code.
WASTE is initially available on the following platforms:
Notice a particularly popular operating system missing from that list? No, I'm not talking about Solaris.
I hate email almost as much as I hate the web.
I've found that I'm using my Windows 2000 laptop a lot these days, but I'm still doing my email on my 4.5-year-old FreeBSD machine (running a vintage 2.2.7 kernel, complete with the a.out runtime linker bug). Switching back and forth between the two has turned into too big of a pain in the neck, especially since I seem to be getting tons of resumes (and various other attachments) in Word and PDF formats.
So it's high time to switch to a Windows email reader. What's the path of least resistance? PC-Pine.
Yes, it still has an olde-school xterm-like interface. No, it doesn't display HTML or graphics. But it's what I've been using for the past 8 years, and I'm not about to switch again. I made the great leap forward from good ol' /usr/bin/mail to Pine back in 1995 and it took weeks to get used to a new interface. I don't want to repeat that pain.
Our corporate IS department doesn't support IMAP (only POP3), so I initially tried to get an IMAP server running on my ancient FreeBSD box and use fetchmail to pull from our POP server. But I couldn't really get UW's imapd to work. Instead of wasting time trying another IMAP server (folks here have suggested Inter7's Courier-IMAP), I instead decided to use Pine's native POP3 support in conjunction with the Mail Drop feature.
Porting my pinerc file from Unix to Windows was pretty easy. I had to make a few tweaks (looking up names in our corprate LDAP server instead of getting them from /etc/password, switching forward-slashes to back-slashes in folder names, moving my filtering from procmail to Pine's built-in filtering feature, etc.) After a couple of hours, I'm up and running in an environment that feels really familiar.
After 3.5 years of using TiVo, I've finally decided to crack open the case and increase the recording capacity.
I purchased my Philips 14hr HDR112 TiVo (the first model ever manufactured) from Fry's Electronics in Sunnyvale on October 22nd, 1999. Today, Ariella and I schlepped out to Fry's in Woodland Hills to purchase a Maxtor 120GB hard disk for the upgrade.
I'm three hours into the process and am finishing step 8 out of 11. I hope to finish before midnight.
Update (11:47pm): Whoo-hoo! I'm done! Just gotta put the cover back on and bring it back into the family room...
163 hours, baby. Nice.
John Doe.
Joe Schmoe.
Ploni ben Ploni.
When the Gemara needs a placeholder name but doesn't want to use a real one, apparently it uses the name פלוני (transliterated here as Ploni). Ploni can be used both as a person's name as well as a name of a place.
In mock contracts, sometimes the formula פלוני בן פלוני במקומ פלוני (Ploni ben Ploni b'Makom Ploni) is used. This translates rougly as "Ploni, son of Ploni, from the city of Ploni."
Delightful. I remember finding it equally amusing a few years ago when I learned that French programmers don't name temporary variables foo or bar, but rather toto and tata.
I like the Unix DBM file format (a.k.a BerkeleyDB). I use it for static data (like the zip code-to-latitude/longitude database for the Hebcal Interactive Jewish Calendar) and for dynamic data (such as the subscriber database for the Mountain View High School Alumni Internet Directory).
BerkeleyDB is also great because it has many language interfaces. I can access the same DB files in both Perl and PHP.
My high school alumni directory subscriber database has experienced corruption a few times recently. It's a good thing I also keep a daily text backup of the database in RCS because it makes it easy to rebuild the DB.
But it's obvious to me that the underlying cause of the problem is concurrent access that isn't protected by mutual exclusion. Heck, I wrote the code back in 1995 when I didn't know better.
So I've gotta go add some locking code to the 25 scripts that manage the site.
However, older versions of BerkeleyDB (such as the one installed on my ISP) don't natively support locking, so I've gotta use flock for concurrency. No problem; it's relatively easy to turn every occurance of this:
use DB_File;
my(%DB);
tie(%DB, 'DB_File', $file, O_RDWR|O_CREAT, 0644, $DB_HASH);
$DB{'foo'} = 'bar';
untie(%DB);
into something that looks like this:
use DB_File;
use Fcntl qw(:DEFAULT :flock);
my(%DB);
my($db) = tie(%DB, 'DB_File', $file, O_RDWR|O_CREAT, 0644, $DB_HASH);
defined($db) || die "Can't tie $file: $!\n";
my($fd) = $db->fd;
open(DB_FH, "+<&=$fd") || die "dup $!";
unless (flock (DB_FH, LOCK_EX)) { die "flock: $!" }
$DB{'foo'} = 'bar';
flock(DB_FH, LOCK_UN);
undef $db;
undef $fd;
untie(%DB);
close(DB_FH);
Bingo. Problem seems to be fixed. No more DB corruption.
But then, a few weeks later, I get DB corruption again. Ugh. Turns out that I managed to fix 24 of the scripts, but there's one that I occasionally run by hand (the one that removes someone from the directory) that I forgot to add locking code to. With flock, it only takes one script to screw it up.
So last night I was about to go through the scripts and update them, but reading the DB_File manpage, they point out a possible problem with the classic "tie the db, dup the fd, then flock" approach. So fixing the 25th script to use the same locking scheme won't necessarily solve the problem either. Doh!
Reading a little further down the manpage, I see a reference to a simple CPAN module called DB_File::Lock that transparently does flocking when you tie and untie the DB. It's perfect for what I need.
Now I can simply do a search-and-replace throughout the entire codebase and change all DB_File references to DB_File::Lock, and get rid of whatever dup/flock stuff I used to use.
use DB_File::Lock;
my(%DB);
tie(%DB, 'DB_File::Lock', $file, O_RDWR|O_CREAT, 0644, $DB_HASH, 'write');
$DB{'foo'} = 'bar';
untie(%DB);
I've also considered moving the code from DBM files into MySQL. My ISP started offering limited MySQL access for an additional buck a month, and relational DBs tend to solve the concurrent access problem in a much more elegant (and consistent) way.
Unfotunately, it would be too much work. I don't want to rewrite all of my 8-year-old Perl code that serializes an alumni record (just a bunch of key=value pairs) into a delimited string. And the DB access parts of the code aren't very well abstracted, so switching from a simple hash DB format to a more structured multi-column format is going to be trickier than it seems.
Someday when I find the time to do a complete rewrite I'll use MySQL as the backing store. And I'll use that opportunity to get rid of all of my perl4-isms and replace them with appropriate perl5 constructs. Heck, if I delay long enough, perhaps I can go straight from perl4 to perl6! :-)
For now, DB_File::Lock is good enough.
Dave Jeske, one the many brilliant Yahoo! alumni I know, is new to the blogging world. Here's his second entry:
Linux on the Desktop is a long way off, here's why. I'm a UNIX developer and proud of it. I love the stability, scriptability, and remote administration capabilities of UNIX. I've built everything from small scale scripts to large web-applications running on hundreds of machines. However, I've never run UNIX/X as... [unsolicitedDave]
I'm looking forward to reading more from him.
Rachel has discovered that Minnesotans play "Duck, duck, gray duck" instead of the traditional "Duck, duck, goose." She's been thinking more about it recently, too.
James Lileks of the Minneapolis Star & Tribune even wrote an article about the phenomenon.
Wow. It's a compilcated world we live in.
Just discovered this today (by way of Victor Chang):

Reading the most recent copy of PC Magazine, I stumbled across an article called Generating Dummy Text in Word. I gave it a shot this morning, and sure enough, it worked:
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
Although it's nifty to have such a tool on your desktop, I much prefer the web-based Lorem Ipsum Generator, which uses a time-tested formula for page-filling text. Anyone who has ever worked for Adobe knows that "Lorem Ipsum" has been a favorite of typographic professionals for the past 500 years.
While we're on the loosely-related subject of pangrams:
Got any other favorites?
I bought a Palm Zire at Fry's Electronics last night. It was on sale for $89.
I lost my trusty old Palm V in November and have been miserable without it for the past 6 weeks. One of the reasons it took me so long to get a replacement was that I saw it as an opportunity to purchase some hot new technology. I toyed with the idea of getting a Dell Axim X5 for a while since I've been meaning to play with a handheld Microsoft OS, but I already know the Palm Desktop user interface and I'm too lazy to learn how to use Outlook. Hard to teach an old dog new tricks and all.
In the end, there's nothing hot or new about the Zire. It's a monochrome device with a wimpy 2MB of RAM and has absolutely no expansion capability whatsoever. The other extreme would've been to go with the Tungsten, but it's kinda absurd to spend more on a handheld than you do on a desktop computer.
Well, I completely ripped off the CSS from Jeremy Zawodny's blog.
Still doesn't look right, but it's way better than the MovableType defaults.
I'm off to UCLA now to hear a lecture about "Seeing as Statistical Inference" for my CS201 class.