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.

Standard
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:

lakes-summary

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.

Standard
Programming

Automatically set window titles in GNU screen

Although GNU screen is actually a window manager, I mainly use it to turn nano into a tabbed text editor. If you do something similar, you might be interested in the way that I automatically set each window’s title to the filename that I’m editing (and reset it back to a default value when I exit the editor).

Make two additions to your .bashrc:

nano () { echo -ne "\ek${1##*/}\e\\"; /usr/bin/nano "$1"; }

This modifies the nano command to set the window title to the filename that’s being edited, sans any leading directories, before opening the file with the real nano. (If your true nano isn’t in /usr/bin/, make the appropriate substitution.)

export PROMPT_COMMAND='echo -ne "\ekbash\e\\"'

This has the effect of resetting the title to “bash” after nano exits, because the prompt has to be printed. (Note that it will reset any custom titles you set manually. There’s probably a better way to reset the title when a program exits, but this has worked for me.)

These two changes allow me to effectively use screen as a tabbed terminal text editor and see at a glance which files I have open in which “tabs.”

Standard
Christmas

Our 2013 Christmas Letter

Another year, another single sheet of paper summing it up. Let’s get this over with.

In January, we went on a weeklong trip to Hawaii. I know what you’re thinking — “Hawaii in January? Soooo clich√©!” I know, but our place in St. Bart’s was getting its ceilings re-gilded.

In February, we refinanced our mortgage again. It’s a pretty interesting story really, much too long to fit in this letter, but we got a great rate reduction under the terms of the HARP program, reducing our yearly interest rate from 5.5% down to WAIT WAIT DON’T STOP READING I’LL STOP TALKING ABOUT MORTGAGES.

Christina left her job at GE in March to pursue other opportunities, like not working. Unfortunately, it turns out that being at home with the kids all day does not fit the definition of “not working.”

We found out this year that Gideon is allergic to dogs, our cat Sancho, dairy, eggs, and peanut butter, so we made the tough decision to give him up for adoption. We can’t have someone like that cramping our style!

At the end of April, Christina’s dad unexpectedly passed away in part due to esophageal cancer. No jokes in this paragraph; we miss Doug.

The month of May saw us pack up our car and take a 3,000 mile road trip through the Appalachian mountains and the Cotton Belt. We did see some Appalachian mountains but, sadly, no cotton belts.

Gabriel participated in a sports camp in July. Oh, did I say participated? I meant “participated.” j/k, LOL. He did have fun and is planning on doing a football camp in January. Hopefully next year’s letter will not mention any sort of youth concussion study.

(In case it was not clear, the “him” that we gave up for adoption four paragraphs ago was our cat Sancho, not our son Gideon. That would be ridiculous! Who could say goodbye to that cute widdle face?? Sancho’s widdle face, on the other hand, is very goodbye-sayable-to.)

In August, we didn’t have a baby.

In September, we did have a baby! (Well, Christina had a baby. But I helped!) Gloria Abigail Finke missed an August birthday by four hours (and her due date by two weeks), and I don’t think we could have waited any longer. (We literally could not have waited any longer; the doctors wouldn’t have let us.)

By November, Gloria had had enough of us and needed a vacation, so she flew to Oregon to visit her best friend Jackson. Christina tagged along and visited her friend Leah, who happens to live in the same state, city, neighborhood, and house as Jackson. WHAT ARE THE ODDS

Christina is teaching Gabriel to read, but I like to think that we’re all learning a little something. Well, except Gloria. And Gideon. And me. And maybe Christina. So just Gabriel then.

Until next year’s letter,

The Finke Family

Standard
AOL, Plugins, Programming, WordPress

Import your chat transcripts into WordPress

Problem: You have years’ worth of chat (AIM/MSN/Adium/IRC) transcripts saved on your computer, and you’d love to stroll down memory lane and reread some of them, but how? Manually open each one in your browser or chat program?? There’s got to be a better way!

Solution: Install IM-porter, the WordPress plugin that imports your instant message transcripts to your WordPress blog so you can read through conversations from ages past just as easily as you browse the archives of a blog.

After activating the plugin, visit Tools > Import > Chat Transcripts. Then, you can upload a single transcript or a ZIP of transcripts.

IM-porter currently supports transcripts from:

  • AOL Instant Messenger
  • MSN Messenger
  • Adium
  • Colloquy

but you can extend it to parse other formats too. (See the README.)

Imported posts are given the chat post format, and you have the option of tagging them with the participants’ usernames, making them public or private, and adding them to a category.

The IM-porter configuration screen.

After they’re imported, chats will look something like this:

A chat imported by IM-porter

The output may not be perfect (the output will not be perfect), but the original raw transcript is saved as post meta so the post can be updated if you want or fixed by a later version of IM-porter.

If you want to style your chats like AIM used to display them (like in the screenshot I included), you can use this CSS:

.post.format-chat .entry-content p {
	margin-bottom: 0 !important;
}

.post.format-chat .entry-content span {
	color: #00f;
	font-weight: bold;
}

.post.format-chat .entry-content span.participant-1 {
	color: #f00;
}

.post.format-chat .entry-content span time {
	font-size: x-small;
}

Standard
Facebook, Programming, WordPress

Export your Facebook posts to WordPress

I’m a big proponent of owning the data that you create. I use WordPress (of course) wherever I blog, and I use the Keyring Social Importers plugin to make backup copies of my Twitter updates and Foursquare checkins. And as of today, I am also syncing my Facebook updates back to a private WordPress blog using Keyring Social Importers.

Not familiar with Keyring Social Importers? That’s too bad, it’s amazing. Install it, and within minutes, you can be importing data from any one of a dozen sites to your blog. Remember all of that data you put into Myspace/Jaiku/Bebo/Pownce and how it disappeared when the site shut down? Wouldn’t it have been nice to be able to save a copy of all of that? That’s what Keyring Social Importers makes possible.

There’s no built-in Facebook importer in Keyring Social Importers, so I wrote one. You can use it to save copies of your Facebook photos, photo albums, and status updates to an easy-to-browse (and easy to share) WordPress blog.

To use the Facebook importer, install Keyring Social Importers, copy the keyring-importer-facebook.php file into wp-content/plugins/keyring-social-importers/importers/, and then visit Import > Facebook to get started. Let me know what you think.

Note: I’ve only tested the importer on my own account, so it’s possible that it won’t be perfect. All imported data is set to private, just to be safe. Patches and bug reports are welcome.

Standard
Software

Convert iChat transcripts to (useable) XML

iChat (a.k.a. Messages) doesn’t store its chat logs in a format that can be (easily) parsed outside of iChat, so if you want to use your chat data for anything, you’ll need to convert those logs to something better. (Anything would be better. Even AIM’s <FONT>-ridden HTML 3 is more useful than iChat’s binary plists.)

One suggestion I found that came close was to convert the binary plist to XML so that the XML could be parsed with the tool of your choosing:

$ plutil -convert xml1 example.chat

However, the XML generated by that command doesn’t include enough information to reliably determine which participant sent each message. (Or if it does, it doesn’t make it obvious enough that I would dedicate time to writing a parser.)

After trying every other promising script and program, here is the only thing that worked:

  1. Install Adium.
  2. Use Adium’s File > Import to import all of your iChat transcripts.
  3. After it finishes, look in ~/Library/Application Support/Adium 2.0/Users/Default/Logs/ and voila! Folders full of XML chat logs with data you can actually use. The file extension is .chatlog, but the content is sensible XML.

This process worked for me to convert 5,000 transcripts created by iChat between 2007 and 2013, and I used Adium 1.5.8.

Standard
Programming

Websites shouldn’t close at 10pm

HealthCare.gov is getting a lot of flack for being inaccessible and just generally bad, so I thought I’d check if Minnesota’s state insurance exchange website is any better. I learned this:

And once the website is up and running, it won’t offer 24/7 service. Instead, it will operate from 6 a.m. to 10 p.m. Monday through Saturday, officials said. There will be no Sunday hours.

MNsure spokesman John Reich said the website’s limited hours won’t be permanent.

“The initial hours are so that we can continually update and improve the user experience and add new features,” he said in an email.

(via TwinCities.com)

I can understand (but don’t agree with the idea of) having some planned downtime when you deploy major new changes (like, maybe an hour), but shutting down every night at 10? That’s especially bad for a website targeted towards people who might be working two jobs and don’t get a chance to visit the site until they get off work late at night. They’re out of luck.


Shameless plug: At Automattic, we continually update and improve the user experience and add new features to products like WordPress.com as often as fifty times per day without making the site unavailable 43% of the time.

(If that sounds good to you, come work with us.)

Standard