Pragmatism in the real world

2021 in Pictures

2021 is over! A very strange year where I have been vaccinated against COVID-19, with an additional booster, yet I caught it and took months to recover. Fortunately, I continued to take a photo every day though my Project 365 which allows me to appreciate what happened during this year of my life. January January started out quietly with a hint of snow. I did a lot of walking, presented at The Online & my… continue reading.

Add TouchID authentication to sudo

Now that I have a TouchID enabled Mac, I want to be able use TouchID for sudo access. There's a pam module available, so it just needs enabling: Edit /etc/pam.d/sudo Add a new line under line 1 (which is a comment) containing: auth sufficient pam_tid.so (Leave all other lines in this file.) That's it. Now, whenever you use sudo, you have the option of using TouchID to authenticate. Scripting it It turns out that whenever… continue reading.

Quick script to (re)create my python virtualenv

When working on rst2pdf, I use pyenv as I've written about before. Recently, I've found myself needing to recreate virtualenvs for various Python versions and then recreate them to easily reset the list of packages installed into them via pip. To my my life easier, I created a script that I can run from the command line: $ newenv rst2pdf-dev-py3.9 3.9.5 This creates a new virtualenv called rst2pdf-dev-py3.9 from Python version 3.9.5, upgrade pip and… continue reading.

Changelog generator for GitHub milestones

For many years now, I've been using Matthew Weier O'Phinney's changelog_generator script to generate an easy-to-read list of changes for a given milestone. Time has moved on; the Laminas project now uses Laminas Automatic Releases and Matthew hasn't updated his script since 2013. Since PHP 8, warnings have started appear, so it's clear updates were required. While I fully intend to see if I can use Automatic Releases on some projects, I have others where… continue reading.

Setting HTTP status code based on Exception in Slim 4

One thing that's quite convenient is to be able to throw an exception with a valid HTTP code set and have that code sent to the client. For example, you may have: throw new \RuntimeException("Not Found", 404); With the standard Slim 4 error handler, this response is sent to the client: $ curl -i -H "Accept:application/json" http://localhost:8888 HTTP/1.1 500 Internal Server Error Host: localhost:8888 Content-type: application/json { "message": "Slim Application Error" } Ideally we want… continue reading.

A few Git tips

I don't do that much that's clever with git, but I've found the following helpful. Automatically prune When you do a git fetch or git pull, you can ask it to remove remote tracking branches for a branch that has been removed on the remote by using the –prune flag. This can be automated globally with: git config –global fetch.prune true and if you only want it for a specific repository, you can use: git… continue reading.

OpenConnect on Mac

One of my clients has recently moved to AnyConnect VPN and I've been having routing problems with the official Mac client. As my colleagues on Linux on the project have not had these issues, I investigated and installed the OpenConnect client. These are my notes after scouring the Internet to set it up how I want it. Installation I used Homebrew: $ brew install openconnect OpenConnect is a CLI tool. If you want a GUI… continue reading.

Dependency injection in Serverless PHP with Bref

When writing PHP for AWS Lambda, Bref is the way to do it. One thing I like about Bref is that you can use PSR-15 Request Handlers to respond to API Gateway HTTP events as documented in the API Gateway HTTP events section of the Bref docs. The request handler is the same as used in PSR-7 micro-frameworks like Slim or Mezzio and can be thought of as a controller action. As such, it's really… continue reading.

MailTrackerBlocker

One thing that has annoyed me about receiving email is so-called tracker pixels. These usually 1x1px transparent images that are remotely loaded into HTML email enable the sender to track information about be. A good resource about them is No To Spy Pixels. As such I've tended to run my email clients with remote resource loading disabled, which isn't the best experience as a surprising number of legitimate email even display the call-to-action link as… continue reading.

Keyboard control of Big Sur notification alerts

With the release of Big Sur, my scripts for keyboard control of macOS notification alerts stopped working. With a bit of experimentation and help from Google, I have written new ones. Closing an alert To close a notification alert on Big Sur, conceptually we want to press the X button that appears when you hover over it. The AppleScript to do this is: activate application "NotificationCenter" tell application "System Events" tell process "NotificationCenter" set theWindow… continue reading.