|
|
|
July 15th, 2008
02:12 pm - Lolcats mystery phone number On Saturday I went with gleemie, Matt, and others to a screening of Nerdcore 4 Life. This is a courageous and hard-hitting documentary about the genre of nerdcore rap. Afterwards there was cake.*
On a telephone pole outside of the Roxie was a flyer that read:LOLCATS: responds to cheeseburger Attached were little tear-off strips with a phone number:

The number remained a mystery for several days. Who had left it? Why was it in an Iowa area code? What dark and terrible message would it reveal? (For a day I was convinced that it was a trap set up catch lolcats fanboys.)
I could tell you the message that is at the number, but it's not that exciting. The mystery is more important.
*There was not actually cake. **There WAS an afterparty with MC Lars, Nomad, Dr. Popular, and CK.
|
July 9th, 2008
02:01 am - Alaska and Canada Pictures Most of my good Alaska and Canada pics are up on Flickr now, so I'll start reposting them here with stories.

This is Mt. McKinley (a.k.a. Mt. Denali) as taken from a 9-seater twin-engine prop plane at 12000 feet. At 20320 feet, McKinley is the highest mountain in North America. We got close enough to the mountain to see the base camps at 7000 and 11000 ft, and a line of tiny climbers moving up a glacier, dragging sleds behind them.

This is a serious, chew-your-face-off grizzly bear in Denali Park. Doesn't it look soft and cuddly? I encourage you all to go out and hug a bear today! Don't listen to the signs that warn you to stay 300 yards away. This one was asleep. When our busdriver told us to speak only in whispers, the hard-of-hearing man behind Geoff shouted, "What's that? Say, it's a bear!"
|
July 6th, 2008
02:35 pm - Marin Headlands The culture shock of returning from Denali was so intense that I went hiking yesterday in the Marin Headlands.
This time I made it up to Hill 88, then all the way back down to the beach to watch the surfers.


|
July 4th, 2008
02:22 am - Yukon Ho! I made it safely back from my two-week trip to Canada and Alaska!
Photos will trickle out slowly (I took 2470 photos, about 6gb worth), but here is one to whet your appetite:

That's Geoff hunting moose on the plains of Alaska. A naturalist told us that moose like bananas, so the next step was obvious.
|
June 15th, 2008
08:16 pm - Hacking MUSHes It's a little-known fact that l33t hackers don't attack military computers or wrangle botnets. They find and exploit privilege escalation vulnerabilities in text-based online role-playing games. That is why I am a l33t hacker.
( Learn how to hack a MUSH )
How do I protect my code?
- Sanitize your input. Any input is a possible vector for malicious data. Buffer overflows, corrupt data formats, man-in-the-middle attacks, etc.
- Read Larry Osterman's series on threat modeling. This is the process Microsoft uses to try to combat these problems. This isn't just a problem for MUSHes.
- Escape your output. Embedding input in commands leads to SQL injection. Embedding input in your output leads to XSS attacks.
- MUSH administrators: disable the
[set()] command. This limits attacks to read-only/information disclosure.
|
June 11th, 2008
11:00 pm - Adventures in Python I've been writing in Python for the last couple weeks to make use of the Google App Engine. I have a couple of questions for you l33t Python hax0rs out there:
1. append() vs. pop()
What bright-eyes named these functions?
array = [1, 2, 3]
array.append(4) # add to end
array.pop() # remove from end
Was push() a reserved keyword already? Would it have been too easy to remember? Too consistent maybe? I know naming is hard, but come on.
"6. Use opposites precisely. For every Open(), there should be a Close(); for every Insert(), a Delete(); for every Start(), a Stop()." 2. Multi-line lambdas
Lambdas allow you to define anonymous functions with lexical closures. They're very convenient, assuming all your code fits on one line!
# Simple sort using lambda
array = [1, 3, 2]
array.sort(lambda a,b: cmp(a,b))
# More complex sort; must use a locally defined function
# because lambdas can only be one line long.
def complexFn(a,b):
if foo(a, b):
return -1
elif bar(a, b):
return 1
return 0
array.sort(complexFn);
I can't help but think that Python shot itself in the foot syntactically here. From PEP 3099: Things that will Not Change in Python 3000:"Adding support for statements...would require allowing multi-line lambda expressions, which would mean a multi-line expression could suddenly exist. That would allow for multi-line arguments to function calls, for instance. That is just plain ugly." Because Python relies on indentation to define lexical blocks, multiline lambdas don't look right. However, in my defense, it's not my fault Python decided to make whitespace significant. After all, I wonder how Javascript and Ruby get around this restriction... oh right, braces!
>>> from __future__ import braces
File "", line 1
SyntaxError: not a chance
Oh. Well, there goes that solution that works for everyone else. Thanks, Python!
|
June 8th, 2008
02:15 am - Port of Redwood City I had no idea that there was a massive metal scrapyard in Redwood City. If you go east on Seaport from 101, towards the emerald city of green glass office parks, you'll pass on your left a massive scrap refinery. Big-rigs hauling flattened cars pulled up every couple of minutes while I was there.

|
May 25th, 2008
01:59 am - Lake Lagunita Lake Lagunita is much prettier when there is actually water in it.
I spent three years living across the street in Flo Mo, so I'm very fond of the lake. How many times did we walk around the edge, debating the afterlife? How many times did we stand in the middle and sing songs from the Phantom of the Opera? How many bonfires did we throw at the firepit, drinking Drambuie flamers and singing Monty Python's 'Philosophers Song'? Good times!
Campus makes me nostalgic, but it also reminds me that I'm glad I got out of there even partially sane. I say, let the pirates have it.

|
May 11th, 2008
11:37 pm - Castles I've always been fascinated with castles. David Macauley's Castle is one of the first books I can remember. They were a gateway drug that led me into King Arthur and his Knights, fantasy, D&D, Chaucer and Mallory.
I've been to Heidelberg, Edinburgh, Neuschwanstein, Hohenschwangau, and Himeji. I've sighted down gun-barrels from the Portuguese fort atop Macao. I've been to the McNaughton family castle on the shore of Loch Fyne, and visited the Campbell castle next door that dominates it. I love them all.
The United States, because we are so young, for the most part sadly lacks in castles. That's why I am attracted to the Marin Headlands. Along the tops of the cliffs overlooking the Golden Gate are a network of WWI and WWII naval fortifications. Most have been abandoned since the mid-1940's and are now in ruins, overtaken by graffiti.


P.S. The astute reader might deduce that my father being a military historian may have had some role in this.
P.P.S. Graffiti in San Francisco is a treat. One picture shows "All Your Base" scrawled on a plank in a spotting tower. Another wall read "Kill all the heteros".
|
April 21st, 2008
12:30 am - jQuery - Fixing DatePicker to work with SimpleModal and BlockUI
There are three popular plugins for making modal dialogs in jQuery. All of them have similar functionality: clicking on a link greys out the page and overlays it with a dialog. While the dialog is showing, you can't click on any other links.
Unfortunately when trying to use SimpleModal, I ran into a problem with DatePicker. The calendar popup keeps falling behind the dialog:
SimpleModal

BlockUI

Thickbox

As you can see, Thickbox is the only one that works correctly. Everywhere else, the calendar falls behind the translucent div/iframe and is not clickable.
The problem is that the overlay divs have incompatible z-indices. DatePicker has a z-index of 199, and SimpleModal has a z-index of 3100 - too high! Thickbox only works because it also has a z-index of 199, a number that was chosen specifically to work with DatePicker.
Luckily the fix is simple. Open datePicker.css and locate the following code:
div#dp-popup {
position: absolute;
z-index: 199;
}
To work with SimpleModal, change the z-index to:
z-index: 3300;
Voila! DatePicker now works everywhere.
SimpleModal

Unfortunately I don't see this problem going away anytime soon. Because many interesting jQuery components utilize overlays, and because z-indices are chosen haphazardly, compatibility appears to occur primarily by serendipity.
|
April 1st, 2008
08:14 pm - March is Mustache Month Big congratulations to all the competitors in Homestead's "March is Mustache Month". You showed the world that by working together and following our dreams, we can grow mustaches.

(I'm on the third row from the bottom, far right.)
|
01:21 am - HDR and Claude Monet While HDR-processing pictures from the Tea Gardens, I noticed that some of them are almost hard to look at. For instance, I challenge you to count the number of trees in this photo! (Click the image for full size.) Something about the saturated colors and lack of contrast makes everything seem to buzz.

This reminded me of an article from several years ago about Da Vinci and Monet's visual tricks:

"Contrary to our perception of the scene, the Sun is in fact no more luminous than the sombre sky it is set in, Livingstone said. Our visual system has two pathways: colour and luminance; due to the 'disconnect' between the two, in the colour version the Sun is only interpreted as a type of brilliance.
So when the neurologist took a black and white photo of the Monet painting, the Sun disappeared in the sky, merging into its greyness - demonstrating that the Sun is of exactly the same brightness as the sky surrounding it."
I like to think that I'm abusing the same bugs in visual cognition that the Impressionist masters did.
|
March 31st, 2008
11:57 pm - Japanese Tea Garden, San Francisco These pictures come courtesy of doublefeh, who suggested that we go out on a photography expedition to SF last weekend.
We used it as a chance to swap cameras (Canon D20 for Nikon 40D), walk around the Japanese gardens, and explore Golden Gate park. One hill (dubbed meta-hill, though apparently it has a name) is a giant hill in the middle of a lake, which in turn has a smaller lake at the top. One imagines that this lake itself has a tiny little hill in the middle with ants taking HDR photos.


Also see doublefeh's Flickr stream for more pics.
|
March 22nd, 2008
11:26 pm - Venice Beach, Half Moon Bay Photos from Venice Beach, Half Moon Bay. Polarized filter + polarized sunglasses = trippy view through the viewfinder.


And a couple that look like they should be backgrounds for an inspirational calendar of tacky religious poems:

|
March 21st, 2008
10:59 pm - The Benefits of Consistency As a developer at Homestead I spend a lot of time doing code reviews. In that role it is my job to be a nit-picky, pedantic, literal-minded sunnovabitch. It's somewhere between being an art critic and an a**hole crossword puzzle editor.
One of the issues that triggers big red warning flags whenever I see it is inconsistent code. Inconsistent code indicates a lack of well-ordered thought and/or attention to detail, both of which are killers for developers.
Totally Made-Up Example
Consider the following totally made-up example:
CFoo foo(10);
foo.CalcNumber(OPERATION_ONE, s_kOperationTwo);
CFoo myFoo( 11 );
myFoo.CalcNumber( OPERATION_ONE, s_kOperationTwo );
if(foo.getNum() >100)
{
cout<< "Really big!";
}
else if ( foo.getNum()>50 ) {
cout<< "Big";
} else
cout << "Small...";
What Is Wrong With This?
In theory, nothing. The results might be exactly correct. However, reading it is like listening to fingernails scrape a chalkboard. Pity the programmer who has to maintain ten thousand lines of this!
- Why do only some method have spaces inside the parens?
- Why is it 'foo' and then 'myFoo'? Should all variables start with 'my'?
- Why are some constants in all caps and some camel-case?
- Why do some methods start upper-case and some lower-case?
- Why abbreviate 'Number' to 'Num' in only some methods?
- Why is spacing different around math operations?
- Why is there a blank line in the first block?
- Why is spacing different around cout<<?
- Why are braces inconsistent in different blocks?
Now let's fix it up a little:
CFoo foo(10);
CFoo foo2(11);
foo.CalculateNumber(OPERATION_ONE, OPERATION_TWO);
foo2.CalculateNumber(OPERATION_ONE, OPERATION_TWO);
if (foo.GetNumber() > 100)
{
cout << "Really big!";
}
else if (foo.GetNumber() > 50)
{
cout << "Big.";
}
else
{
cout << "Small.";
}
How Can I Help?
Consistent code is all about reducing cognitive load and increasing readability. Similar things should look similar, different things should look different. This makes it easy to scan the code and see important differences.
Here are some things you can do to improve your code consistency:
- Publish and follow a set of coding conventions.
- Use consistent names for methods and variables. If you are going to use an abbreviation, use it everywhere.
- Use consistent terms for opposing verbs or adjectives (e.g., enabled/disabled, active/inactive, add/remove, open/close, true/false). Don't use Header/Bottom, use Header/Footer.
- Have a consistent comment format. This is especially powerful when combined with automated tools for generating documentation (doxygen, Javadoc, etc.).
- Use consistent coding idioms. Do you always use iterators to loop? Do so throughout your code.
- Implement peer code review and use it as a way to enforce consistency.
- Read McConnell's Code Complete, which covers this topic in more detail and with numbers to back it up.
These steps are just the beginning. As you can imagine, there are many layers of consistency: code layout, class hierarchy, file naming, directory structure, error handling, memory handling, use of STL, etc., etc. All are valuable.
Good luck and good coding!
Edit: Apparently I am not the only person thinking about this recently. Read The P.G. Wodehouse Method Of Refactoring (print out your code on paper and see if it looks wrong) and associated Slashdot comments.
|
March 18th, 2008
12:08 am - Santa Teresa Park The second half of my haunting this weekend was south of San Jose. These pictures are from Santa Teresa Park, south of the city by the confluence of Highway 85 and 101. The park is only open until sunset, which is a shame because I would love to take night photos from here.


(That's San Jose there on the right... all of it.)
|
March 17th, 2008
12:33 am - San Francisco I drove up to the Marin Headlands this weekend to take a few photos.


I got caught in a rainstorm halfway back across the bridge. There's no cover out there other than hiding behind a pylon. After drying off, I drove up to the headlands, where I darn near froze stiff in the wind.
Moral of the story? Time lapse photography takes time! Bring gloves.
|
January 22nd, 2008
04:22 pm - Something doesn't seem quite right Agile developers sometime talk about 'code smells'. This is a piece of code that, at first glance, just doesn't seem right. It isn't necessarily incorrect (hacks sometimes exist for good reasons), but it's usually a good indicator that you should nose around.
So I ask: does this snippet smell right to you?
</tr>
</table>
</xsl:if>
</td>
</tr>
</table>
</xsl:if>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
(Full disclosure: I have written much the same code in the past, if not worse.)
|
January 7th, 2008
02:50 pm - High Dynamic Time Range (HDTR)
"...for us physicists believe the separation between past, present, and future is only an illusion, although a convincing one." - Einstein Following up on my post about time visualization, I found out that this technique has a name: High Dynamic Time Range (HDTR).

Though the name is somewhat of a marketing ploy (riding the coattails of HDR/High Dynamic Range), the concepts are similar. Whereas HDR is a technique for compositing multiple photos to capture a wide range of light, HDTR uses multiple photos to capture a wide range of time.
An HDR image is the result of two operations: HDR + tone-mapping. The composite HDR image can't be shown directly on your monitor (which, luckily, isn't bright enough to accurately display the sun). Tone-mapping picks the best-exposed part of each image and stitches them together into something your screen can display.
Similarly, HDTR can also be broken into two parts: HDTR + time-mapping. The composite HDTR image is the entire photo stack, with values for each pixel at each time index. This can't be displayed directly on your screen because of the "convincing illusion" of linear time (you have to play it like a movie). Time-mapping picks a time index to use for each pixel in the final image.
Where the HDTR author breaks down is that he has limited himself only to 2-dimensional time gradients, and he hasn't tried to do 3-dimensional time surfaces yet. I assume that's coming though.
Now that I have all my time-lapse gear (timer, tripod, etc.), I hope to start working on TimeComposite again soon.
|
January 5th, 2008
12:42 pm - California Storms We've had two days straight of rain and lightning. Thunder is echoing up the Ralston valley as I type this. Power was out all yesterday both at home and at work, so we took refuge at a friend's apartment and played Halo 3 (the modern version of sitting around a fireplace?). Many trees have been blown down and many roads are flooded out, including the freeways.
I posted a couple of photos on Facebook:



Also, a Canon Intervalometer arrived in the mail today. It's for time-lapse photography!
|
|
|