Pragmatism in the real world

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.

Internet Speedtest from the command line

We recently changed ISP to Aquiss who could not have been more helpful with pre-sales and support for the change over from BT Internet. Aquiss do not provide a router, so I removed the BT Smart Hub and put in a Ubiquity UCG-Max and connected it up to my existing AC Pro Ubiquiti access points. Obviously as it was a new provider, I tested the speed with WiFiman on my phone and was surprised that… continue reading.

Running DisplayLink Manager on Mac without the purple icon

I recently acquired an Elgato Prompter which acts as an additional screen on my Mac. It does this using DisplayLink and the DisplayLink Manager app needs to be running. A new security feature of the newer macOS versions is that when your screen is being recorded, an icon is displayed in your menu bar. It looks like this and cannot be disabled: Certainly unmissable! This icon is displayed nearly all the time DisplayLink Manager is… continue reading.

Testing internal network speed with iperf3

I've been playing with different Ethernet network adapters to see if I can maximise the throughput to my Mac as my ethernet didn't seem particularly faster than WiFi. To test the speed, I want to use my internal network only as going onto the Internet will create too many variables. iperf3 is the solution for this. Running the test To run a speed test with iperf3, you need two computers: one to act as the… continue reading.

Prepending to the terminal's prompt

For some work I'm doing, I have been given access to a Linux box that is part of a legacy production system. The first thing I have done is updated the terminal prompt to include the word PRODUCTION in red, by adding this to .bashrc: export PS1="$(tput setaf 1)PRODUCTION $(tput sgr0)$PS1" The nice thing about doing it this way is that I don't have to worry about whatever is in PS1 already. Not the most… continue reading.

Parsing command line arguments in Python

This is one of those posts that I write so that I can look it up again as this information is all over the Internet, but it took me a little while to find what I was looking for. To accept command line arguments in a Python script, use the argparse package: import argparse You can then instantiate a parser and add arguments you want to accept: parser = argparse.ArgumentParser(description="Convert a JSON array to JSONL… continue reading.

Defining Python dependencies at the top of the file

Earlier in the year, I wrote about updating Flickr metadata using Python. For this script to work, I needed to install the flickrapi package first. I recently came across PEP 723 – Inline script metadata that makes this much easier for single file scripts like my sync-flickr-dates script. Essentially, we can now put a special comment block at the top of the file, before our import statements like this: # /// script # requires-python =… continue reading.

Selecting the correct iPhone to mirror in macOS Sequoia

There's a new feature in macOS Sequoia that allows mirroring of your iPhone to your Mac. This is a nice feature that allows you to fully interact with your iPhone as an app on you Mac's desktop. When I upgrade to Sequoia and run the iPhone Mirroring app, it selected Victory, my old iPhone 14 Pro Max which is running an older version of iOS. This didn't work and there is no way within the… continue reading.

Installing PyMuPDF on a prerelease Python

I recently installed Python 3.13.0 rc2 to test rst2pdf against it and found that I couldn't install PyMyPDF which is required for the tests. $ pip install pymupdf … This is because for a pre-release version, binary wheels are not provided to PyPI for the mupdf dependency which is written in C++. Hence, the compiler needs the headers. On my Mac, I had the CPATH environment variable set to /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include. For mypdf to compile, I… continue reading.

Scripting News is 30 years old

Last week, Dave Winer posted that Scripting News turned 30. That's an amazing milestone and Dave's still writing daily. 1994 seems like quite a while ago; the web was only 3 years old! I started blogging in 2003 on a personal domain and added this blog in 2005. I don't write daily though and I tip my hat to Dave. His writing is also really really good. Scripting News was the catalyst for the creation… continue reading.