Monday, January 29, 2007

Quick Reference Reference

Just stumbled across this page of links to "quick reference" cards and pages:

I think it would be a cool thing to have a web application which lets you build a customizable quick reference guide. From a grand master template, you would pick tools for which you wanted quick reference guides, and then within the guide itself you would pick which features you wanted included on the guide, so you only include reminders for what you tend to forget.

Friday, January 26, 2007

Web design for engineers

If you, a well-trained and highly experienced code slinger, called me one day from your car, travelling 80 MPH away from your mobile phone tower, and said "Mr. JFKBits, I'm designing some web pages for a customer, do you have any design advice?", and based on the way your voice crackled and faded I thought our conversation would be over in seconds, I would shout into the phone "DON'T USE TIMES ROMAN".

If I had a little more breathing room, I would add "use a sans-serif font, like Arial or Verdana".

This answer would have surprised the pre-web me, who had been told the Times font was the best choice for readability. And I still think it is, for books.

There are a lot of design principles that engineers can learn, such as "repetition and variety" and "it should lead your eye around the piece", but I'm still working on how those translate to web design. For now, this is my advice. If you want a web page to look like it was professionally designed, rather than hacked together by an engineer, then you want this right up in the head:

<style type="text/css">
* { font-family: Verdana,Arial,sans-serif; }

The reason for this is simple: Times is the default font, and any web page using it comes off looking like it was modified from My First Home Page featuring the "under construction" animated GIF.

But don't just take my word for it, look at what other people are doing:,,,, (Wall Street Journal), All these commercial web sites, picked from the top of my head, rely primarily on a sans-serif font.

For some entertaining and actually useful reading about fonts, see Criteria for optimal web design (designing for usability) by Michael L. Bernard. This work cites results showing "Overall, Verdana was the most preferred font, while Times was the least preferred font". I like the fact that the article appears on the web in Arial.

I've been experimenting with this advice "use sans-serif fonts" in my own work, and I'm amazed at the results. I'm convinced part of the reason is that it's not the default, the choice of first-time web page creators, as noted earlier. Another possible reason is that most graphical interfaces appear to be based on sans-serif fonts. But the bottom line is just do it, make it Arial, make it Verdana, make it something other than the default. (This is where my extremely left-brained friends take me too literally, pick Comic Sans for their county's public defender's web site contract and wonder why the client is unhappy with the unprofessional appearance.)

And yes, you may be wondering how I can say all this and have my blog appear in a serif font. Tell me honestly: do you think the blog looks bad? I picked one of the Blogger templates, and I think it looks all right. There's enough going on to set it apart from the default. For one thing, the font family is Georgia, not Times Roman, and it's set in a slightly smaller point size than the default. The watermark image and the stylized hyperlinks (no underlines) also work together to give the whole thing its own feel. Obviously this combination is a lot more complicated than my 3-second advice ("DON'T USE..."), so if you want to break my rule and still come up with a pleasing design, you're on your own.

Wednesday, January 17, 2007

Deciding whether a process is running

When I discovered "ps -p pid" would set the exit code to failure if pid wasn't found, I was happy. It seemed a much cleaner and more portable way to decide if a process was running, as opposed to grepping through ps output. However, it looks like the ps command on the Mac (MacOS 10.4) isn't setting the exit code in the case the process isn't found, so you get a false positive (process looks like it's running when it isn't):

% ps -p 2664
% echo $?

While I would like to use ps -p pid since it's a tight one-liner, this looks like I'm going to have to count how many lines of output ps -p has. Something like this:

test 2 -eq `ps -p $pid | wc -l | xargs expr`

The goal is a line (or lines, if absolutely necessary), which is foremost portable, i.e. works on any many platforms and as many variants of ps as possible.

Any comments or suggestions from the readers?

Edited Jan 23, 2007: Removed the "ps -p" and just left the test command.

Tuesday, January 16, 2007

Novel Internationalization Technique

FilZip is a great utility for working with ZIP files and numerous other archive and compression formats. When creating a new folder to hold the extracted contents of the JSP specification, I got to learn a new German word "abbrechen", which apparently means "cancel".