Saturday, February 21, 2009

A little lithp

After almost 20 years of fairly hardcore Emacs love, I finally wrote my first Lisp macro. And now I want to smear my good fortune all over you, dear reader, by recounting my experience in more depth.

How lucky for you!

About Lisp...

Created in 1958, Lisp is the 2nd oldest (not to mention sexiest) programming language in widespread use today. Its syntax is simple: lists of tokens contained within parentheses. In Lisp, code and data are represented the same way: as lists of tokens, duh. This deceptively powerful quality is what allows "Lispers" to create new syntax, i.e. Domain Specific Languages, within Lisp itself.

Lisp is basically what the "executable XML geniuses" -- yes, I'm looking at you Ant, Spring, J2EE, VoiceXML, and countless others -- should have used! XML is what you use when your chosen language for manipulating data can't adequately represent it.

My Macro

Ok, enough with the history. Here's the macro:

(require 'sqlplus)
(defmacro def-oracle (name connect-string)
(let* ((buf-name (concat "oracle-" (symbol-name name)))
(fun-name (intern buf-name)))
`(defun ,fun-name ()
(interactive)
(sqlplus ,connect-string ,buf-name))))
Lisp macros are like functions, except that instead of computing a value, they compute another Lisp expression that will compute the value. In this case, my macro creates a defun expression, which defines a function. Simple, huh?

The trick to macros is the backquote character: `. Combined with the comma character, they allow you to selectively evaluate elements of a quoted list. In my macro, the list whose first token is defun is quoted (by a backquote) and my "selectively evaluated elements" are fun-name, connect-string, and buf-name.

Here's how I invoke my macro:
(def-oracle dev   "user/password@dev.host:port/sid")
(def-oracle qa "user/password@qa.host:port/sid")
(def-oracle prod "user/password@prod.host:port/sid")
After those lines execute, three new functions are created:
  • oracle-dev
  • oracle-qa
  • oracle-prod
Ta-da!

Um, hello?

Your stolid reaction belies the awesomeness of my macro!

Maybe I should've started with my reasons for creating the macro in the first place.
  • Create a handy function that "wraps" the Emacs sqlplus function for each of the databases to which I must often connect
  • Don't prompt me for the dang connection credentials every time I invoke the handy wrapper function
  • Enforce a consistent naming convention for the various sqlplus buffers I have open so that I may, for example, easily switch between qa and dev
  • Make it easy to add more of these handy wrapper functions
There. Is that better? I certainly think so. :-)

But perhaps it would be enlightening to see what I would've had to code to achieve the same result without using a macro:

(defun oracle-dev ()
(interactive)
(sqlplus "user/password@dev.host:port/sid" "oracle-dev"))
(defun oracle-qa ()
(interactive)
(sqlplus "user/password@qa.host:port/sid" "oracle-qa"))
(defun oracle-prod ()
(interactive)
(sqlplus "user/password@prod.host:port/sid" "oracle-prod"))

See how verbose and redundant that is? It's positively VERBOSIDUNDANT!!! And my naming/calling conventions are sprinkled all over the place. To change any one would require multiple redundant changes. And that's not DRY, and that's not good.

Friday, August 15, 2008

PoopTag = Social Defecation

(It's not as gross as it sounds!)

Everybody poops. Every U.S. president. Every Jonas Brother. Every Olympic athlete. Even Michael Phelps. Actually, at 12,000 calories a day, he poops a LOT!

And so while you're pooping, have you ever wondered who else is pooping at exactly the same time? Really? Me, too!

So with the help of some friends, I created PoopTag, a sort of game that strives to be both encouraging and enlightening. It's easy to play: you simply notify PoopTag whenever you poop. You do this by sending a direct message to the pooptag account on Twitter using your mobile device. PoopTag will then determine whether anyone else is pooping at that time. If they are, you will have successfully "tagged" them, and PoopTag will notify its followers of this happy event.

And in response to your direct message, whether you successfully tag anyone or not, you will receive a random pithy reply. That's the "encouraging and enlightening" part.

There are two modes of play: public and covert. You decide which way to play each time you poop.
  • Public (send more than one character):
    d pooptag This text will be broadcast to all PoopTaggers

  • Covert (send any single character):
    d pooptag !

Obviously, the public notification makes it easy for someone to tag you, though they must be pooping in order to do so.

Eventually, we'll publish statistics at pooptag.com, enabling services like Poop Cycle Compatibility Matching, prospective home-buyer bathroom sizing tools, and life-saving medical history to present to your doctor, among other things.

Come join the fun!

UPDATE 9/20/08: Changed covert pooping method from an empty message to one containing only punctuation due to Twitter no longer delivering blank direct messages.
UPDATE 10/13/08: Covert pooping now triggered by a message containing only a single character (letter, number, punctuation, whatever)

Saturday, August 09, 2008

Create

I'm big on creativity. You know, building stuff. Putting things where nothing was before. I think it's both the secret to happiness and the meaning of life. I think it's what humans are SUPPOSED TO DO.

Create. Re-create. Recreation. Play, especially at work.

I follow why the lucky stiff on Twitter. His tweets are usually funny and clever. And once in a while, he'll write something like this:

when you don't create things, you become defined by your tastes rather than ability. your tastes only narrow & exclude people. so create.

Very cool.

Thursday, June 12, 2008

Making Gardening Cool

As if we didn't have enough, here's yet another reason ya gotta love Bob!

Sunday, May 18, 2008

Trying to Save the Crum & Forster

My grandfather, Lewis "Buck" Crook, was a prominent architect. He and his partner, Ernest "Ed" Ivey, comprised the firm of Ivey & Crook, responsible for almost 600 commissions over the course of 43 years, most of which were built in and around the city of Atlanta, Georgia.

One of them, the Crum & Forster building, a midtown landmark at 771 Spring Street since 1927, is in imminent danger of being torn down. Ironically, the demolition is being proposed by Georgia Tech, who purchased the property in December of 2007, apparently with the intent to demolish it and expand the development of their Technology Square.

Georgia Tech is the alma mater of both my grandfather and his partner, Ed Ivey, who helped found the school of architecture there one hundred years ago this year. Through their works, they made a substantial contribution to the esteemed academic reputation Georgia Tech enjoys today.

Rather than destroy it, Georgia Tech has an opportunity to celebrate the work of Ivey & Crook, just as world-renowned architect John Portman, another Tech graduate, did when he expanded Emory University's student center in the 1980's. Ivey & Crook designed and built the original dining hall at Emory. Portman could've torn it down, but instead he chose to incorporate it into his own vision for the Dobbs University Center.

Georgia Tech has every reason to do the same for Technology Square!

An online petition to save the Crum & Forster has been created. Please add your name.

The building has an official blog. More pictures and info can be found here, here, and here.

Tuesday, May 06, 2008

Bizzlr

Our first press release!

Saturday, November 03, 2007

A Few Poems

While doing some digital housekeeping recently, I ran across some poems I wrote back in the mid 90's when I worked with a very creative group of people at a now-defunct company. We were programmers, each responsible for one or more inter-related components of a large distributed system. When someone released a new module, the others would have to recompile to incorporate the changes. Often, a new-release email would be accompanied by a poem -- most often original -- or maybe song lyrics or even particularly elegant snippets of code.

My component was called the Data Access Daemon or DAD, for short. My first release email included this haiku:

Restless, like a child,
searching for its potential,
DAD, ever-changing.

Many of the poems I wrote were related to some feature of the DAD, i.e. stupid when taken out of context in a blog post, but a few of them I think stand on their own, or are at least "somewhat less stupid":

Quicksort
=========
I happened across a big pile of stuff
And decided that it should be sorted.
The time I could spend was hardly enough,
Any more time could not be afforded.

I picked up a thing, at random, I'm sure,
And to each of the rest I compared it.
I made two more piles of stuff, as it were:
The things found above and below it.

To each of those piles, the same thing I done,
And to those thereafter created.
And not 'til the size of each pile was one --
Were my efforts quite quickly abated.

Hardly a minute of time had passed by,
When I realized something important.
The stuff that had been on that very first pile,
After just a short while, was now sorted!

A Little Number I Call "9"
==========================
Begin with twelve and four,
then take away seven.
If you add two more,
You're left with eleven.

Eleven, you could say,
Is two one's combined.
If you take those away,
You end up with nine.

Stressed (Chill) Out
====================
Never settle (Be still) for less.
Always strive (until) to be best.
Never stop (your will) to rest.
Everything (is nil.) is a test.

Work It
=======
"Work it, baby, work it!"
I heard some dancers say.
"Toil it, baby, toil it!"
I joined in their refrain.

At this, they hesitated,
And turned, and frowned at me.
"What did you say?!" they shouted.
For dancers, they seemed mean.

A misinterpretation
Was all that had occurred.
Instead of inspiration,
It was "toilet" that they heard.

Men and Women
=============
"Men are from Mars," of course,
"And women are from Venus."
As if those stupid metaphors,
Some wisdom they could gain us!

Men and women are different,
But not because of Venus.
Only women can get pregnant,
And only men can have a... prostate!

Kicking Squirrels
=================
A squirrel came hopping through my yard,
And got a little careless.
The distance wasn't all that far --
From him to my Adidas.

Ducking behind the nearest tree,
I lied in vengeful wait.
And by the time he noticed me,
It was much too late.

In mid-jump I caught him square --
Just like that fella, Pele.
Soaring higher into the air,
I watched him sail away.

He landed atop my neighbor's house
A little shaken, but still alive.
About that time I spied a mouse,
But my mom called me back inside.

Cubicles
========
The chains descended from the ceiling,
And fastened to the tops --
Of the cubicles.
The motors began slowly turning,
Then rising were the walls --
Like theatre curtains.
The workers stopped what they were doing,
And looked up from their desks --
To peer at themselves.
Then came some men who owned the building,
Too late to warn the folks --
Of their new plans.

Nashville and Seattle
=====================
What if Nashville was Seattle
And therefore, vice versa?
In the place of Mother Maybelle
Could be Ann and Nancy Wilson.

Then Little Jimmy Dickens
And Minnie Pearl, yes ma'am,
Would be Little Jimi Hendrix
And Minnie Pearl Jam.

We could hear Kurt Cobain
Or even Courtney Love
Sing "Blue Eyes Cryin' in the Rain"
Or "Wings of a Dove"

Wouldn't it make you feel alive
To see Shania Twain
Hockin' loogies between stage-dives
Apparently in pain?

Well, maybe not "alive" per se,
But it would be pretty rad,
Seeing Alice and Reba in chains
Switching cities, switching fads.

Fonts
=====
Arial is fairly boring,
And Courier's way too plain.
Modern is the same ol' story,
And frankly, Script is a pain.

Garamond comes off as haughty.
Sans Serif a tad too smooth.
Lucida strikes me as naughty,
And Roman a bit long in the tooth.

Symbol is symbolic of nothing.
Terminal should be put to rest.
Hardly better is Times New Roman,
And Wingdings is simply a mess!

In the end, the font doesn't matter.
You may choose whichever you like.
Whether one or another is better --
Counts far less than how well you write.

Long-Eared, Pickle-Toed Pirate
==============================
Wouldn't it be funny --
If my ears were long, like a bunny?
I'd tuck 'em up under my arm pits.
That wouldn't be gross, would it?

Wouldn't you be tickled --
If instead of toes I had pickles?
I'd clip off the nails and make relish.
Everyone would be so jealous.

Wouldn't it be a riot --
If my leg was a peg, like a pirate?
I'd buckle swashes, say "Aye" and grin,
And eat relish, and... um... listen?

Tony Gwynn
==========
Tony Gwynn's amazing,
But a little overweight.
It won't be getting past him
If it makes it 'cross his plate.

Rooms
=====
There are rooms to do your sleeping,
And rooms to take your bath,
Rooms to do your eating,
And rooms in which you laugh.

Most realtors show you common rooms
In the houses that they sell.
But an agent took me on a tour
I'll long remember well.

"Here's a room for your improvement,
And one for you to grow.
These rooms are not the kind you rent
They're rooms you come to know."

That's what the agent sang to me.
That's right, my realtor sings --
'Bout rooms that ain't so roomy,
But let you spread your wings!

Childbirth
==========
It won't be long for her.
It will all be over soon.
What now seems like November -
Will tomorrow seem like June.

What Is Is
==========
By the definition
In my deposition,
I have no recollection
Of a sexual relation.

I mean to be truthful
Without being helpful.
To admit that I'm a mouthful
Would be very, very harmful.

A Crappy Poem
=============
"Roses are blue,
Violets are red."
Er...no... that's not true.
Nevermind what I said.

"Stars in the morning,
Sunshine at night."
Now wait just a minute!
That can't be right.

"Ships on the prairie
Planes in the sea."
What am I saying?
What's happening to me?

"My eyes won't steady --
I feel like a nap."
Shut up, already.
Enough of this crap!

Seven Fools
===========
Seven separate fools considered their lot,
And in turn, each of them ruled,
"I know well enough to know I know not,"
"I'm content", as fools are, "to be fooled".

"Be wary of too-happy people", one claimed,
"And also avoid the too-sad",
"Try to eat well!" "Make beautiful things!"
"And be a good mother or dad."

Mr. Stroustrup
==============
An email, from Bjarne,
today I received.
"Thanks" was all that --
it said.

Ironic that he
should be thanking me.
I should thank him --
instead.