Sunday, November 08, 2009

Google can render your equations for you!

In my last post I mentioned that Knol and Google Docs now have equation editing. What I didn't mention is that this is an undocumented feature of the public Google Chart api, and it's easy to use. For instance, if I wanted to include the Schrödinger equation on this blog. I would construct an url like this:,s,FFFFFF00&chco=AACCFF&chl=i\hbar\frac{\partial}{\partial t} \Psi(\mathbf{r},\,t) = \hat H \Psi(\mathbf{r},t)

Put your code in the chl parameter. The chf parameter lets you specify a background color in RGBA, chco lets you set the foreground color in RGB. When you drop it in inside of an image tag you get this:

If you anticipate making 250,000 calls to the chart server a day, contact Google first at There's no limit to how much you can use it, but they reserve the right to turn you off.

Thursday, October 01, 2009

Simple Simhashing, My favorite trick.

Knol got equation editing a few days ago, and to celebrate I've written up a knol on one of my favorite CS tricks, simhashing using sets. It's a technique I picked up at Google, and it's extremely useful for grouping together similar things in a large dataset.
Suppose you have a huge number of items that you would like to group together by a fuzzy notion of similarity. Suppose the only tool available to you is a key-value store. Suppose you only have the resources to consider each object once. Never fear, simhashing is here!

Saturday, May 30, 2009

Keep Your State Parks Open

Governor Schwarzenegger has proposed closing 80% of California state parks, including most of those in the Bay Area. This is estimated to save $143 million out of a $24 billion deficit, or half a percent. This strikes me as a very poor decision given the miniscule effect it would have on California's finances, and the large effect it would have on California's quality of life. Furthermore, it may end up costing the state more than it saves if it decreases tax revenues from tourism. Admittedly it's a tough decision to spend $143 million on parks rather than on health insurance for poor children, but ultimately $143 million is a drop in the bucket for the latter. To put this in perspective, $143 million is $4.35 per capita after removing the unemployed. I'd much prefer higher entry fees or taxes to outright closures, or he could parole ~3000 non-violent drug offenders instead.

This site makes it easy to contact your state representatives.

Closing these state parks means that gates would be padlocked, and parking and restrooms won't be available, though it will likely still be physically possible to enter. You can find a list of all 220 here. Here are a few of my photographs from the parks they are intending on closing.

Point Lobos

Big Basin

Prairie Creek Redwoods

Henry W. Coe

Sugarloaf Ridge

Pfeiffer Big Sur

Castle Rock

Moss Beach

Sunday, April 12, 2009

To those for whom I recommend games . . .

You have to try Braid.

It looks like Super Mario Brothers redone as a shimmering, moving, impressionist painting. It plays a little like Portal, but really unlike anything you've played before. The game explores the concept of time, how we perceive it, how it effects us. In each world, time operates in a different way, and there are maddening ingenious puzzles built out of the implications. Each puzzle teaches you something new about the logic internal to the world, and will make you think in a way you've never thought before. Once you've figured out a puzzle it doesn't require much more physical dexterity to complete than getting through the first few levels of Mario, but some puzzles may take hours of thought before you stumble upon the solution. As penny-arcade described it, epiphany is the central game mechanic.

The story is as impressionistic as the artwork, mostly told in snippets of text that accompany the entrance to each world. They relate the mechanics of time in that world to the ways in which we experience events in our lives. One section describes how returning to a place laden with memories can cause us to feel as if we are travelling in time, and not just space. In that world, time moves forward as you move to the right and backwards as you move to the left. The story and the art both get darker and more mysterious as the game progresses, with a baffling ending that will leave you reevaluating everything you've seen up til that point, probably for days afterwards.

If there was any debate that games are an art form as expressive as any other, Braid has settled it.

You can get the PC version from several sites, including Steam, or the Xbox version from Xbox Live Arcade. All are $15, and a free demo is available.

Monday, March 16, 2009

How to convince yourself to get rid of stuff (especially if you live in CA)

I helped some friends move into their new home over the weekend, and as always, moving became an opportunity to decide whether certain things were really worth moving. The broken grill that just needs an afternoon's woodworking to fix, the rusted recumbent bike bought with good intentions, the box full of leis and decorative sticks left over from a theme party, all become a little less benign when you have to load them into a truck and then figure out where they "go" in a new home. Some popular metrics for throwing it out: if you haven't used it in the last year, if you haven't used it since your last move, if you forgot you owned it. I hereby propose another metric particularly suited for those living in California: what it would cost you to get that space back by enlarging your dwelling.

First, figure out approximately what it would cost in dollars per square foot to increase your living space. From browsing Craig's List postings of comparable apartments, my current 400 square foot apartment could be upgraded at a rate of about $1.5 per square foot per month. Now compute the floorspace that the item consumes, multiply, and you have an approximation of the opportunity cost of that item in dollars per month. Translate this to years for added impact. To keep my new conga drums at 27" × 14" I'm giving up about $50 worth of floor space per year, which is a rate I'm comfortable with.

To compute this metric for stackable items such as books, divide this number by how deep the items are currently stacked in the way you are storing them, so as your bookshelf gets taller the storage of each book gets cheaper. It's cheating to compare it against the height of your ceiling directly. Add in the extra space wasted in storage. On my 3 layer bookshelf, the average 6" × 1" paperback stored vertically with 5" of wasted space in front of it is costing me $1.35 per year. That's more than I paid initially for some of these used paperbacks that I still haven't read after a few years of lugging them around. Out they go. If you are living with someone and they want you to throw something out, experiment with paying rent to them on it at the rate you get from this calculation.

Friday, February 06, 2009

Texture Targeting

I made it to the San Francisco Postmortem, a get-together for bay area game developers, for the first time last Tuesday. I finally got to meet the creators of Natural Selection as well as reconnect with some friends from college, Sam Hart and Chris DeLeon. The guys at Unknown Worlds are busy working on a sequel to Natural Selection on a shoestring budget with minimal staff, and they are doing an amazing job of doing things as efficiently as possible. The biggest bottleneck though for a modern game is the incredible quantity of art assets required to achieve the graphical standards gamers expect. I've been interested in texture synthesis since I took a graphics class in college, and decided this would be a good opportunity to experiment with it in the hopes that it could speed up creation of texture sets. I've started a texture synthesis project on Google Code, and there are two bare-bones utilities there that are ready to start playing with. The code is all based on techniques from Efros and Leung with a variety of experimental modifications of my own. The ultimate aim of this is to produce something akin to an "automated super clone tool" such that an artist can make a few textures for a theme in exacting detail, and then synthesize the rest from sketches using this software.

So far I haven't been able to get satisfying results for any non-stochastic textures, but that's my aim. With this technique there seems to be a dramatic trade-off between giving the artist any control at all over the resulting texture, and the amount of detail present in that texture. If anyone has an interesting results or ideas in that regard, drop me a line.

Monday, January 12, 2009

My first painting since Kindergarten!

From Portfolio
Mike Rotondo held an art party last Friday night, and I took the opportunity to learn to paint! I mysteriously remembered a lot of techniques either from watching my mom paint, the tips she's given me, or my art-history class in highschool. It's 16"×20", acrylic on canvas paper.