Macos

Partitioning a large directory into subdirectories by size

Since I’m not fond of carrying around all my photos on a cell phone where they’re perpetually at list of loss, I peridiocally dump the image and video files to a drive on my desktop for later burning to optical disc.1 Saving these images in archival form is a hedge against the bet that my existing backup system won’t fail someday.

I’m using Blue-Ray optical discs to archive these image and video files; and each stores 25 GB of data. So my plan was to split the iPhone image dump into 24 GB partitions. H

An alternative method for keyboard input switching on macOS

macOS offers a variety of virtual keyboard layouts which are accessible through System Preferences > Keyboard > Input Sources. Because I spend about half of my time writing in Russian and half in English, rapid switching between keyboard layouts is important. Optionally in the Input Sources preference pane, you can choose to use the Caps lock key to toggle between sources. This almost always works well with the exception of Anki. Presumably Anki’s non-standard text management system thwarts the built-in Caps Lock/toggle mechanism for reasons that are not clear to me. Equally unclear is why this worked previously but now does not. I’ve not updated either Anki or the system software. It’s a mystery. Nonetheless, began to search for an alternative method for switching between keyboard layout switching. What I developed relies on several tools:

Scripting thumbnail image file creation on macOS

One of the sites that I manage uses a jQuery-based image gallery to display images in a grid. The script decides which thumbnail to use based on how large and image is needed. A series of suffixes à la Flickr^[Well, sort of. I don’t think this is exactly what Flickr uses; and I made up the _q suffix for the less than 500px image.] is used to signify classes of image size. I wrote the following script to automate the process of scanning a source folder and creating four thumbnail sizes to an output directory.

Setting up Arduino IDE with Heltec ESP32 module for macOS

Heltec WiFi Kit 32 ESP32 module

The Heltec WIFI Kit 32 is an interesting little module that integrates a WiFi/MCU SoC and a small OLED display on a single board. If you want to set up the Arduino IDE to work with this device and you’re on macOS, this is for you. This particular ESP32 module has a number of impressive features: 240 MHz processor speed and 4 MB of flash memory. The onboard OLED display can be conveniently used for debugging.

Using macOS NSSpeechSynthesizer to generate audio content for Anki cards

As I’ve written before, I use Anki for Russian language learning. One of the skills to master in learning a foreign language is to quickly speak and recognize numbers. With a little help from macOS, I’ve developed a way of rapidly creating audible content of spoken numbers for my Anki cards.

That’s the good news. The bad news is that as of right now, you’ll have to have Xcode and build the app yourself. Someday, I’ll deal with all the official certificate stuff again (I’ve not developed apps seriously for iOS or macOS for several years now.)

AppleScript and iTerm2

Among the many reasons I use iTerm2 in lieu of the macOS Terminal is its AppleScript support.

I recently had the need to automate some tasks on my Amazon Web Services EC2 server in a way that takes advantage of iTerm2 AppleScript functionality.

Use case

I’ve found recently, that my screen sessions were disappearing. Although I haven’t completely excluded other causes, some have suggested that infrequently-reconnected sessions can be cleaned up. Since I’m not a Unix sysadmin, I’m not sure about this. However, I decided to test the hypothesis by writing an AppleScript that logs into my EC2 server, attaches to each screen session, detaches and closes the connection.

Spotlight-searchable pinboard bookmarks

I use the excellent, dependable Pinboard service for managing my bookmarks. A one-time fee gives you lifetime access to the service; and there is an API that has fostered an ecosystem of desktop and mobile apps that interact with the service. Of course, Safari can synchronize bookmarks among devices; but it doesn’t allow tagging. Since tagging is a major part of my workflow, Safari bookmarks don’t work for me.

So, here’s where pinboardspotlight.py comes in. It’s a relatively simple Python program that downloads your Pinboard bookmarks, writing them to local .webloc files and applying the tags you’ve used in the Pinboard metadata to the local files. Now you’re Pinboard bookmarks are searchable locally.