Monday, January 01, 2007

Spending more time with emacs

For a variety of reasons, it's been a while since I wrote much code. But last Friday, a few ideas I've had rattling around came together, along with some free time, and in a very pleasant heads-down frenzy I cranked out an interesting little tool.

At work, we don't really have a good way of monitoring or recording HTTP traffic. Web server logs aren't turned on and are inconvenient to collect in our current configuration, but even beyond that, some of the information we would need to do anything useful is sometimes stuck in the POST bodies. For other operational reasons, it's even more inconvenient to put any recording tools in the HTTP stack right now. I would expect our load balancer to be useful for this sort of thing, since it's already got its hands pretty deep in the HTTP conversations, but it isn't.

From time to time, therefore, I've looked around for an open-source tool which would let me reassemble and analyze HTTP traffic as seen on a span port or something. Unfortunately, everything I've found that does this kind of TCP / HTTP reassembly and analysis is designed for troubleshooting or intrusion detection, like Ethereal or Snort.

I've been meaning to get a better handle on Ruby, too. I think it's my current favorite programming language, but Python is still my trusty standby tool for this kind of thing, the one I can reach for and use without having to think too hard or look everything up in the language reference. So after a quick search revealed Ruby bindings for libpcap, I decided to sit down and write my own TCP and HTTP reassembly tool.

Once I started, it came together surprisingly quickly. The layering was pretty obvious; packets come in from libpcap and get fed to the appropriate TCP stream; the TCP stream layer handles reassembly (and punts, for the moment, on out-of-order packets); data is fed to the HTTP layer and the whole HTTP stream is buffered in memory, lightly parsed to separate the first line, the headers, and the body. Once both halves of the connection are closed, both streams are handed off to an analysis function.

I haven't gotten my hands this dirty with TCP before, and discovered a few interesting things. First of all, I didn't understand the push flag correctly before; I thought it was set whenever there was data, but apparently it means flush your buffers to the application. Interesting. Second, I didn't have to bother with acknowledgements at all. Third, I haven't had to set up any TCP timers yet. Fourth, Microsoft stuff has a weird habit of sending one byte of data—always just one—along with an ACK. And lastly, my first-pass caveman implementation gets pretty far without even attempting to deal with things like reassembling out-of-order packets, data arriving after the FIN, etc.

I still have to refine the sorts of things you'd expect, cleaning out old streams and perfecting my capture setup so I'm not dropping any packets and tackling reassembly, but the main thing to sort out now is actually recording the data for analysis, in different ways. Patrick Logan wrote a very interesting blog post a long time ago, arguing that the only patterns you really need for persistent data are tuple spaces, versioned document trees, and star schema storage, i.e. (my interpolation) data warehouses. This idea has stuck with me ever since, particularly with respect to tuple spaces, since I've seen the deficiencies of regular SQL databases and of message queues for storing working data. I've kept an occasional reading interest in data warehouses, too. But there is a serious shortage of open-source implementations of those two concepts; Javaspaces is the only tuple space technology I've heard of that sounds production-ready (and I am following Patrick's growing stream of posts on it with a keen interest), but as far as I can tell the star schema universe is owned by commercial databases with five-figure price tags. You can use a regular old database, of course, but it's not what they're optimized for in any sense, and they certainly don't rate as simple or low-maintenance.

Nonetheless, I think that is exactly what I am going to do, record all my web traffic in SQL Server (wouldn't I like to have Oracle back again...). I'll try to do a decent star-schema design; it'll make a good exercise, if nothing else. We have some external feeds that will want web server log files, but I think I'll just write a little tool to synthesize those from the database. That way we won't lose any information, and I can record all the application-specific information I want for each request.

Plus, the TCP and HTTP reassembly layers of this tool could easily and usefully be open-sourced. I know I would have liked to find such a thing, and HTTP certainly lends itself to out-of-line monitoring, so I have to think at least one other person somewhere would find it useful. I guess I have to name it first.

And regarding the title, I'm not happy at all with the XEmacs ruby-mode, or at least its default bindings. C-M-f and C-M-b really need to be forward-sexp and backward-sexp, not whatever-mark-defun. I'll start by trying to customize it the way I like it, but Dave keeps telling me I should take TextMate for a spin, and maybe I will.

Tuesday, November 15, 2005

MP3 Heist, part II

I've been listening to Brian Eno and John Cale's collaboration Wrong Way Up for days now. It's nosing out Garbage's Version 2.0 for top-of-the-CD-stack right now. This has been a busy position; British Sea Power became my new favorite band a month or two ago, and for a while I was wearing out Arcade Fire, but Eno and Cale would hold that honor if only they were a band. Somebody needs to banish them to Kerguelen Island for a couple of years with only a recording studio and a little French restaurant. This is the most incredible thing I've heard in ages.

I've always thought the recording industry was being shortsighted to attack MP3 swapping, but now I realize how thoroughly mad they are. One high-quality MP3 stash and I'm all set to buy up the Eno and Cale back catalogs and start hunting down interesting jazz and quasi-jazz in the wake of St. Germain. Rick named all our old servers at Iridio after bands: blondie, lush, culture, ella, byrd, dandy, cocteau, breeder, marley, pixies, gusgus, and miles off the top of my head. I contributed radiohead, kraftwerk, and catherine. And now I'm inclined to go through the rest of them. (Score two so far for cocteau and pixies, and half points for gusgus.) Blondie I've already been listening to (from a roommate's MP3 collection, naturally) and they're pretty good.

Thursday, November 10, 2005

The Great MP3 Heist

Rick has left our poor little team at work, in order to go back to doing cool stuff, having natural light, and that kind of thing. We are very sad about this. (We're really excited for him, though, and looking forward to the Big Party next Friday.)

On the other hand, he left his Powerbook behind; being a man of impeccable musical taste and generous spirit, he left his impressive MP3 collection intact. I tried slurping the whole thing up but iTunes told me I didn't have enough disk space. So I had to be choosy, but so far the highlights include Garbage's 2.0, St. Germain's Tourist, and the Gotan Project (which I already had, somewhere, but haven't seen lately). And I've hardly even gotten started. I think my next trip to Easy Street Records is going to be expensive.

Thanks Rick!

Wednesday, November 09, 2005

Oh, the kids these days

I've been thinking that when I go to college, I shouldn't have too much trouble with the cultural adjustment. But today Hampshire's admissions propaganda department sent out a link to a student's blog. Apparently the idea was to show us how cool it is to go to Hampshire.

Mein Gott. Reading that makes me feel about a hundred years older than her. And tired. She has a paragraph that I'm guessing has more words in it than this entire blog. I'm not at all sure I'm prepared to use the word "ginormous" or fight over Fruit Roll-Ups with my friends. I haven't even seen a Fruit Roll-Up in a very very long time. And Harry Potter is not even a little bit part of my cultural background—I read the first one and was entirely ungrippèd.

Not that this changes anything. But I hope there are some grown-ups there too, this notwithstanding. Otherwise I guess I will have to hang out with my sister more, just for cultural conditioning...

Saturday, November 05, 2005

Calling cards

If there's time, I'd like to print some calling cards. I have a decent-size pile of light blue Magnani Pescia, and I'd certainly like to use the platen presses, which are lovely old cast-iron Industrial Revolution pieces. One is a Chandler and Price Old Style, with curved spokes on the flywheel, and the other is a Pearl with fabulous red pinstripes on the black paint.

On the other hand, October was a big letterpress casualty already. I don't regret that one bit—this has been the most amazingly mind-expanding and horizon-broadening thing—but I really really need to take care of some other things. Like college applications for instance. So I don't know. Perhaps I'll see if I can just do something not-too-complex in class time.

Letterpress progress

My letterpress project is nearly done now. I managed to fill up every spare moment I had in October with wandering around the library looking for ideas, sketching them up, setting type, setting the same text in half the typefaces in the shop, and otherwise getting things ready. Those things took so much time that I had to basically pick out paper and ink without thinking about them; I just went with the one clear vision of it that I had, which was black type and a dark blue linocut on light blue paper. I was thinking of more of a dusty cadet blue paper but oh well. Practically everyone recommended the Magnani Pescia, which was brilliant. Thick and soft and beautifully-textured and squishy, the type bites right into it and gives a very pleasing impression.

Getting all the rest of it together, especially setting my colophon (good lord, did I test a lot of typefaces for that) took so long I ran out of TA-supervised shop time to actually cut my paper. I was getting kind of concerned about that and considering who I would have to beg (probably Jynn) to help me cut it between then (Sunday afternoon) and my press date on Tuesday. But after leaving the print shop, I ran into Gabe from my class at Uptown Espresso, and as I was explaining my predicament I realized that we have a perfectly good print shop with a big paper cutter at work, so I went in Monday morning, picked up my paper, and took it in to work. Robert asked Matt to show me the ropes, which he very kindly and patiently did. I now know how to run a Heidelberg hydraulic paper cutter; that one must cut the edges that one wants to keep with the back side of the blade, so the pieces you want must be cut long and trimmed; and lots more, although there are still plenty of buttons that I have no idea of the purpose of. Thank you Matt! I owe you a broadside and a beer!

I took the day off of work Tuesday to mix my ink. Amy was there and helped me a great deal. She made me feel a lot better about using plain old black for my type pass, pointing out that not only would the play of light and shadow created by the impression of the type be as good as having a third color, black would look very handsome and not dull at all on the fine blue paper. She was exactly right.

Finally, with only a short sandwich and coffee break, I was ready to go on press. Robert (one of the TAs) and Brian (one of my classmates) assisted me on the Vandercook Number 4. Getting everything set up just right took a long time. Now and then, things like this make me realize that I take a long time at many, many things. Getting the alignment just right was hard, and I couldn't get the measurements to all add up, so I was convinced that the page or something was crooked. Robert had to gently upbraid me for trying to do everything with measurements and arithmetic and not just setting the thing up, straightening it up on press, and printing. I wonder who is right and in what context. Certainly I like to be meticulous and precise in my measurements in woodworking and that kind of thing; otherwise you wind up with crooked kayaks and downdraft tables that don't seal. But when in Rome...

We got through the first pass, producing 48 good pieces out of 60 that I cut. About a third of the spoilage was the expected test pieces during setup, while we got the alignment and ink coverage nailed down. Another third came from not adding ink until a piece came out without enough ink, which one can learn to avoid by listening to the inking rollers and adding ink before you run short. I need to work on that. Finally, I wrecked a disgusting number by forgetting to set the trip/print lever to print, producing only a faint and smudging impression.

That left about half an hour in class, so we cleaned up and Amy scheduled me to print the second pass—just the linocut, with my blue ink—with Robert on Sunday. Twelve hours away as of this writing. I went in today, got out my blue ink, brayered it onto my lino block, and pulled an ink proof onto one of the almost-but-not-quite-fully-inked spoiled pages. I was concerned about whether my blue was going to look good on the blue paper. It is. I've got a beta copy (I pencilled in a beta where the edition number would go) and I'm very happy with it. I only hope there's enough blue ink to get me through all 48. If not, I'll have to see if I can squeeze in another run later. At least if that happens I'll have a chance to use a different color, which would be interesting.

Sunday, October 16, 2005

Ink Studies, refinement of

OK, after hitting the books on this all weekend, things look a little different. The front rank, the schools that appear to have both a strong liberal arts college nature and a very strong (for a liberal arts school) art department (or functional equivalent), are Brown, Hampshire, Sarah Lawrence, and Bard. Macalester and Wesleyan appear to be equally strong as liberal arts colleges but do not quite appear to be in the same class in respect of their art departments. Carleton appears to trail those two by a little bit, again only in the art department. There seems to be a noticeable gap between it and Reed, Grinnell, and Vassar in that category, which I am afraid are definitely in the third rank on that basis.

More disturbingly, it appears that there is no way to get a BFA without being a somewhat-accomplished artist at college-application time, and that the BFA level is where one obtains a real design education (see RISD, Parsons, etc). This is a great injustice, if not a violation of my human rights. I think this will have to be resolved by calling up people in the art department at these schools and asking "how do I become a graphic designer or some such thing if I go to your school?"

Brown has a misnamed Resumed Undergraduate Education program, which applies even to old fogies like myself who are not resuming any undergraduate education but beginning it, just a little later than everybody else. It sounds perfect and wonderful, except that it sends its admission notifications approximately May 1. What happens on May 1? Let's see. It is International Worker's Day for one thing. Anything else? Oh yeah, it's the day when all of the other schools require you to tell them whether you are accepting their admission offers. Does a college application plan consisting of "stake everything on Brown" strike anyone else as, um, brave?

P.S. In the spring of 2005, Bard offered a Foundations: Constructivism class. That is just unspeakably cool.

Thursday, October 13, 2005

Ink Studies

I've been starting to go over my college list again, this time with art firmly in mind. I don't know whether I want to major in it, but I certainly want to get much more into the visual arts than I have before. And having some kind of letterpress / book arts facilities and courses would be very cool, too. A brief check, starting from my existing list, shows a few that clearly have this: Bard, Bowdoin, Carleton, Macalester, and Sarah Lawrence for sure, possibly the Amherst colleges via Smith. Still need to find out if us menfolk are allowed to take Smith classes or what. Interesting, though, that Reed, Oberlin, and Grinnell don't seem to, although Reed at least has a wonky, specifically "nontraditional" book-arts class or two. Probably not the decisive factor, but it does keep Bard and Sarah Lawrence high on my list, for sure. A little disappointing about Oberlin. [Update: Reed does have a Reprex letterpress. Missed it the first couple of times. Google to the rescue, naturally.] I'll have to look at the others I mentioned in more depth.

Also, a number of these (have to go back and look again, but Bowdoin, Grinnell, Hampshire, and Oberlin for sure) have preparatory programs for students intending to go into architecture and urban planning. Perhaps not essential, but very helpful, to be sure. And... oh... I have to remember what that one school was that offered a sort of one-year post-undergrad urban-planning prep program. I think it was in New York, for some reason, but NYU doesn't sound quite right. Hmm.

Time to get moving on this, no doubt about it.

Creativity, visual and otherwise

My working hypothesis about the pain and difficulty of this whole broadside-design process is that creating visual stuff is a structured creative process kind of like writing, where you need to learn—or be trained in—the techniques and modes of thought involved to get to the point where you can effectively just turn your brain on and start making something. I can write tolerably well, but I clearly remember just how hard it was to learn, how many hours my dad spent working with me on it, and how noticeably my skills developed through endless revisions for school. Hopefully there is a similar process ahead of me here.

I really wish I had had any meaningful involvement with art before, so I could at least have an idea whether this is true. It certainly could be that it's more like programming, where if you don't have the true aptitude you're wasting your time, and if you do have it you realize that pretty quickly. I hope not, though.