paint-brush
I made a hack to get in TechCrunch’s Hackathonby@salmaanp
187 reads

I made a hack to get in TechCrunch’s Hackathon

by Salmaan PehlariSeptember 4th, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

A friend recently told me about the <a href="https://hackernoon.com/tagged/techcrunch" target="_blank">TechCrunch</a> hackathon happening soon. I was obviously excited and wanted to join but then he dropped the bomb on me that tickets were sold out in less than 15 minutes. Whaaaat! Well, the good thing was that the tickets were being given out in batches.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - I made a hack to get in TechCrunch’s Hackathon
Salmaan Pehlari HackerNoon profile picture

A friend recently told me about the TechCrunch hackathon happening soon. I was obviously excited and wanted to join but then he dropped the bomb on me that tickets were sold out in less than 15 minutes. Whaaaat! Well, the good thing was that the tickets were being given out in batches.

That’s great, maybe next time I will be prepared when they announce that on Twitter. The notifications thing might help, right? I’ll know about it as soon as they tweet. Well sure but not quite, I hate frequent notifications on my phone and TechCrunch tweets out every 20–25 mins. I can’t have that!

Well, since I want to go to a hackathon, it’s only fitting I hack something out to get there. Time to open Python!

Just thinking about what to do, it seems really simple. My hack needs to know about every new tweet by @techcrunch. Then it needs to figure out some way to know if that’s the tweet I care about. Finally, just notify me about the tweet as soon as possible. So this seems fairly straightforward, just also need to care about some small things like keeping it running without interruptions (for free!) and discard the tweets already seen.

The plan looks good, let’s see how to put it up together. I really like Python for small projects as it allows to quickly bootstrap and be up and running. The abundance of libraries doesn’t hurt either. First things first, we need to get Techcrunch’s tweets as soon as they are tweeted. Although we can use the Twitter API directly, Python has a great library called Tweepy which is a wrapper around the Twitter API. Of course, you will still need to create an app on twitter apps and get the OAuth keys.

Sweet, in just a few lines part 1 is already done. We can get the recent tweets by techcrunch every time we run this script. Now onto the next step.

By just glancing over TechCrunch’s tweets we can see they use the #hackdisrupt for all the Hackathon related tweets. So let’s just filter out the tweets with the words we are interested in.

Well, now we’re in business. We have the tweets we are interested in. If any of those keywords are in the tweet, the script prints it out. We make sure the tweet text is in lower case and compare it with the keywords.

Moving on, now I need to be notified about this tweet. There are a lot of options here like an email or a Facebook message. I wanted it to send me a text message, so at-least I’m not dependent on the internet to be notified about it.

We can use the Twilio API for this. They do have a trial account which is quite simple to sign up for get a trial phone number which you can use to send a text message to your real phone. Let’s integrate Twilio, make sure that the code runs indefinitely and also discard the tweets we have already seen.

So now, we will get a text message whenever Techcrunch tweets about the hackathon. One thing is remaining though, I can’t be running this on my personal computer 24x7. We need to host this somewhere. Lots of options again — Amazon AWS, Digital Ocean, Heroku etc. I decided to go with Heroku since it’s very easy to set up and does all the heavy lifting for you. We just need 3 more files to configure Heroku.

  1. Procfile — The command we want to run the script and the type of process we want. This will just contain “worker: python <script_name>.py

  2. requirements.txt — The libraries required so Heroku can download them. tweepy3.5.0twilio6.5.1

  3. runtime.txt — The runtime and version we need for the script. “python-2.7.13”

The final step is to just create a new app on Heroku, download its CLI and run the following commands in the project directory to deploy.








$ heroku login$ git init$ heroku git:remote -a <heroku_app_name>$ git add .$ git commit -am “We’re going to a hackathon”$ git push heroku master$ heroku ps:scale worker=1$ heroku logs

The result?

That’s it! Thanks for reading, come say hi if you’re coming at the Hackathon and let me know what you liked/disliked about this post.