Pragmatism in the real world

BBEdit Hosts File Syntax Highlighting

While editing my Hosts file in BBEdit, I wondered how hard it would be to create syntax highlighting for it. A quick google later, I discovered that I needed to create a Codeless Language Module and this is my first attempt: To install, download Hosts.plist and copy to your iCloud Drive's BBEdit/Application Support/Language Modules directory, restart BBEdit and you're done. I've kept it really simple and just highlight comments and the IP address, but it… continue reading.

Background images and multiple styles in rst2pdf

Over the weekend I released rst2pdf 0.99. The list of changes is quite long as it's been over a year since the last release. There are some key things in this release that I'm particularly pleased about including Python 3.9 and 3.10 & Sphinx 4 support, multiple styles in the class directive and the ability to specify background images in the raw:: pdf directive. There's also a number of bug fixes, particular to math rendering… continue reading.

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.