How to improve your Google PageSpeed score with Webp images

If you're still serving images in long-time standard formats such as JPEG and PNG then a Google PageSpeed Insights analysis of your site will identify an opportunity to improve your page loading times by serving images in "next-gen" formats. There are several so-called "next-gen" image formats which offer superior compression to JPEG and PNG but in this post we will be focussing on Webp, a format developed by google. Lossless Webp image files are 26% smaller than PNGs and lossy Webp images are 25-34% smaller than comparable JPEGs according to Google. As you'd expect with a compression format developed by… Continue reading »


A puzzle with one piece missing

What are WebSockets?

What do WebSockets do? Hypertext Transfer Protocol (HTTP) is unidrectional, meaning requests can only be made by the client. This is a limitation which means that a certain class of web application cannot be built using HTTP alone. WebSockets are a separate communication protocol, fully compatible with HTTP, which allow for bidirectional communication between a client and a server. A protocol is simply a set of rules; in the case of WebSockets they were standardised in 2011. This protocol can be utilised via the WebSocket API or popular JavaScript libraries such as SocketIO, both of which have excellent browser compatibility. WebSockets… Continue reading »


A laptop with PHP code on the screen

A look at some of PHP 7.4’s new features

PHP 7.4 was released on 28 November 2019 and with it comes a lot of new features. In this post we'll examine a few of the more interesting ones along with examples of how they can be used. PHP has long been the punchline in low-effort memes, and though some of the disdain for the language is justified, more recent versions have made significant improvements to PHP and this latest one is no exception. Typed properties With the introduction of typed properties, class properties now support type declarations. This means that only values of the specified type can be assigned… Continue reading »


Some text from a computer terminal

Scheduling database backups with cron jobs

We're going to create a bash script which runs mysqldump (a MySQL backup program) to generate a database backup with a filename containing the date. We're then going to set up a cron job (a utility for running scheduled tasks) to run the script at regular intervals. We'll do all of this securely so that other users on the server can't access your MySQL username and password. This guide assumes that you're using a Unix based server (e.g. Ubuntu) with terminal access and a MySQL database. Step 1: Configure mysqldump with a user and password Before we can set up our… Continue reading »


Chess pieces

What is Game Theory?

Game Theory is a mathematical discipline developed by one of the most influential figures in computer science, John von Neumann. Simply put, it is the study of strategies of rational decision makers in games. From that description alone it may not be immediately obvious why that game theory is an influential field, or why it's even of interest to anyone. Game theory enables us to make predictions about how people will behave in games. The word "game" can be misleading, because the field isn't limited to conventional games but applies to all kinds of interactions between rational decision makers. Continue reading »


Servers

Copying files from a server to your local machine with SCP

Having a local version of a website for development is a necessity. Chances are, you aren't saving all the uploaded content for your website in your repository and there are many reasons you may need to download the files to your local machine. Perhaps you're working on a new machine and you've checked out a copy of the project. You have a copy of the database with all the posts and pages but you're missing all the associated files and this can interfere with development in some cases. Or perhaps you haven't worked on the site in 6 months and… Continue reading »


A laptop and notepad

Compressing audio with FFmpeg and PowerShell

I recently had a folder full of audio files which I wanted to compress and I found that using FFmpeg and PowerShell offered a solution, so I thought I'd share what I learnt. In this short guide we'll learn how to use FFmpeg, a command line based program for processing of video and audio files, to make batch compression of audio files quick and easy. Continue reading »


Auditorium

The Value of Harvard’s CS50x Course

Harvard is, of course, one of the best and most well-respected universities in the world. If you've ever wondered what it would be like to be in the privileged position of students lucky enough to attend Harvard then you'll be glad to know we are living in a world where you can find out. Since 2016 their CS50x course, along with many other courses in a variety of subjects, has been available online for free. Continue reading »



The Birthday Problem

The Birthday Problem is one of those clear examples that our intuitions about probability can be severely flawed. I find these examples fascinating (see my post on The Monty Hall Problem) and I think they're valuable to learn about because they can help us improve our understanding of probability in our own lives. Most of us will never have a good enough understanding of probability to be able to accurately estimate the probability of complex events but, at the very least, we can gain a better understanding of the limits of our intuitions and the kind of cases where we… Continue reading »


A control panel

Taking Control of Video and Audio on Web Pages

I’ve been using a chrome extension called Video Speed Controller for a few weeks to control speed of videos on web pages which was a productivity-hack recommended by Wes Bos on the excellent Syntax podcast, which he co-hosts alongside Scott Tolinski. As Wes pointed out, most video on the web is just HTML5 video elements and that is what allows plugins of this kind to work. Recently, my friends were discussing the lack of basic functionality, such as even a pause button, on many videos on the wb. I was already familiar with the HTMLMediaElement properties and methods, which I've… Continue reading »