Finding the country distribution of the people I follow on Twitter

Andrej Karpathy, recently had a fun weekend project in which he wrote a Python script which would recommend twitter followers for you. The source of signal is that the people you follow follow other people you probably should follow but so far do not. Basically, like how Facebook recommends people based on your mutual friends.
I had the same idea a couple of weeks before Karpathy posted the code and was very happy (and a little disappointed) that he did it. I finally got around to getting the script to run on my laptop. It's incredibly slow because of the rate-limits by Twitter's API. It's been running 24x7 for 5 days and has only gone through ~110/299 followers.
It took me a while to understand the Python code that powers the code but I finally managed it.
I wanted to build something that would help solidify my understanding even further. I follow ~300 people on Twitter. I became curious about their country distribution. That is, I wanted to find out where did the people I follow belong to?

I used the find-birds script as a base and spent a couple days stumbling about and modifying it to do just that!

Here are the results. https://pbs.twimg.com/media/DdupjmuV4AA6uCH.jpg:large I made it look pretty in Figma, the actual output was just printed out onto the command prompt. Haha.

What does the code do? It uses the Tweepy module to download some data about each of your followers and writes all of it to a file. The code then reads the file, extracts the location of each friend, runs it through the Google Geocoding API and selects the country name from the resulting output. It does this for each person you follow and after everything's done, it writes all of it to the same file, iterates over the elements, counts occurrences of each country and prints the result.

I'll put it up on Github by the end of this week.

I'm pretty stoked that I learned to use the Google Maps API. APIs were mystical creatures before. They've been downgraded a notch but still have an air of magic around them because I used the 'googlemaps' Python module. I only had to call a function to do a call, I'm still unsure of how the call is actually made.

As I've mentioned, the output wasn't well formatted. I wanted to do something about that. Guess I could write it to a .csv file but that's boring. I wanted to create a web-interface for it. I enter a username and the code running on the server does the rest.

But, how do I run python code on a website? I've only made static websites before and they used HTML, CSS and Javascript. So, I thought I had to find a way to run python code using Javascript. Haha.

A long time ago, I remember asking my uncle if Xbox games would run on a PS3. 10 years later, I feel I've come full circle.

Nevertheless, I googled it and found out I needed a python web-framework to run python code on a website. No mention of Javascript. Of the web frameworks names I read, Django was the only one I had heard of previously. I decided to take a look. ~6 months ago, I spent some time doing a part of a node.js tutorial on MDN. Django code/concepts seemed very similar to that. There is a 7 part tutorial for beginners on the Django documentation site, as of writing this I've done 2. Django feels like a back-end framework. I'm not sure where and how the python code's gonna run.

But hopefully by the end of the 7 part series, I'll have figured it out.