October 19th, 2014 permalink
Fall’s vogue flavor seems to be the pumpkin spice latte. This limited-edition Starbucks concoction comes around every year, but things have finally gone viral. As a result, about a third of all pumpkin spice latte tweets are nice and earnest, and the rest are mostly trolling misogynistic comments about white women in yoga pants.
So I decided to make a pumpkin that listens for new PSL tweets and randomly boos or applauds them. I call it the PSL modem. Spicy!
(In case it’s not clear from the video, the applause is coming from the pumpkin, not the laptop.)
The PSL modem is an Arduino Yún with an MP3 breakout board, operating wirelessly, working in conjunction with a helper script operating on a computer. The helper script uses ajax to check for tweets every 5 seconds (Twitter’s 1.1 API rate limit). It’s not strictly necessary, but it moves the Twitter API action out of the Arduino, which saves on overhead. (If you’d like to make the thing completely headless, check out Temboo’s Arduino library. But I like seeing the live tweets, god help me.) The PHP script passes the unique tweet ID to the Yún via the browser using the Yún’s mailbox library, which takes the format psl.local/mailbox/tweetID. Each time the ID changes, the Yún plays a random track from a collection of MP3s.
In case you’d like to build your own smartgourd, the PSL modem uses this hardware:
– Arduino Yún (for its fancy wifi and bridge library)
– Adafruit VS1053 MP3 breakout board
– Adafruit 3.7w Stereo Class D Amplifier
– Breadboard (or, if you’re smarter than me, perfboard)
– Male-to-female jumper wires
– Micro-SD card
– ≥3Ω speaker (I used this 8Ω, 1w model)
– Small USB battery pack (I use the Instapark MP1800U2 ‘cos it’s compact)
– Sugar pumpkin, or commensurate squash
…and this software:
– Arduino IDE 1.5.8 (beta) or greater
– Arduino script and helper PHP scripts
– Adafruit VS1053 library
– tmhOAuth library & Twitter API
– Laugh track MP3s (I used Amazing Sound Effects of Crowds)
– BlueHarvest for cleaning invisible temp files from your SD card (optional)
OK! First up: connect the Yún to your wifi network!
(You can follow along here.) When you first power up the Yún, it’ll create a wifi network called ArduinoYun-XXXXXXXXXXXX. Join this network with your computer, wait to obtain an IP address, and then navigate to arduino.local. When prompted, enter “arduino” as your password and click “Log In.” On the next page, click “Configure” to set up wifi. You can assign a name to the Yún (if you use anything other than “psl” you’ll need to change the PHP example pages accordingly). Choose your wifi network from the drop-down, enter the password and click “Configure & Restart.” Now you can rejoin your regular wifi network. After a couple of minutes, you should see a white LED on the Yún illuminate, meaning the Yún is online. (If you don’t, reset the wifi and try again. The relevant reset button is next to the USB port and is oriented sideways, and if you hold it in for >5 and <30 seconds, the Yún will recreate its original wifi network so you can try your configuration again.) Hey, look at that, you’re up and running!
Now’s a good time to head back to psl.local and identify your Yún’s IP address and MAC address for port forwarding, in case your server isn’t on your LAN (though this tutorial assumes that it is). In order for the Yún to receive commands from the browser located outside your LAN, you’ll need to forward a port to the Yún’s TCP port 80.
Now, let’s unplug the USB connection and then solder the VS1053 and amp to the header pins, then wire everything up.
The VS1053 breakout and the stereo amp both need to be soldered to their header pins. (Or, I suppose, you could try using these solderless header pins from Sparkfun, but they get mixed reviews.) There are a lot of small connections, so work slowly and be careful. Adafruit has instructions here (for the VS1053) and here (for the amp). The amp is a little trickier, since it only has header pins on one side. As per the diagram, stick the leftover header pins between the amp and the breadboard to keep everything steady while you’re soldering.
Once you’re done soldering, hook everything up. The VS1053 gets hooked up to the Yún as per these instructions (don’t wire in the headphone jack), with one important distinction. Because the Yún’s SPI interface doesn’t run through its digital pins (as with the Uno), you need to route the SPI pins on the VS1053 (CLK, MISO and MOSI) directly to the ICSP header on the Yún. This is where those male-to-female jumpers come in. Instead of using Arduino pins 11, 12, and 13, use the following schematic:
Once the VS1053 is wired, you can hook up the amp and the speaker, using these instructions. LOUT and ROUT on the VS1053 go to the L+ and R+ pins on the amp. L- and R- go to the AGND pins. Then use the speaker terminal you soldered earlier to connect the speaker. (If you have a red wire, that’s positive.) I only use the right channel. Who needs stereo inside a pumpkin? Consider using the jumpers to adjust the gain on the amp. It’s well-insulated in that gourd! But start low, so you don’t blow anything out while you’re testing.
Congratulations, you now have a completely functional physical setup. Let’s take a break and set up the Twitter API.
Head over to apps.twitter.com and login with your Twitter account info. Then click the button to create a new app. Provide all the relevant details, accept the terms, and create the app. Then, head over to the “Keys and Access Tokens” and take note of the Consumer Key (API Key) and Consumer Secret (API Secret). On the bottom of that page, generate your access token. Then take note of your Access Token and Access Token Secret. You’ll need these to scrape the Twitter feed. (For each key, make sure you’ve copied the entire key. They often have dashes in the middle, and double-clicking on the text may only pick up everything on one side of the dash.)
So, let’s upload the PHP scripts (and CSS file) to your server of choice and test them out. They can be downloaded on github, and they consist of index.php, psl_json.php, and psl.css. Also download tmhOAuth and place it in the same folder. Remember those secret keys you copied? Paste them in the appropriate variables at the top of psl_json.php. (Note: it’s important to safeguard these keys, so you should look into the best way of doing that. Here’s a Stack Overflow thread with advice on how to store those API keys in php.ini, which is outside the webserver’s root.) Now, open your browser and load index.php. You should be seeing live tweets.
Now, format your micro-SD card as fat32 and upload your songs to it (and make sure the MP3’s filenames are ≤8 characters long). OS X creates many invisible temporary files and folders which can get in the way of your script’s efforts to pick and play a random track. An easy to way to resolve this is with BlueHarvest, which offers a 14-day free trial, but it’s not necessary. You should be able to get the same results with any tool / shell script / app that allows you to identify and delete invisible files.
Once the SD card is loaded and inserted into the VS1053, we need to do one more thing before we can upload your code. We have to remove conflicting SD card libraries from the Arduino app. Basically, the VS1053 comes with an SD card, as does the Yún. Both have competing libraries, so we’re gonna remove the Arduino IDE’s library and stash it elsewhere for later. To do this, find the Arduino app in your Applications folder. Right-click it and click “Show Package Contents.” Then navigate to Contents > Java > libraries > Bridge > src and remove FileIO.cpp and FileIO.h. Stash these somewhere so you can restore them later if you need to. (Or, you can always download a fresh copy of the Arduino app later.)
Now, it’s time to plug everything back in, upload the code to your Yún and test everything out. I’d like to take a moment and give credit to Aero98 on the Arduino and Adafruit forums, whose code for identifying and playing a random track I am adopting here. (I have added one thing to it, which is randomSeed — this uses the output of an unused analog pin to seed the first track. Without it, your random sequence will always start at the same place. I also corrected a memory leak by making “path” a global variable.) The rest of my code is adapted from two sources: the “MailboxReadMessage” example in the Yún’s bridge library, and the “player_simple” example in the Adafruit VS1053 library.
Assuming everything’s working as it should be, and your browser (or perhaps someone else’s, if your PHP files are hosted outside your LAN) is currently accessing index.php, you should start hearing your songs every time there’s a new tweet! You can unplug the Arduino from your PC and plug it into the USB battery pack to go completely wireless.
Onto the pumpkin. Select one that’s a little larger than you think you’ll need — the walls are thick, and the chamber somewhat small. Cut a hole in the bottom, and scoop the guts out (don’t forget to save those seeds for roasting!). The widest component I used is a 3″ x 3″ speaker, so that’s about the size of the hole I made in the bottom. Stuff your components haphazardly into a gallon-sized Ziploc bag (I invite you to find a more elegant and static-resistant solution), and shove them into your pumpkin like it’s a Thanksgiving turkey. (With an appropriately-sized gourd and gourd aperture, I find that everything stays in place pretty well without needing to be secured in any meaningful way.)
Flip the pumpkin over, and you’ve got yourself a PSL modem. Happy tweeting!
September 4th, 2014 permalink
I recently gave a mini PechaKucha-style talk at SVA IxD about habits and cowpaths and such, which I’ve reproduced here:
One day, when I was about thirteen years old, I decided to bike from my house to Brooklyn Heights for the first time. All was going fine… until I nearly merged onto the highway. (Don’t worry. I veered off, found a payphone, and called my mom for directions. She almost had a heart attack.) Why did I almost make such a boneheaded decision? Well, I was following the route my mom used when she drove us to school every day. She took the Prospect Expressway, so I was going to do the same. It was the path I knew the best, and habit is an extremely powerful force — one that problem-solvers ignore at their own peril.
In the IT world, we like to blow up bad habits. We have a phrase for this: “don’t pave the cowpath.” In other words, wouldn’t it be nice to come up with an objectively superior solution for a problem, rather than cementing the jury-rigged method that some former employee implemented some Friday afternoon ten years ago? This sounds really good, but it’s shortsighted. If we try to torpedo an existing system, human nature — those bad habits — will still find a way.
Take, for example, the mysterious case of the client who likes to keep their password on a Post-It stuck to their computer. As an IT consultant, I come in and my eyes bug out. I say, here, let me set you up with a fancy password manager. It’ll solve all your problems, it’s really pretty, and all we have to do is set up a master password so you can use it. So what happens next? (img)
Of course. My client has simply scrawled their master password onto the Post-It note. Why? Well, zooming out, maybe we weren’t solving the right problem. Their goal was to remember their password and easily access their files. Perhaps instead of undoing the Post-It cowpath and introducing a much larger security breach, we can dig deeper and solve the unspoken problem. So, what is the problem?
As usual, XKCD has the answer. It turns out, apparently, that we’ve all been crafting terrible passwords for years. Adding complex numbers and symbols is (relatively) easy for a computer to brute-force, but nearly impossible for a human to remember. Choosing a random string of words, like “correct horse battery staple,” is far easier for a human to commit to memory, but far harder to crack. By looking at the root of this issue — convenience and ease of memorization — we’re far more likely to keep the password off the Post-It.
Getting to the root of the problem involves noticing that some seemingly-senseless paths are intentional — these are known as desire paths. Returning to the parable of my fateful bike ride, it turns out that the best way to get to Brooklyn Heights from my old house is to cut across the Parade Grounds, dart across a long street with heavy, near-continuous vehicular traffic, and walk your bike through a hole in the fence around Prospect Park. No matter how many times the Parks Department puts up a new fence, folks keep tearing it down, because the alternative (biking around half the park to get to the proper entrance) is so onerous. Rather than try to rebuild the fence and correct the behavior, perhaps we can embrace it — by putting up a traffic light, for instance.
Similarly, by paying attention to what’s going on and trying to withhold judgment, we might (might!) learn that a cyclist biking down a one-way street against traffic is actually not an asshole. Perhaps he’s not even going the wrong way. Maybe he’s made a prudent decision that this route is the safest and most expedient, and maybe instead of giving him a ticket we can design a solution, like a protected two-way bike lane, that would be more effective. (img)
Sometimes the behavior we must design for is largely invisible, so we have to get creative. Here, looking at the tracks that cars leave after a snowstorm, we can see the desire path developing in negative space. The cars have done the research for us, and now we can identify an obvious spot for a pedestrian refuge. This behavior isn’t accidental, but it does require a well-trained eye to observe it. (img)
And for another example of nearly-invisible behavior, here’s a closeup of that desire path into Prospect Park. Take note of that string bridging the gap in the fence. That’s part of an eruv, which is a consecrated, unbroken filament strung around entire neighborhoods to virtually extend the borders of Orthodox Jews’ households on the sabbath. Designing for this space requires awareness of many diverse, hidden needs — none of which we can ignore, and all of which will route around any obstructions.
The moral of the story is that life finds a way. Habits are powerful, and behavior is stubborn. It also usually has an internal logic, even if that’s sometimes hidden on the surface. In order to design mindfully, we have to embrace these “bad habits” and figure out their root cause, rather than torpedoing an existing system in favor of an impossible “objectively superior” solution.
July 9th, 2014 permalink
Today, I helped bury my dear friend Chloe Weil.
I first met Chloe thirteen years ago, in an elective high school health ed course called “Death & Dying.” Remembering that makes me laugh now, darkly. There was something dreadfully apropos about it then, and it’s even more devastatingly perfect now.
We rolled our own social media outlets back in the day. She maintained a proto-Twitter feed in which each entry was precisely 101 words long. She documented her teenage life in stark detail online, with the same clarity, maturity, observational prowess and humor that attracted so many to her in recent years. We bonded over our personal websites when we were sixteen. Her site was always better than mine. On April Fools Day, we switched our index.html pages and befuddled our friends.
Chloe was the least sentimental person I’ve ever met — she routinely shredded her ephemera and jettisoned old projects with ease — so I feel vaguely guilty telling you too much about her. But goddamn it, I want to make sure you understand.
I want you to know that she vibrated at a different frequency. I don’t really know how to put it any other way. Her raw talent just seemed so effortless. Her dark discomfort wouldn’t allow her to see how loved she was, or how incredible, or how talented. But you can see it, and you don’t need my help. Read for yourself. She will stop you in your tracks.
Chloe and I didn’t always sync up, but when we did it always involved a fantastic, hilarious, unreal voyage. She visited me in college and we spent the entire weekend doing nothing but silently typing to each other on our laptops — it was one of the best weekends I’ve ever had. A few years later, we met up in the City and circumnavigated Central Park one evening, staying up sitting on a bench just chatting until 7am. It was one of the best nights I’ve ever had. And a couple of summers ago, we met up with our friend Jon and walked through the wilds of Red Hook, marveling at every dark corner and fortress-like tower and pier to nowhere. It was one of the best twilights I’ve ever had. We’re all lifelong Brooklynites, so none of this should have impressed us, but when you’re walking with Chloe, you’re on the adventure of a lifetime. Every single time.
I hadn’t seen Chloe in a few months, but I did get to have one more adventure with her recently. I had a dream about her a couple of weeks back. I scrawled it down in the middle of the night and emailed it to her in the morning, and here it is.
Dream Chloe met up after a long time. Walking around. Lots of abandoned carnicerias. There was a time lord. Some guy got sucked into an engine block. Beautiful ethereal bats shadows. Someone waiting for a flight had hacked in and pretended to be you. We talked about our relationships and making time for our friends. You said you only liked my sister. Some people were taking wedding photos in a car, lit from outside. You weren’t sure how to get home from there.
February 21st, 2014 permalink
I turned 29 last week. I entered my thirtieth year.
It wasn’t the easiest of birthdays, but the invisible countdown has actually been extremely helpful for me. I’ve been more productive since January 1st than I had been in perhaps all of 2013. The nagging call of my thirties haunts my every lazy impulse.
I predict that it’s going to get a lot easier after my next birthday. I’ll be able to substitute the guilt of wasting my twenties with the freedom and power of an entire new decade to squander!
To that end, I had these little cards printed. Like me, many of my friends will be turning 30 during the next twelve months — and many family members will be turning 20, 60 and even 90. They could all use a little reminder that once they turn that corner, the pressure’s off — for a while, at least.
February 2nd, 2014 permalink
I found this post-apocalyptic calendar from the future in an old, dusty, ambiguously-ethnic gift shop down a back alley that was mysteriously bricked over the very next day.
Conveniently, it appears that the 2127 calendar is backwards-compatible with 2014, in case you’re ready to swap out your Twelve Months Of Doge calendar for some bleak futurism.
Just $30, including shipping.
January 16th, 2014 permalink
I needed some peaceful, distraction-free time this month.
To that end, I edited my hosts file to filter out unwanted sites. I deleted social media apps and enabled parental restrictions on my phone. I even created a small Safari extension to block access to certain sites unless I accessed them via a Google search (I don’t need to drink from the MetaFilter distraction firehose, but it’s still helpful to filter results to site:ask.metafilter.com when searching for recipes and date night suggestions).
It still wasn’t enough, so I decided to
downgrade upgrade to a lovely flip phone. Amusingly, it’s actually my first! (Before the iPhone days, I had a non-flippy Nokia 8210, and I loved it dearly.) It cost me $14.99 on Amazon.
One big problem. My dinky new phone knows nothing of iMessage! I don’t need to respond all that quickly to most people I text with, but my girlfriend does not always appreciate it when I walk away from my desk in the middle of a conversation. (“But — Wendy! Darling! Light of my life! I consider texting to be an asynchronous form of communication!” Good luck with that one, fella.) To make matters worse, she has to pay per text on her work phone. So, what’s to be done?
The answer: using Google Voice and my inbox as a bridge, I’ll use AppleScript to sling my SMS messages over to iMessage, and to extract my girlfriend’s replies.
This project assumes that you’re an iCloud user with access to a Mac running Mavericks, and that you have access to Google Voice. Note that this solution only lets you bridge your SMS/iMessages with one of your buddies. I’m sure the scripts could easily be adapted for multiple contacts, but that’s not what I needed to accomplish here.
Step 1: set up Google Voice.
Choose a Google Voice phone number, and enable SMS-to-email. This lives under
Settings > Voicemail & Text > Text Forwarding.
Once you’ve been assigned a number, send a text to it from your cell! When it arrives, take note of the custom email address Google sends it from. It will look something like this:
1[GV #].1[SENDER #].[HASH]@txt.voice.google.com
Step 2: sling your SMS messages to the Messages app.
Open the “iMessage Slingshot Sender” script in AppleScript Editor. You’ll need to change two things here:
send theBody to buddy "718-555-1212"
of service "E:firstname.lastname@example.org"
“718-555-1212″ should be replaced by the phone number of your spouse, loved one, compatriot, buddy, or other most important iMessage contact. “email@example.com” should be replaced by your iCloud email address. (Make sure to retain the “E:” prefix.)
Now save your script, and move it somewhere Mail can find it! That’d be
You’ll need to create a new rule in Mail to trigger the script every time you an SMS that you’ve sent from your cell lands in your inbox. Mail rules live in Mail > Preferences > Rules. Click “Add Rule.” Give it a fancy name, and set the following as your only condition: From is equal to 1[GV #].1[SENDER #].[HASH]@txt.voice.google.com. Under “Perform the following actions,” select “Run AppleScript” from the first drop-down, then select your script from the second drop-down. Save the script, but don’t apply it to your entire inbox when prompted. Oh, and, before you leave the Preferences window, you might also want to make sure that mail is being checked regularly.
Now test it out! Send an SMS to your GV number from your cell. It should open the Messages app and send that SMS to your loved one as an iMessage.
Now, we just need to slingshot their replies…
Step 3: …slingshot their replies.
Open the “iMessage Slingshot Receiver” script in AppleScript Editor. This script is triggered whenever anyone sends you a message in Messages. If the sender is your loved one (your very patient loved one, who doesn’t question your need to use a dumb phone for a couple of days until you finally come to your senses), it extracts their iMessage, plunks it down into an email sent to that same txt.voice.google.com address, and sends it.
You’ll need to change two things here, too:
if theHandle = "+17185551212" then
set recipientAddress to
"1[GV #].1[SENDER #].HASH@txt.voice.google.com"
“+17185551212″ should be replaced by your lover’s phone number. The txt.voice.google.com number should be replaced by that email address GV generated for you.
Note that there’s a lot of cruft in that script. In Mavericks, the Messages app has lost its event handling GUI. Instead, every single script needs to define every possible event or AppleScript will throw an error. Sorry about that. Just ignore it. You might also notice that “on active chat message received” is defined separately. I’d recommend ignoring it, or your texts might come through twice. (And if the receiver script is suppressed because you’re actively using Messages? Not a big tragedy.) Again — sorry.
Now, save your script. This one needs to live in
~/Library/Application Scripts/com.apple.iChat/. To activate your script, head over to Messages > Preferences > General. At the bottom of that pane, select your script from the “AppleScript handler” dropdown.
Congrats! You’re done! Your SMS messages will be routed to your inbox through GV, then slung (slinged? slang!) to your favorite iMessage user. The interstitial email will be summarily trashed. Then their iMessage replies will be emailed back to GV via your Mail app. The best part is, a complete record of your conversation will exist in both iMessage and GV!
Just keep in mind that you should add your GV number to your phone’s contacts. You’ll be texting to that number, not your iMessage buddy’s number.
You can grab the two scripts via github. Please let me know how they work out for you.
Now, to master T9…
January 10th, 2014 permalink
We made it to the middle of nowhere over New Years. Then we drove another twenty miles east.
The Noah Purifoy Foundation, in Joshua Tree. Decades of sunbleached desert art. Though I can’t imagine two more dissimilar environs, it sort of reminds me of Opus 40 in Saugerties, NY. Both examples of a person with a singular, unfinished dream and decades to hash it out. One of the High Desert Test Sites.
The Salton Sea and Palm Springs at sunset, as seen from Keys View, Joshua Tree National Park.
Lauren and Joshua.
Your best bet in Twentynine Palms.
Salton Sea State Park. Yet another ecological disaster hiding in plain sight.
Lauren is unimpressed by Salvation Mountain.
Still Life With Tilapia.
September 19th, 2013 permalink
New York City’s mayoral primaries were held last week, and I was apparently the only person in my electoral district to get on board for the great populist uprising… but, no matter. The rest of the city took care of everything for me.
For this primary (and only this primary), The Board of Elections wisely decided to bring back the vintage, 1960s-era, 900lb lever voting machines, which had been mothballed in 2009 after a decades-long effort to modernize the state’s voting machines. Why? The Board wasn’t confident of their ability to perform a recount using the new optical scanners, in the event that a runoff election would be called.
The largest manufacturer of the lever machines, the Automatic Voting Machine Corporation of Jamestown, NY, went bankrupt in 1983, the same year that the City of New York started to consider replacing the then-20-year-old machines with computerized models.
In an effort to upgrade antiquated voting technology and avoid a replay of the 2000 presidential election donnybrook, Congress passed the Help America Vote Act of 2002, sealing the fate of the Shoup and AVM lever voting machines. New York’s paralyzed legislature was still unable to act, though, so the Justice Department sued New York in 2006, and the optical scanners were finally introduced in 2009.
And now, after only 3 years, the lever machines are back en vogue. I’d meant to record the dying sound of voting via these machines, but got distracted by the hubbub of the voting process. Fortunately, my girlfriend was willing to help out!
August 17th, 2013 permalink
I visited Rafael Lozano-Hemmer’s Voice Tunnel, a site-specific installation created as part of the NYC DOT’s annual Summer Streets program, which closes off Lafayette Street and Park Avenue to vehicular traffic from the Brooklyn Bridge up to 72nd Street for three consecutive Saturday mornings each August.
Voice Tunnel consists of 300 theatrical profile lights and 150 loudspeakers, set up in the Park Avenue Tunnel each morning and broken down every afternoon before it can be reopened to traffic. There is one microphone in the center of the 7-block-long tunnel, where visitors can record brief greetings, which then get replayed in a loop via the individual loudspeakers. Each loudspeaker plays a different voice recording, and each profile light displays in brightness that’s proportional to the loudness of the recording. Every 30 seconds or so the lights go dark and the recordings fall silent, and then the sound loops move down the tunnel by one loudspeaker, until they are gone.
Voice Tunnel, an extension of Lozano-Hemmer’s earlier Pulse Park in Madison Square Park, has been extremely popular. At 8:35am, I stood in a line that went from Park Ave and 32nd St all the way to Lexington and 34th. The fast-moving line vibrated with excitement.
What dawned on me only later (around, probably, 36th Street, underground) is that I was already part of the installation. From the moment we were allowed into the tunnel, visitors started snapping portraits and excitedly chatting with their friends as they slowly ambled through the tunnel. As the lights and recordings fell dark and quiet at regular intervals, I realized how hard it was to distinguish the voices of the crowds from the voices in the recordings. As I walked past each loudspeaker I could isolate the sounds (“I need a pie”, “My love to Lauren”, “New York is super incredible”), but they quickly faded into the din.
As we walked back into the open air and my fellow visitors continued yammering about their days, about Citi Bike, about Starbucks, I remembered, with a grimace, that unlike the recordings in Voice Tunnel, our cicada’s song is never hushed.
July 12th, 2013 permalink
I started thinking about a new project recently — a personal database of environmental sounds. I started with a classic tune that will one day be unrecognizable (unless, of course, it becomes the only way we ingest nutrients in the future): the desperate, deeply tragic scraping sound one hears upon reaching the bottom of a Chipotle bowl. I’ll have more on this soon.