Using DDclient for dynamic DNS on Amazon EC2

When using Amazon EC2, IP addresses of your instances are assigned dynamically when launched. If you are bring up and down instances frequently, it can be helpful to use a dynamic DNS service so you can use a consistent hostname for your instance, event if it's IP address changes.

DDclient is a command line tool which works with a variety of dynamic DNS providers and is available pre-packaged on many Linux distributions (e.g. apt-get install ddclient on Ubuntu 14.04). DDclient can use various methods to look up the IP to use. In this case, I want DDclient to use the EC instance's external IP address. One method is to look up the IP from a specified web page, usually used with a site like or

On an EC2 instance, we have another option: Instance Metadata. You can fetch all kinds of useful metadata about an EC2 instance using a REST API served from To retreive the public IP address (IPv4) of a running EC2 instance, fetch from that instance. To use this with DDclient, include the following line in your DDclient config file:

use=web, web=

Fun with Sikuli and Baldur's Gate

A few months ago I was playing Baldur's Gate: Enhanced Edition (BGEE), and going through the character creation process. The game chooses the character's initial statistics by simulated random dice rolls. You can re-distribute points between different attributes as you desire, but you can only increase the total number of points by re-rolling. You can re-roll as many times as you want, hoping to get a higher total number of points. You can also "store" and "recall" a single roll.

The lazy programmer in me saw this as an a task begging for automation.

I spent the next several hours developing a Sikuli script which automates the process of re-rolling until a desired total roll is reached. I've finally gotten around to cleaning up the code and releasing it on github as BGEE_Sikuli_auto_roller.

Here's a video demo (painfully edited in iMovie) of BGEE_Sikuli_auto_roller in action:

Happy dungeon/code hacking!

Python Markdown Extension for Inline Gist

As discussed in this thread on the Nikola forum, I'd wanted a way add a custom inline "gist" directive to Nikola which I could use in my markdown posts to include the full contents of the gist in a <noscript> tag. This makes gist contents available in the site RSS feed and when viewing the site with Javascript disabled. Here's a gist (of course) with the Python Markdown extension that makes this possible:

Read more…

Today I set up a new coding blog on I've tinkered in the past with Blogger and Tumblr, but this time I decided to go with a different solution which gives me more control of my content. This site is generated using Nikola, a static site generator implemented in Python. Hosting is provided via Github Pages (see the repo).

I've been writing lots of little Python scripts and JavaScript bookmarklets lately which I hope to share here. Perhaps some Grails/Groovy/Java discoveries from my day job will also find there way here.

Open in SourceTree from IntelliJ IDEA

I'm quite fond of SourceTree for managing Git repositories (it does Mercurial as well). SourceTree comes with an stree command to open repositories from the command line. I wanted to set up an external tool in IntelliJ IDEA to the repo containing the current source file, stree only works if you call it without any arguments with a current working directory of the root level of a repo, or if you pass the path to the root level of a repo as an argument. This is fine if you have only a single Git source root in your IntelliJ project: You can just use call stree directly with the $ProjectFileDir$ macro as a parameter. But if you have multiple modules in your project with different Git source roots, it gets more difficult. I tried using the $ModuleFileDir$ macro, but this seems to the directory where the .iml file for the module is stored, which is not the source root of the module.

So, I ended up writing a small wrapper for stree which can take the path to any file or directory within a Git or Mercurial repo as an argument and invokes stree with the path to the root of the repo:

Read more…

Contents © 2010-2018 Michael Rabbitt - Powered by Nikola