Automatically Unshortening Links in WordPress Posts


On this site, I have the Broken Links Checker Plugin chugging away in the background. He tirelessly checks and rechecks every link in every post to find URLs that no longer work; pages sometimes just disappear.

In most cases, I’m able to use the Internet Archive Wayback Machine to find archived snapshots of the long-gone links so that the context of my writing archive remains preserved.

I also recently imported all of my old Twitter posts from the past years into my Microblog. Quite a few of those tweets contain links I shared.

At some point, Twitter started automatically shortening links to go through their service. Link shortening has become somewhat commonplace. Lots of companies exist to provide link shortening services (ex.; one of their value propositions is that they provide interesting analytics about the kinds of sites people visit.

Others have written about the problems with link shorteners.

A primary concern is that link shortening creates a single point of failure on the web; this is the antithesis of the way the Internet is supposed to work. If any one of these shortening services goes down, then suddenly those short links point to nothing, effectively breaking the web. This is a real issue; it actually happens.

Furthermore, if the unshortened link goes away, then the short link obfuscates the original source, making archiving nearly impossible.

Brett Terpstra’s StretchLink is an invaluable tool that watches your clipboard for shortened links to expand in the background. However, manually going through the thousands of back posts on my blog to unshorten links by copying and pasting seems a bit obsessive and not really worth my time. Automatic cross-posting happens using IFTTT, and I don’t want to have to “fix” posts that are inbound from Twitter.

So I quickly hacked some code to automatically unshorten links in my posts. It uses a code snippet I found by Jonathon Hill and Gruber’s URL matching regex.

I noticed that the unshortened links tended to have analytics-enabling “UTM” parameters, so I strip those out as well.

A next step would be to somehow “bake” the older links using the Wayback Machine or via downloading snapshots so that they remain in an unchanged format.

Just add this code to the functions.php of your WordPress theme and you’re on your way to abandoning shortened links whenever you save or update a post.

Rebooting my Blog for 2015

Journal / Meta

I have had moments where I’ve made sweeping, public declarations of reboots and fresh starts. These pronouncements have ranged from triumphant to cringe-inducing. This is one of those posts.

Existential crises keep me up at night, and If I’m to be honest, have probably haunted me for at least a decade now. They reach a boiling point, and suddenly it’s time for blog reset… as if writing out loud would make things manifest in a more certain direction. Magical thinking.

Don’t get me wrong… I enjoy some privilege… you know, water and electricity (not to mention amazing partner and genuinely exciting opportunities all around).

There’s just a nagging sense of creative stagnation. A little version of me sitting on my shoulder tugging my earlobe, “ok, but you’re not quite there yet…. And it’s now or never, chief.”

I know I’m not the only one that feels like this sometimes, and yes, there’s probably a lesson somewhere about contentedness and happiness and mindfulness I should investigate. I’ll put that on the list.

For now, I’m installing WordPress plugins and restoring past blog posts.

Read More

Week Notes 1831-1835 – Major Projects LEGO & Silos


Trying to catch up on a month of very intense activity is a really daunting task. I have a (small) breather before Thanksgiving, so figured it’d be good to squeeze this out before the real end-of-semester crunch begins. I’ve been keeping pretty detailed time logs, though, showing what’s been going on every day (indeed, every minute) these past months; these are coming in handy as I reflect.

So here we go. An attempt to recap and summarize briefly the last month or so.

Read More

Week Notes 1830 – Short Week


This is a short blog post for a short week, last week. It was a bit of a recharge / reset week; when people have been asking me, lately, “how are things going?” I noticed I’ve been responding with rather draining, “they’re going fast” and “can you believe it’s already October.” That’s a pretty large red flag, I think. The “woe is me” rhetoric doesn’t really do justice the things which are exciting to me.

For example, I met with Ethan Zuckerman, my mentor/coach for the Data Centric Project class I am taking to help craft a data story about the Ethiopia tablet project. Here’s a snippet of a follow up email I sent about what we discussed re: general scope of data:

We have too much data. It may likely hold lots of compelling answers, but I haven’t asked even basic questions, yet.

There is still a bit of work to do on gathering up data, logistically — it exists across a few different servers in multiple formats. It’s not normalized and much of the data is noisy/dirty (won’t try to solve that yet).

…and about the research questions:

Ultimately, I am trying to tell the story of how tablets get used by kids (and possibly their families) and see if usage patterns emerge in an instructive way. As a beginning question, I’m going to look at the “who, what, when” for one tablet. I hope to visualize the “usage trajectory” over the course of a week for a tablet — when was the screen on and off and then what apps were open over the course of the timeline.

Next, I will attempt to associate users, via photos, on this timeline.

I hope a pattern of usage will appear, but multiple tablets will need to be investigated to see if there are some generalizations we can start to build (or unexpected, novel usage patterns)

If usage patterns appear, I will see if these can be grouped or generalized by “category” or “nature” of interaction. (unclear what how this might actually manifest… the hope is that I can review a brand new set of data from a tablet and “fit” it to a usage pattern I’ve seen before) — This baseline will be valuable, especially if we hope to scaffold or direct learning activity in any interesting way

I will look at how usage patterns change over time for a given tablet (ex. do users start their use by “sampling apps” and then hone in on single apps?)

I’m also excited about starting to formulate some interesting project ideas for ‘side’ work.

New ideas are awesome, but as the “do-acracy” of the lab (and, let’s face it, the world) dictates, ideas are much, much less respected than actually shipping projects; I have a few things in motion, now, so really want to put down the fiinishing strokes.

There is an event that happens every semester at the Media Lab where members (i.e. “sponsors”) of the lab come to visit and see the current work of students. There is some lore around these events as crunch times — people are pushed to desparately make something new.

I, however, kind of wanted the stretch goal. I wanted to force myself to make something crazy, in a hurry, for this largely artificial deadline. So I’m, a bit secretly, working on a small project for me to present to satisfy this urge.

A very dangerous devleopment: I discovered I can get cable tv delivered to my computer while in the lab. Yay for watching football, boo for productivity.

An equally dangerous discovery: I have a newfound love of soup dumplings (Xioa Long Bao). I had them twice last week. If this keeps up, I’ll turn into a dumpling!

Week Notes 1828/1829 – Two Types of Media Lab Presentations


It’s already October and well into the semester. Deadlines for adjusting course schedules have passed. Project deadlines are coming up and whatever passes for “routine” around here is taking over.

I think this is all best characterized by something Laura (another new student) said to me earlier today, “We’re pretty much done with the ‘settling in’ time.” Indeed, I’m not going to get any more settled than this. It’s now squarely time for disruptive thinking and making. Read More

Week Notes 1827 – Bad Week for Art


I’m falling into a few old patterns of not being able to apply a good filter on things I want to be working on. This is especially problematic at a place where opportunities come really fast and constantly. How do you say no to awesome, shiny bobbles that are in high supply at MIT?

I used to really be disappointed that Media Lab people rarely showed up at Dorkbot-Boston events. I’m beginning to understand why. There is just too much to do here & it’s hard to break away!

One amazing thing MIT offers is an Art Loan Program where items from the MIT collection are available for students to take home or to their offices. There’s a lottery system, though, and a few weeks ago, Lauren and I picked out 3 great pieces and crossed our fingers. Sadly, we weren’t selected, so no art for us.

I also half-way participated in art hack day – boston this past weekend. The organizers were friendly and helpful; they arranged for great food and did their best to provide a comfortable hacking environment. They went out of their way to connect teams with resources needed to complete their projects, and the end result was a set of wonderful ideas. Read More