When I was 12, I was given a Raspberry Pi. For the first couple of days, it was really fun. After I had browsed the web for a while and played a bit of Minecraft, it sat in it’s box for a few months. I really had no idea what to do with it. That was until I discovered that I could build a website with it.
Note: Healthy was launched about 5 months ago but I’ve only just got around to writing this post.
On Nov 3, 2015, SubjectRefresh spent a day in London at the annual Open Data Institute Summit, where we gave two presentations on our Young Rewired State Festival of Code 2015 Refresh app.
We were also challenged to create an application using open data that gets people to eat healthier. We came up with Healthy, a calculator that tells you “the time to burn” of a particular food.
It’s built on top of Node.js and uses Socket.io to communicate with the browser in real time. This means no page refreshing, no Ajax calls and no latency. We use an API to collect the information about the food the user has requested and then use some algorithms to figure out how much time doing a particular excercise is needed to burn off the calories.
I worked mainly on the algorithms to extract the information from the API and also wrote a large amount of the main JS for the Node.js web server and Socket.io integrations.
The code is available on GitHub and you can try out Healthy now at http://subjectrefresh.info/healthy/!
Friday night, or more specifically, Friday February 26th 2016 at 19:45:57, I was having a group Skype call with Alexander Craggs, Miles Budden and Tom Emmerson when Alexander started complaining that all the URL shorteners out there were becoming too long. To clarify, URL shorteners were becoming bloated. He suddenly said, “Let’s make a URL shortener”. The situation escalated very rapidly and within 5 minutes, Miles had bought the domain subr.pw for an astronomical price of £0.60, I had setup Nginx on the server used for the majority of SubjectRefresh‘s projects and Alexander had setup the codebase and had a Node.js skeleton ready to go.
During the YRS Festival of Code 2015, “SubjectRefresh” and I created a revision app called Refresh. It’s built using Node.js and works by scraping the exam board website (currently only CIE) for the PDF for the syllabus the user has requested. The PDF is then converted to HTML using a PDF to HTML converter and is then shunted through Node’s Cheerio library. We then find out where the relevant information in the HTML is and send that off to TextRazor.
I admit it, I’ve started writing all of my new projects in Node.js. Why? Because most of them are lightweight and I want them to be real time.
PHP can be a real pain when it comes to doing anything remotely real time. First off, it’s designed to execute as quickly as possible and send a response to the client, which is of course good. However, what is bad about that is that it doesn’t stay alive – it does its stuff and then dies. Node.js on the other hand runs in a single process, which stays running all the time. This is perfect for real time applications because you can fire off an event to Node.js and then (say, using Socket.io) update the client, instantly. To do this in PHP would be nigh on impossible, due to its ‘execute and die’ style.