Bouke van der Bijl

Learning from old code

May 2016

Recently GitHub announced that any paying personal user will now have unlimited private repositories. I immediately started migrating some of my old private repos of dead projects that I had on Bitbucket, and in the process I found two old PHP projects that I wrote about 5 years ago.

TopHyvers

This is a project I made when I was 16, and I have vague memories of working on it in my grandma’s attic. It was a site that showed the top users for a now-defunct social network called Hyves.

People could add their own profiles to the site and come back daily to see how their views and friend count progressed over time. The Hyves website contained a list of all the celebrities that had profiles on the site, so I remember scraping that page and mass-importing all the profiles, to make sure my site had some interesting content from the beginning on.

How it worked is that I would request the profile of all the registered users every 24 hours and insert the number of followers and pageviews into the database. I made a very primitive Webapp framework that allowed for defining routes which would then be routed to the correct ‘handlers’. I couldn’t get cron to work correctly with commandline PHP, so I remember just setting it up to curl my update handler every minute.

At one point I could see the demise of Hyves, with all the top users losing tonnes of ‘followers’ every single day. I’ve decided to open source this project, hardcoded secrets and all, so others might gain some wisdom from my crappy PHP code. If you’re interested in the history of Hyves (and know Dutch) I suggest you read ‘van 3 naar 10 miljoen vrienden’, about the history of Hyves and how it exploded in popularity in The Netherlands.

I remember the design of the site being pretty cutting-edge, with rounded corners and gradients and everything. This is what it looked like:

Ishetkutweer

The second project I found was one I made for fun which showed you the weather for your current location in a rude way (the name roughly translates to “Is the weather a bitch?”. Depending on the weather, it would either be complaining about the heat or the cold.

One thing I remember being proud of for this project is a cache I built in to make sure I don’t do multiple API requests within the same hour for a certain IP address.

The spirit of the project still lives on at the current ishetkutweer.nl site, which I transferred the domain over to since they asked me for it.

Conclusion

While the code has lots of obvious issues, it’s still a fun exercise to go through it and look at what I knew then and what I’ve learned since. It also reminds me that while PHP has a lot of… imperfections, it still can’t be beat for rapid prototyping and ease of deployment. I was able to put up and run these sites on super cheap PHP/MySQL hosting without having to worry about operating systems and package managers and all that. That’s something that hasn’t become easier for many development stacks.


You should follow me on Twitter!