It’s called “Parakeet” and it automates your Twitter.
- 14 cups of coffee
- 6 cans of diet Coke
- 6 packs of top ramen
- A single tear
- 4 lbs lost
- 0 minutes spent listening to Kanye’s new album
- 45 commits
I know that’s probably one the first things people think when it comes to posts like these. Why? Why would you set a time limit for yourself? Why should I care? Why does it matter?
I’m originally a mobile developer from Seattle and the only experience I’ve had in full stack web was mostly offshoot PHP projects and occasionally in Python/Django. One of the things that surprised me when I moved to the Bay Area is that it seems like every startup out here is on Rails.
Rails, Rails, Rails, Rails.
After the 20th person suggested to me that I should look into learning Rails, I finally caved and hopped on the bandwagon. However, I wanted to make the learning experience fun so I challenged myself to see if I could go from learning to deploying in 7 days or less. Here’s what happened.
- Ruby on Rails Tutorial: This was my go-to resource for Rails. It’s pretty thick and will take you all the way from setting up Rails and Git to deploying your project on Heroku. If you can get through this, you can deploy an app.
- Rails SaaS Template: It’s probably bloated and contains more than you need, but it’s an excellent way to quick start a SaaS project. It contains the configurations already for Stripe, Devise, emailing which will probably save you 10 hours of work.
- Themeforest: I consider myself a decent designer. I’m not great, but definitely better than the average hacker. However, even so, creating a comp from scratch and converting all of that into HTML/CSS would have been a pain. I purchased a bootstrap theme there for $10 and modified it from there. For $10, it saved me another 10 hours of work.
- Stackoverflow: Obvious one. One of the problems I had with Ruby was that I couldn’t find a goto resource as I did with Rails so I constantly referred to Stackoverflow. If any of you guys had a good suggestion, would love to hear about it.
- Heroku: Another obvious one, but for those of you who build on a different stack may not be too familiar with this one.
I spent about 2 days total going through the Ruby On Rails Tutorial. As I mentioned before, I come from a mobile and with some experience in Django so I understood conceptually how MVC works. The important pieces that I needed to learn were:
I skipped over all the the parts where it takes me through writing tests. That probably saved me an additional day in being ready to start writing my web app, but as a result, I have no tests for my production code. Whoops.
Anyways, from there, I figured that as long as I understood how to point URLs to my controllers and how to fetch my models into my controllers, I felt pretty comfortable in building something.
One piece of popular culture that I hardly understand is Twitter. I just don’t get it. I know that it’s important and I know that it’s valuable because everyone uses it, but I never understood how to use it or what to use it for.
Instead, when I see Twitter, I just see a lot of noise and repetitiveness. I tried to make sense of some of it and evaluated what some of the Twitter power users were doing with their accounts: posting content to their Twitter feed, engaging with users and retweeting occasionally. Great. I can do that.
From that point, I committed to spending about an hour a day working on getting my Twitter follower numbers up but soon realized that that was consuming way too much of my time. One hour a day on Twitter for a 5 years equates to roughly 210 hours of my life. Did I really want to spend that much time managing my social media profile?
So I did what many programmers would do — I tried to automate it.
The original scripts I wrote were in Python and were quite simple. It’d automatically Tweet an interesting article based upon keywords, it’d retweet “rising” Tweets for you to keep your users a constant stream of good content. I posted it about it on Facebook and Twitter and there was a decent amount of interest. I thought, well, maybe as a fun side project, I’d turn this into a SaaS product and see where it can go.
I spent about 5 days total from writing the first line of code to deploying my app live and Tweeting about it and posting it on Hacker News. As mentioned above, I used a Rails SaaS template to get started which helped a lot. It had already integrated Stripe and Devise, so it got some of the more difficult parts already out of the way.
One problem that I realized whilst building this application is that although I conceptually knew how Rails was supposed to work, I had spent almost 0 time learning how to actually program in Ruby. As such, my code looks like a huge mess. If I were to redo this again, I’d probably spend the the time to learn some Ruby first.
However, I figured that as long as I was the only one writing to this codebase (which I was), maintainability would have to take a back seat to time to market. It’ll have to be refactored at one point, but for the sake of launching, it probably doesn’t matter as much. (If anyone would like to see the source code, let me know)
I used Heroku to deploy my production app. Currently, I’m only running on the dev database with a single dyno to maintain on the free plan. A lot of the heavy lifting with the Twitter logic happens still on a Python Flask API running on a different Heroku app.
The reason why I chose a Python backend in addition to Rails is that I found the default Twitter Gem for Rails to be a bit lacking. Whenever I do API requests, it seems to only return a cursor of objects? Which meant that I would get rate limited a lot. Also, since I actually don’t know Ruby that well, it was really hard trying to code the chunk of my app that was supposed to be a bit more efficient.
However, because of this, it also helps take a little bit of the load away from my main website. To further improve things, I have each dyno unicorn running 4 concurrent requests.
I posted the website to Hacker News on June 24th. After about 20 minutes, it received 8 upvotes and was on the front page. 5 minutes later, I was seeing my application handling 200~ concurrents at once. Uh oh.
I had already anticipated an influx of users from launching so I had about 10 dynos running. However, what I failed to calculate for was that my free dev database could only handle a maximum of 10 concurrent connections at a time… With all of these requests coming in from my unicorns, they were affectively locking my own database. Yikes.
Moar Less Dynos??
It was bit counter intuitive, but scaling down my dynos to about 3 appeared to make everything fine and dandy again. The front end was still slow, but at least the entire application wasn’t locking up.
However, right when I got the site back up and running, Hacker News decided to kill my post and remove it from the front page. Probably because the site wasn’t loading at all? Who knows.
It also appears from the graph below that one of my requests to my Flask Python server seems to be blocking. Yikes. Looks like I’ll have to fix that too.
That one week of attempting to learn Rails to building out a web app to deploying it was one of the most productive moments in my life. I still don’t quite know how to code well in Ruby, or write tests in Rails or even what exactly ARE dynos and unicorns, but hey, it gives me a good template to build off of and was a lot of fun.
If you’re into learning a new framework, language, try to come up with some fun projects, commit to it for a week and see what you can build yourself as well. Who knows, you might surprise yourself!
Here are some of the caveats with trying to “learn” RoR so fast. It’s hard to say that I’ve actually learned the Framework after only a week.
- I don’t know how to write unit tests.
- I don’t know Ruby
- Your eyes will bleed from reading my code
- Some of my model queries can be better optimized