James Williams

Books I Read in 2016

Nadine Heidrich - Forgotten Day 33/365 - https://www.flickr.com/photos/nadineheidrich/11194895594 CC2.0

My reading this year fell into three categories: politics influenced by the election cycle, statistics and data, and a rekindled interest in American history. Books that didn't project overwhelming American exceptionalism and instead showed the real hardships and human qualities of the founding fathers intrigued me. I'm working on building my French fluency so there are a couple of French books too.

Runaway: How a Slave Defied America's First President by Bill Donahue.

This was a fun quick read because it corresponds with several of the events in the play Hamilton. I like that it helps shatter the infallible image that we've built up for George Washington. Like the play, it made him more human. Random tidbit, I'm typing this about 1.5 miles from the original Washington Monument. It's located in Baltimore and is an anchor of the Mount Vernon neighborhood in the city.

The Elephant In The Room: A Journey into the Trump Campaign and the "Alt-Right" by Jon Ronson.

One of my favorite post-election activities is reading all the behind the scenes stories/recaps. This year it's probably more important than ever.

Le Président Barack Obama: L'entretien des Kindle Singles by David Blum.

I started reading this earlier in the year but got around to finishing it after the election. It was a bit sad to read the sound rationale behind things that will likely be rolled back in some way.

Chronriques de l'Amérique au quotidien: Une Française décrypte l'American Way of Life by Sophie Landrieux.

It was enlightening to see all the things I see as normal be questioned and picked apart from a French point of view. Some years earlier when I did a semester abroad, I experienced this in reverse. Two things I found really odd were the lack of initial refrigeration of milk and Séyès paper, which I later grew to love.

Harry Potter and the Sorcercer's Stone by JK Rowling.
Harry Potter and the Chamber of Secrets by JK Rowling.
Harry Potter and the Prisoner of Azkaban by JK Rowling.

After finishing the Hunger Games trilogy last year, I started on Harry Potter. Loved the twist ending from Potter #1, hated the points system from the second book and was hoping for a final escape from the Dursleys.

The Big Short by Michael Lewis.

Hands down, this book should be required reading for any elected official. Even with the constraints of having to squeeze a story into 2 hours, the movie did a good job translating the core of the book.

Liar's Poker by Michael Lewis.

Liar's Poker details the Savings and loan crisis of the 1980s that shared a lot of characteristics with the Great Recession of 2008.

On Being A Data Skeptic by Cathy O'Neil.

"Big Data" is often thrown around with little meaning. O'Neil outlines a number of ways that big data can be dangerous and should be questioned. We are getting to the point where we are exhalting and trusting algorithm as somehow infallible while also allowing it to be unknowable by the masses. This book seems to be a primer for O'Neil's larger work Weapons of Math Destruction that I'm currently reading.

Mayflower: The Voyage From Hell by Kevin Jackson.

American history kind of TL;DRs the Pilgrims as "wanting to separate from England because the English were heathens, Plymouth Rock, and the first Thanksgiving." Our lessons in middle and high school often group the Puritans and the Pilgrims together. That's unfortunate. The Puritans came about 10 years after the Pilgrims. The Pilgrims weren't even known as that name during their time. They saw themselves as Sepratists. Another shocking thing from the book was the deplorable conditions of the crossing and the number who didn't survive.

Lost in Kandahar by Alex Berenson.

The book gives a quick snapshot into one of America's longest wars and the futility trying to secure against IEDs and the casualties caused by them.

Blockchain: The History, Mechanics Technical Implementation and Powerful Uses of Blockchain Technology by Matthew Adams.

It was ok if you wanted an overview of Bitcoin and the blockchain but it focused on Ethereum and smart contracts a bit too much. I'd skip it and suggest people read The Internet of Money.

The Internet of Money by Andreas M. Antonopoulos.

The book is a series of transcribed conference talks about Bitcoin that have been lightly edited. Each section is light in tone but informative. I think it should be the first thing someone should read to learn about Bitcoin (or watch the conference talks the book references).

Making a game mod: Icicles Holiday Edition

One of my favorite memories as a kid was playing holiday versions of my favorite shareware games. Sometimes these holiday graphics were hidden as easter eggs in the game. In other cases, there were special reduced code mod packs with new holiday levels.

Jazz Jackrabbit Holiday Hare

As a fun tutorial, I decided to make a holiday version of Icicles. We made it for one of our game development courses at Udacity. With a name like Icicles, it's already somewhat winter themed. But we can ramp it up.

Thanks to the free resources at kenney.nl, we can turn our icicles into falling Christmas trees. We can also make our player a bit more festive by adding a Santa hat. I used Kotlin for my code but the original course code is in Java, you can follow along there if you'd like.

A santa hat is a combination of three shapes: a circle, a triangle, and a rectangle. The function below gets called by the Player class's render function. Check out the standalone code for the Santa Hat here.

fun drawHat(renderer: ShapeRenderer, centerX: Float, centerY: Float, widthHeight: Float) {
        // Draw hat cone
        renderer.color = Color.RED
        renderer.triangle(centerX, centerY, centerX - (widthHeight / 2f), centerY - widthHeight, centerX + (widthHeight / 2f), centerY - widthHeight)

        // Draw fuzzy end
        renderer.color = Color.WHITE
        renderer.circle(centerX, centerY, widthHeight * 0.2f, 20)

        // Draw head band
        renderer.color = Color.WHITE
        renderer.rect(centerX - (widthHeight / 2f), centerY - widthHeight, widthHeight, widthHeight/4f)

In the current game, our icicles are triangles. To use images instead, we need to load the texture for our tree and render the texture using a SpriteBatch (which you can learn more about here or in this course).

class Icicle(position: Vector2) {
    companion object {
        val TAG = Icicle::class.java.toString()

    var position:Vector2

    var velocity:Vector2
    var texture:Texture

    init {
        this.position = position
        velocity = Vector2()
        texture = Texture("foliageTree_02.png")

    fun update(delta:Float) {
        velocity.mulAdd(Constants.ICICLES_ACCELERATION, delta)
        position.mulAdd(velocity, delta)


    fun render(renderer:ShapeRenderer) {
        renderer.triangle(position.x, position.y,
                position.x - Constants.ICICLE_WIDTH / 2, position.y + Constants.ICICLE_HEIGHT,
                position.x + Constants.ICICLE_WIDTH / 2, position.y + Constants.ICICLE_HEIGHT )

    fun render(batch: SpriteBatch) {
        batch.draw(texture, position.x, position.y, Constants.ICICLE_WIDTH * 1.2f, Constants.ICICLE_HEIGHT * 1.2f)

Icicles Holiday Edition

After changing added function calls for the updated render functions and a few other tweaks, you have Holiday Themed Icicles. Check out the code here.

Basics Without Boilerplate: Java the Pain-free Way, Part II

In the last post, I talked a bit in general about we taught introductory Java without advanced constructs in a recent Udacity course. Now let's get to the finer detail of how it all works.

The need for JVM magic

I had a few non-negotiable requirements:

  1. The student must be able to use real constructs and not mocked classes.
  2. The student must write syntatically correct Java code for the portions they write.

The first requirement meant that we needed to look beyond the Java language for testing student code. Java is statically typed so all its classes and functions can't be changed after compile time. That presents a problem when you are trying to check student code that uses Random which by definition shouldn't be reproducible. And we didn't want to do something like having students use a FakeRandom class because they might try to use it outside our course and encounter errors.

Luckily there's a language for the Java Virtual Machine(JVM) called Groovy. Most valid Java is also valid Groovy but a major plus is Groovy's Meta Object Protocol(MOP). It's a mechanism that controls how methods, properties, and attributes are resolved and allowing an application to intelligently respond to method calls. This next bit is impossible in regular Java but is valid Groovy code:

Database.findByAgeAndIncomeAndCity(25, 50000, "Baltimore")

The database object doesn't know anything about the underlying request before I run it. The first time the code is invoked, the lookup fails and methodMissing is called. In methodMissing, the library uses the name to create the query and caches it as a named function. Any future invocations will skip the lookup and use the cached version. The MOP feature we used the most was rewriting the implementation of Math.random() to something that is reproducible.

def randomNumberGenerator

Math.metaClass.'static'.random = {
    if (randomNumberGenerator == null)
        randomNumberGenerator = new Random(42)
    return randomNumberGenerator.nextDouble()

Using Groovy also enabled us to combine what would be separate compilation and execution phases into a single phase.

Generating a class from inside a Java class

The first programming quiz, PrintALine, where a student inputs a single line of code was actually the hardest to create.

There's a library called JavaPoet that allows you to embrace your inner inception and construct functions and classes around student code.

Here's the code that constructs a class for the PrintALine quiz:

def codeBlocksString = """
     System.out.println("Java Rocks!");\n

def javaRocks = MethodSpec.methodBuilder("solutionCode")
            .addModifiers(Modifier.PUBLIC, Modifier.STATIC)

def studentSolution = MethodSpec.methodBuilder("studentCode")
              .addModifiers(Modifier.PUBLIC, Modifier.STATIC)

TypeSpec codeClass = TestUtils.createClass(true, studentCode, javaRocks.build(), studentSolution)
JavaFile javaFile = JavaFile.builder("com.udacity.javand", codeClass).build()

And the output class looks like this:

package com.udacity.javand;

public class CodeClass1471932125479 {

    public static void studentCode() {
        System.out.println("Hello, World!");

    public static void solutionCode() {
        System.out.println("Java Rocks!");

When Groovy isn't so helpful

One feature of Groovy that was initially helpful was joint-compilation. The Groovy compiler can use Java class files as is. But Groovy is too helpful in some cases. Groovy doesn't require semicolons and parentheses are optional when the compiler can infer the intent. In the absence of a return statement, Groovy returns the last statement as a return value. As a result it's easy to accidentally create valid Groovy that isn't valid Java. It doesn't matter if the class was labeled as ClassName.java, in Groovy's mind, it's Groovy code.

All of these features are great if you know the fundamentals and want to save time, not so great if you are a beginner trying to learn as these Groovyisms can sow bad habits. The best and only way we've found to check Java syntax is to compile it and see what happens. From about Java 6, you can invoke the compiler and run it inside an app.

So we receive a String from the student, programmatically create a Java class, run the output through a compile and load it if compilation passes.

Check out the Java Programming Basics course and our Android Developer Nanodegree.

Basics Without Boilerplate: Java the Pain-free Way

For many of us, the first introduction to Java was the classic Hello, World! program. For something that's supposed to show you the most simple thing you can do in the language, there's lots of procedural and ceremonial things you as a student need to know or ignore. There's access modifiers, classes, functions, arrays and more.

Java HelloWorld Animated GIF

That's a lot. Some students can ignore the foreign concepts and others can't cope with not knowing. In their defense, it is a weird feeling to have parts of the most basic program be unknown and hard to understand. So when we were discussing making this course, I asked, "What if we didn't have to teach students about the advanced topics present in a Java app until the moment they needed them?"

So our version of Hello, World! looks like this:

In-Class IDE Animated GIF

As the student progresses through Java Programming Basics and the upcoming course on advanced topics, less and less code is written for them. By the end of the course, students will be really confident with general Java syntax, control flow, looping, and functions.

Check out the Java Programming Basics course and our Android Developer Nanodegree.

In case you were wondering what actually gets executed when the student hits "Submit," here's a sneak peek. I'll talk about some of the technical details in a future post.

A Sponge, A Starfish, And The Apocalypse

Whilst in Chicago for a totally different reason, I happened to flip on the TV and saw a commercial for The Spongebob Musical. I thought, "this could be really good or really bad." I checked BroadwayInChicago.com and tickets seemed to be sold out for the week. Next, I checked the TodayTix app on my phone and not only did they have seats available, they were only $39 (+ fees). Definitely worth the risk if it turned out to be bad. I ended up purchasing a ticket for night three of the pre-Broadway previews, night three!!! Opening night would have been a better get but seeing it in previews still garners theatre geek bragging rights. The seats were pretty awesome as well, Row G in Orchestra, pretty much dead center. Shout out to TodayTix.

The Spongebob Musical Playbill and Ticket

The Premise

It's just a normal Bikini Bottom Day until a series of events occur that threaten Bikini Bottom. Will Bikini Bottom be saved? Can Spongebob, Patrick, and Sandy save the day?

The Music

The music boasts a cadre of Grammy winning songwriters and artists ranging from pop to gospel to hip hop/soul to rock. I'm serious, look at them ...

The Spongebob Musical songwriters

The songs balanced the iconic style of the original artist while fitting into and driving the story forward. "BFF" is so iconically Plain White T's that I wondered for a second if they just changed the lyrics of an existing song.

The Sets, Cast, and Costumes

The set was in many cases what I'd call an "Under the Sea" prom theme on a shoe string budget. Whereas it would be a fail at a prom, the cheapness made everything feel more cartoony. I marveled at the creativity in unconvential materials. I wouldn't have thought to make a coral reef out of pool noodles or a jelly fish from an umbrella. There was also a sort of Rube Goldberg machine that drives part of the story. As Dolly Parton said, "It costs a lot of money to look this cheap."

That creativity also extended to the cast costumes (sorry no pics, rules is rules). Even though some were somewhat literal translations from the cartoon versions, I mean there are only so many ways you can do Spongebob, there were little twists here and there were unexpected. Sandy the Squirrel was portrayed by a African-American actress with a fro. Not absurdly sized...kind of Pam Grier in Coffy. Just enough to hint at the helmet though wouldn't be feasible for a human jumping and dancing around. Another costume twist was the a crustacean of some sort whose shell was fashioned from traffic cones and a very colorful sea anemone. Mr. Krabs costume was pretty simple, just died hair and oversized boxing gloves, but it was one of the most successful. Pearl Krabs threw me for a loop but that's forgiven for several reasons: (1) I'm not an uberfan of the show and she's a relative minor character, and (2) the character is a sperm whale, there isn't much that you to mimic the character as a humanoid without greatly limitly the confort of the actress.

Spongebob Set

The humor

There's lots of classic Spongebob slapstick / physical comedy but there's also layered humor peppered in the show for the adults. It's a bit weird laughing at the sexual inneudo between Karen and Plankton whilst surrounded on two sides by kids laughing at the more accessible joke that came seconds before.

Should I go see it?

I'd say if you are mildly familiar with the cartoon and don't abhor it, you'll have a good time. I've watched maybe 5 episodes of Spongebob from start to finish and my cheeks were hurting from smiling and laughing so much. There's a tap dance number that brought the house down due to the skill and ermm challenges of our characters costume. It was a full-on Rockettes/A Chorus Line number. I loved the show so much if it weren't for work, I would have gone and seen it again.

Spongebob Set - Animated GIF

Books I Read In 2015

We're already a quarter into 2016 and I'm just getting this list out. I read lots of good things and some that were just meh. Here's last year's list.

Don't Make Me Think: A Common Sense Approach to Web Usability (3rd Edition) by Steve Krug. Don't Make Me Think was a part of my self-study whilst preparing for my Material Design course.

I've been reading a lot lately about design these days. Don't Make Me Think: A Common Sense Approach to Web Usability (3rd Edition) is something I've finished that has got me thinking about how I approach how I present information to my users.

Though focused primarily on web design, much of the content applies to mobile app design. It aligns with my current Material Design work in trying to present information in an intuitive and glanceable way guides the user from point A to point B with little turbulence.

The section on accessibility spawned an "A-ha" moment. A cluttered site with a confused design is frustrating to both sighted and blind users. I can't say that every design I do will strive for total accessibility but I'll try to tackle the low lying fruit like using the label tag in forms, alt text for images, and using a decent contrast between text and the background.

Don't Make Me Think is IMHO essential for any developer that wants to dabble in design.

Hooked by Nir Eyal.

Zero to One by Peter Thiel.

The One World Schoolhouse: Education Reimagined by Salman Khan‎.

I believe I enjoyed these somewhat when we read them for the work book club but I can't really think of anything from them that I apply to my every day work.

The First 20 Hours:How to Learn Anything.

I liked the concept of The First 20 Hours but the implementation was kind of painful. The first three chapters were pretty useful but the last six were either way too slow, like the chapter on Programming and Touch Typing, or so left field that they were boring (Ukulele, Wind Surfing, and Yoga). Given the recent buzz about AlphaGo, I might visit the Go (game) chapter.

The Hunger Games by Suzanne Collins.

Catching Fire by Suzanne Collins.

Mockingjay by Suzanne Collins.

I had a couple of long flights panned and decided to start the Hunger Games series. All are great reads, though I like the first and second books better than the third. I hadn't watched the movies before reading each book so it was fun seeing how they adapted things. They did a good job IMHO.

Off-Course: Inside The Mad, Muddy World of Obstacle Course Racing by Erin Beresini.

As you may know from my Instagram, I do a lot of obstacle course runs. Off-Course is a feel good book about the craziness and pain that I and a growing number of people all over the world pay to endure. If you want to know a bit more about how OCRs work, check out Off-Course.

Listening Brands: How Data is Rewriting the Rules of Branding by JR Little.

Probably the best work related book I read this past year. I got it on a whim from Kindle Unlimited and have referred it to everyone at work that will listen. :D One of the basic premises of the book is that you don't get to 100% decide how your brand is defined or seen by the general public. Listen and embrace what your communities say/think and profit.

The Martian by Andy Weir.

I loved that it was sci-fi by felt more based in science and fact that some of the more Jetsons style sci-fi. A great story of survival.

Taming Google Calendar With Org-Mode

Over the past few weeks after setting up Org-Capture, I've been spending more of my raw time in Emacs but would have to context switch to a browser to look at my calendar events. That's no good. Luckily, we can solve this egregious problem by using a combination of Org-Capture, Org-Agenda, and Emacs-Calfw. Don't worry, the setup isn't as complicated as it sounds.

Setting Up Org-Capture

If you don't use Orgmode for your TODOs, you definitely SHOULD. Org-Capture allows you to quickly enter notes without a big context switch. You can even make templates for different types of data. I use Org-Capture templates for TODOs and logging food and exercise. The following snippet sets up the default location to store the notes you log and defines a shortcut as C-c c. I like to know what time I finished a task so org logs that as a property when the task is done. Lastly, I have template for TODOs. The first argument is the shortcut to log a TODO, in this case C-c c t. The other arguments specify the file where the TODO will be saved, what heading in the org-file it will be logged under, and the format of the template. Check out these links for more info about Org-Capture:


(setq org-default-notes-file "~/Dropbox/Org/notes.org")
(define-key global-map "\C-cc" 'org-capture)

; Log done state in TODOs
(setq org-log-done t)

; Set Org-Capture templates
(setq org-capture-templates
    `(("t" "todo" entry (file+headline "~/Dropbox/Org/notes.org" "Tasks")
        "** TODO %^{Task} %?")))

Setting Up Org-Agenda

Org-Agenda gives you multiple views to visualize data in Org files. These don't have to be all in one location and can be spread across multiple areas. I have one file for my calendar data and another for my TODOs that I set earlier. Org lets you schedule your TODOs with C-c . and these will show up on your agenda when you hit C-c a.

(setq org-agenda-files (list "~/Dropbox/Org/notes.org"
; Set key combos
(define-key global-map "\C-ca" 'org-agenda)

Emacs Calfw & Org-Gcal

The last piece of the puzzle is Emacs-Calfw (https://github.com/kiwanami/emacs-calfw) and its org-gcal integration (https://github.com/myuhe/org-gcal.el).

Calfw in Emacs

Calfw uses our Org-Capture and Agenda setup to give us a new calendar view. We can view an individual day or week and its associated events. Open a day's agenda by selecting it and hitting the space bar. Drop the following in your .emacs setup wherever that lives.

(add-to-list 'load-path "~/.emacs.d/emacs-calfw")
(require 'calfw)
(require 'calfw-org)

So far we can grab scheduled TODOs and see them populated on our calendar by opening an agenda buffer with C-c a and then running M-x cfw:open-org-calendar. For Google Calendar integration, you need to feel comfortable with the Google Developer Console. Follow the org-gcal setup instructions(https://github.com/myuhe/org-gcal.el) to get a client id and secret looking somewhat like the following to drop into your config files.

(require 'org-gcal)
(setq org-gcal-client-id "something.apps.googleusercontent.com"
      org-gcal-client-secret "something"
      org-gcal-file-alist '(("calendar@something.com" .  "~/Calendars/schedule.org")

As you can see, org-gcal dumps everything into an org file that Org-Agenda is aware of, which emacs-calfw knows about and it's turtles all the way down.

Refresh your listing of calendar events with M-x org-gcal-fetch. Sometimes you'll get prompted to refresh your OAuth token M-x org-gcal-refresh-token.

Org-gcal populates your org file with the event's location, video conference links, and a link to the event on GCal. With the day's agenda open (Space), you can see the properties of an event by moving your cursor to it and hitting TAB which takes you to that entry.

Add a entry to that file and run M-x org-gcal-post-at-point and an event will be created for you.


I don't generally use org-gcal-sync and only fetch events from my calendars. org-cal doesn't have a way to accept events or add other people to a calendar invite. That works for me because I don't generally reject things and merely go to the event or not.

You can not reserve rooms through org-gcal.

My next task is to setup a snippet to refresh my calendars on an interval.

What #2015BestNine can tell you about your brand

I just finished reading a great book called Listening Brands: How Data is Rewriting the Rules of Branding and the recent hashtag going around #2015BestNine got me thinking about what it means for brands.

The basic premise of the book is that the old inituition, big idea, "talk at the customer and make them like you" point of view in advertising is old fashioned. Instead, you should listen to your customers and engage in a conversation with them proving that you provide value for them and deserve to be a part of their lives. One way to do that is with data.

So what does this have to do with #2015BestNine? #2015BestNine gives you a mini-dataset that you can base some limited conclusions on. For example, do certain filtered photos perform better than others? Is there a certain type of photo that performs better than another?

I will caveat that clarify of the data goes down as the volume of photos go up. A high school friend of mine is a model and instragrams alot, taking many shirtless photos in his underwear. His best nine was filled with these and while it gives a strong signal that his followers love to see him with his shirt off, the sample size is too small to give any other insights to his other photos.

Below is my 2015 Best Nine. I only started sharing on instagram about 6 months ago with an average posting schedule of once every 3-4 days(~57 posts) with a small amount of followers(~ 90). So 9 posts will be statistically significant as it is roughly a 15% sample.

My Best Nine

My Best Nine tells me that people see me as athlethic. Seven out of nine pictures relate to fitness, running, or obstacle course runs. If I were trying to maximize likes with this group, I would endeavour to post more pictures from runs and maybe think about what peripheral stuff I could post (going to the gym, etc). One of the best nine is a darkly lit video of myself doing burpees in front of a Christmas tree from four days ago. I think it was either the timing of the post or the novelty of the Christmas tree that made it perform well.

The only data that is too small is no data al all.

Using Kotlin with libGDX

I've been kind of fascinated with Kotlin recently and when I learned of the #libGDXJam, I decided to use it for whatever game I'd end up creating. It turns out that it is remarkably easy to add Kotlin support to a libGDX game.

1.Generate your game without the html target.

The JS sources are generated with Google Web Toolkit which operates on Java source files. Because your files will be in Kotlin, the GWT compiler will complain about them. This is a bit of a bummer but I'd wager that you are more likely to deploy to desktop or mobile anwyays.

image of gdx-setup

2.Tweak your root level build.gradle file.

In the buildscript section, you'll need to add the kotlin-gradle-plugin on the classpath. This is so that the core project will be able to find it.

image of gradle buildscript

In the core project, add apply plugin: "kotlin" and the compile dependency as follows. You can add a variable in allprojects.ext for the kotlinVersion or hard code it here. Either works. Use the same version number from this page for both the kotlin-gradle-plugin and kotlin-stdlib versions

image of gradle core project dependencies


One thing you might notice is that sometimes the Android build gets confused and says it can't find your game/application file. To fix that, go to the AndroidLauncher file and make sure it has a proper import for your game/application.

If you'd like to learn more about making 2D games with libGDX, Udacity has couple courses and a nanodegree program, check them out.

Material Design at BABBQ15

This past week, I represented Udacity at the Big Android BBQ and gave a talk on Material Design. It was based on the Udacity course I launched earlier this year with Roman Nurik and Nick Butcher.

Check out all the recorded talks here.