programming

Using AppleScript with MailTags

I’m a fan of using metadata to classify and file things rather than declarative systems of nested folders. Most of the documents and data that I store for personal use are in DEVONthink which has robust support for metadata. On the email side, there’s MailTags which lets you apply metadata to emails. Since MailTags also supports AppleScript, I began to wonder whether it might be possible to script workflows around email processing.

Waking the computer to allow AppleScript to run

I have a number of AppleScript applications that need to run at odd times. These maintenance tasks often attempt to run while the computer is sleeping. Particularly those that rely on UI scripting do not function during this period. This most flexible way of dealing with this is to manipulate the power management settings directly via the pmset(1) command. The variety of options available using pmset is staggering and beyond the scope of this post.

Resizing of images for Anki with Hazel and ImageMagick

I use Anki to study foreign language vocabulary. It’s the de facto spaced repetition software for memorization.^[Yes, I’m aware that others exist. I’ve tried many but always have come back to Anki.] When making flashcards for language learnings, I try to use imagery as much as possible. So a card may have a Russian word on one side and just an image on the opposite side. (Since I already know the English word that the image represents, why not try to engage a different part of the brain to help with memorization?

Writing Hexo filters

Hexo, the static blogging system that I use is very extensible and provides numerous hooks into generation pipeline. While working on a Russian language blog that’s coming online soon, I had the opportunity to write a filter to render Cyrillic text in a different font than the rest of the body text. Markup filter use case I wanted to set the Cyrillic text apart both in color, typeface, and font weight.

Fine-tuning caching for S3-hosted static blogs using AWS CLI

Because the blogging system that I use doesn’t apply finely grained object-level caching rules, I end up with objects such as images that cache appropriately but an index.html page that does not. I don’t want client browsers to hang on to the main index.html page for more than an hour or so because it should update much more frequently than that as its content changes. It’s possible that I could dig around under the hood of hexo and create a version that applies customized caching rules.

JavaScript in Anki cards

[N.B. 2016-03-26 Nathan Ifill pointed out that it is possible to use Anki’s built-in conditional replacement feature to do what I’m illustrating. I’ll have to work on another example!] Anki is a widely-used flashcard application. If you’re learning a foreign language and you’re not using Anki, you should be. If you are using Anki and are picky about the appearance of the cards, you should know that JavaScript can be used in the card template.

Detecting Russian letters with regex

How to identify Russian letters in a string? The short answer is: [А-Яа-яЁё] but depending on your regex flavor, [\p{Cyrillic}] might work. What in the word does this regex mean? It’s just like [A-Za-z] with a twist. The Ёё at the end adds support for ё (“yo”) which is in the Latin group of characters. See this question on Stack Overflow.

A new hexo deployer for Amazon web services

I recently migrated this and my other blog to Hexo which is a very fast static blogging framework built on node.js. As when I used Octopress, this blog is still hosted from an AWS S3 bucket. However the deployers that I tried with Hexo failed because of dependencies that were incompatible with the OS X version I was running. Not being a node.js expert, and having no time to delve into node.

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.

Markdown anchors

TIL how to use anchors in Markdown documents. I needed to use this in a long blog post in my Octopress blog and was stymied. As usual, I found the answer on Stack Overflow. Beam me up, Scotty <a id="enterprise"></a> It’s a great way to move around in longer content. 2014-03-03: I no longer publish using Octopress; but this should work in most cases where Markdown is used. Bitbucket is a notable exception.