Skip to content

Greenfoot: Teaching Java to 5th Graders

Once upon a time, I would have said that its impossible to teach 5th graders to program in Java. Even the most basic hello world requires exposure to complex concepts: the print statement must be wrapped by a method with very specific modifiers and parameters, which is then wrapped in an class and compiled. Enter Greenfoot.

When helping to teach a class for the Northwestern CTD weekend program**, I was introduced to Greenfoot for teaching and learning Java. After my first day of class, I was so inspired by the educational possibilities of Greenfoot that I wrote a little Breakout clone to show the kids the next day what they could do with Greenfoot.

Rather than using the classic programming education sequence, from hello world to user input, string manipulation, file I/O, and so on, Greenfoot instructors Continued…

Posted in Education.

Cocoapod lint error: [xcodebuild] No such file or directory

I just started learning how to write my own Cocoapod yesterday. There’s a great tutorial to get you started. However, I ran into an issue when trying to lint my new spec. It looked like this:

$ pod spec lint MyAwesomeLibrary.podspec
 -> MyAwesomeLibrary (0.0.1)
    - ERROR | [iOS] [xcodebuild]  2013-05-29 23:03:08.370 xcodebuild[91499:3f03] error: Error Domain=NSPOSIXErrorDomain Code=2 "Non-zero exit code 255 returned from shell command: /usr/bin/gcc-4.2 -v -E -dM -arch armv7 -isysroot /Applications/ -x objective-c -c /dev/null 2>&1" UserInfo=0x4001c4e60 {NSLocalizedDescription=Non-zero exit code 255 returned from shell command: /usr/bin/gcc-4.2 -v -E -dM -arch armv7 -isysroot /Applications/ -x objective-c -c /dev/null 2>&1, NSLocalizedFailureReason=No such file or directory}
    - ERROR | [iOS] [xcodebuild]  2013-05-29 23:03:08.457 xcodebuild[91499:3f03] error: Error Domain=NSPOSIXErrorDomain Code=2 "Non-zero exit code 1 returned from shell command: /usr/bin/gcc-4.2 -v -E -dM -arch armv7s -isysroot /Applications/ -x objective-c -c /dev/null 2>&1" UserInfo=0x4018946a0 {NSLocalizedDescription=Non-zero exit code 1 returned from shell command: /usr/bin/gcc-4.2 -v -E -dM -arch armv7s -isysroot /Applications/ -x objective-c -c /dev/null 2>&1, NSLocalizedFailureReason=No such file or directory}
Analyzed 1 podspec.
[!] The spec did not pass validation.


Posted in Tutorials.

Multiple Keystores in Apache Camel/HttpClient

Now that we know how to use multiple SSL keystores in Java, how do we configure Apache HttpClient (embedded in Apache Camel) to use them? This is useful if you want to load additional keystores in addition to the “factory” installed ones, for example. There’s no obvious way to do this using HttpClient or Camel. If you look at any of the documentation online, you’ll either see configuration via the JSSE configuration utility, like so: Continued…

Posted in Tutorials.

Intro to Streams2: Design Patterns (Part 2)

This is the last part in the Intro to Streams2 series. If you haven’t read Part 1 yet, you should. The examples here build on the ones presented there.

Part 2 is about design patterns for streams. Design patterns help us write clean code, like this.

function publish(data) {
    .on('error', function(err) {
      self.emit('error', err);
    .on('success', function() {


Posted in Tutorials.

Java SSL with Multiple KeyStores

For communication between internal services at BrightTag, we use self-signed certs on both the client and server. Simple and cheap (free!). Most of the time, these services only communicate over HTTPS with other internal services, so its been fine to use our own keystore; we didn’t need access to the “factory” certificates anyway. However, I ran into a case last week where I needed to be able to talk to both internal and external services and realized there’s no simple way to use multiple keystores in Java. We wanted to use both the standard JVM keystore and our custom keystore. The cleanest solution I found was to write my own CompositeKeyManager and CompositeTrustManagers. Creating a new keystore with both the standard JVM certs and our custom certs was also considered, but ultimately we didn’t want the responsibility of updating the standard certs in a bundled keystore.


Posted in Tutorials.

Intro to Streams2: New Node Streams (Part 1)

There’s a saying among the core Node contributors: if you’re not using streams, you’re doing Node wrong*. So I spent last week learning the new Node streaming API (“streams2″) while building a small node app. While the documentation is pretty good, there’s not a lot of examples that are both realistic and easily digestible.

This two-part tutorial aims to build on the DailyJS’s Five Minute Guide to Streams2, providing real use cases for each of the different types of new streams (part 1) and the application of more complex design patterns to streams (part 2). Continued…

Posted in Tutorials.

Elegant Shell Scripts

Shell scripts aren’t known for being the cleanest, most elegant part of your technology. But I argue that, as a vital piece of your stack, they should be afforded the same thought and care as other parts of your codebase.

Sure, shell scripts like bash have some inherent limitations, but they shouldn’t prevent you from following standard software engineering principles.

For example, bash functions can’t return values, but functionality should still be broken into small reusable chunks each having a single responsibility. Just call the function in a subshell and have it echo the result. Or use a standardized return value. Plus, you can easily take advantage of the return codes of invoked programs.

Consider this simple script for generating a random alphanumeric identifier that’s unique across a group of files within a folder Continued…

Posted in Tutorials.

What I’ve Learned About Objective-C

I spent the start of 2013 working on my first iOS SDK. In no particular order, here’s some of what I’ve learned about Objective-C.

  • The hash of a collection is equal to the number of elements in that collection
  • Singletons (er, “shared singletons“) are an accepted pattern in Objective-C
  • Categories are cool. They’re kind of like Ruby’s mixins.
  • Class clusters defy expectations. You can’t cleanly override a method in a class cluster with a category.
  • The community seems to be suffering from Apple’s control. Too many mentions of “I can’t tell you because of NDA” on StackOverflow
  • Apple’s docs are pretty good… if you can find the right ones
  • There’s no easy way to build a “fat archive” and static framework unless you start with this project template, which I didn’t.
  • appledoc should be the de facto documentation engine now, but isn’t.
  • Unit testing networking code is much harder than it should be.
  • I miss Guava. Simple things like Objects.toStringHelper, Objects.hashCode, and EqualsTester.
  • I miss the builder pattern. Objective-C loves telescoping constructors initializers. Likewise, I miss Guice.
  • Many of my favorite libraries for unit testing have been ported to Objective-C.
  • The various abstractions for multithreaded programming are at war. GCD (the latest and greatest) vs NSOperationQueue (the most abstract) vs RunLoops. (Does this belong in this category? NSURLConnection can specify a runloop OR a queue, so I think so.)
  • Some (but not all) of CoreFoundation is open source. A lot of NS* classes are the same as their CF counterparts via “toll-free bridging
  • Variable argument lists don’t know the number of arguments without being told. Most people use a nil-terminated list. A format string (implicit count) or explicitly passing the count also works.
  • There is no NullPointerException; sending a message to nil is fine (no exception raised). This can really bite you in the ass.
  • There are best practices. Read them before you start your next (first?) iOS or Objective-C project. I found this after I figured them out in bits and pieces.

Since I was simultaneously writing an Android SDK, expect a similar post about what I learned about Android in the process.

Posted in Ramblin' Thoughts.

Open Source: Cassandra Super Columns to Composite Columns Migrator

If you’ve been following Cassandra’s development, you’ll know that its made huge progress in the last two years. My company first start using Cassandra v0.8.x, and the latest stable version is now v1.2.3.

One of the major changes was adding support for composite columns. In DataStax words, “composite comparators can be thought of simply as a comparator composed of several other types of comparators.” Since introduction of composite columns in v1.0, there’s been a trend to slowly fade out super columns in favor of composite columns. Cassandra itself is refactoring supercolumns to use composites under-the-hood in v2.0.

So when my company upgraded to v1.0, I wrote a little tool to migrate our data from using super columns to use composite columns instead. This was about a year ago, but I wanted to announce I’ve open sourced it on Github. Better late than never, right?

Grab the source and try it yourself **.

** Disclaimer: I waive all responsibility for your use of this code. Think twice before using it on a large production dataset.

Posted in News.

Case Study: Measuring Your Health

Ever step off the scale and wonder if a weight increase was due to gained fat or muscle?

A couple weeks ago, I was frustrated that my scale was showing the same weight, yet I could see my progress in the mirror and on the mat. That’s when I had a DEXA scan, and I’ve since learned how few people know about it.

If you’ve read any of my other case studies, you’ll know that I use numbers to make a lot of decisions in my life. I love DEXA because of the awesomely detailed and accurate information it can provide. A couple days ago, we learned why smart scales don’t cut it for measuring body fat; not coincidentally, data from a DEXA scan was used to make the point.

Now that I’ve built it up, I bet your wondering what kind of information you can get from DEXA.

  • whole body breakdown into lean pounds, fat pounds, and bone mineral content (BMC)
  • lean pounds, fat pounds, and BMC for each leg and each arm, your android (abdominal) and gynoid (hips/thighs) areas
  • lean mass symmetry, fat mass distribution, bone density, and more

Forewarning, your body-fat percentage will likely be higher than you expect. I was in shock on my first consultation. DEXA includes all the fatty tissues in your body, even those in your brain (around 3 pounds). If you weigh 150 pounds, that’s an instant 2% increase in body fat.

What’s this data look like? Well, I’m glad you asked.

Without further ado, here are my DEXA results as an example. Continued…

Posted in Case Studies.

Log in here!