Run, Forrest! Run! - Tweet #runforrestrun to make Forrest Gump run another mile. | Product Hunt Embed

Run, Forrest! Run!

Ruby | Ruby on Rails | Heroku | Javascript | CSS | HTML | PostgreSQL | Twitter API | Mapbox API | WebSockets | Sidekiq Scheduler | Bootstrap

In 1979, Forrest Gump started running. 3 years, 2 months, 14 days, 16 hours, and 13,089 miles later he said he was tired... and went home.

forrest gump running gif as reporter asks 'why are you doing this?'
forrest gump smiling and waving wearing a singlet

I wanted to see how long it would take Forrest (and the Internet) to do it again. So I built a Rails app where every time #runforrestrun is Tweeted, Forrest runs one mile across America.

Forrest runs between the 9 known locations from the movie. The GeoJSON route was calculated using the Mapbox Directions API, which generated thousands of latitude-longitude coordinates following the roads.

forrest gump running gif as reporter asks 'why are you doing this?'
map from forrestgump.live showing forrest gump marker in nebraska

However, the API wouldn't calculate a route this long. So I wrote a function combining several API calls and mapped the coordinates to the, well, map using Javascript.

A scheduled Sidekiq background task calls the Twitter API every 24-seconds (maximising Twitter's 150 API calls/hour limit) to search for new Tweets using #runforrestrun.

tweet from forrestgump.live showing someone using #runforrestrun while playing world of warcraft
forrest gump marker saying i just felt like running in a speech bubble

When a new Tweet is found, the Forrest Gump marker moves 1 mile, the map zooms into the new location, and a random Forrest Gump quote appears in a pop-up.

map from forrestgump.live showing forrest gump marker in nebraska

Using WebSockets and Javascript, the new Tweets are dynamically pushed to the top of the DOM and the mile remaining counter is updated.

Tweet(s) are stored in a PostgreSQL database and the most recent 50 Tweets are displayed in a custom card. Hash tags, mentions, and links are all clickable.

The site has been optimised for mobile using the Bootstrap grid. You know, for those on the go!

map from forrestgump.live showing forrest gump marker in nebraska