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:

I'll be sending a push request shortly to get this integrated into Nikola. Thanks to Roberto Alsina for already gist support to reStructuredText posts in Nikola.

Update: Pull request accepted!

Confluence numbered heading bookmarklet

This bookmarklet adds hierarchical section numbers to the section headers on the current confluence page. Note that it does not permanently change the content of the page; it only transforms the displayed HTML until the page is re-loaded. One of these days I'll figure out how to get this to work as a user script.

Confluence numbered section header bookmarklet


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.

Python Script to download Splunk Documentation PDFs

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:

Diff-ing .zip files with FileMerge

This isn't particularly elegant, but you can use the FileMerge application that comes with Mac OS X developer tools to compare the contents of zip files using a custom filter.

Create a script ~/bin/zip_filemerge_filter.bash with contents:

#  List the size, CR-32 checksum, and file path of each file in a zip archive,
#  sorted in order by file path.
unzip -v -l "${1}" | cut -c 1-9,59-,49-57 | sort -k3
exit $?
Make the script executable (chmod +x ~/bin/zip_filemerge_filter.bash).

Open FileMerge, open the Preferences, and go to the "Filters" tab. Add an item to the list with:

  • Extension: zip (I've also added the filer for .jar and .war files.)
  • Filter: ~/bin/zip_filemerge_filter.bash $(FILE)
  • Display: Filtered
  • Apply: No

Then use FileMerge (or the command line opendiff wrapper) to compare two .zip files.

This won't let you diff the contents of files within the zip archives, but will let you quickly see which files appear within one only archive and which files exist in both but have different content (i.e. different size and/or checksum).

(Cross-posted on StackOverflow and my old blogger blog.)

Contents © 2010-2017 Michael Rabbitt - Powered by Nikola