So, suddenly, I'm 50 years old. Almost a quarter of my life behind me.

50 really doesn't seem that bad. 40 felt much more like an oh-man-I'm-old-and-have-wasted-my-life event. I'm much happier now than I was then. This has been a great decade for me. I met a wonderful woman, and we are celebrating our ninth wedding anniversary this year. I live in a comfortable house with people and dogs who make me feel connected and loved (most of the time). Being 50 and happy is much better than being younger and miserable.

What's Good on TCM This Week?

I like old movies. In the old days, we had TV stations known as "UHF channels" that showed lots of old movies all night long. But UHF channels are gone, and today all we have is the Turner Classic Movies (TCM) channel and website.

I like film noir, sci-fi, horror, and westerns. TCM has a lot of these movies, but it also shows a lot of stuff I'm not interested in. I don't like browsing the upcoming schedule via the TCM website or via my cable provider's interface, so I wanted a way to generate a schedule just for me so that I can record good stuff on my DVR, or watch available movies on Watch TCM or my cable provider's on-demand service.

It turns out that TCM offers a web services APIs that allow one to retrieve schedule information. So I've whipped up a script that that grabs the schedule for the next week and identifies the movies that match my preferences.

The result is a web page: What's Good on TCM?.

The page displays the movies coming up during the next week that might "good" according to my taste. You can click the name of a movie or name of a director, actor, or screenwriter to search the TCM database for more information.

Your preferences may not match mine. That's OK; if you are a computer person, you might be able to customize my script to find your musicals or romances or screwball comedies or whatever it is you want. It's available on GitHub: https://github.com/kristopherjohnson/kjtcmws.

cxxforth: A Simple Forth Implementation in C++

Because implementing obsolete programming languages is a great use of my free time, I've created cxxforth, an implementation of Forth in C++.

Inspired by JONESFORTH, I wrote it in the style of a tutorial. The source code is automatically converted to a pretty-printed format: https://github.com/kristopherjohnson/cxxforth/blob/master/cxxforth.cpp.md.

Now, on to the next waste of my time...

A Gforth Interface to the wiringPi Library

I recently obtained a Raspberry Pi, an Arduino, and a model train set. This should keep me busy and out of trouble for a while.

My plan is to use the Arduino to read sensors and control the turnout switches on the track, but I think it is easier to use the RPi to do some initial experimentation with driving relays and other electronic components. I did the typical make-an-LED-blink exercise using the wiringPi library. It wasn't difficult, but I wished there was an interactive way to play with the GPIO pins, rather than going through a cycle of editing, compiling, and executing a C program whenever I wanted to try something.

Then I remembered Forth. Forth was designed as an interactive language for controlling hardware, and seemed like the perfect solution for me.

After looking at a few possibilities for Forth-based solutions, I decided to use Gforth, as it provides a straightforward way to call functions in the wiringPi library without the need to build my own Forth.

Here is my Gforth interface to the wiringPi library: https://github.com/kristopherjohnson/wiringPi_gforth

Now, back to the train set...

Performing Privileged Operations in an OS X Application

I am currently developing an OS X application. The application needs to perform some operations that require root privileges (installing and uninstalling launchd daemons, sending signals to other users' processes, etc.) So I started looking for some documentation about how to do that. I figured it would take a few minutes.

A day later, I finally think I understand it. The solution isn't complicated, but learning about it was difficult for a few reasons:

  • Apple's "Authorization Services Programming Guide" is woefully out of date. It tells you to use AuthorizationExecuteWithPrivileges(), but that has been deprecated since OS X 10.7. It also has links to sample code that doesn't exist anymore. (Apple developer documentation people: It seems many of your docs are way out of date. Pls fix.)
  • Apple provides a SMJobBless sample that purports to demonstrate how to use the new SMJobBless() API that replaces AuthorizationExecuteWithPrivileges(). However, while it does indeed install some kind of service that could in theory run as root, the service it installs doesn't do anything, so it is useless as an example. (But you could waste a lot of time with it before you figure that out.)
  • A lot of old documentation and sample code for the original low-level XPC API is still floating around, but once you have a clue (which I didn't), you'll just use the high-level NSXPCConnection API.

So, in the hope I can help others avoid this tortuous path, here is how i would suggest others learn how to do this:

And here is what I wish somebody could have told me before I started:

  • What you will need to do is create a "helper tool" application to perform the privileged operations. This will be a command-line app that creates an XPC listener and handles requests.
  • The helper app has to have an info.plist and a launchd plist with some magical keys (see the EvenBetterAuthorizationSample for details)
  • The helper app will be embedded in the main app's package.
  • The main app will use the AuthorizationCreate() and SMJobBless() functions to authenticate the user and install the helper tool as a privileged launchd service. (This is the point where the system will display a dialog asking the user for an admin username and password.)
  • After the helper tool is installed, use -[NSXPCConnection initWithMachServiceName:options:] to connect to the helper tool. This will launch the helper tool on demand, running with root privileges.

Marathon Aborted

A few months ago, I signed up for the Chickamauga Battlefield Marathon, which will take place this Saturday (November 14). I thought I would have adequate time to train, but it hasn't worked out that way. I ran a half marathon last week, with a time of 2:30 (not great) and in my longer training runs over the past month, I've found that after mile 12, I have to do a lot of walking.

So I've canceled my hotel reservations and will not be running that marathon this weekend. Instead, I've decided I will concentrate on the half-marathon distance. When I get that down to around 2 hours, I'll start thinking about a full marathon again.

A Brainf__k compiler in C++

For fun, I wrote an interpreter for a programming language with a rude name, in C++.

It's available here: https://gist.github.com/kristopherjohnson/e5fc3d19c251dc561f62

There are other C++ interpreters for this language, but most of them look a lot more like C than like C++. My goal was to avoid archaic C-isms like pointers, fixed-size arrays, global variables, and the use of C stdio and UNIX functions, and write something that looks like "modern C++" (which may be an oxymoron).

C++ beginners may prefer to look at the code for a simplified implementation that represents my first pass at the problem. That is available here: https://gist.github.com/kristopherjohnson/55092ba62e82c2166125

A collection of BF example programs is available here: http://esoteric.sange.fi/brainfuck/bf-source/prog/. It pleases me that the ones I've tried all work with my interpreter. The hanoi.bf program is especially impressive.

Labor Day Run for Autism Half Marathon 2015

Today I ran the "Labor Day Run for Autism Half Marathon" at Fowler Park/Big Creek Greenway.

My time was 2:37. Not as good as I had expected. I was hoping for a time in the 2:20-2:30 range. I ran out of gas around mile 9, and walked a lot of the last few miles.

But, the November marathon for which I'm training still seems doable.

A Clock, using D3.js

Hey, look! I made a clock! The Apple Watch is now obsolete.

I am learning how to use the D3.js library to do data visualizations. It doesn't really make sense to consider hour, minute, and second as data to be "visualized", but this was a simple exercise to learn how to create graphical elements and animate them as the data changes.

If you're interested, you can click the JavaScript, CSS, and HTML links at the top to see exactly how it is implemented. (Note that JSFiddle is magically importing the D3 library, so you don't see that in the HTML.)

Here is another way to view the clock along with its source: http://bl.ocks.org/kristopherjohnson/1db0d39a9ed54d224ee7

Setting Up a Personal TiddlyWiki Server on OS X

For a new job, I decided to set up a personal wiki to keep notes. I wanted to keep it simple, meeting these requirements:

  • All the data is in a Dropbox folder (so it can be automatically synced between machines)
  • It must support Markdown syntax

After looking at the options, I settled on TiddlyWiki. I've used "classic TiddlyWiki" before, and liked its simplicity, but I was always a little annoyed with the weird steps you have to go through to save changes. The new version of TiddlyWiki ("TiddlyWiki5") includes support for running it as an HTTP server, so you can use it just like an online wiki.

But it took me a couple of hours to figure out how to set that up. The TiddlyWiki documentation is not clear ("not clear" is a euphemistic way of saying "terrible"). So I've written up these instructions in the hope it will spare somebody else all the frustration I had.


The following instructions assume you are using a Mac running OS X, and that you know how to use the Terminal to run commands and how to create and edit text files.

(If you're using Linux or BSD, you can probably figure out what you need to do differently. If you're running Windows, you have my sympathy.)


Dropbox is not required to run TiddlyWiki, but I use it so that my personal notes will be available on all my machines.

If you don't already have Dropbox, go to https://www.dropbox.com to get started.


The TiddlyWiki server requires Node, so you will need to install that if you don't already have it.

If you are already using Homebrew, then installation is as easy as this:

brew install node

If you aren't using Homebrew, then go to https://nodejs.org and click the Install button.

Time Machine

The first rule of using TiddlyWiki is back up your data. Using Dropbox serves as a rudimentary backup system, but it's not a real backup system.

If you haven't already set up Time Machine on your Mac, then go do it right now. See https://support.apple.com/en-us/HT201250 for details.

Installing TiddlyWiki

The TiddlyWiki server is available as an NPM module, so once you have Node installed, all you have to do is this:

npm install -g tiddlywiki

You can do this to verify it is installed and usable:

tiddlywiki --help

Initializing Your Wiki Directory

You'll need to decide where to store your TiddlyWiki data. As I'm using Dropbox, I'll store everything in /Users/kdj/Dropbox/tw, but you can use whatever directory makes sense for you.

Run this command to initialize the directory for a TiddlyWiki server:

tiddlywiki /Users/kdj/Dropbox/tw --init server

Note: you can run tiddlywiki --editions to see if any edition other than server might serve as a better starting point for you. I know that server works.

After running the above command, you should see that the specified directory contains a tiddlywiki.info file. This is the configuration file that controls how the server works.

Enabling the Markdown Plugin

TiddlyWiki's Markdown plugin is included with the distribution, but is not enabled by default. To enable it, you have to edit your tiddlywiki.info file and add "tiddlywiki/markdown" to the plugins section. When you have finished editing, the file should look like this:

    "description": "Basic client-server edition",
    "plugins": [
    "themes": [

Running the Server

With everything set up, you can do this to run the server:

tiddlywiki /Users/kdj/Dropbox/tw --server 19671

And then view it in a web browser: http://localhost:19671

Run tiddlywiki --help server to see what other options are available. You may want to use a different port, set a username/password, or otherwise customize the behavior.

Starting the Server Automatically When You Log In

It would get annoying to have to type "tiddlywiki /Users/kdj/Dropbox/tw --server 19671" every time you wanted to use your personal wiki. Let's create a launchd configuration file in the ~/Library/LaunchAgents directory that will cause it to be automatically started every time we log in.

Go to your ~/Library/LaunchAgents directory and create a file named com.tiddlywiki.plist with the following contents, substituting the appropriate path for your data directory and the paths to the node and tiddlywiki executables. (Run which node and which tiddlywiki if you don't know what those paths are.)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

After saving that file, log out and then log back in, and try to visit http://localhost:19671. If it works, great! If not, look for an error.log or output.log file in your data directory that may explain what went wrong.

Restarting the Server

Unfortunately, using Dropbox to sync TiddlyWiki data between machines does not work as expected. The TiddlyWiki server does not monitor changes to the filesystem, so even though Dropbox will copy changed files between machines, each TiddlyWiki instance just keeps displaying whatever data it read when it was launched.

So, after saving changes on one machine, we have to restart the TiddlyWiki server on the other machines to have those changes displayed everywhere.

The TiddlyWiki developers may eventually fix this, but in the meantime, we can define some shell commands to make it easy to restart the server when necessary. Add these lines to your ~/.bashrc file:

export TWPLIST=~/Library/LaunchAgents/com.tiddlywiki.plist
alias twstart="launchctl load $TWPLIST"
alias twstop="launchctl unload $TWPLIST"
alias twreload="twstop && sleep 1 && twstart && echo 'TiddlyWiki restarted'"

With these definitions, you can just execute twreload and refresh your browser whenever you sit down at one of your computers, and that local TiddlyWiki will refresh itself from Dropbox.

Further Steps

Once you have everything working, explore the TiddlyWiki website to learn more about how to use it.

One of the first things you'll want to do is click the gear icon to go to the Control Panel and customize the site title and other settings.

Syndicate content