Everyday python
September 10, 2013 — Alex Guerra
I hang out with a lot of non-programmers. Something I get asked pretty often is "what have you been working on?"
"Well..."
The real answer to that question makes a lot of eyes glaze over. For a person who's entire idea of what programming college kids do in their dorm rooms is based on a viewing of The Social Network, it's probably a little disappointing too.
But that sucks. Because programming is cool. Maybe not Justin Timberlake "billion dollars" cool, but cool nonetheless. And it's tough to convey exactly what makes programming so cool to your average everyday non-technical person.
So now, whenever someone comes to me genuinely interested in why I spend most of my nights at the library in front of a screen until 2 AM, I like to tell them a story.
It's spring break and I'm in Austin. SXSW Music is in full swing and I'm sleeping on an old classmate's couch out in west campus, walking downtown every day to enjoy the city with my friends.
The Myspace secret show was the talk of the town. The "secretness" of this show is up for debate (the building on 5th where it was going to be had "MYSPACE SECRET SHOW" painted in big letters on the side), but damn if that one word didn't make a lot of people desperate to grab a ticket in.
And I was one of them.
I've never claimed to be immune to hype. Even without hope of actually passing through the gates (21+), the novelty of getting a wristband to the "secret show" that everyone was freaking out about was just too strong to pass up. That Justin Timberlake was playing was icing on the cake. Plus I figured if I could manage to get a pass, I'd be able to find some tall white kid to lend me an id.
Registration for the show was supposedly first come first serve and done on Myspace's shiny new website. The thing was, no one knew when registration would open. That night, while everyone else in the city was sitting at their computers collectively pounding f5, I kicked back on my buddy's couch and hacked this together.
import time
import sys
import requests
s = requests.Session()
login_data = {'email':'alex@heyimalex.com',
'password': 'pw',
'rememberMe': 'on'}
s.post('https://new.myspace.com/ajax/account/signin',
data=login_data)
while True:
r = s.get('https://new.myspace.com/secretshow')
if 'secretshow2.jpg' not in r.text:
print 'YEAH!'
server = smtplib.SMTP("smtp.gmail.com", 587)
server.starttls()
server.login('alex@heyimalex.com', 'pw')
server.sendmail('alex@heyimalex.com',
'2106934790@txt.att.net',
'MYSPACE RSVP OPEN')
sys.exit()
else:
print "nope :( @ {}".format(time.time())
time.sleep(10)
For the non-programmers reading, those few lines check the secret show webpage every ten seconds to see if it's changed and, if it has, sends me a text message saying as much. That took me something like 15 minutes to write out and I wasn't sober while I did it.
The next morning I got a text and me and all my friends hopped online to grab our wristbands. Unfortunately the "first come first serve" part of registration was a little less than true, so my triumphant story about technology conquering all falls short of true greatness. Sorry about that.
But it's not really the point.
The point is that I had the power to imagine something and then make it a reality at a moment's notice. Like the craftsman who can envision a work and forge it into life, or the novelist who brings her thoughts into existence on the page, programmers have the gift of creation literally at their fingertips, and in a medium with nearly endless possibilities.
When I was annoyed by the gate at my girlfriend's apartment complex, I built a script using Twilio to automatically buzz me in. When my friends started playing snake on Facebook and I wanted to beat their scores, I built a bot. When I wanted A list features on OkCupid without paying money, I built OkSearch and OkMirror.
See, at a certain point, if you can dream it you can make it. When you consider just how much influence a piece of software can have on the world today, you realize just how valuable that superpower is.
That's cool.