SMC7004AWBR Barricade Printer Setup from Mac OS X

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.

Hackers need offices, not cubicles

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.

Coding conventions

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:

  1. always use curly braces for if/else/for/while, even if you don’t need them
  2. every brace goes on a line by itself
  3. the * is adjacent to the variable name, not the typename
  4. no extra whitespace inside parens
  5. always use one space after comma to separate function args
  6. prefer &foo[i] over foo + i
  7. prefer foo == NULL over !foo

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.

Dotfiles from 1993

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:

.plan


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.

.aliases


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.

.article


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 text export formats

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).

Emacs and *.tar.bz2 files

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.

No more blog spam

mt-logo-small.gif 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.