The source code for this example is available here.