« January 2002 | Main | February 2004 »

January 23, 2004

iTunes RSS feed parser

I cobbled together a parser for the iTunes RSS feed which renders the feed as HTML suitable for inclusion into a web page.

I made an effort to generate HTML in a manner that one can apply a style sheet to it and change the layout and appearance of it in a flexible manner, rather than using some sort of template mechanism. CSS is, unfortunately, both hard and in most, if not all, browsers generally broken, so it's not a perfect system, but I got it working well enough to render the page how I like it, so that's good enough for now. :-)

You can try it out and download it from http://www.wsanchez.net/itms/.

January 21, 2004

Flying rocks on the freeway

This morning on the way in to work, I got in behind one of those semi trucks that is hauling a couple of large bins of gravel. These bins are open at the top, so some of the gravel is constantly flying off the top and effectively projected at whatever is moving beind the truck, in this case my car. I change lens to pass him on the right, because my exit is coming up, and he signals right; he's getting on the the same exit. I'm stuck behind this damned thing with rocks raining on my car so I slow way the hell down to put some distance between us.

Which got me thinking. A couple of years ago, this happened and one of these small rocks smacked rather forcefully into my hood, making a loud noise and scaring the crap out of me. it also put a noticable ding in the hood, having taken the pain off in a small spot. This was particularly infuriating given that the week before, I'd had the hood repainted.

I have to think that there must be a rule against launching projectiles on the freeway. If some guy's lawn chair flies out of his pickup and smacks into someone's car behind him, I'm sure there would be some consequences. In hindsight, I should have gotten that truck's license plate or something.

January 18, 2004

Apache HTTPd <Directory > and HFS+: A Couple of Work-arounds

I wrote yesterday that Apache HTTPd's <Directory > directive doesn't quite work on case-insensitive filesystems such as HFS+. Here I offer a couple of work-arounds.

This is only a problem for files sub-directories that are exposed to the URI space by the server navigating through the filesystem. You can protect your entire document root through a RedirectMatch directive rule, for example. This works because / on your server's URI space is explicitly mapped to a location in the filesystem (ok, also because there are no case variants of /). However, it wouldn't work for a <Location /foo> rule if foo is a file or directory in your document root, because other URIs (eg. /Foo) can be used to get to that file or directory, and you only specified one.

(This almost makes me suggest that we need a <CaseInsensitiveLocation > tag, but fundamentally, this issue is about the filesystem, and we don't want to add a new tag for every possible semantic of all possible resource stores, so no, I'm not going to suggest that.)

The good news is that until this gets fixed, we can come up with a couple of work-arounds.

The first is pretty straighforward. If you want to change the configuration for a directory in your doc root, stick a .htaccess file in there. No matter what URI was used to get to the directory, the server will always find the .htaccess file and read it. There are a few drawbacks here, but they may be insignificant for many users:

  • You have to enable the use of .htaccess files on your server and allow overrides for the configuration directives you want to use in them. This may be a problem if people you don't trust to use those directives have access to those files, which isn't an uncommon arrangement.
  • If you edit your web site using WebDAV, you may not be able to edit .htaccess files via DAV, as access to those files is disables in the default config. If you use a different virtual host for DAV access (you pretty much have to if you are going to have any kind of processing done on served files, such as server-side includes, php, etc.), so you may choose to disable access to .htaccess files on the main server and allow it via DAV. That rules out using .htaccess for configuring the DAV server, however, so if you want per-directory config on DAV also, this won't work.
  • There is a small performance penalty, as the server has to open and handle the extra file. This is probably insignificant unless you have a very high-volume site.

Another option, the one I am using, is to move the directory in question out of your server's URI space (i.e. out of document root) and use an alias. For example, we'd move /path/to/docroot/foo to /path/not/in/docroot/foo and add some config options:

RedirectMatch Permanent "^/foo$" http://myservername/foo/
Alias /foo/ /path/not/in/docroot/foo/
<Location /foo>
   ...options...
</Location>

This involves a bit more cofiguration, but solves the problem nicely. Because foo is no longer in your document root, the only URI that will get you to it is /foo/. You can use <Location /foo> as well as <Directory /path/not/in/docroot/foo> here because now that /foo is the only URI that will get you there, this should be sufficient.

The RedirectMatch directive isn't strictly necessary, but it emulates that the server normally does when you access a directory without the trailing slash, and redirects you to the URI with the trailing slash. You can let the server do this for you by omitting the trailing slashes in the arguments to the Alias directive, but then you have a potential conflict if you have another URI /foobar on your server; this avoids that.

January 17, 2004

Apache HTTPd <Directory > and HFS+

The <Directory > directive in Apache HTTPd doesn't work if you have a case-insensitive file system.

For example, if you have:

<Directory /path/to/docroot/foo>
  Deny from all
</Directory>

And you try to open http://localhost/foo/bar.html, you will fail due to the above deny rule. But an attempt to open http://localhost/Foo/bar.html will succeed (assuming foo/bar.html exists, etc.), despite the deny rule.

If the above were written as a <Location > rule (<Location /foo>), the above behavior would be correct because URIs are case-sensitive and the two URLs are different, but in the <Directory > case, we're placing a rule on an object in the filesystem, and on HFS+ (and others), Foo and foo refer to the same object.

In beginning to investigate what's going on in code, I noticed that server/request.c has code switched by a CASE_BLIND_FILESYSTEM macro, which is enabled on Windows. A macro implementation assumes that all file systems on the system you are building for have one of either case-sensitive or case-insensitive semantics. On Mac OS, and I assume other systems as well, we have a variety of available filesystems which may use either set of semantics.

The correct solution, I think, would be to add an apr_canonical_filename() function to APR and have HTTPd use that in server/request.c instead of the macro. We match up canonical file names with the <Directory > entries, and all is good. That takes care of request processing. Presumably, we should also canonicalize path names when parsing the <Directory > directives; though that can at least be worked around by making sure you type the canonical name into the configuration. Even so, we should deal with that, since the canonical name may not be obvious to the user.

Apple has a solution to this in HTTPd-1.3, which they implemented in a module (mod_hfs_apple). Much better would have been a patch to the HTTPd server which does what I describe above, and the problem remains unsolved for Apache 2.

January 13, 2004

TEN Technology's Google cloak

Interesting that a Google search for "TEN Technology" (with the quotes) doesn't turn up http://www.tentechnology.com/ until page 6, by which time I've usually given up. And yet, there are several results, starting in at page 2, which refer to TEN Technology and their one product. If you search for NaviPod (the product), you don't get a URL from their site until page 11. For a while there, I didn't think they had a web site. It takes a special kind of obscurity, to get missed by Google in that particular fashion.

Maybe I only find this interesting because it's late at night and I'm stuck at work shuttling data around. Guess I'll find out in the morning when I see this again.

January 07, 2004

MacWorld Expo San Francisco 2004

Payam and I went to MacWorld Expo today. It's a smaller show this year, area-wise, as seems to be the trend in many trade shows these days, but there seemed to be a lot of people there, to the point where it was uncomfortably crowded, like shopping after Thanksgiving.

We stopped at every booth with iPod accessories in search of the ideal iPod cover. There was the leather, the neoprene, and the plastic; the bulky, the form-fitting, the modular and expandable.

The Apple-provided iPod sleeve is pretty nice. It looks good, and it's easy to get the iPod in and out of, but I have a couple of problems with it. First, there is no access to bottom connector, so I end up having to take it out of the sleeve while I'm in my car, to plug in the charger. Second, you can't see the display while it's in there.

We both settled on a blue iSkin eXo2. It's like a rubber glove for the iPod. It has access to both the bottom connector as well as the plus on top, and has windows for the display and controls. The only time you would need to remove the iPod from the iSkin is while docking, and you can just pull the bottom half back (it's strechy) to dock it. A bit awkward, but docking isn't the common case for me. I found that I also need to pull the top half back, in order to connect my NaviPod IR remote, so it looks particularly goofy docked on my stereo. All of the stretching weirded me out when I saw it online, but in practice it seems like it can handle it. It's not perfect, but outside of the docking issue, it's just right. Well, I might add a clear hard plastic window over the display to prevent scratching. It looks like they thought of that, (there is a notch under the window frame) but didn't include it.

We found James, whose O'Reily book on Panther just came out. A lot of people were asking about that book, and it looks like a great read. He got me a copy as well as a copy of the new Postfix book, which I really need after having upgraded my home server to Panther and noticing that the postfix.org docs are not very good unless you already know Postfix. More on that later.

Update: the iSkin web site says that the plastic window is included, but neither I nor Payam got them. Not sure what to make of that. Payam says he's going to call them and ask about it.

January 03, 2004

Chicago, Blue Brothers style

This weekend I went to Chicago to visit my sweetheart's family, and today we both had flights home. Since she was leaving in the morning, and I in the evening, I had called on my very good friend Fitz to take me out to lunch and help me kill some time in Chicago. Last time I was in Chicago was for work, and Fitz and Peyton and I went out for some great Greek food, but that was a short evening in the suburbs. This was a whole afternoon. Even better, Kristen got her airline to put her on a later flight as well, so she could hang out with us, and Fitz had talked Karl Fogel into coming along as well.

We had a great time. Chicago rocks (except for the mayor tearing up one of the country's best G.A. airports in the middle of the night for no good reason, which sucks). First, we went to the Hancock tower for drinks and a fantastic view of the city. Karl met us there, and we wandered over to a fantastic Armenian restaurant downtown (Sayat-Nova, 157 E. Ohio; 312.644-9159). The food was excellent, and I tried out the gritty Armenian coffee. Not what I'm used to, but quite good. I know Karl because he is the original driver behind Subversion, and I had a few email exchanges with him about it. He also virtually introduced me to Fitz, a story that Fitz tells better, and we've had a couple of occasions to meet in person. But today, I got to know him a bit better, and I have to say that I'm glad I did. He introduced me to the Spatula System for managing who pays for lunch, which I hope to get to write about later.

After lunch, Fitz took us all for a grand tour of the city of Chicago, complete with a history of every building we passed. It was awesome. But it gets better. We're scooting along in his car and he mentions a building which one might remember from the Blues Brothers, which instantly gets my attention (I'm a fan). Noticing this, he takes us to Lower Wacker Drive, where in the film there forms a massive pile of police cars. I mention that we need music, and it turns out Fitz, of course, has his iPod with the soundtrack. So we pull over, cue up Peter Gunn, and start tearing down Lower Wacker Drive the way God intended.

Fitz, you really made my day.