Hacker News Leaderboard
Hacker News is a great community for all things technology. It’s the place where I spend most of my free time, always impressed by the various people I get to meet. And so, with the mandatory excuses for directing my attention to such earthly matters, I wanted to check which users are the most active on the forum. The connoisseurs out there might already think https://news.ycombinator.com/leaders, yet that was not enough for me. I didn’t want an all-time, static ranking; I was interested in the most active people at this specific moment. As I could not find what I was looking for anywhere, I decided to build it myself. Now I can find the users that showed a huge engagement recently, the users that have something important to say. Check it out here: https://why.degree/hn-top/.
This post is an example of a mini-project suitable for your portfolio. If you’re a junior like me, and you want to prove to a potential employer that you got what it takes to work for them, you most definitely need a portfolio. There is no better way to showcase your skills than building and shipping actual products.
To this end, because I am planning on becoming a Developer Advocate, I chose to build something related to this line of work. In more concrete terms, I decided to work with the Hacker News API and inspire others to use it as well, by writing about one possible application. Although extremely simple, the idea behind this example provides a generalised thought process that can be summarised as follows:
- I knew what job I’d like to have
- I understood the requirements for the job
- I identified a problem related to my daily activities
- and finally, I provided a solution for that problem
Notice how I emphasised on the personal aspect: a problem related to my daily activities. By treating the project as a way to make my life better, it’s not only that I genuinely improved the quality of whatever it was that I was doing, but ultimately I ended up telling a better story. Remember that the goal should be to present your skills, and how you achieve that is as valuable as the product itself.
******
Let’s begin! I would first like to introduce you to Hacker News. You can see that it has a generic interface, displaying 30 entries with a few important details for each one of them: title, author, source, #points, #comments.
Comments are normal entries, that only have an author, and some comments under them. If you’re the author of the comment, you can also see #points.
Now that you’re comfortable with the platform, here’s their API, which is free at the moment, thus making it a great way to try out implementing a bunch of different things. For example, you could use it to build an extension for the page, possibly focusing on following some users in particular, while also blocking others.
What I have in mind is building a leaderboard for the most active users in the current top 30 stories on the website. Obviously, for that, I need a method of getting the top stories, together with their comments, and aggregating everything based on the author. This is simply done with only a couple of calls to the server. As the response to every such call is in JSON, I can just deserialise it and take the ‘by’ field out. Computing the score for each author can be done using a key-value structure, e.g. a dictionary in Python. You can see the full code on my Github profile or by clicking here.
The last part of the project is to host the results live on the internet. With a bit of HTML and the magic of Cron, the final result is available at the following address: https://why.degree/hn-top/. I wanted to have a fully working, end-to-end solution. I could have stopped at the first working step: the leaderboard on my machine, but that wouldn’t have been fun.
In conclusion, the message you should take out of here is that you should work on something, no matter how easy it is. If you plan to be a coder, go out there and build a prototype for your new app. Deliver a product and try to tell a story while you’re at it.
If you feel like I missed anything or you want to continue the discussion, leave a comment on Facebook or Twitter or send a direct email at [email protected].
References:
- https://youtu.be/bK2iPDu7RDE
– Presentation on solving the parking problem in New York City