Pragmatism in the real world

QAuth scopes vs user roles

There is a different between scopes and roles. A scope is the abilities that the client requests that the user can then decide if they are going to authorise that client to do those things. A role is the rights that a given user has within the application. Scope examples are "read-name", "read-address", "read-email", 'write-all", etc. Example roles might be "moderator", "user", "administrator", etc. and is used by the app to determine what the user… continue reading.

Writing out the page contents in Playwright

I recently had a problem with a failing Playwright test that only happened when running in Docker. The test that was failing was: let locator = page.locator('a[href="/login"].nav-link'); await locator.click(); await expect(page).toHaveTitle(/Log in/); The test clicks the link to go to /login and then checks that the next page's title contains the text "Log in". Not an especially complicated test, so I was quite surprised when it failed claiming that the title was blank. To work… continue reading.

Activating rather than relaunching a menu bar app on macOS

One very minor thing that's been bugging me since macOS Sequoia came out is that if you launch an app that lives in your menu bar, but also has a hidden Dock icon a second time, then the Dock icon will re-appear. This happens to me a lot because I use Alfred to launch apps and also to bring an app to the front. This works because opening a running app will bring it to… continue reading.

Using uv as your shebang line

I create a fair few scripts in my ~/bin/ directory to automate tasks. Since discovering uv and inline script metadata, I've started using Python far more for these. As ~/bin is on my path, I want to run the script by calling it directly on the command line. To do this, I use this shebang: #!/usr/bin/env -S uv run –script The command line will now run uv run –script and pass the file as the… continue reading.

Always expand the Fantastical editor popover

My preferred calendar app for the Apple ecosystem is Fantastical as I've found that it meets my needs well. One minor irritant is that the editor popover defaults to a collapsed view and I have to expand it to see everything, in particular the notes field which I use frequently. I recently discovered that there's a hidden preference to change this. It's set via a custom url of x-fantastical3://defaults?key=AlwaysShowAll&value=1&type=bool&group=1. Just click this link to set… continue reading.

Global git ignore patterns

One thing that I've found helpful is to add a set of patterns to my global git ignore file (config/git/ignore for me) that allow me to create temporary files that are automatically excluded from git. The patterns I use are these: # Ignore a file by renaming it with ignore its name *.ignore ignore.* *.ignore.* This lets me create a file with a prefix ignore., a postfix of .ignore or add .ignore. somewhere in the… continue reading.

Enabling a focus mode when an app is running on Mac

When I'm on a Zoom or FaceTime call, I want stop all notifications on my Mac so that I'm not distracted by them and would like this automated. It's not easy to tell when a call is happening, so I simplified the problem to stopping all notifications if the Zoom or FaceTime is running as I only run these apps if I'm on call. To do this, I created two Shortcuts to turn the Do… continue reading.

2024 in pictures

As usual, at the end of the year, I look back over the photos I have taken and think about the year. This year I have published 1162 photos to Flickr. It has been a good year, seeing friends and family, taking photos, attending conferences all coupled with enjoyable work for a good client. I am pleased to have kept up with taking a least one photo every day as part of my Project 365,… continue reading.

Developing rst2pdf with uv

Thanks to Kyle and Lorna, we've moved rst2pdf's development out of the dark ages of setup.py and into uv with pyproject.toml. As a result, I've changed the way I develop rst2pdf locally; these are my initial notes. Set up Python environment Given a clone of the rst2pdf git repository, do this get going: $ uv sync –all-extras This will create a virtual environment in .venv with all dependencies installed. It will also install Python if… continue reading.

Sunrise and sunset times on the Mac command line

I recently discovered the /usr/libexec/corebrightnessdiag command line tool on macOS. In particular, /usr/libexec/corebrightnessdiag nightshift-internal will give information about when the Mac's nightshift settings, including when sunrise and sunset are! $ /usr/libexec/corebrightnessdiag nightshift-internal Night Shift Status { AutoBlueReductionEnabled = 1; BlueLightReductionSchedule = { DayStartHour = 7; DayStartMinute = 0; NightStartHour = 22; NightStartMinute = 0; }; BlueReductionAvailable = 1; BlueReductionEnabled = 0; BlueReductionMode = 0; BlueReductionSunScheduleAllowed = 1; Version = 1; } Night Shift Sunset/Sunrise {… continue reading.