06.28.10

Sunrise/Sunset Onebox

Posted in astronomy, personal, web at 6:45 pm by danvk

If you try searching for [sunrise san francisco] on Google, you’ll see a special display in the results:

This is known as a “onebox”. It’s designed to get you answers quickly. Other examples include the calculator (e.g. [2*2]), weather ([weather 94110]) and time ([time italy]) oneboxes.

The sunrise/sunset onebox is a project that I worked on in my spare time and recently launched. You can read more about it on the Official Google Blog. I first had the idea for this onebox about two years ago, so it’s very gratifying to see it finally launch!

A few features which are worth calling out:

  • The sunrise and sunset times are calculated when you perform your query. They are a function of latitude, longitude and the current time. The algorithm is based on the one used by NOAA.
  • In most places, you can just search for [sunrise] or [sunset] to get results for your current location. Google figures this out based on your IP.
  • This onebox works on mobile phones, too, so you can search for sunset times when you’re out on a hike.

There’s a wrinkle to the sunrise/sunset calculation that non-astronomers don’t typically think about. The sun starts to behave strangely once you get north of the arctic circle or south of the antarctic circle. If you’re north of the arctic circle, then there will be at least one day during the summer when the site never sets. And there will be at least one day during the winter when it never rises. This is truly a special case for the onebox! Here’s what it looks like:

I feel bad for those Barrowans — hopefully they’ll be able to fall asleep sometime in the next 34 days!

03.22.10

Introducing lmnowave

Posted in programming at 12:02 am by danvk

logoLast Winter, a dear friend of mine moved from San Francisco to Brooklyn. With an entire continent between us, my principal crossword puzzle buddy and I looked in vain to the internet for help. Was there truly no good way to do a crossword together online?

The New York Times offered an applet, but it proved to be finicky and would only let us do the most recent day’s puzzle. A friend’s project offered hope, but only led to “Service Temporarily Unavailable”.

Enter: lmnowave!

lmnowave is a crossword puzzle gadget for Google Wave. To do a crossword puzzle with a friend, you’ll both need Google Wave Accounts.

Once you’ve got that taken care of, click this big link to get going:

lmnowave installer

You should see something like this:

lmnowave installer

Click the “Install Icon” and create a new wave. You’ll see a crossword puzzle icon in your toolbar:

puzzle icon

Click it to add a crossword gadget. It should look like this:

load screen

If you’re using Chrome or Safari, you may get a warning about not being able to upload puzzle files. This is fine — just switch to Firefox for a minute or try one of the built-in Onion puzzles.

If you have a .puz file on your computer (perhaps from your times subscription), drag it onto the big lmnowave icon:

dragging a puz file

The puzzle will load instantly. Now drag a friend into the wave:

Adding a friend

and you’re ready to compete or collaborate as you see fit! Each player gets his or her own color, so you can keep track of who’s filled in each square:

partially-solved puzzle

lmnowave is an open-source project written entirely in JavaScript. If you’d like to contribute, check it out on github. Run into a bug or have a feature request? Let me know here.

12.30.09

Books I Read in 2009

Posted in books, personal at 10:00 am by danvk

As part of my 2009 year-in-review, I tried to make a list of all the books I’d read. Give it a shot for yourself, this is hard to do! I can remember what I’ve read in the last few months, but my memory starts to fade as I get towards summer. I found a few books from the start of the year via Amazon receipts and library records, but I’m sure there are many I missed.

Here’s the list, with a few thoughts about each.

oracle-bonesOracle Bones, Peter Hessler
A follow-up to River Town, this book chronicles Hessler’s time in China as a journalist. Both books offer a great impression of life in China, though this one started to drag on a bit towards the end. Highlights: his discussion of the alphabetization of Chinese and his interactions with Polat, the Uighur trader who wants to emigrate to America.

betterBetter: A Surgeon’s Notes on Performance, Atul Gawande
This book fits neatly in the “find six interesting stories and give them a catchy one-word title” genre pioneered by books like Freakonomics. But the stories here are very interesting! And the thesis is, too. In medicine (and presumably elsewhere), there are huge gains to made through non-technological means. Apgar scores reduced child mortality by making it easier to test the efficacy of treatments and changing perceptions about which babies could live. Changed expectations and the sharing of case histories had dramatic effects on the life expectancy of Cystic Fibrosis patients.

Guns, Germs, Steel, Jered Diamond
My thoughts on why this is a really bad book are documented in another blog post.

botanyThe Botany of Desire, Michael Pollan
As always, Michael Pollan treads that fine line between greatness and wishy-washiness. The Omnivore’s Dilemma was great. In Defense of Food was not. This book is somewhere in between. At least Michael Pollan is always honest, a welcome change after reading Jered Diamond. His researches into Johnny Appleseed were particularly fun to read. I’d never thought about this historical figure.

copernicusThe Book Nobody Read, Owen Gingerich
After reading Koestler describe Copernicus’s De Revolutionibus as “the book that nobody read”, Gingerich sets out to find every extant copy and document the marginalia — evidence of who read the book and what they thought. Part of what makes this book fun is just what a quintessential academic Gingerich is. The one thing lacking is any discussion of where Copernicus got his ideas from. This book also implicitly makes a strong argument for digitizing books: think how easy his quest would have been if he’d had search!

The watershed; a biography of Johannes Kepler, Arthur Koestler
A 250-page excerpt from the book with which Gingerich took issue. I’d always though of Kepler as the first astronomer who really “got it”. His three laws cleared away millenia of intellectual baggage. If nothing else, this book rid me of that delusion. Kepler is a really frustrating figure. He is spectacularly modern in some senses, but frustratingly medieval in others. He certainly did not consider the three laws for which we remember him his most significant contribution to science. Koestler clearly has an agenda, but I didn’t find it too distracting.

scourgeScourge: The Once and Future Threat of Smallpox, Jonathon Tucker
A really fun read. The eradication of smallpox was one of the most significant technological feats of the 20th century, and yet I’d never heard/read anything about it before. There are many great stories in the final steps towards eradication. I learned a lot about disease and pathogens from this book.

parisParis from the Ground Up, James H. S. McGregor
I read this on the way to Paris. It gave me a great sense of the city: where things were, what the significant sights were, why they were significant, etc. It follows a bizarre chronological cross thematic progression as you read which I found confusing at first, but ultimately enjoyed. If you’re going to Paris and want to have to have some context for what you’ll be seeing, this is a great book to read!

crowded-universeThe Crowded Universe: The Search for Living Planets, Alan Boss
This book chronicles the hunt for extra-solar planets between 1998 and 2008, a time during which this area exploded. It reads like a blog, with dated entries any time something interesting occurred. I wrote the author and suggested he start a blog, but he didn’t want to lose the potential revenue from another book ten years from now. NASA does not come across well in this book. The trials and tribulations of what became the Kepler Mission span the whole time frame.

asset-allocatorThe Intelligent Asset Allocator, William Bernstein
This is really close to the ideal personal finance book that I’d like to read. Whereas A Random Walk Down Wall Street explains why you should index, this book talks about how you should allocate assets between bonds, stocks, real estate, etc. It’s not particularly prescriptive — it won’t say “you should be 75% stocks and 25% bonds” — but at least it gives a good background on the issues involved. Basic upshot: some diversification is always a good idea.

long-emergencyThe Long Emergency, James Kunstler
This book is bad, bad, bad. Kunstler’s argument is that our society is so deeply dependent on oil that, once we run out, the effects will be completely catastrophic. Large swaths of the United States will become uninhabitable. Much of modern agriculture is dependent on fossil fuel-based fertilizers, so billions of people will starve to death as earth’s carrying capacity plummets. Kunstler loves laying out doom and gloom scenarios. The problem is that he can’t be bothered to explain why they’re inevitable. There are zero charts or tables in this book, and his dismissal of technological solutions as cornucopianism is infuriating. See my thoughts on Guns, Germs, Steel for what it’s like to read a non-fiction book where you feel actively mislead.

12.26.09

Crossword Word Frequency

Posted in math, programming at 10:45 am by danvk

In a previous post, I discussed downloading several years’ worth of New York Times Crosswords and categorizing them by day of week. Now, some analysis!

Here were the most common words over the last 12 years, along with the percentage of puzzles in which they occurred:

Percentage Word Length
6.218% ERA 3
5.703% AREA 4
5.413% ERE 3
5.055% ELI 3
4.854% ONE 3
4.585% ALE 3
4.496% ORE 3
4.361% ERIE 4
4.339% ALOE 4
4.317% ETA 3
4.317% ALI 3
4.227% OLE 3
4.205% ARE 3
4.138% ESS 3
4.138% EDEN 4
4.138% ATE 3
4.048% IRE 3
4.048% ARIA 4
4.004% ANTE 4
3.936% ESE 3
3.936% ENE 3
3.914% ADO 3
3.869% ELSE 4
3.825% NEE 3
3.758% ACE 3

(you can click column headings to sort.)

So “ERA” appears, on average, in about 23 puzzles per year. How about if we break this down by day of week? Follow me past the fold…


Read the rest of this entry »

12.04.09

A new view on Minard’s Napoleon

Posted in web at 5:29 pm by danvk

Charles Minard’s chart of the demise of Napoleon’s Grand Armée is famous for its “brutal eloquence”. Edward Tufte says it “may well be the best statistical graphic ever drawn”.

Minard-small

The width of the line represents the size of Napoleon’s army as it marched to Moscow and then retreated.

I found a version of this visualization put on a Google Map using protovis. This visualization is great! It draws attention to one of the main problems with this famous visualization: it doesn’t give any geographical context. I had no idea where Napoleon’s army started and turned around until I saw this map:

grand-armee

Some things that stand out:

  • The Grand Armée was way far away from France at the start of this.
  • The march wasn’t as long as I’d imagined. When I think “march across Russia”, the image in my mind goes halfway across Siberia.

11.05.09

How long is a day?

Posted in astronomy, math at 5:39 pm by danvk

As we approach the winter solstice, the days get shorter and shorter. There’s a common misconception about how quickly this change happens. Most people know that:

  1. The summer solstice (June 21) is the longest day of the year.
  2. The winter solstice (December 21) is the shortest day of the year.
  3. The days get shorter between Summer and Winter.
  4. The days get longer between Winter and Summer.

Many people take these four pieces of information and assume that the day length changes like this over the course of the year:

(The x-axis is the date. The y-axis is length of the day in hours.)

This is consistent with the four pieces of information, but is incorrect! There aren’t many sharp edges like that in Physics. Reality is much smoother:

The length of the day slowly increases as we approach the summer solstice, then slowly decreases as we leave it. This is great — it means that there are lots of long days in the summer. As we get to the autumnal equinox, the rate of change hits a maximum. The same thing happens around the winter solstice, only in reverse.

The summer solstice is the longest day of the year, but not by much! Here’s some day lengths for San Francisco:

Date Day Length Difference
Jun 18, 2009 14h 46m 45s + 09s
Jun 19, 2009 14h 46m 51s + 06s
Jun 20, 2009 14h 46m 54s + 02s
Jun 21, 2009 14h 46m 54s < 1s
Jun 22, 2009 14h 46m 50s − 03s
Jun 23, 2009 14h 46m 43s − 06s
Jun 24, 2009 14h 46m 33s − 10s

The lengths of the days around the solstice differ by only a few seconds! On the other hand, here are some day lengths around the autumnal equinox (September 22):

Date Day Length Difference
Sep 19, 2009 12h 15m 35s − 2m 24s
Sep 20, 2009 12h 13m 10s − 2m 24s
Sep 21, 2009 12h 10m 46s − 2m 24s
Sep 22, 2009 12h 08m 21s − 2m 24s
Sep 23, 2009 12h 05m 56s − 2m 24s
Sep 24, 2009 12h 03m 32s − 2m 24s
Sep 25, 2009 12h 01m 07s − 2m 24s

The length of each day changes by several minutes in September. Over a single week the day gets a whole 15 minutes shorter!

note: the interactive graphs are dygraphs, a JS library I created. Check it out!

11.01.09

Healdsburg Half Marathon

Posted in personal, sports at 1:25 pm by danvk

I ran my first half marathon this weekend, the Healdsburg Half in scenic California wine country. The race was held on Halloween, and no small number of runners came in costume. This is a nice twist on the usual “what should I be for Halloween” dilemma. Instead, it’s “what should I be that I can sweat in for 13 miles?”

My first goal was to finish. My second goal was to finish in under two hours. And I did! Final time was 1:54:33.1 (they are apparently very precise about these things!)

A race like this is a field day for data junkies like me, especially when you jog with an iPhone app like RunKeeper. I had it going for the first 10 miles, before my phone ran out of batteries. Here’s the track and mile splits:

mi pace
1 9:40
2 9:43
3 8:54
4 8:21
5 8:57
6 9:10
7 8:57
8 8:40
9 8:21
10 8:20

I must have picked it up after that — my pace over the remaining non-iPhone miles was 8:14/mile.

Some more stats and thoughts on what to do differently next time:

  • My co-worker Jeremy suggested that a good goal for a first half marathon would be a “reverse split”: running the second half faster than the first. I did that, too! The first 6.6 miles took 61 minutes, so the second must have taken 53. I guess I should have run the first half faster!
  • I should have charged my iPhone the previous night! More important than recording a track, it let me know exactly how far I’d gone: “6.34 miles” instead of “a few minutes past that six mile marker”.
  • I should have brought a jacket with me to the start. The race started before dawn and it was very cold! They even transported stuff to the end of the race for the runners. Something to remember for next time.
  • Running with a friend is great and can be good motivation. I ran most of the race with my friend Erica, who shaved a full 20 minutes off her previous half marathon time!
  • Erica’s dentist (a former marathoner) told her that she should take a drink at every water station. This was good advice. The only drink station I skipped was the one serving wine samples!

The Healdsburg Half was very well-organized. They had full results (PDF) posted the day of the race. I finished 396/1438 overall, 234/496 amongst men and 40/76 amongst 25-29 men.

10.27.09

Guns, Germs, and Steel

Posted in reviews at 8:50 am by danvk

I recently picked up a copy of Jared Diamond’s Guns, Germs, and Steel, a self-described “short history about everyone for the last 13,000 years.” This book should have been right up my alley: it’s all about history, specifically early human history, which I don’t know much about.

Diamond’s goal is to explain why civilizations on the “Eurasian” continent developed to a much greater extent than they did in Africa, Australia or the Americas. Why did Europeans conquer the Americas and not the other way around? He wants to do this by looking for ultimate causes, not proximate ones like “Europeans had guns, while Americans didn’t.” He wants to explain this with environmental factors, not genetic ones. This seems like a nobel goal and an interesting subject for a book.

After about fifty pages, I was growing increasingly skeptical. He would make a point, present a very specious argument against it, then counter this argument. The old Straw man!

Then came the snippet that did this book in:

On the Chatham Islands, 500 miles east of New Zealand, centuries of independence came to a brutal end for the Moriori people in December 1835. On November 19 of that year, a ship carrying 500 Maori armed with guns, clubs, and axes arrived, followed on December 5 by a shipload of 400 more Maori. Groups of Maori began to walk through Moriori settlements, announcing that the Moriori were now their slaves, and killing those who objected…

Moriori and Maori history constitutes a brief, small-scale natural experiment that tests how environments affect human societies. Before you read a whole book examining environmental effects on a very large scale—effects on human societies around the world for the last 13,000 years—you might reasonably want assurance, from smaller tests, that such effects really are significant…

He’s holding this up as a small-scale example of how environmental factors can take two civilizations in different directions. The Maori (of New Zealand) and the Moriori (of the Chathams) were only separated around AD 1500. But by 1835, the Maori conquered the Moriori using disproportionate force! Diamond argues that they were able to do this because they were a stratified, agricultural society while the Moriori were loosely-organized hunter-gatherers. Such a short time-span! No western influences! Such a clean sociological experiment!

But this is incredibly misleading. The giveaway should have been “armed with guns”. The Maori did not develop guns independently. But I skimmed over this. The bit that did jump out at me was “November 19, 1835″ and “December 5″. How do we have such precise dates for an interaction between native peoples? It was enough to send me racing to the Wikipedia article on The Chathams.

Those 500 Maori came to the Chathams on a British whaling ship. They were armed with British guns. They were told of the existence of the Chathams by the sailors on the same whaling vessel. There are no hints of ultimate causes here. If the British had armed the Moriori instead, things would have turned out very differently.

I try to retain a healthy sense of skepticism when reading any non-fiction book that presents a thesis. But it stops being fun when you know that the author is willing to deliberately mislead.

I’m curious how this book won a Pulitzer Prize. Did any of the reviewers actually read it?

09.12.09

Morning Headlands Ride

Posted in personal, san francisco at 10:07 am by danvk

On my way in to work Friday morning, I took a detour via the Marin Headlands:

It was a total whiteout on the Golden Gate Bridge, but as soon as I got to the north bay, it cleared right up. I went back into the fog for the ~800 foot climb up Hawk Hill before breaking through and getting some amazing views from the top:

Top of the World

I saw a fighter plane zoom into the city, which made me briefly think that it was Fleet Week. Not so! (It’s in October.)

The ride down the back side was misty, beautiful and frighteningly slick. All in all, I left at 7:40 and got into work with a change of clothes right around 10.

One more view from the top:
View from Headlands

09.07.09

Character Palette Bookmarklet

Posted in web at 3:20 pm by danvk

The other day, I noticed that one of my friends had Wikipedia’s article on the em dash bookmarked in her toolbar. While that article is a gem of punctuation literature, it turned out that she would go to it, select an em dash, and copy/paste it into emails.

A better way to do this is with a bookmarklet. Drag this to your browser’s bookmark toolbar:

character palette

Click the bookmarklet on any page. You’ll see a character palette like this:

Screenshot

Select the character you like and either copy/paste it or drag it where you like. Then click “Close” to make the palette go away until you need it again. Enjoy!

Note: I’ve tested this in Firefox, Safari and Chrome. This probably doesn’t work in IE.

« Previous entries Next Page » Next Page »