Essays

Essays for September 2007

2 years ago

Saturday, September 29, 2007

Nice Touch: Search Stores by ISBN

Did you know that Amazon’s search field accepts ISBNs? It does — both the 10- and 13-digit variety. Type or paste in an ISBN, hit “Go,” and you’ll be taken straight to the book page. It’s perfect for when you’re searching for a book whose title isn’t very unique. (Sorting through the various editions of “The Elements of Style” is how I found this feature.)

It’s the sort of obvious, hidden feature you don’t think about until you try it. You’re hoping it will work, and it does. Sweet.

(This also works on Half.com, Barnes & Noble, and of course Borders, which is just an Amazon storefront.)

Comments

2 years ago

Saturday, September 29, 2007

Creating a Self-signed SSL Certificate for Apache 2 on Debian lenny

While setting up SSL for Apache 2 on Debian lenny for our development server, I got stuck when all the instructions I could find (1, 2) said to use the script apache2-ssl-certificate, which wasn’t installed on the system.

After some more Googling I found Ubuntu bug #77675 in Ubuntu’s apache2 package, which notes that apache2-ssl-certificate is missing. Debian bug #398520 indicates it’s also a problem in Debian. Both bugs indicate that the solution is to use make-ssl-cert instead. So, this is what I originally did.

Yesterday, however, the certificate expired, and I noticed it had only been created to be valid for 30 days. So, I went through the trouble of regoogling everything I just mentioned above in order to refresh my memory about how to create a certificate. This time, however, I read to the bottom of both bug reports. They mention that the default lifetime for make-ssl-cert is only 30 days. Debian bug #293821 mentions the problem, and even seems to include a patch for make-ssl-cert that gives it a -days option. The patch doesn’t seem to have made it into lenny, though.

So, I copied /usr/sbin/make-ssl-cert to /etc/apache2 and modified it myself. All you need to do is add the -days option to the openssl line near the bottom:

94c118
<     openssl req -config $TMPFILE -new -x509 -nodes -out $output -keyout $output -days 1095 > /dev/null 2>&1

>     openssl req -config $TMPFILE -new -x509 -nodes -out $output -keyout $output > /dev/null 2>&1

While I was at it, I copied /usr/share/ssl-cert/ssleay.cnf and modified it, too, by removing the required country, state, locality, and organizational unit fields in the certificate, since I didn’t have anything useful to enter for them:

1
2
3
4
5
6
13a14,16
> countryName                     = @CountryName@
> stateOrProvinceName             = @StateName@
> localityName                    = @LocalityName@
14a18
> organizationalUnitName          = @OUName@

I also changed the relevant lines in my new make-ssl-cert:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
12c12
<     templates="organisationname hostname email"

>     templates="countryname statename localityname organisationname ouname hostname email"
23a24,35
>      db_get make-ssl-cert/countryname
>      CountryName="$RET"
>      db_fset make-ssl-cert/countryname seen false
> 
>      db_get make-ssl-cert/statename
>      StateName="$RET"
>      db_fset make-ssl-cert/statename seen false
> 
>      db_get make-ssl-cert/localityname
>      LocalityName="$RET"
>      db_fset make-ssl-cert/localityname seen false
> 
27a40,43
>      db_get make-ssl-cert/ouname
>      OUName="$RET"
>      db_fset make-ssl-cert/ouname seen false
> 
37a54,56
>      CountryName="XX"
>      StateName="There is no such thing outside US"
>      LocalityName="Everywhere"
38a58
>      OUName="Office for Complication of Otherwise Simple Affairs"
44c64,68
<     sed -e s#@OrganisationName@#"$OrganisationName"# 

>     sed -e s#@CountryName@#"$CountryName"# 
>       -e s#@StateName@#"$StateName"# 
>       -e s#@LocalityName@#"$LocalityName"# 
>       -e s#@OrganisationName@#"$OrganisationName"# 
>       -e s#@OUName@#"$OUName"# 

Then, all you have to do is run the following:

/etc/apache2/make-ssl-cert /etc/apache2/ssleay.cnf /etc/apache2/ssl

This should create the necessary certificate in /etc/apache2/ssl as explained by all the other instructions.

The patched scripts are available in their entirety below. I also posted the diffs above, in case you have different versions of ssleay.cnf and make-ssl-cert and you want to patch them.

2 Comments

2 years ago

Friday, September 28, 2007

Constructive Criticism: The Library Postcard

Okay, so maybe I was nitpicking when it came to the postcard, but I stand behind my critique! “It could be better,” I said, and I meant it. We’re as much about construction as we are about criticism here at Sakuzaku, so I’d like to present a hypothetical redesign to the Hawaii State Public Library System book request notification postcard. Click the image below for a closer look.

Hawaii Library Notification Card: After

To Consider

  • Braille would be a nice addition and would make the card much more accessible.
  • The backside of the card currently lists the phone numbers for every library on the islands. It would be nice to have the website URL listed there as well.
  • I tried to avoid any solid blocks of color or images in the interest of saving ink.

I still think the postcard itself is obsolete, and I should have been able to receive an email notification. For those without email, though, this should suffice.

What do you think? Leave your thoughts in the comments here or on the photo page.

Comments

2 years ago

Thursday, September 27, 2007

Library Litany

I recently requested a book through the Hawaii State Public Library System. It wasn’t pretty.

Horizon Information Portal — Powered by Dynix! Awesome!!

First, I had to find the book in the online catalog, which was as well designed as most online library catalogs. That is, not well at all.

I know what I want, and I know I can probably get it by typing the title in that box in the middle of the page, but I have no idea what the logos in the top left and under the form are for, or what those tabs up there do. (Note that the copyright date for the “Horizon Information Panel,” which is also the title of the page instead of something relevant like “Hawaii Public Library Catalog,” hasn’t changed since 2004.)

I just want a book. Everything else but the search form and the submit button is noise. If I wanted to do something else, though, I wouldn’t know where to begin — those tabs doesn’t really offer any clues as to what they do. (What is “WebFeat”? “PC Reservation”?)

I soldier on. The results page is okay, despite what seems to be a database-wide disregard for the most basic rules of capitalization.

It’s relatively easy to find the “Request” button on the detail page, although it would have been nice to indicate the book wasn’t available at the library closest to me instead of just listing the locations where it was available, and leaving me to sort through each one.

I’m going to have to log in to request the book. Here’s the form:

Barcode? PIN? Well, “barcode” must be the number under the barcode on my library card, but I haven’t a clue what my PIN is. I try the PIN I usually use for things like this; no luck.

(Note that this form never remembers the Barcode number or PIN you input. Probably to keep the public terminals safe. Annoying.)

I called the library, and they told me my PIN was the last four digits of the phone number I used to register for a library card. I didn’t have a phone when I registered, so I figured I had no PIN. I was informed I’d need to come down to the library in person to set it up.

I did so and immediately sat down at one of the computers in the lobby to request the book. Here’s the confirmation page for requesting a book:

My hold queue position is 1. I can only imagine that means I’m first in line. I will be notified by — hold on, what? Mail? Postal mail? Are you kidding me? No other options here? No phone? No email? This is 2007. At least it auto-selected my pickup location. But wait, what do you mean my request is effective until 9/26/2008? They’ll hold the book for a year? I still haven’t figured this out.

I click “Request” and I’m given a confirmation screen. All right! Now I just have to wait for the mailman.

(Note that upon compiling this blog post and stepping through these screens to get screenshots, I was routinely redirected back to the homepage automatically after a certain amount of time. This, like the forgetful login form mentioned above, is probably to ensure the public terminals are returned to the home screen for the cycle of visitors in the library. That’s probably a good idea, but it should be restricted to the library computers. At home it’s just annoying — what if the phone rings and I’m in the middle of requesting a book?)

Carded

About a week later, a postcard arrived in the mail. And what a joy that was. I knew that I had to go pick up the book at the library without even reading the card, but reading it revealed it was as confusing and poorly designed as the catalog website.

First, the return address is obviously the factory where these things are printed:

Thanks. That’s useless. What if I don’t know where the library is and I need, say, directions on Google Maps? This should not be the most prominent address on the card.

What else can we find on this card, this card that is filled with type that is boringly consistent in its face, style, size, and spacing, this card that is completely devoid of useful elements like contrast and organization?

We can find the same capitalization whimsy:

We can find a “print date,” which is maybe useful (I can’t think of how) but certainly shouldn’t be as prominent as the rest of the text.

We can find a “Due Date,” which must be the date by which I must pick up the book to avoid the $1 fee. I suppose it’s the date I’m “due” at the library?

We can’t quickly find the phone number of the library we need, because it’s buried with sixty others.

We can’t know the secret message, because a sticker is covering it. Does the fun ever end?

And why is there a $1 late fee for not picking up the book? The book is at another library now… so what? If they want to curtail the expense of transporting books back and forth for people who casually request them on a whim, the threat of a $1 fee isn’t going to stop anyone. And anyways, anyone who survived the maze of the Horizon Information Portal is certainly serious about wanting the book they request.

I took the card to the library, assuming I’d need it to get the book. But what if I had assumed I didn’t need it? I did, in fact, need it, it turns out, but there’s no indication on the card that I should carry it with me. (Maybe that was the secret message?) I was sent back to my house twice when applying for a card (first I didn’t have photo ID, then I didn’t have proof of address), so I’m guessing they wouldn’t be too forgiving about forgetting my magical postcard either.

Deep Breaths

Now I’m all set, thoroughly enjoying Twyla Tharp’s “The Creative Habit,” but this isn’t the last time I’ll have to use the system.

Why complain about a library catalog system and the postcard it sends? Because I believe these systems are fundamentally impaired, plagued by bad design. I don’t believe there’s anything arrogant about wanting something better. The website and the card are both obviously the product of design by engineers who possess either little concern for usability or lack the skills to design for it. That’s okay; it shouldn’t be their job to take care of both code and presentation unless they’re adequately talented in both. But it would benefit everyone — library staff, technicians, and engineers as well card-carrying library users — to have a talented designer refactor this system from the ground up.

Have your online library experiences been any better?

3 Comments

2 years ago

Wednesday, September 19, 2007

Installing the Ruby mysql-2.7 gem on OS X 10.4

You would think installing the mysql gem for Ruby would be as easy as doing

sudo gem install mysql

Unfortunately, it’s not. If you do a quick Google search you’ll find hundreds of blog posts lamenting the problems with this gem on OS X 10.4, all with varied solutions that don’t work. The command above gives you this:

Select which gem to install for your platform (powerpc-darwin8.8.0)
1. mysql 2.7.3 (mswin32)
2. mysql 2.7.1 (mswin32)
3. mysql 2.7 (ruby)
4. mysql 2.6 (ruby)
5. Skip this gem
6. Cancel installation
> 3
Building native extensions.  This could take a while...
ERROR:  While executing gem ... (Gem::Installer::ExtensionBuildError)
    ERROR: Failed to build gem native extension.

ruby extconf.rb install mysql
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no

Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out

What it’s complaining about is the fact that it can’t find your MySQL client libraries. You have to pass in the location of your MySQL installation using the following switch:

sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

Many posts regarding the problems with this gem use the switch --with-mysql-dir. Don’t be confused — --with-mysql-config does basically the same thing, but apparently the mysql_config binary provides out all the command-line switches, including --with-mysql-dir, necessary for the installation (according to a comment here). Oh yeah, you did install MySQL in /usr/local/mysql, didn’t you?

OK, so that wasn’t so bad, right? No. For some reason the gem itself has been broken for at least a year. You next get the following error:

Building native extensions.  This could take a while...
ERROR:  While executing gem ... (Gem::Installer::ExtensionBuildError)
    ERROR: Failed to build gem native extension.

ruby extconf.rb install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
checking for mysql_ssl_set()... no
checking for mysql.h... yes
creating Makefile

make
gcc -I. -I. -I/usr/local/lib/ruby/1.8/powerpc-darwin8.8.0 -I. -DHAVE_MYSQL_H  -I/usr/local/mysql/include -Os -arch ppc64 -fno-common -fno-common -g -O2 -pipe -fno-common  -c mysql.c
mysql.c: In function 'Init_mysql':
mysql.c:2015: error: 'ulong' undeclared (first use in this function)
mysql.c:2015: error: (Each undeclared identifier is reported only once
mysql.c:2015: error: for each function it appears in.)
mysql.c:2015: error: parse error before numeric constant
mysql.c:2018: error: parse error before numeric constant
make: *** [mysql.o] Error 1

A post by Jarkko Laine explains the problem. You must add

#define ulong unsigned long

to the top of /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/mysql.c.in. I saw mentioned in a few places that this is a bug in the MySQL libraries — whatever the case, the gem author should include this fix in the gem itself to save a lot of people a lot of frustration.

After adding the above line to your mysql.c.in, you can’t simply run gem again, because it will download the gem source anew and overwrite the change you just made. Instead, you have to build and install the gem manually:

cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7
sudo ruby extconf.rb --with-mysql-config=/usr/local/mysql/bin/mysql_config
sudo make
sudo make install
sudo make clean

This creates a makefile, and then builds and installs the gem.

So, all working now? No — not at all:

% irb -r mysql
Powermac:/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7% irb -r mysql
/usr/local/lib/ruby/site_ruby/1.8/powerpc-darwin8.8.0/mysql.bundle: Failed to load /usr/local/lib/ruby/site_ruby/1.8/powerpc-darwin8.8.0/mysql.bundle (LoadError)
        from /usr/local/lib/ruby/1.8/irb/init.rb:252:in `load_modules'
        from /usr/local/lib/ruby/1.8/irb/init.rb:250:in `each'
        from /usr/local/lib/ruby/1.8/irb/init.rb:250:in `load_modules'
        from /usr/local/lib/ruby/1.8/irb/init.rb:21:in `setup'
        from /usr/local/lib/ruby/1.8/irb.rb:54:in `start'
        from /usr/local/bin/irb:13

This generic LoadError is so ambiguous that I have no idea what the problem is. It seems like Ruby can’t find the gem after manually installing it. Does anyone have any idea how to fix this?

I emailed (in Japanese, no less) Tomita Masahiro, the author of the gem, as well as the Rubygems mailing list. Tomita ignored me, and the Rubygems mailing list moderator refused to approve my message.

15 Comments

Next Page