Articles

Drawing A Parabolic Curve With Straight Lines In PHP

A parabolic curve is a type of curve where every point is an equal distance from a focal point. There a number of different way to generate this sort of curve using math, but one of the simplest is to use straight lines to create the illusion of the curve.

The curve is created by diving two axis into equal points and then drawing a line from the first point on one axis to the last point on the opposite axis. Each line of the curve is drawn in the same way, repeating the process of drawing a line between opposite points for every point along the axis.

LocalGov Drupal Camp 2024

April 23rd, 2024 saw the first LocalGov Drupal Camp, held at the Birmingham Council buildings in Birmingham city center.

It's been ages since I attended an in person Drupal Camp in the UK, so when I saw that the LocalGov Drupal people were organising one just down the road for me I jumped at the chance to grab a ticket.

LocalGov Drupal is a distribution that combines Drupal, some configuration, some contributed modules, and some glue code with the aim of making it easier for councils to generate sites.

Drupal 10: Adding Extra User Account Protection

One of Drupal's strengths is its ability to create communities of users who contribute towards the content of the site. Whether you have an open forum, where users can create their own accounts, or a closed magazine with just a few editors your need to take the security of your users seriously.

Out of the box, Drupal has a number of account protection features that assist in making sure that users are authenticated correctly.

For example, the user login page is protected by a brute force system and will lock accounts after a number of incorrect password attempts in a short amount of time.

Getting Started With Git Bisect

Git bisect is a git command that makes it easier to track down where a problem was introduced to a codebase.

In large projects you may find that a change was added to the code that causes a problem and you then need to track down where that problem occurred. Knowing where the problem was introduced makes debugging the issue a lot easier.

You could just checkout commits until you find the culprit, but git comes with the bisect tool that can assist in this process and can even be automated to quickly find the problem.

Recreating Spotify Wrapped In PHP

I quite like the end of the year report from Spotify that they call "Wrapped". This is a little application in which they tell you what your favorite artist was and what sort of genres you listened to the most during the year. It shouldn't come as a surprise to me that I listened to this or that, but since I listen to Spotify around 30-40 hours a week I certainly lose track of what my favorite artist was that year.

This years report got me thinking about how difficult it would be for me to generate my own Spotify report, whenever I wanted. Maybe to see who I had listened to the most during the week, or what sort of genres I was into at the moment.

Lily58 R2G Mechanical Keyboard

Last year I was looking through the shop at Mechboards and saw that they had a number of Lily58 R2G (ready to go) kits available. These are kits that have all of the soldering done and are pretty much complete, they just need some switches, keycaps and assembly.

My trusty Keychron K2 has been my daily driver for about 3 years now, so I was looking for something a bit different to type on. I have found that if I try to swap to a keyboard that is similar to the K2 I end up hitting the wrong keys.

Should A Constructor Throw An Exception?

Let's say you had a class that you wanted to use, but there was some sort of error in creating the object. This might be that the wrong parameters were passed, or the third party service (eg. a database) wasn't available at the time of creation.

If this happens you'll obviously want to handle the error correctly, but the question is would you throw an exception in the constructor or handle the error condition elsewhere?

Note that this article will talk about PHP, but the same discussion applies to other languages that implement OOP principles.

That Time I Dropped The Production Database

I was reminded recently about how a GitLab engineer managed to delete the prod database, and that got me thinking about one of my biggest (production) mistakes.

It's been at least 5 years since this happened so I think it's safe to tell the story of when I dropped a production database of one of my clients.

At the time I was working on a (pretty large) Drupal website for an international organization. The site consisted of an extensive content area and allowed users to make anonymous purchases through the website, which were sent to a CRM every night. It was hosted on the Acquia platform and used BLT to perform the day-to-day development operations on the site.

Solving Query Performance Problems With The MySQL Slow Query Log

MySQL's slow query log is a key component in your MySQL administration setup. Whilst normal logging can help you in terms of tracking down issues with your database system, the slow query log can help you track down issues in your database setup before they become problematic.

Getting the slow query log set up correctly can help you find and solve issues with slow database queries before they become more problematic. Most slow queries will work fine when there's just a few rows, but as your data grows so will the time taken to find the data. Having the slow query log in place will show these queries and help you do something about them.

Drupal 10: Opening An Ajax Dialog On Page Load

Drupal has a quick and convenient way of creating ajax dialogs that gives users the ability to embed links in content that open up dialog boxes when clicked. This is a useful way of presenting a bit of content to a user without them navigating away from the page.

I have previously written in detail about creating ajax dialogs in Drupal, and I refer back to that article quite often when the need arises.

The simplest way of creating an ajax dialog is by adding the class "use-ajax" and the data-dialog-type attribute, which can be one of dialog, dialog.off_canvas, dialog.off_canvas_top and modal. Using the "use-ajax" class tells Drupal that this is an ajax link and to intercept the click to perform an ajax request.