Monthly Archives: June 2010

Dear City of Boston

Thanks for repaving Cambridge St.! The deadly potholes are much less frequent now. It’s too bad that they’re still invisible, because the streetlights are all broken, so it’s pitch-black at night. You should consider fixing those next. It would also be great if you could paint in some lane markings around the I-90 onramp, so that drivers could see where the lanes are. A crosswalk next to that onramp would also be nice, so that pedestrians could legally cross the street once the sidewalk ends.

Then we can talk about bike lanes.

Hot

It’s been hot, at least for June.  I’ve gone into my damp summer sleeping mode, all limbs and fingers spread to touch the most air and the least sheet.  I got a great e-mail in my inbox today, from the hospital’s facilities manager.

The weather today is problematic for our operations. We are doing the best we can to keep the humidity in check and manage temperature. Unfortunately, the chilled water supply temperature from the local power station is very high relative to their normal supply compounding our ability to better control cooling.

So hot, then, that the local cogen couldn’t keep their cold stream cold.

Bike

It was a clear, dry, sunny day today, and a few friends proposed to bike out to Hull, on the South Shore.  It seemed like a good opportunity for a shakedown cruise for my Atala, since I finally had a chance to put some much-needed thread-locker on the drive-side bottom bracket cup.  For the first few miles everything seemed to be going well, but as we got south of the city my left crank began to wobble.  I tightened it by hand periodically, but somewhere in South Dorchester it fell off entirely.  Fortuitously, we were right next to a gas station with an auto mechanic who kindly obliged to apply a socket wrench to the problem.

The crank held for maybe two miles, and then started to wobble again.  Auto mechanics, it turns out, can’t be expected to apply enough force to the crank nuts.  My father would say here that bicycles are really 19th century technology, designed to be held together by plenty of elbow grease.

I hand-tightened the nut every mile or so for the next ten miles, and tried to pedal mostly with my right leg.  It was tenuous, and put us a bit behind schedule.  By the time we got to east Quincy bicycle shops were thankfully beginning to open, and the party stopped for a bit while I paid the $10 minimum service fee to get both sides properly tightened, to 260 in-lb according to the mechanic.  From then on, the pedals were fine.

I had announced a World Cup viewing party at my apartment at 2:30, so by the time we arrived at the Hull beach my return timeline was already looking pretty tight.  I had misread the ferry schedule, and there was no ferry at an appropriate time.  I missed the commuter rail, which would have been inconvenient anyway since it stops at South Station.  Ultimately, I decided to bike back, alone, to the Quincy stop on the Red Line, which would take me right back to my apartment.  This was complicated somewhat by my lack of a map or any idea where the station is.

It was almost exactly 10 miles to Quincy, and I biked it alone.  I think that makes it my longest solo trip, one-way.  It took about half an hour; the Atala is a fast machine when it’s working.*  I got awfully lucky with the route, and happened to ride right up to the station just as I was about to ask directions.  I got home before 2, with enough time to take a shower and eat something before guests arrived.

As it turns out, the rush was unnecessary.  My deadpan advertising may have been too dead.  Only one person came, and not until an hour later.

*: It would be faster still if I had lubricated anything in a year, which might have prevented the  angry grinding noises heard in most gears.

How to Not Use mod_layout

mod_layout is an Apache module designed for inserting dynamic banners (headers and footers) into pages. That’s what I needed to do, so mod_layout seemed heaven-sent. Unfortunately, when I tried to use it, I was blocked by two bugs

  1. mod_layout misbehaves when the root (/) has a 301 redirect and the banner is specified by URL. I have a wiki in the root (actually /index.php) which creates a 301 redirect to /index.php/Main_Page, and as a result mod_layout’s LayoutHeader directive was failing with errors indicating that it couldn’t find “/var/www/banners/header.html/Main_Page”. Unless I wanted to reorganize the whole server layout, that meant I couldn’t use mod_layout directly.
  2. I came up with a (slightly nutty) workaround: use mod_layout to insert a static banner containing a Server-Side Include, which when parsed includes the actual banner URL. This requires mod_layout to run first, transform the page, and then pass it to mod_include for additional processing. Apache lets you specify the ordering of these kinds of filters, e.g. “AddOutputFilterByType LAYOUT;INCLUDES text/html”. Unfortunately, mod_layout doesn’t seem to obey the ordering directive, and so the mod_include filter never runs.

I reported these problems to the author, who replied

We have[n't] supported it [(mod_layout)] in years. The apache 2.0 version never could be made to work very well because of changes that kept occurring in the internal Apache API.

That seems perfectly fair to me, but it means these bugs aren’t likely to be fixed any time soon. Accordingly, I drew up a plan for how to not use mod_layout.

The solution is best described by the relevant piece of Apache configuration:

FilterDeclare Sub
FilterProvider Sub SUBSTITUTE resp=Content-Type $text/html
FilterDeclare SSI
FilterProvider SSI INCLUDES resp=Content-Type $text/html
<LocationMatch "^/(?!(someurl)|(banners))">
# Apply the banners to the whole server except for someurl/, which doesn't
# need them, and banners/, which contains the banners. (It doesn't
# break anything to allow the banners to be processed, but it would cause
# two unnecessary additional SSI passes on every page load.)
Options +Includes
FilterChain +Sub +SSI
Substitute "s|(<body.*?>)|$1<!--#include virtual=\"/banners/header.html\"-->|i"
Substitute "s|(</body.*?>)|<!--#include virtual=\"/banners/footer.html\"-->$1|i"
</LocationMatch>

The idea, then, is to use mod_substitute to insert a Server-Side Include immediately after <body> and before </body>. The include directive is then parsed by mod_include to insert the actual banner from a file. We apply all of this inside a LocationMatch section, which allows us to exclude certain subtrees from the processing. In the list of paths that shouldn’t be processed we include the location of the banners, because (at least in my case) they are known not to contain any SSI directives, so parsing them for SSI would just waste time.

You might reasonably question the sanity of this approach. One particular problem, you might note with fear, is that I’m parsing HTML with a regular expression. If “<body>” appears verbatim in some Javascript code, it will be replaced. If the tag has an attribute value containing “>”, it will be mis-parsed. Your fears are not misplaced. However, this configuration is still a suitable replacement for mod_layout … because mod_layout does the same thing! I was surprised, when I read the code, to discover that mod_layout doesn’t employ any actual HTML parsing; it just uses a nearly identical regexp search.

The other obvious downside of this approach is that it could be slower than mod_layout. I don’t think this is going to be too much of a problem. The regexps are compiled once when the server starts, and executed using the highly optimized PCRE engine. Apache SSI is also highly optimized. mod_substitute is not especially tuned for speed.  Unless your server is truly CPU-limited, I think any additional processing is likely to be irrelevant.

So in conclusion, if mod_layout works for you, great!  If not, you might try this instead.

TO DO: Devise insane regexps that are safer but not too slow, and/or Fix mod_layout.  Contributions welcome.
EDIT: AddOutputFilterByType is deprecated in Apache 2.2, and was misbehaving for me after an upgrade (disobeying the filter ordering). Example updated to follow Apache’s advice and switch to mod_filter, which fixed the behavior.

Earthquake

My advisor just came over to inform me that there had been an earthquake shortly before lab meeting, noticeable in his office because of a picture tapping against the wall. I wondered, for a moment, if it had actually been the whole country jumping up from their chairs when the US team broke the tie against Algeria, and qualified for the next round of the World Cup, with three minutes remaining in extended time.

As it turns out the epicenter was northwest of Montreal, and the quake was quite severe for any moose who happened to be roaming that particular bit of uninhabited wilderness.

Pioneer One

On Sunday I watched Pioneer One. It’s a pilot episode for something like a science fiction television series, shot on an extremely low budget. The remarkable thing about Pioneer One is that it was funded by small donations from hundreds of people, and released under a relatively liberal license. I am (almost) free to reuse the video from that episode for whatever purpose I choose.

The quick and dirty nature of the production is clearly visible in the writing and acting, which are sometimes less than believable. The editing and sound are also not quite Hollywood, but they’re pretty good. The concept is reasonably original, with room for at least a full “season” of episodes to explore the story.

The website claims to be trying to raise $20,000 in small donations to shoot the next six episodes. That’s obviously not enough to pay the actors, which raises some questions about the production’s strategy. Maybe they’re hoping to get picked up for a second season by a major network, or maybe the actors are hoping to launch independent careers from here. My hope is that, once they’ve proven themselves, they will raise their funding targets to sustainable levels, and adopt the Street Performer Protocol. I’m hesitant to send them money with no strings attached, but if my donation were held in escrow until each episode were released, I would gladly pay for every one.

Bananas

Banana pancakes were on the menu Friday morning, so my roommate bought a bunch of bananas on Thursday. I bought bananas on Thursday too, just for general eating. On Friday the blueberry and chocolate pancakes got made first, and the bananas never got used at all. On Saturday we had 10 bananas, and some of them were getting to look kind of old.

I took half of them, mashed them up with a fork, and did what my mother taught me to do with a surplus of bananas: banana bread. Some adjustments were required, like using five bananas (since I was trying to use up bananas) and baking the bread cake in a spaghetti pot, since I don’t have a loaf pan.

Anyway, it turned out great. Hooray for recipes, bananas, and conventional wisdom.

Cup

There is, right now, at 9:50 AM on a Friday, a breakfast party going on in my living room, in honor of a World Cup game being held in another time zone. The game is US vs. Slovenia.

I don’t even know who the favorite is.

Pancake time.

Pizza!

In our kitchen, a whole drawer is devoted to items of non-perishable food left by previous residents. The drawer is now absolutely full, and I took it upon myself to start emptying it in earnest. Three items stood out this week: a jar of pizza sauce, a vacuum bag of sun-dried tomatoes, and a huge surplus of flour.

After work I picked up mozzarella and yeast, and got to work immediately on the dough. It took about two hours, and the topping and cooking took maybe another hour.

My primary objective was to kill off the sauce, so I poured the whole jar on … which turned out to be about triple the amount you’d get from any sane pizzeria. Chastened, I didn’t quite use up the tomatoes, which smelled a little funny (although it turns out they’re great, if salty).

The results, I’m proud to declare, were nonetheless undeniably Pizza, and tasty to boot.

Portobello

I think I ate my first ever “Portobello” “burger” for dinner tonight, at The 21st Amendment on Beacon Hill. It was surprisingly not awful, and I hear it’s better if they don’t run out of basil. I’m still no mushroom fan, but I could imagine potentially eating this again.

For the record, a Portobello mushroom is in fact just a normal mushroom, like the ones in salads, but harvested later. Also, putting a mushroom on a bun does not make it a burger, and indeed the Amendment’s menu avoids the term.