Pragmatism in the real world

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.

Writing a Lightroom Classic plug-in

As part of my migration to Lightroom Classic from Photos, I needed to recreate my folder and album structure. In Photos, folders container albums (or other folders) and albums contain photos. An album cannot contain a folder. This maps directly to Lightroom Classic which has "collection sets" for folders and "collections" for albums. To transfer the folder and album information over to Lightroom Classic, I wrote an Apple Script for Photos that added a keyword… continue reading.

2019 in Pictures

As we reach the end of 2019, I again get the opportunity to look back at my year through the photos that I took as I have done every year since 2009. I have been doing a Project 365 for a good few years which acts as a diary too, so I have the opportunity to appreciate what happened this year in my life. January Early in January, I spent an afternoon taking photos with… continue reading.

Migrating to Lightroom Classic from Apple Photos

I recently moved over to Adobe's Lightroom Classic from Apple's Photos in order to have more flexible non-destructive editing features – in particular local brushes. Rather confusingly, there's also another Adobe product called Lightroom which is a new build for cloud-based storage which doesn't (yet?) have all the features of Lightroom Classic. In particular, the lack of virtual copies and smart collection sets make Lightroom feel like a step backwards from Photos, while Lightroom Classic… continue reading.

Routing in Slim 4

Routing in Slim 4 works pretty much exactly the same as in Slim 3. They are used to map a URL that the browser requests to a specific handler that executes the code for that particular page or API endpoint. You can also attach middleware that will only be run when that route is matched. The route in the slim4-starter looks like this: $app->get('/[{name}]', HomePageHandler::class); It is made up of the method, the pattern and… continue reading.

Keyboard shortcut to mirror displays on a Touch Bar Mac

One feature of the 16" MacBook Pro that was new to me is the Touch Bar. This thing replaces the F-keys with a touch pad that adjusts itself to the app in use in order to provide useful shortcuts you can just touch. This is all well and good, but when presenting, I use the cmd+F1 keyboard shortcut to toggle display mirroring. A useful Stack Overflow answer tells me that I can use cmd+{dim brightness}… continue reading.

My JetBrains IDE shortcuts

In the JetBrains IDEs, the "Default for macOS" keymap isn't doesn't feel very Mac-like to me, especially for keyboard navigation in particular. Apple provides details of the keyboard shortcuts you can expect to work in a Mac application, so these are the changes that I've made to make PhpStorm and PyCharm feel more at home on my Mac: Open Preferences and select Keymap from the left hand side. Then select "Default for macOS", click the… continue reading.

Dark and light mode blog images with MarsEdit

As dark mode is more popular than ever now that the iPhone supports it, I've been working out how to get the browser to render a dark image in dark mode and a light image in light mode. It turns out that the way to do this simply is to use the <picture> element like this: <picture> <source srcset="/wp-content/uploads/2019/11/example-image-dark.png" media="(prefers-color-scheme: dark)" /> <source srcset="/wp-content/uploads/2019/11/example-image-light.png" media="(prefers-color-scheme: light), (prefers-color-scheme: no-preference)" /> <img src="/wp-content/uploads/2019/11/example-image-light.png" alt="Description of example image… continue reading.