Compile and run Java 9 code using Docker

Java 9 is scheduled to release on September 21. If you want to try Java 9 early-access builds now, you can download them from and install them locally. However, installing the Java 9 builds makes them the default JDK in your machine, which may affect other applications that depend on the JDK. A better choice is to use Docker. If you don’t have Docker installed, download and install it from

The Docker image we are going to use is the official Apache Maven image which supports Java 9. We use the tag 3.5.0-jdk-9 to get the Maven 3.5.0 with JDK 9.

Read More

Use private NPM registry

I just want to share some private NodeJS modules for reuse in my other projects. A simple private registry is a good choice. sinopia is what I used.

The installation is very easy.

$ yarn global add sinopia
$ sinopia &
$ npm set registry http://localhost:4873/

Read More

Add Disqus to AMP site

Now I’m going to add Disqus comments to my AMP site. Disqus already supports this and has an official guide about it. The whole process is smooth with only few exceptions.

  • You need to have a separate domain. This is not an issue for me. If you don’t have an extra domain, you can host your disqus HTML file in GitHub or other places. Or you can use a universal HTML file as discussed in this GitHub issue.

Read More

Create Jackson custom serializers and deserializers

Jackson is a popular library to handle JSON in Java. It has built-in serializers and deserializers to handle common data types. If you want to serialize and deserialize custom types, you can add custom serializers and deserializers. The code in this post is tested using Jackson 2.7.2 and should work with Jackson after 1.7.

The class we want to serialize and deserialize is com.github.zafarkhaja.semver.Version from the jsemver library. We want objects of this class to be serialized as simple strings, e.g. 1.0.0.

Read More

React Native - Build Android APK bundle

This guide is for React Native 0.42.

When working on an app with many static images, I found out that those images were displayed correctly on the emulator, but were blank when testing on a real device. It turns out that those images need to be bundled as assets when running on a device. Google search gave me this SO answer. However, this answer doesn’t work for the RN 0.42 version.

Read More

Return value from Python script to bash shell

We have a legacy Python script to launch a new AWS EC2 instance. The current version of this script just lauches the instance and prints out some logs. Now we need to terminate the EC2 instance created by the script. To use the aws ec2 terminate-instances command, we need to get the instance id.

Read More

Use proxy in Angular CLI

It’s common for an Angular 4 project to use proxy during development to workaround the same-origin policy, especially when the server-side is not developed using Node.js. If the Angular 4 project is created using Angular CLI, we can add a proxy.conf.json file in the root directory to configure the proxy.

Read More