I’m Joshua (or joshu, or @shu). I studied Geophysics, but now I work as an SRE. For fun, I read, make computers do math, go for hikes, and take pictures of things. Some of that makes its way onto here.

“Fearchar” should be pronounced FARE-uh-car, though pretty much everyone pronounces it FEAR-char.

command-line Google

Because I was bored today, and do such things when I’m bored, I came up with a command-line interface for Google in Python using Google’s web search JSON API.

Hafnia % google-search -n 1 "Google"
Google (http://www.google.com/):
 * Enables users to search the Web, Usenet, and images. Features include
   PageRank,   caching and translation of results, and an option to find similar
   pages.

Strangely enough, Google seems to leave bold tags (as well as an entity or two) in the “content” section of their search results on this API, so I ended up using lxml to parse the HTML into plain text, but other than that, google-search doesn’t use anything outside of the stdlib.

EDIT: I changed the script to use string modification so that lxml is no longer necessary. If I feel like it, I might put all of the text processing into something more suited for it …

Rather than pasting the source code here, I’ll just link to google-search on my website.

Japan earthquake data

After a big earthquake, I’m always tempted to pull some data from various sources and see what kind of graphs I can produce. My friend Charlie found the NOAA tide data by station, once again driving home the point that NOAA (and USGS, to a lesser extent) is great at collecting data but not that great about indexing it in a way that makes it easy to find by a casual user.

USGS, however, publishes a catalog of earthquakes in various formats; they offer a list of the last earthquakes >= 2.5 Mw in the last week: in Atom/RSS if you’d like to track it in a feedreader, or in CSV for more base crunching. I decided to use R for the more base crunching. But first, a little bash:

#!bash
curl -s 
"http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-M2.5.txt" 
   | grep -Ee '^(.*Japan|Src,)' | sed -En 
   -e '1,/05:46:23 UTC/ p' > ~/japan-earthquakes.csv

Then opened R, and ran:

earthquakes <- read.csv(file="~/japan-earthquakes.csv",head=TRUE,
    sep=",")
times <- strptime(earthquakes$Datetime,
    format="%A, %B %d, %Y %H:%M:%S UTC", tz="UTC")
times <- times - times[350]distances <- ((earthquakes$Lat -
    earthquakes$Lat[350]) ** 2 + (earthquakes$Lon - 
    earthquakes$Lon[294]) ** 2) ** 0.5

Having all of the data now compiled, we can do things like produce a histogram, demarcated at every 24 hours, of frequency with time:

Histogram of time

hist(times, freq=F, breaks=0:60 * 3600, col=heat.colors(24),
    main="Histogram of time", xlab="time (in seconds)", 
    ylab="frequency")

or a histogram of magnitude:

Histogram of magnitude

hist(earthquakes$Magnitude, freq=F, breaks=45:90/10,
   col=heat.colors(45), main="Histogram of earthquake magnitude", 
    xlab="magnitude (Mw)")

or a histogram of distances:

Histogram of distance

hist(distances,freq=F,breaks=0:50/10,col=heat.colors(50),
    xlab='distances (in degrees)',main='Histogram of distances')

On “Eskimos have [many] words for snow”:

From Pullum’s The Great Eskimo Vocabulary Hoax:

[When you encounter this hoax,] don't be a coward like me. Stand up and tell the speaker this: C.W. Schultz-Lorentzen's Dictionary of the West Greenlandic Eskimo Language (1927) gives just two possibly relevant roots: qanik, meaning 'snow in the air' or 'snowflake', and aput, meaning 'snow on the ground'. Then add that you would be interested to know if the speaker can cite any more.

This will not make you the most popular person in the room. It will have an effect roughly comparable to pouring fifty gallons of thick oatmeal into a harpsichord during a baroque recital. But it will strike a blow for truth, responsibility, and standards of evidence in linguistics.

Roasted garlic and black bean spread

If I keep doing these recipe posts, sooner or later I'm going to need to break out my camera and start documenting it along the way. What good is writing about food if you don't take pictures too?

In any case, on Saturday I decided to make some more of a black bean spread that I'd made a while back. I had a few minor improvements to try out: I'd used olive oil the first time, but the flavor of extra virgin olive oil was way too strong and overpowered the beans.

The first step, naturally, was cooking up some black beans. Or, I guess, if you have canned black beans, opening up a can. I cooked the ones I made for a little longer than I would usually so that they'd be a little mushier and mix better in the blender. For this recipe, I wanted about a cup of cooked black beans, so I started with a half cup of dry black beans and two cups of water. I threw in some epazote (to relieve the gassy aspects of beans – or so I've been told) and tossed the beans a little in some oil in the dutch oven first (not really sure why I did that – usually if I’m making black beans for eating, I fry an onion in there first, so I guess it’s just force of habit).

I checked on the beans regularly, and when I was satisfied that they were done to a good consistency, I threw them into some tupperware to cool while I roasted three cloves of garlic in the broiler. If you haven't done it before, it's dead simple: wrap the whole cloves of garlic in aluminum foil and throw them in the broiler. Take them out when they're soft and a little mushy. I chopped them up into chunks (again, to aid the blending process) and threw them in the blender with the beans, some salt, and about a quarter cup of vegetable oil.

I didn't blend them too finely. Not because I like some texture in my spread, though I may claim that in the future, but rather because I'm impatient and turning the blender on, turning the blender off, poking at the beans that didn't get blended, turning the blender back on again, etc., is a long and tedious process. However, it was delicious.

Торт Медовик (Russian Honey Cake)

To ring in the new year, I decided to make a recipe that I’d been wanting to try out for ages, but had never had enough courage to try. This particular recipe is for Торт Медовик, or Russian Honey Cake, and the only recipe I could find was in Russian. My Russian’s sketchy at best, but after being run through a machine translator, it’s surprisingly comprehensible. To save everyone the confusion of a machine-translated, recipe, I’ll just provide a link to the original recipe and then post my translation (and general thoughts on the recipe).

Tort Medovik

Ingredients:

Cake Dough:

Custard:

Directions

Preheat your oven to 350 °F (180 °C).

In a double boiler, heat the butter/margarine and stir in the sugar and honey, stirring until smooth. Add in the baking powder and continue stirring; once the baking powder is mixed in, remove the mixture from heat and allow it to cool.

After the mixture has cooled, mix two eggs in a separate bowl and then mix them in. Add the first three cups of flour in and stir to mix the dough; the last half cup will probably need to be kneaded in by hand. If you need a little more flour to keep it from sticking to your hands, go for it; it’ll make the next steps easier.

The recipe says to divide the dough into 6-8 pieces, though 5 worked fine for me. Then flatten each piece of dough onto a greased baking sheet and bake for 6–12 minutes. My method was to stagger baking the dough: after 6 minutes with the first one in the oven, I’d put the second one in, and so forth. This worked relatively well and allowed me to only use two baking sheets.

If you’d like to have a more uniform cake, I’d recommend taking a cake pan and using it as a guide to cut off the edges of these pieces. If you do this, do it right after they come out of the oven: they’re soft then, but they get kind of brittle as they cool and don’t soften until they’ve been soaked with the custard.

For the custard, put the enormous mass of softened butter (seriously, we’re talking in like, Paula Deen quantities here) in a bowl and blend it with an electric mixer. Pour in the condensed milk slowly so that it doesn’t splatter all over the place, and then add lemon juice to taste. If you like the custard without lemon juice, more power to you: that’s how the original recipe is written … but personally it was a little too simple and sweet for me when made that way.

After the custard is made, interlayer the cake pieces with custard and frost the top (and edges) with some custard as well. Take the broken pieces from the edges that you trimmed/broke off and crumble them up, and top with the crumbs and walnuts, if you’d like (I didn’t). Put it in the fridge for a while and let the custard soak in a bit to soften the layers, and you’re done!

Personally, I’m a little wary about making a recipe with this much butter a second time, because I kind of like my arteries to permit some flow through them. I was thinking about trying it again but with the custard replaced with whipped egg whites or a cream-cheese based frosting, but I’m not sure how well it would work in terms of soaking into the pastry. If I give that a go, I’ll post the results on here.

Oh, and happy new year!