Back to Blog Home

Strut Your Stuff with Strut

Richard Huffaker image

Richard Huffaker -

Strut Your Stuff with Strut

The winner of last month’s Sentry Winter Hackweek 2017 (reminder: we know November is not in winter, but Autumn Hackweek doesn’t have quite the same ring to it and it was cold outside on the day we decided to name it) was Strut, the ultimate in office culture technology.

Who doesn’t want a theme song that plays whenever they arrive at work? Literally everyone wants this. Yet, for some reason, such a wonderful idea has previously only been successfully implemented in professional wrestling. Sentry co-founder / Head of Design Chris Jennings and highly skilled engineer / King of LinkedIn Matt Robenolt have fixed this oversight.

Strut brings entrance theme music to all, playing a short music clip — pulled randomly from a theme song playlist employees create using music from YouTube (Strut automatically downloads the song, converts it to mp3, and trims it to a set time the user selects) — as soon as you walk through the door.

Songs are added to a user's Strut playlist via a ridiculously perfect site. Here it is:

The Strut UI

Strut’s UI

Usually this kind of design would be way over-the-top. For Strut, it’s under-the-top if anything.

How does Strut work?

Strut leverages Google Cloud functions to handle events sent over from Lockitron (the app we use at Sentry to unlock the office door). When someone opens the door it sends off a webhook that hits a cloud function that validates the payload and says who the person was; we look that up in a database and broadcast that event over Google Pub/Sub where we can write consumers of that event stream in order to do stuff with the data, which in this case means playing an employee’s theme song.

The consumer that writes these events is written in Python. When a song is added by a user, it scrapes Youtube for whatever song that user selected, downloads it, sends it over to FFmpeg to strip the audio from the video, chops the audio down to the user’s chosen timeframe, and then stores it in Google Storage for future use. On every subsequent Lockitron door unlock, it just reads and plays the small five-to-whatever-second mp3 that’s left over.

The end result essentially works like this:

There were two keys that really helped this all come together:

  • We’re lucky that we use Lockitron to get into the building. Lockitron provides webhooks that we can hook into (classic webhooks right there), so when anyone unlocks the door this key information can be pushed to a place where we can utilize it to play music.

  • Using Google Pub/Sub was a pretty critical functional design decision. You can write anything that is consuming from Pub/Sub and anything that puts events in to Pub/Sub. So if you wanted to use another approach to handling events — like, say, pulling data from an RFID chip instead of Lockitron — it’ll work just fine so long as you can get the data into Pub/Sub.

Strut form for adding a song

The form for adding a song

The bigger scope here is that this has been structurally built in a way that is agnostic to Strut, which means that a wide variety of functionality can be driven off this same approach. Another of our Hackweek projects, Get Lit, used some of the same work put into Strut to create an LED board (run off an Arduino) that flashes an employee’s name when they walk through the door. Maybe you have some sort of Doc Brown style breakfast machine that can whip up an employee’s favorite breakfast and you’d like to see it activated when the door is unlocked. Or maybe you’d just like to know an employee arrived. Strut can do most of the work behind accomplishing both those things.

Strut is open source and completely functional, but, to be technical, the code is janky as hell because it was written during Hackweek. If you want to see how we implemented everything and play around with it yourself, take a look on GitHub and run wild.

Share

Share on Twitter
Share on Facebook
Share on HackerNews
Share on LinkedIn

Published

Sentry Sign Up CTA

Code breaks, fix it faster

Sign up for Sentry and monitor your application in minutes.

Try Sentry Free

Topics

Sentry

New product releases and exclusive demos

Listen to the Syntax Podcast

Of course we sponsor a developer podcast. Check it out on your favorite listening platform.

Listen To Syntax
    TwitterGitHubDribbbleLinkedinDiscord
© 2024 • Sentry is a registered Trademark of Functional Software, Inc.