The @Square Tweetwriter
The story of a new inforad created during our last Hack Week.
Written by Scott Perry.
Each quarter, Square sets aside a full week for everyone in the company to build something they believe should exist in the world and transform ideas into working prototypes. Hack Week is an opportunity to create and innovate in the exact same way Square itself was formed: 3 people in a tiny room going after a big problem. Sometimes these ideas turn into new products; other projects serve as learning exercises. The @Square Tweetwriter project was somewhere in between.
Square’s office is littered with monitors that display various dashboards and metrics. We call them inforads (“information radiators”), and they display everything from transaction visualizations, to system health, to our @Square Twitter feed. We like inforads because they provide us with useful information and give us an opportunity to experiment with visualization technologies.
During a Hack Week earlier this year, I worked on an inforad called the Odominator, a mechanical counter designed to track our Gross Payment Volume. Since then our Twitter inforad started acting ornery, and the display was reappropriated for introducing new employees to the company. As our next Hack Week approached, I stumbled across a typewriter in my garage that I’d modified to work as a teletype, and a new Twitter inforad was born.
Creating a program to read Twitter data using the search API is straightforward with the help of Python and rauth, but I didn’t want to commit a machine to power a typewriter. Using a Raspberry Pi emerged as the best solution given both cost and availability. Combined with a USB wireless adapter, the Pi can do its job from inside the typewriter.
All that was left was connecting the two. The typewriter exports a USB interface (providing a serial port) which understands a certain character set that corresponds to the keyboard. This is more complicated than just transmitting ASCII because typewriters (being optimized for writing and not for computing) have keys for characters like §, ¶, ½ and ¼ while lacking the ability to print curly braces or a caret. The Python script replaces all unrecognized characters with question marks, and rate-limits its serial traffic to 0.1s per character and between 0.2s and 2.2s for carriage returns, based on how far the head has to move to get back to the beginning of the page.
This is all coordinated by an init script, so the typewriter resumes automatically after power strip mishaps.
I expected there would be a lot more action than usual on Square’s Twitter feed once news of this thing spread, and naturally the first tweets afterward were intended to break it. Here at Square, we test our code exhaustively. Here’s Kyle testing the typewriter’s emoji support:
Naturally it wasn’t long before other people started abusing it as well, for the benefit of everyone watching.
For the curious, the code powering the tweetwriter is available. In true Hack Week tradition, it is not without its bugs — the typewriter sometimes doesn’t notice a key was repeated and prints out a single character instead of two — but it works well enough that the typewriter been stationed by our pool table. Unlike our other inforads, it does require some regular maintenance, such as recentering the paper in the feed (every few days), replacing the ink ribbon (every few weeks), and replacing the continuous-feed paper (every few months). Scott Perry (@numist) | Twitter The latest Tweets from Scott Perry (@numist). Polytechnics and pyroamory. He/him. Be better. sfbaytwitter.com