Midgets standing on the toes of others

Code That Matters

iOS - Upgrade App to iOS 8

It has been a long time since I updated the iOS app, so I need to upgrade it to be working with iOS 8.1. Below are some issues I found during the upgrade.


InAppSettingsKit needs to be updated to version 2.1, otherwise it will have compilation error. Use pod update InAppSettingsKit to update.


A new delegate method needs to be implemented, otherwise clicking a person’s phone number will call this person. See this StackOverflow question.

ABPeoplePickerNavigationController new delegate method
- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
    [self peoplePickerNavigationController:peoplePicker shouldContinueAfterSelectingPerson:person property:property identifier:identifier];

Maven JGitFlow - Working Tree Has Uncommitted Changes

When I was trying to start a new release using Maven jgitflow plugin, it always complained about Working tree has uncommitted changes. I checked Git repository using git status -s and it seemed that all changes had been committed. I even tried to use git clean -f -d to clean all untracked files, even though I’m pretty sure that I already configured jgitflow to allow untracked files using <allowUntracked>true</allowUntracked>. But still no luck.

Scala - Write Files to Hadoop HDFS

Writing files to Hadoop HDFS should be that hard, but I searched and tested different approaches and finally got it working.

Use correct version of Hadoop client

The version of Hadoop client must be the same as Hadoop server version. For example, if you are using Hadoop 2.5.1, then Hadoop client must be the same version 2.5.1.

sbt file
libraryDependencies += "org.apache.hadoop" % "hadoop-client" % "2.5.1"

Build Hawtio Locally

When I was searching for open source solutions for better JMX support, I found out Jolokia and Hawtio is a very powerful combination. So I planned to to use them in my project. One major goal to achieve is to manage Quartz jobs. Hawito already has a Quartz plugin to support that, but the plugin has a bug which prevents it from listing Quartz jobs with JobDataMap and a PR already exists. I cannot wait for this PR to be merged and new version is to be released. So I decided to create a local build with that PR.

Deploy Maven Site to Nexus

Maven has a handy site plugin which can generate a website about your Maven project. Once the website is generated, normally it needs to be published to somewhere. A simple web server using Apache httpd or Nginx will be enough. Use a SSH/SCP wagon to upload website files to the server. Or website can be published to AWS S3 using wagon provided by community. Nexus can also host Maven websites. So if you are already using Nexus as internal Maven server, then it’s a better choice to use Nexus to host the Maven site.

AngularJS - Handle Session Timeout in JavaScript

If you have a web page which updates itself using Ajax background refresh tasks, when the user’s session is timed-out, the response of the refreshing Ajax request will be a 302 redirect to log-in page. But the Ajax request may not be able to handle that and simply fails. The user may not see the updated results. In this case, web page should detect the session timeout and redirect the user to login page.

When using AngularJS’s $http service for Ajax request, it’s very simple to handle session timeout. All you need to do is to add a $http interceptor and handle the response. See CoffeeScript code below.

AngularJS and Rails 4

After you have created a Rails 4 project and want to use AngularJS for the front-end development, this post can provide some tips.

Use Bower

It’s a common practice to use Bower to manage front-end dependencies. Bower should also be used in Rails development. After Bower is installed, create .bowerrc in project root directory to specify directory to put dependencies.

  "directory": "vendor/assets/components"

Then update config/application.rb file to include Bower components. Add following line to your application configuration.

Install AWS CLI on Ubuntu

To install AWS CLI on Ubuntu, you need to use Python 2.7. If you use Python 2.6, there is a conflict error with simplejson library.

You may need to uninstall Python 2.6 first using sudo apt-get remove python. Then install Python 2.7.

sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python2.7

Then install pip using sudo apt-get install python pip, then install AWS CLI using sudo pip install awscli.