Projects

Cantrips

Cantrips

A cantrip is a magical spell, but just a little one.

My cantrips are small, single-file command-line scripts that I keep available in my $PATH. They're more than an bash function or an alias, but less than a full grown-up program. Some are a bit rough around the edges, but nonetheless I use most of these daily. Perhaps you'd like to too?

You can download the full set, as they're all open source, but here are some highlights.

audiobook-chapterise.py

Breaks a single-file audiobook, like an m4b file, into individual mp3 files, one per chapter. The cheap little mp3 players I use to listen to audiobooks need this, and I need them; I don't want to risk my phone while gardening, or painting, or cleaning out the chicken coop! Download audiobook-chapterise.py.

git-forgotten.py

Ever forgotten to push out your commits for the day? Or even leave some edit uncommitted? Ever get a testy message from a coworker about it? I sure have, so now I run this script before I leave the office. It quickly finds your all your git repos and bugs you if you've forgotten anything. Download git-forgotten.py.

hevc-convert.py

I like to back-up our family photos and videos, but my daughter often goes long with the recordings. I don't really need a 3GB high-bitrate zoo clips. This script just makes compressing over-large videos using ffmpeg and libx265 easy. Writing a command-line for ffmpeg can be a lot, otherwise. Download hevc-convert.py.

photorec-rename.py

Has a friend or family member every come to you with a corrupt drive or memory card desperate for you to recover their photos? If you're on my website, of course you have. Several times in recent years I've used PhotoRec, the 'digital picture and file recovery' tool. Wonderful tool, but its output is hard to work with. This script uses the EXIF data from the recovered images to build nicer file names. Sounds basic, but it saved me hours of work. Download photorec-rename.py.

redirects-test.py

I've done a lot of web work. Once caches and clients get involved getting all the DNS and redirections correct can become very troublesome. You finally get it right, and then hostnames start to expire. This little tool takes a list of URLs then prints the DNS resolution redirect chains. Download redirects-test.py.

rerename.py

Bulk file renaming. I use one this all the time. Inspired by the venerable rename Perl script, my version uses Python regular expressions and focuses on safety. Bulk renaming is dangerous enough, but add regular expressions into the mix and It's all too easy to shoot yourself in the foot. Documentation and download.

rust-clean.py

Before you know it, you've got multiple gigabytes of build files across your Rust projects. This script simply finds Rust projects under the current (or given) folder that have a target folder and runs cargo clean in them. Download rust-clean.py. For quick access, I alias it to rsc which works in well with pyc which is the bash function I use to clean up my Python projects.

sitemaps-test.py

Download a website's sitemap.xml and all of the index files that it references, and report on how many links were found, and what sort of attributes they contained. Download sitemaps-test.py.