Sat, 28 Jun 2008

I've been staying in Oakland, taking care of my cousin's house and
garden as he and his partner Becca visit family in New Mexico.

The other night, I ordered a carnitas burrito from a taco truck in a
parking lot at midnight, just after some Mexican-American teenagers
who talked to each other in English but ordered in Spanish.  They
breakdanced in the parking lot as other people, middle-aged men with
their toddler sons, young pregnant women with their young husbands or
boyfriends.  I felt very blessed to be there, under the flickery
yellow lights with the smell of many kinds of grilled meat wafting out
from the taco truck: lengua, carnitas, cabeza.  The burrito was
delicious; I ate it as I walked home.

***

Today, as I watered the garden, two young women drove up in a van full
of picnic supplies.  They turned out to be next-door neighbors I
hadn't met yet.  I was watering the green beans, occasionally munching
a succulent, sweet green pod.  When I initially said hello, they
didn't respond; I thought maybe they didn't speak English, so I told
them in Spanish how good the beans were and offered them some.  One of
them answered in English and accepted a pod, but didn't like it very
much.

***

Yesterday morning, I left their house at 7:30 so I wouldn't be late
for a meeting at HP Labs in Palo Alto at 10:00.  I stopped at the 16th
and Mission stop where I'd left Becca's bike the night before, with
both wheels and the frame locked to a parking meter, in between all
the other bicycles.  When I arrived, it was the only bike left; the
others had all left the night before.  Nothing was missing from it,
not even the pump and polyethylene water bottle.  But I missed my
connection at the 16th and Mission station, and I arrived at the
meeting at 10:45.

Unbeknownst to me, I had ruptured the rear inner tube riding it up to
HP Labs, and I had neglected to carry a tube repair kit with me ---
although there was one on the living room coffee table and one on the
shelf in the bedroom.  My friend Rohit gave me a ride to downtown with
the bike, where I bought tire levers and a patch kit, repaired the
tube, and broke the pump.

***

The other day, I wanted to make capresse sandwiches to share with my
friend Josh.  I picked fresh basil from the back yard and cut up some
tomatoes and mozzarella, but then discovered no bread.  But I had made
pancakes for breakfast with my friend Linley that morning.  So Josh
and I ended up having capresse sandwiches on cold pancakes made with
vanilla soy milk, on a rooftop plaza in the new San Francisco Public
Library building, accompanies with a garden salad from Ben and Becca's
garden, with nasturtium flowers, oxalis, arugula, purslane, and I
think a little mint, on top of some store-bought lettuce.

***

One day, on the way "home", I stopped at the 16th and Mission station
to buy a phone card.  The $5 La Leyenda card I bought has provided
about 45 minutes of talk time to Beatrice in Argentina over the course
of more than a week.  I called her immediately before leaving the
phone-card store and talked for 15 of those minutes, because we hadn't
heard each other's voices in days.

This is the kind of thing I wish everybody could write for themselves.
It automated a simple, repetitive task that Beatrice was spending a lot
of time on.  I wrote most of it in a few minutes, and then she finished
it.

#!/usr/bin/perl -w
use strict;
# script to help beatrice with her web pages
# comments for perl newbies

# ARGLEBARGLE marks the end of $stylelinks
# "my" creates a new variable
my $stylelinks = <<ARGLEBARGLE;
     <link href="../css/global.css" rel="stylesheet" type="text/css">
     <link rel="shortcut icon" href="../../paisley.ico">
ARGLEBARGLE

# similarly with SIMILARLY
my $sidebar = <<SIMILARLY;
<ul class="first"> 
	<li><a href="../animals/index.html"><h2 localizable="true">Animals</h2></a></li>
	<li><a href="../architecture/index.html"><h2 localizable="true">Architecture</h2></a></li>
	<li><a href="../light/index.html"><h2 localizable="true">Light</h2></a></li>
	<li><a href="../macros/index.html"><h2 localizable="true">Macros</h2></a></li>
	<li><a href="../performances/index.html"><h2 localizable="true">Performances</h2></a></li>
	<li><a href="../plants/index.html"><h2 localizable="true">Plants</h2></a></li>
	<li><a href="../../index.html"><h2 localizable="true">Home</h2></a></li>
SIMILARLY

sub mogrify_file {
  my ($input_filename, $output_file) = @_;
  # creates a variable $file, opens the file for input (<), and sticks
  # the open file in $file
  open my $file, "<", $input_filename or die "Can't open $input_filename: $!";

  # <$file> reads a line from the open file and sticks it in $_
  while (<$file>) {
    if (/<h2/) {              # /foo/ looks for "foo" in $_, returns true if found
      print $output_file $sidebar;
    } elsif (/rel="stylesheet"/) {
      print $output_file $stylelinks;
    } elsif (/CC-Attribution/) {
      print $output_file ' <p localizable="true"><a href="http://creativecommons.org/licenses/by-sa/3.0/">CC-Attribution 3.0</a> Beatrice Murch</p>';
    } else {
      print $output_file $_;
    }
  }
}

sub dirname {
  my ($filename) = @_;
  # chop off slashes followed by zero or more (*) nonslashes ([^/]) at
  # the end ($)
  $filename =~ s|/[^/]*$||;
  return $filename;
}

die unless (dirname "fixed/foo/bar/baz.html") eq "fixed/foo/bar";

sub ensure_dir_exists {
  my ($filename) = @_;
  my $dirname = dirname($filename);
  # invoke shell command mkdir -p fixed/foo/bar
  system "mkdir", "-p", $dirname;
}

sub create_new_file_from {
  my ($filename) = @_;
  my $newfilename = "fixed/$filename";
  ensure_dir_exists($newfilename);
  open my $output, ">", $newfilename or die "Can't open $newfilename: $!";
  mogrify_file($filename, $output);
}

die "no files" unless @ARGV;
for my $file (@ARGV) {
  create_new_file_from($file);
}