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… 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… 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 »


an hourglass and various clocks

Converting Seconds Into Readable Time

Converting time into a human-readable format presents a few tricky problems. You can't simply divide by a number and get your answer because time, unlike money for example, is non-decimal; there are 60 seconds in a minute and 60 minutes in an hour and not 100. Then, on top of that, the number of hours in a day, days in a week and days and weeks in a year would seem incredibly arbitrary if it weren't for the fact that we've known them all of our lives. Continue reading »


closed doors

The Monty Hall Problem

The Monty Hall problem concerns the change in probability when reducing the number of wrong answers to a question. The problem gets its name from a game show hosted by Monty Hall in which contestants were tasked with guessing which door a prize was behind. In this game there are 3 doors, behind two of which are goats and the other a car. The doors are identical and the prize is behind a random door so the odds of picking the correct door, as anyone could tell you, are 1 in 3. Continue reading »