Animals, Alphabetical: Part 2

I made a lot of progress today on the lyrics for the song I'm writing for my daughter. As I blogged earlier (http://whylom.posterous.com/animals-alphabetical) the music has been waiting for lyrics patiently for at least a year now. I envision the song as an alphabetical listing of animals, with some more poetic bits musing on the infinite beauty and variety of the animal kingdom. Vaguely educational but a solid rock song, like They Might Be Giants.

Here is what I have so far. For some idea of how challenging this was (and for a good laugh) try reading it out loud.

alligator, beetle, cow, dog.
elephant, flamingo, groundhog.
hummingbird, iguana,
jackal, kangaroo.
llama, marmoset,
and a nightingale for you.

octopus, platypus, quail.
rattlesnake, squirrel, or snail.
turkey, turtle, tiger,
and the ungulates.
vulture and vicuna,
all the vertebrates.

armadillo, bumblebee, crow.
monkey, eagle, firefly, goat.
hippopotamus, impala, jellyfish.
koala, lion, monkey,
narwhal, ostrich.

This is nearly all of the super-structured "litany" of animals that happens in the verses. When I get into the chorus and the rousing finale (which is freaking sweet in my head) I'll actually have to go beyond rhyme and meter into something more like actual poetry. Yikes!

If you think I'm proxy

At the interactive agency where I'm a lead developer, we support some seriously scary legacy applications.  Systems so twisted and magical that all the developers have to share the single development environment that took weeks to set up.  This used to force even the front-end developers to upload each change to the server to see if it worked.  Hours and hours down the drain that could have been spent playing Wii in the break room.

My solution: a desktop proxy server.  It serves static files (JavaScript and CSS) right from your filesystem and passes all other requests to the shared development environment, then serving the response.  Just point your browser at localhost and you have a faithful replica of the application in which you can see your front-end changes instantly.

The first version used PHP and mod_rewrite, but it was a beast to set up and configure.  A later incarnation in Ruby (using the Sinatra framework) was user friendly but relied too much on a YAML configuration file to be flexible enough.

Yesterday, I doodled my dream solution.  A Ruby DSL my team could use to effortlessly set up multiple sites, and define proxy rules.  In the following examples, "foo.com" is mapped to localhost in a dev's hosts file.

# a simple HTTP server
host 'foo.com' do
  docroot 'C:\foo'
end

# or define some common HTTP server settings
host 'foo.com' do
  docroot 'C:\foo'
  aliases 'boo.com', 'baz.com'
  error :404 => '/404.html'
  directory_indexes 'index.html', 'index.htm'
end

That's fine for quickly doodling some ideas.  How about we add the ability to fetch missing assets from a remote server?

host 'foo.com' do
  docroot 'C:\foo'
  fetch_from 'www.bar.com'

  # control which assets are fetched from remote host
  always_fetch '/data/*.xml', '*.jsp'
  never_fetch '/index.html'

  # cache fetched assets (served from cache on subsequent requests)
  cache :what => [:jpeg, :gif, :png], :where => 'C:\caches\foo.com'
end

When developing interesting Ajax applications, it's often helpful to be able to quickly mock different responses from the back-end.  This is what I really missed from the PHP version.  This new DSL (inspired by Sinatra) makes it trivial:

host 'foo.com' do
  docroot 'C:\foo'
  
  handle '/time' do
    Time.now
  end

  handle '/time.html' do
    "The time is #{Time.now}."
  end
end

In order to actually implement this DSL, I will have to take my kung fu to the next level, and learn the dark art of metaprogramming in Ruby. I hope to find a little time at work to pick at this over the coming weeks.

Animals, Alphabetical

Animals

I'm writing a song about animals for my daughter.

I came up with a lot of good tunes during her newborn / infant days.
Something about the sleep deprivation, the utter silence of 3 AM, and
watching this little person look up at me. One of these tunes came
from me singing along to some of the alphabetical decoration in her
room: "Alligator, building, car, dog..." The tune grew and grew, as
they tend to do, until I found myself with the full arrangement in my
head, background vocals and everything. I could hear the lyrics of
the verse simply listing animals in alphabetical order.

Unfortunately, lyrics don't come nearly as naturally to me, so it has
been wordlessly stuck in my head for a while now. But Thing-a-day has
inspired me to roll up my sleeves and try to finish this song!
Tonight's session was spent listing out animals by letter, to help me
string along their names to fit the tune and rhyme scheme. With this
handy matrix of animals, I made a HUUUGE start in getting the lyrics
together for this song!

I learned in the process that my memory is in no way alphabetized (I
mean, who remembers "dromedary" before "duck"?). I also learned that
adults would be happier if they talked about animals as much as kids
do. Animals rule.

A Ditty

Music

Like many others, I was a little busy with toddler wrangling and preparations for Super Bowl entertaining to post anything yesterday. Preparations for our evening guests included a trip to the market for sundry chips and dips. The trip conveniently doubled as a family outing with our 2-year-old, who is always delighted to be able to walk with her parents and to lend a hand filling the shopping cart.

My wife and I sing nearly constantly, and are always making up songs for and about our wee one. On our way up the stairs of our walkup, I sang just such a song to encourage our daughter to keep climbing those stairs. It was the only thing I made yesterday, and so tonight I wrote it down on actual staff paper. It was a great feeling to write down music (with a pencil!) again, with no computer in sight.

Wikipedia Reboot

One of things I'm hoping to accomplish this month is an extension for the Google Chrome web browser. The nutty professors at Google unveiled the extension API a short while ago, and I was delighted (but not surprised) that it lets you use the traditional tools of the web developer: JavaScript, CSS, and HTML.  Today, I had an idea for an extension and spent some time sketching it out.  It was inspired by all those Firefox extensions like Better Gmail (http://bit.ly/XXLTA) and Helvetireader (http://helvetireader.com) that were designed to tweak a particular web site.

The site I want to tweak is Wikipedia: the greatest compendium of human erudition since Diderot's Encyclopédie of 1772.  Yes, I am joking.  But I do love the 'Pedia, despite its flaws.  I am on the site hourly, especially to wrap my head around the latest technical acronym that is running for election to the Board of Buzzwords.  And where else can you find an article as delightfully useless as this:

http://en.wikipedia.org/wiki/Locks_and_weirs_on_the_River_Thames

For my Chrome extension, I'd like to restyle the site to suit my own perverse tastes and add some new UI elements.  My fantasy reboot of Wikipedia would:

  • simplify the layout and typography for easy reading
  • remove unnecessary branding
  • remove the entire left column
  • simplify the titles to something like "Aardvark (Wikipedia)"
  • make image thumbnails open fullsize versions in a modal
  • have keystrokes to show/hide footnotes and the ubiquitous "edit" links
  • restyle the table of contents to be less obtrusive

 

 

Lock & Load JavaScript

I did not have any time to make something today, so here is something I did make in the last week.  Warning: serious geekery ahead...

At work (a small but mighty NYC interactive agency) we are putting the finishing touches on a web application that has a lot of Ajax going on.  A lot of scenarios where you click on a button, a small animation appears to entertain you while you wait, and eventually some new information or a message is displayed.  If you should get impatient and click on that button 25 times while you're waiting, all sorts of weird things can happen.

So I needed a way to temporarily disable a button, and then re-enable when all is clear.  This happens in so many places in the application, even on one screen, that it cried out for a reusable solution!  I daydreamed about turning something like this:

button.onclick = function() {
  saveData(function(data) {
    display('Your data has been saved.');
  });
};

into something like this:

button.onclick = function() {
  lock(function(unlock) {
    saveData(function(data) {
      display('Your data has been saved.');
      unlock();
    });
  });
};

The lock() function fires the anonymous function it is passed, and then locks it.  So your first click results in a call to saveData(), and your subsequent clicks are ignored.  What's cool is that lock() passes the callback a personalized unlock function that can be used to re-enable the locked functionality when it is ready.  In this case, after the Ajax call (saveData) has completed.

The implementation was not nearly as difficult as I had feared.  The clever hack (which works on all browsers we support) was to keep track of "locked" anonymous functions by their string representations:

lock = (function() {
  // array of string representations of functions that are currently locked
  var lockedFns = [];
  
  return function(callback) {
    // convert callback to string to support locking anonymous functions
    var fn = callback.toString();

    // define some helper functions, bound to the callback
    function index() { return $.inArray(fn, lockedFns); }
    function locked() { return index() > -1; }
    function lock() { lockedFns.push(fn); }
    function unlock() { lockedFns.splice(index(), 1); }
    
    // if not already locked
    if (!locked()) {
      // lock and fire the callback, passing it a reference to its own unlock function
      lock();
      callback(unlock);
    }
  };
})();


I was really proud of how much simpler this function made the entire application.  One little wrapper applied here and there, and an entire class of weird errors goes away.

 

Hey, elemenopy!

One of the unexpected pleasures of being a parent is getting to hear
the alphabet spoken (and sung) all the time. I'm pretty sure my
little monkey is experiencing the alphabet, more or less, as pure
sound.

I remember thinking as a kid that L-M-N-O-P sounded like "elemenopy".
An ancient Greek word, I imagined. Something Aristotle would use to
describe something indescribable. Like the stillness that falls over
a room after someone has said something profound.

This evening I found myself doodling the word on my trusty Thing-a-day
legal pad, and wondering what other words I could find in the sounds
of the alphabet. Before I knew it, I had written the following poem.
. .


A bee.

Seedy e-effigy.

Hey, chai Jake! Hey, elemenopy!

Queueorous tea, you "vie".

Double, you ex-why zee.

Triskadekaphobia: The Musical!

Indexcards

Tonight, I filled up 13 index cards with the 13 stanzas of "Thirteen
Ways of Looking at a Blackbird" by Wallace Stevens.

http://www.writing.upenn.edu/~afilreis/88/stevens-13ways.html

I'm working on a musical setting of the poem this month. I only came
across this poem last April, so we're still getting to know each
other.

Writing out a text by hand helps you get inside it, I find. And the
physical act of writing really slows down your reading. So you hear
all those lovely details the poet painstakingly put together with his
tweezers and microscope. And as Rilke said to his young poet friend,
seeing any poem in your own handwriting is a pleasant shock to the
system.

The index cards will help me separate and recombine the stanzas.
Also, they are very good for reading while pacing in a circle
muttering to oneself. And I don't know about you, but that's my basic
create M.O. in a nutshell.

A handful of passages made my heart race. Stanza 11 made me scratch
my head ("what the effing hell is this doing in here?"). Most
importantly, I had some very promising musical ideas during this
process. I hope to share some tunes with you all before March
arrives!

Legal Padding (or Hello Yellow, My Old Friend)

Legalpad

I write music and stories.

Or, if I am to be honest, I have written music and stories. There was
once a play, a composition for student orchestra, a short film score,
many sketches for stories, and a quiet little sea of songs.

These days I mostly write code. For money -- like the harlot of
higher reasoning I am. I also provide, free of charge, real-time
commentary on the form and structure of any primetime dramas I happen
to be watching. (Starting a story "in medias res" draws in the
audience and dispenses with such trifles as exposition.)

In the desperate hope that my muse has been patiently awaiting my
return, flipping through magazines in the Thing-a-Day waiting room, I
spent my first day a-planning and a-plotting. I sat down with a legal
pad and brainstormed through some idea I'd be excited to spend some
quality time with this month.

As you can see from the picture (if this newfangled Posterous
contraption displays it) my enthusiasm overcame any concerns for the
blue lines on the paper.

Among the possible projects are:

- setting the last page of James Joyce's story "The Dead" to music
- mindmapping / index carding / stick figure doodles of my 4 most
fertile story ideas
- a user interface that combines the joys of an enormous sheet of
music staff paper with programming
- a musical setting of Wallace Stevens' poem "13 Ways of Looking at a
Blackbird"
- my first Google Chrome extension (not terribly sexy, but I'm still
pretty stoked)

I'm really looking forward to chipping away at some of these projects
this month. Now I'm off to do the dishes, which is just Zen-like
enough in its tedium to always get my creative juices flowing!