programming

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.

Sunday, September 16, 2018

Regex 101 is a great online regex tester. Speaking of regular expressions, for the past year, I’ve used an automated process for building Anki flash cards. One of the steps in the process is to download Russian word pronunciations from Wiktionary. When Wiktionary began publishing transcoded mp3 files rather than just ogg files, they broke the URL scheme that I relied on to download content. The new regex for this scheme is: (?

Serious audio processing on the command line

I’ve written previously about extracting and processing mp3 files from web pages. The use case that I described, obtaining Russian word pronunciations for Anki cards is basically the same although I’m now obtaining many of my words from Forvo. However, Forvo doesn’t seem to apply any audio dynamic range processing or normalization to the audio files. While many of the pronunciation mp3’s are excellent as-is, some need post-processing chiefly because the amplitude is too low.

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.

Extracting mp3 file from web page with Python and ApplesScript

As I’ve mentioned before I use Anki extensively to memorize and practice Russian vocabulary. With language learning in particular, adding spoken pronunciations to the cards makes an enormous difference. Since I use Open Russian extensively to provide information to built my Anki cards, it’s a natural source of audio data, too. To optimize my learning time, I built two small scripts to grab and rename the audio files from the Open Russian site.

Using Python and AppleScript to get notified if a site is down

I manage a handful of websites, like this one. Having built a few on other platforms, such as Drupal, I’m familiar with the dreaded error “The website encountered an unexpected error. Please try again later." On sites that I don’t check on frequently, it can be an embarrassment when people begin emailing you with questions about the site being down. I wrote the following Python script to deal with the problem:

Import and tag with Hazel and DEVONthink Pro Office

Hazel and DEVONthink make a great pair as I’ve written before. Using AppleScript, it’s possible to take the import workflow even further by tagging incoming files automatically. Use case I download a lot of mp3 files containing pronunciation of words in a language I’ve been learning. I keep a record of these words and tag them appropriately using my hierarchical tagging system. I’d like to download the files to a directory on the desktop.