Blog

We offer the articles below in the hope that they will be useful, but we cannot accept liability for any problems caused by the instructions that they contain. If you have a problem, question or feedback relating to one of our articles, please post a comment so that other readers can benefit. We regularly review comments and reply or update the articles, to ensure their continued usefulness. All articles are provided free, without any advertising or tracking, for the benefit of the technical community.

If you require paid commercial support, please contact us for assistance.

Next.js external Script onLoad quirk in Head

Sometimes it’s necessary to load external JavaScript into a React/Next.js system. There are various ways of doing this, but one of the most commonly recommended is via Next.js’s <Script /> component. Today I discovered a strange quirk. If you load the script inside a Next.js <Head /> component, then the onLoad function must be a conventional JavaScript onload function, not a React function. If you try to use a React function, it will not run, but there will be no warnings.

Automatically monitor and restart Linux processes using monit without a process ID pid file

On some of the servers that I maintain, I use monit to monitor the status of key system services. I have it set up to try and automatically restart the service and only notify me if it’s unable to restart it. This helps to keep everything running smoothly without manual intervention.

How to enable the PHP opcache JIT compiler on Debian Bookworm

PHP 8.0 introduced a new JIT compiler, which theoretically decreases the processing time for PHP-generated content. According to the official instructions, it’s very easy to enable, but it is disabled by default in Debian and requires some slightly different configuration changes to re-enable. Be aware that the Debian maintainer decided to disable it due to reports of segfaults from some users.

How to purge residual config packages on Debian and Ubuntu

The apt package management system often ends up uninstalling packages but leaving behind their configuration files. For many years it’s been easy to find them using the command dpkg -l | grep --perl-regexp '^rc', but it required fiddling around with shell commands to purge the packages (remove the leftover configuration files) because apt didn't support a way of filtering them by installation state. Since apt version 2.0 this is no longer the case, but I always forget the command and searching online usually turns up the old and overly complicated way of doing it.

Suppress PHP deprecated warnings from wp-cli

This is a follow up to my previous article on automatically updating WordPress using wp-cli. A number of the sites that I maintain run on servers that have been upgraded to PHP 8.x, but some of their plugins and themes include deprecated code. As a result, every time that cron runs to check for updates, I get a load of PHP Deprecated warnings. Searching online suggested a few fixes, but none of them worked for me, so I developed a different workaround.

Things that didn’t work:

Configuring an L2TP/IPsec VPN client on Ubuntu for specific IP addresses only

Every few months I have to set this up on a new machine, and it’s always very confusing because most VPN instructions are for Windows, Mac or mobile devices. Ubuntu’s GUI tool for managing VPNs is quite powerful, but not very intuitive. Here’s how to find all of the necessary options.

How to prevent text from auto-selecting when focusing an HTML input element

Quite frequently I start typing text into an HTML <input type='text'> element, then Alt-Tab to a different window to look something up, then Alt-Tab back to continue typing. Firefox automatically selects all of the text when the input field is refocused, which causes me to overwrite it because I automatically start typing  with the expectation that it will continue where I left off. Here is a partial mitigation for that:

Create a Custom Drupal Views Style module

What problem are we trying to solve here?

Views is a Drupal tool for organising blocks of information that repeat: it’s great for rows in a table, items in a list, and panels in a grid. But our project needed something that didn’t neatly fit any of these models, and in a sense was a bit of all three. So, rather than try to bend the defaults to our will and wrangle with the inevitable compromises, the obvious thing to do was create our own option.

I struggled to find a straightforward tutorial on this, so this is how I went about it.

How to set up a minimal server with Monit and email alerts using MSMTP

Recently, I was setting up a Debian server on an old laptop with the sole purpose of running Draytek's VigorConnect software to monitor and manage the network on my campus (which uses Draytek switches and wireless access points). There are plenty of cloud-based management AP controller options, but I wanted a local, self-hosted option because our internet has been patchy in the past, and because I don't want any monthly license fees.

Fixing XFCE lock screen bug in Ubuntu 23.04 Lunar Lobster

There’s a bug in the latest version of Ubuntu, whereby the XFCE4 lock screen repeatedly crashes. It’s already been fixed upstream in version 4.18.0, but as yet a fix has yet to be backported to Ubuntu. The fix is fairly simple, so I applied it to the current Ubuntu package and rebuilt it. Below are notes on how to do that.

First, edit your apt sources list to enable source download. Make sure that /etc/apt/sources.list includes the following line, uncommented (leave the other lines unchanged):