Pragmatism in the real world

Step-debugging linked composer dependencies with PhpStorm

One project I'm working on has multiple separate parts in different git repositories that are brought into the main project using linked composer directories. I needed to get step debugging working in PhpStorm and this is the approach I took.

Completely reset Apple Watch's Mac auto-unlock

Recently, the ability for my Apple Watch to automatically unlock my Mac started failing on Big Sur betas and then on my main Catalina installation. I'm not sure, but it's possible that updating to WatchOS 7 caused it, though it might have been related to re-pairing to fix the battery life issues I was having. Or, of course, some other software gremlin! Whatever, it was annoying. Scouring the Internet, I discovered what to do in… continue reading.

Recursive PHP lint

There are many scripts that recursively execute php -l on a set of files or directories. This is mine: #!/usr/bin/env bash set -o nounset # Recursively call `php -l` over the specified directories/files if [ -z "$1" ] ; then printf 'Usage: %s …\n' "$(basename "$0")" exit 1 fi ERROR=false SAVEIFS=$IFS IFS=$'\n' while test $# -gt 0; do CURRENT=${1%/} shift if [ ! -f $CURRENT ] && [ ! -d $CURRENT ] ; then echo… continue reading.

Prevent an external drive from auto mounting on macOS

I have an external drive attached to the USB hub on my Thunderbolt Display that I use to clone my laptop's internal drive every night using the schedule feature of SuperDuper!. At the appointed time, SuperDuper! will mount the external drive, clone the internal drive and then unmount the external drive again which is very convenient. However, whenever I plug in my laptop, the drive automatically mounts. This doesn't particularly worry me, but when I… continue reading.

Ignoring mass reformatting commits with git blame

I've recently merged a PR by Stephen to rst2df that reformats the entire codebase to align with PEP 8. As rst2pdf is over a decade old, this has resulted in a lot of changes to the files which now have Stephen's name attached. This affects git blame. For example: git blame -L 137,145 rst2pdf/findfonts.py e753c71eb (roberto.alsina 2008-09-05 14:49:24 +0000 137) d56705e4f (roberto.alsina 2009-10-30 15:07:05 +0000 138) # So now we have a font we know… continue reading.

Converting JSON to a struct in Go

I'm in the process of writing a little command line app in Go that uploads images to Flickr. It's called Rodeo and it's working well as a project with which to learn Go in 2020. Rodeo uses ExifTool to interrogate an image file for meta data. ExifTool is wonderful and very comprehensive and with the -j switch can return JSON. Today I want to note down what I learned about dealing with JSON. $ exiftool… continue reading.

Validating default PHP session ID values

I recently needed to validate the value created by PHP for its session ID. After a bit of research, I realised that there are two interesting php.ini config settings that relate to this value: session.sid_length is the number of characters in the ID session.sid_bits_per_character controls the set of characters used. From the manual: The possible values are '4' (0-9, a-f), '5' (0-9, a-v), and '6' (0-9, a-z, A-Z, "-", ","). Therefore, to validate the session… continue reading.

Turn off foreign key checks when restoring a mysql file dump

I recently received a MySQL dump file where the various tables in it had foreign keys to each other. I usually restore with this command: mysql –login-path=rob < dump.sql but this generated the error: ERROR 1217 (23000) at line 288805: Cannot delete or update a parent row: a foreign key constraint fails It turns out that the easiest way to solve this is to use the –init-command switch to set foreign keys off for this… continue reading.

A logo for rst2pdf

All projects seem to have a logo these days, so I asked my friend Jane of iD to create a logo for rst2pdf and she came up with this: This met what I was looking for with a clear design that is related to the what the application does, so thank you Jane. I've set the profile icon for the GitHub organisation and Twitter accounts and we'll be using this in other places as we… continue reading.

Creating collections with the Lightroom Classic SDK

I currently organise my photo library in Lightroom Classic with one folder per day for my images and then I extensively use collection sets, collections and smart collections to manage the photos that represent an "event", regardless of whether the project is a single day, such as a family BBQ, a multi-day event such as a conference or a multi-month thing such as my Project 365 or mainline railway photos. The nice thing about using… continue reading.