3D Printing

I saved a pair of sunglasses with a 3D printer

My sister-in-law’s sunglasses lost an accent from one of the earpieces, leaving the left temple loose. Could I fix this?, she asked. Twenty minutes and 63 millimeters of plastic filament later, my purchase of an Orion Delta 3D printer was 100% validated.


The accent on the print bed.


The accent installed.


With the temple opened.


And the other side, with the original accent, for comparison. I later painted the printed accent gold with some nail polish, and you could hardly tell the difference between the two.

If you happen to have this same pair of sunglasses, and your pair has also lost one or more of its accents, you can download the 3D models and print a replacement yourself.

PHP, Programming

Quick and Dirty Command Line PHP

I do 99% of my programming in PHP, and when I’m on the command line, I would rather use the PHP functions I know than look up the Bash functions I don’t, so I wrote this PHP script and saved it in my $PATH as an executable file named p.

#!/usr/bin/env php

		array_slice( $argv, 2 )

This way, if I want to quickly get the length of a string, I can type:

$ p strlen paraskavedekatriaphobia

and get


instead of looking up that I could have done:

$ foo=paraskavedekatriaphobia && echo ${#foo}

(or apparently a dozen other methods of finding the length of a string in Bash).

It even works with Bash variables:

$ foo=acbdef
$ p strlen $foo

Thanks to all the time this script has saved me, I was able to write this post!

Life, Minnesota, Woodworking

My Minneapolis Table Has Found a Forever Home

Backstory: Last year, I built a table that resembles the downtown skyline of Minneapolis.

Minneapolis Table

I didn’t intend to keep it after I finished building it, so I contacted a few local organizations to see if they’d be interested in accepting it as a donation. I’m happy to announce that the Minneapolis table has found a home at the Minneapolis Institute of Arts, a fine-arts museum in Minneapolis.

Minneapolis Institute of Arts

Here I am making the furniture delivery on a Monday in June:

Donating the Minneapolis Table

The museum employees that I spoke to when I dropped it off said they planned to use it in their retail store to display work by local artists, and when I visited the museum yesterday for the first time since then, I found it after just a few minutes of browsing the gift shop:

Minneapolis Table in the Minneapolis Institute of Arts Retail Store

I imagine this is how parents feel when their child moves out and gets a job, no longer needing their support. I’ll never forget you, Minneapolis table; don’t forget to call me on Christmas and my birthday.

Life, Programming

Data Mining My Family Tree

One of my hobbies is researching my family tree; I enjoy learning about where I’ve come from as well as reading about how my relatives lived in centuries past. I was recently fortunate enough to come into possession of a 200-page family history written in the late 1970s, and after I finished reading and digitizing it, I wanted to see what data and trends I could extract from my now 2,500-person-strong family tree, so I started writing a collection of PHP scripts aimed at reading and manipulating GEDCOM files. (GEDCOM is the defacto standard for digital family tree files, and it is used by essentially all family tree software.) The scripts are open source and available via Github in my PHP GEDCOM Tools repository.

I downloaded my family tree from Ancestry.com in GEDCOM format and got started. First things first: I generated a second GEDCOM file containing only the people that are related to me by blood. This isn’t strictly necessary, but I prefer to limit the results to my genetic relatives.

./export-related.php --gedcom=Everyone.ged --person='Christopher Finke' --out=Related.ged

After I had a tree with all in-laws removed, I started with something simple: gender breakdown.

./gender-counts.php --gedcom=Related.ged

Gender breakdown chart

53/47% male/female split. Not that interesting, and possibly skewed by incomplete data. How about something more personal, like name choices?

./name-histogram.php --gedcom=Related.ged --histogram=cloud-raw

Given Name Word Cloud

(The image was generated by pasting the command output into the tool at http://timc.idv.tw/wordcloud/)

That’s kind of neat. Women are outnumbered, but they teamed up to make “Mary” the most common given name. “John” and “William” were close behind. “Melvin” brought up the rear.

Does my family line favor any of the months for giving birth?

./date-histogram.php --gedcom=Related.ged --type=BIRT --specificity=month --histogram=counts

(This and other charts were generated by pasting the command output into a Google Docs spreadsheet and using that data to create the image).

Births by month

September and July have little (baby) bumps, but births are pretty uniform across the board. The same chart for deaths is a little more interesting though.

./date-histogram.php --gedcom=Related.ged --type=DEAT --specificity=month --histogram=counts

Deaths by month

A little more variation — deaths seem to be less common in the summer months, but no month really takes more than its fair share of lives. September has the best net gain for life, since it produced lots of babies and the fewest deaths. You go, September!

How about marriage? Is June really the most popular month for weddings, as is often assumed?

./date-histogram.php --gedcom=Related.ged --type=MARR --specificity=month --histogram=counts

Marriages by month

Well, yeah.

How old are those lovebirds when they tie the knot?

./age-histogram.php --gedcom=Related.ged --type=MARR --histogram=counts

Marriages by age

Across my entire recorded family history, the most common time to get married has been between the ages of 20 and 25; the median marriage age is 23.

How many children do those married couples end up having?

./child-count-histogram.php --gedcom=Related.ged --histogram=counts

Number of children per family

There’s a steep dropoff after the fourth child, and I’m not surprised. As Jim Gaffigan said, “If you want to know what it’s like to have a fourth, just imagine you’re drowning, and then someone hands you a baby.”

Death comes to all, but when??

./death-age-stats-over-time.php --gedcom=Related.ged --timeframe=decade

Death age over time

You can see that over the last 50 years, my family’s median and average age at death has been slowly rising. That’s good news for me, right? (Early numbers are pretty jumpy due to a lower sample size and frequent stillbirths.)

How did these people die? Does any cause of death stand out?

./death-note-histogram.php --gedcom=Related.ged --histogram=cloud-raw

Most causes of deaths weren’t known or mentioned, but for those that were, cancer was at the top of the list.

Cause of death word cloud

Where were my ancestors born? Can I see my family spread across the country as sons and daughters move away and start their own families?

./place-progression.php --gedcom=Related.ged --type=BIRT --out=birth-places.gif --key=[Google API key] --icon=[URL of icon mask] --start_year=1860

Birth places

I can! You can literally see my family spread like an outbreak of measles. (Note that this GIF begins in the year 1860 when my ancestors first began arriving from Europe.)

If you want to investigate your own family tree, grab a copy of the scripts and see for yourself. If you have ideas for any other interesting stats that could be gleaned from family trees, leave them in the comments and I’ll add some more scripts to the repository.

HTML, JavaScript, Photography, PHP, Programming

Turn your iPhoto library into a Web photo album

iPhoto is good for managing and organizing photos and photo metadata, but it’s not easy to get that information back out if you want to share more than a few photos. I recently finished scanning 13,000 family photos and importing them into iPhoto, and I wanted to be able to share all of those photos (complete with the faces I spent hours tagging) with my brothers and sisters.

I could just burn copies of the iPhoto library to discs, but not all of my siblings have Macs, and iPhoto may not be around for very long. I needed a way to export all of the photos and metadata in a format that I felt comfortable would be supported for a long time: the Web.

The result was a PHP script that exports an iPhoto library into folders of image files (one folder per event), generates JSON arrays of event and photo metadata, and builds a minimalist JavaScript-powered website that provides a simple photo viewing experience. The website can be put online, or it can be run entirely offline (like from a DVD, which is my plan for sharing with my family members). The code is all open source (https://github.com/cfinke/iPhoto-Disc-Export) and the usage instructions are in the README.

Here’s a screenshot of the main page of the website it generates:


And here’s an example of a single photo’s page:

I know it’s a pretty niche project, but hopefully it will come in handy for anyone looking to make their iPhoto library more shareable and accessible, especially as Apple drops support for iPhoto in the near future.

iPhoto Disc Export

Facebook, Themes, Twitter, WordPress

Keyring River: A new WordPress theme to complement Keyring Social Importers

It’s no secret that I use Keyring and Keyring Social Importers to import my activity on third-party services into a WordPress blog. All of my Facebook posts and photos, Twitter updates, foursquare checkins, and Reddit comments and submissions are archived in a single location; this makes it simple to see a snapshot of my online life at any point in time. I’ve even imported my IM chat transcripts from over a decade ago.

I’ve long been searching for the perfect WordPress theme to showcase all of this data. Typical blog themes didn’t work because each “post” needed different styling based on the service it came from, so it was unlikely that I was going to find what I needed already built for me.

But then, I came across an effort by David Hariri to build a non-WordPress lifestreaming product called River. While I’m already committed to using WordPress, his frontend design was exactly what I had been looking for. Luckily, David’s project is open source and MIT-licensed, so I was able to use his design and adapt it to a WordPress theme. With that, I present Keyring River:


Keyring River is a new WordPress theme coded specifically to complement Keyring Social Importers. It’s feature-poor and purposefully so; there are no sidebars, no footers, no menus, no comments — just a search box and a list of activity. For maximum enjoyment, install Jetpack and activate the Infinite Scroll module so that you can scroll infinitely into your online history. See it in action on my example lifestream blog, where I’ve imported my Twitter and Reddit history.

The timestamp on each entry links to the single-item view in WordPress, and the logo links to the item on the service it was originally posted on. Amuse yourself by scrolling back a couple of years, finding an interesting Facebook post, and reviving discussion on it!

Keyring River currently supports posts imported by the following plugins:

…and of course, regular WordPress posts.

Download Keyring River from Github, and let me know if you put it into practice. Taking ownership of your data is important, and more importantly, it’s fun!

Plugins, Programming, Reddit, WordPress

Import your Reddit activity into WordPress

I try to maintain a copy of all of my social media activity in a single WordPress-powered archive. Twitter, Facebook, foursquare, Reddit, Usenet, chat logs: all searchable in one place via a single search box. Or, I can just scroll back in time, using Jetpack’s Infinite Scroll module. It’s heavenly.

Screen Shot 2014-01-17 at 12.09.02 AM

To import my activity from third-party services, I use Keyring Social Importers. Keyring Social Importers ships with support for a handful of services, but not Reddit, so I’ve written a WordPress plugin that adds support for importing comments and submissions from Reddit.

The plugin (“Reddit for Keyring”) is available at Github. (Make sure you install Keyring and Keyring Social Importers first.) After installing it, use it like any of the other Keyring Social Importers. Submissions (both link and text) and comments will be imported and saved as posts.

Let me know if you use it; bug reports are welcome in the comments below or in the Github project.

Life, Minnesota, Programming

Does Minnesota really have more shoreline than California?

There’s a popular piece of trivia that says that Minnesota, ostensibly due to 10,000+ lakes, has more shoreline than California. Sometimes, the ante is upped and Minnesota is claimed to have more shoreline than California, Florida, and Hawaii combined. Other times, it’s simply “Minnesota has more than 90,000 miles of shoreline.”

Shoreline of Lake Superior

According to Explore Minnesota Tourism, who used the “more shoreline than California” line in a 2011 television ad, it’s a “commonly-used statistic that was researched and compiled at least 20 years ago by a former advertising agency.” But despite how ubiquitous the factoid has become [1], there’s no definitive proof that it’s true. So: does Minnesota have more shoreline than California? Let’s find out.

Minnesota Shoreline

First, let’s determine the total shoreline in Minnesota. There is no official source for the shoreline of each lake, so we’ll have to get creative. In 1968, the Minnesota Conservation Department published a report titled “An Inventory of Minnesota Lakes” (warning: 498 page PDF). This report included a summary of lakes by size:


We can use this as a starting point. Lake shorelines are irregular, and the further they deviate from being circular, the more shoreline there is for a given area. But if we assume each lake is a perfect circle, then we can calculate the minimum possible lake shoreline in the state:

Minimum Lake Size, in Acres Minimum Lake Size, in Square Feet Number of Lakes Minimum Circumference of Each Lake, in Feet Minimum shoreline length for this set of lakes, in feet
10 435,600 4,482 2,339 10,486,262
25 1,089,000 3,728 3,699 13,790,968
50 2,178,000 1,892 5,231 9,898,172
75 3,267,000 1,167 6,407 7,477,395
100 4,356,000 765 7,398 5,659,920
125 5,445,000 546 8,271 4,516,442
150 6,534,000 689 9,061 6,243,293
200 8,712,000 1,262 10,463 13,204,538
500 21,780,000 400 16,543 6,617,498
1,000 43,560,000 225 23,396 5,264,187
2,500 108,900,000 63 36,992 2,330,555
5,000 217,800,000 62 52,315 3,243,587
Total Shoreline, in feet 88,732,822
Total Shoreline, in miles 16,805

16,800 miles is the minimum possible shoreline, given lakes of those sizes.

If we had the exact acreage of each lake, we could get a better estimate. Fortunately, that same 1968 report also contains the acreage of each lake! Unfortunately, it’s a PDF of a typewritten document from 45 years ago, and OCR efforts to digitize the table failed. Fortunately, the good folks at the Minnesota DNR provided me with a CSV containing the name of every lake in Minnesota and its last-surveyed acreage! Thanks, DNR! (The spreadsheet with lake sizes is available here.)

Now that we know the exact surface area of each lake, we can do the same “perfect circle” calculations and find that the newest minimum shoreline length is 22,384 miles.

We’re getting closer, but it would be great to not have to rely on the crutch of assuming circular lakes. Isn’t there some way that we can get access to lake dimensions? It’s our lucky day, because the spreadsheet provided by the DNR actually included shoreline measurements. When I said there was no official source for the shoreline of each lake, I fooled you!

According to the DNR, Minnesota has 44,926 miles of lakeshore. (Spreadsheet with data here.) That’s a lot of shoreline, but is it more than California’s?

California Shoreline

I’ve been unable to find a California DNR resource as helpful as Minnesota’s, so we’ll have to take another approach. Where else can we get geographical data about lakes? OpenStreetMap to the rescue!

OpenStreetMap is like Wikipedia for maps, and a service called Geofabrik provides downloads of OpenStreetMap data on a state-by-state basis. (Here’s Minnesota.) The download is an XML file containing all of the information needed to map a given state. Fortunately, we can use a tool called osmfilter to filter the XML file and give us a much smaller file with just the water features.

I wrote a program to parse that file and measure the shoreline of each lake. When I ran my program on the Minnesota data and compared the results to the DNR-supplied data, I found it was off by about 10%:

DNR Shoreline Results compared to OpenStreetMap Shoreline Results
DNR OpenStreetMap
Minnesota 44,926 miles 49,759 miles

It’s mainly because OpenStreetMap includes the entire boundary of some lakes that are only partially in Minnesota.  If I took some time, I could weed those out, but I’m satisfied that this data is close enough for my purposes.

California has 3,427 miles of ocean shoreline as (generously) calculated by NOAA [2], and according to OpenStreetMap, it has an additional 32,050 miles of lakeshore. That’s a total of 35,477 miles of ocean and lake shoreline.

California Shoreline vs. Minnesota Shoreline
Ocean Lakes Total
California 3,427 32,050 35,477
Minnesota 0 44,926 44,926

So yes, Minnesota does have more shoreline than California.

Raising the Stakes

Can Minnesota beat California and Hawaii? Hawaii is practically all shoreline, but because it is so small, it only has 1,052 miles of ocean shoreline [3] and 229 miles of lakeshore. Add that to California’s total, and even at 36,758 miles, it still doesn’t top Minnesota.

California and Hawaii Shoreline vs. Minnesota Shoreline
Ocean Lakes Total
California 3,427 32,050 35,477
Hawaii 1,052 229 1,281
CA + HI 4,479 32,279 36,758
Minnesota 0 44,926 44,926

So yes, Minnesota does have more shoreline than California and Hawaii combined.

Let’s add Florida to the mix. Florida has 8,436 miles of ocean shoreline [4], and according to OpenStreetMap, it has another 22,236 miles of lakeshore. That’s a lot of shoreline, and it increases the tri-state total to 67,430 miles, more than Minnesota.

California, Florida, and Hawaii Shoreline vs. Minnesota Shoreline
Ocean Lakes Total
California 3,427 32,050 35,477
Hawaii 1,052 229 1,281
Florida 8,436 22,236 30,672
CA + HI + FL 12,915 54,515 67,430
Minnesota 0 44,926 44,926

So no, Minnesota does not have more shoreline than California, Hawaii, and Florida combined.

Or does it? We’ve only been considering lakes and oceans, but Minnesota has an additional 69,200 miles of natural rivers and streams [5], both of which have shoreline on each side. That’s an extra 138,400 miles of shoreline, giving Minnesota a grand total of 183,326 miles of shoreline. That’s a lot of shoreline!

Rivers and Streams

According to Wikipedia, Hawaii has about 360 streams [6], the longest of which is 28 miles. Even if we assume they are all 28 miles, that gives Hawaii an additional 10,080 miles of shoreline. (I know it’s bad form to cite Wikipedia, but I think we can agree it’s good enough for this case. And look at that advantage I’m giving Hawaii!)

The Florida Public Service Commission states that Florida has “11,000 miles of rivers, streams & waterways.” [7]

California, according to the California Department of Fish and Wildlife, has 29,664 miles of streams and rivers. [8].

California, Hawaii, and Florida Shoreline vs. Minnesota Shoreline, including Rivers
Ocean Lakes Rivers Total
California 3,427 32,050 59,328 94,805
Hawaii 1,052 229 20,160 21,441
Florida 8,436 22,236 22,000 52,672
CA + HI + FL 12,915 54,515 101,488 168,918
Minnesota 0 44,926 138,400 183,326

California, Hawaii, and Florida combine for an additional 101,488 miles or river shoreline, bringing their grand total to 168,918 miles, which, if you recall, is less than Minnesota’s total of 183,326 miles.

So yes, Minnesota DOES have more shoreline than California, Hawaii, and Florida combined, but only if you consider rivers and streams.