Sunday, September 1, 2013

Adding Godaddy G2 root cert to JDK 7

Java 7 doesn't recognise Godaddy's latest root certificate.

$ java -version
java version "1.7.0_10-ea"
Java(TM) SE Runtime Environment (build 1.7.0_10-ea-b16)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)

Trying to connect to a site signed with the root certificate gives an exception. PKIX path building failed: unable to find valid certification path to requested target
Caused by: PKIX path building failed: unable to find valid certification path to requested target

Until Java 7 supports the certificate natively, it's necessary to install the certifate manually. I installed both the root and intermediate certs, but it's probably only necessary to install the root cert.

wget -O gdroot-g2.crt ''
wget -O gdig2.crt ''

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk/Contents/Home
sudo $JAVA_HOME/bin/keytool -import -file gdroot-g2.crt -alias gdrootg2 -storepass changeit -trustcacerts -keystore ${JAVA_HOME}/jre/lib/security/cacerts
sudo $JAVA_HOME/bin/keytool -import -file gdig2.crt -alias gdig2 -storepass changeit -trustcacerts -keystore ${JAVA_HOME}/jre/lib/security/cacerts

Thanks to Dave Rose.

Friday, August 9, 2013

Online photo printing prices in NZ

I don't know any of these places, but here are my notes from a quick survey of prices. I used 15×10 sized prints for comparison.

Saturday, July 27, 2013

URL path segment encoding

Java's URLEncoder class is not suitable for encoding path segments in URLs. It's not even really suitable for encoding GET parameters in the query part of a URL, e.g. it encodes unreserved URI characters, which should not be encoded, such as tilde (~).

Spring has a good encoder. Now Play does too. :)

RFC 1738 is obsolete, so don't just go and percent-encode the characters it lists as unsafe. Encoding such characters may violate the newer RFC 3986. Ignore instructions that say otherwise!

Thursday, July 18, 2013

100% CPU with UserEventAgent

My Mac laptop has been running hot, with the UserEventAgent process pegged at 100% CPU.

This is apparently due to a bug in the interaction between the AppleHIDMouseAgent and some mice and keyboards. In my case it is probably my Kinesis keyboard.

The fix is to disable the AppleHIDMouseAgent plugin and restart the computer.

sudo mkdir /System/Library/UserEventPlugins.disabled
sudo mv /System/Library/UserEventPlugins/AppleHIDMouseAgent.plugin /System/Library/UserEventPlugins.disabled

Note: renaming the AppleHIDMouseAgent.plugin within the same directory won't work—it will simply prevent your computer from booting. :)

Saturday, June 15, 2013

DNS servers for Vibe Communications

My modem, a CNet CAR2-804, returns DNS responses on a non-authoritative port. This causes 30 second lookup delays in Linux and timeouts in Windows 7. The workaround is to use an external DNS server instead. I set this up manually on each machine.

The settings for my machine are taken from my ISPs support page: (recorded here because I always forget where to find them)


Friday, April 5, 2013

Simple OutOfMemoryError profiling with VisualVM

Today I used Java heap profiling to investigate a problem with Scala futures.

  1. Start your Java program with the following options. I used a maximum heap size of 32 megabytes to speed up the error. When an OutOfMemoryError occurs, a heap profile file will be dumped.
    -Xmx32m -XX:+HeapDumpOnOutOfMemoryError
  2. Start VisualVM. On Mac OS 10.8 it is located at the following location:
  3. Choose File > Load and open the heap profile (hprof) file.
  4. You'll be presented with a summary of class memory usage.
  5. Investigate!

Wednesday, April 3, 2013

Play Framework Git workflow

Fork and clone the repo

  1. Visit to fork the repo.
  2. Clone your fork.
    git clone mydir
    cd mydir
  3. Track upstream in your fork.
    git remote add upstream
    git branch --set-upstream master upstream/master

Starting work on a feature branch

git checkout master
git pull
git checkout -b mybranch

Folding commits and rebasing a feature branch

git commit -a
git log # review changes
git rebase -i HEAD~2 # for 2 commits
git checkout master
git pull
git checkout mybranch
git rebase master

Pushing a feature branch

git commit -a
git push origin mybranch

Folding commits and re-pushing feature branch

git commit -a
git log # review changes
git rebase -i HEAD~2 # for 2 commits
git push origin +mybranch

Linking a feature branch to an existing issue

hub pull-request -i 999 -b playframework/Play20:master -h richdougherty/Play20:mybranch

Tuesday, January 22, 2013

Updating an existing Github pull request

Akka uses single commits for its pull requests, so that changes can be easily understood and rolled back. Pull requests are contained in their own branch. Here's how I updated my single-commit pull request with some changes and resubmitted it.

  1. Rebase the last two commits interactively.
    git rebase -i HEAD~2
  2. When asked, squash the latest commit into the previous one.
  3. Replace the existing upstream branch with the updated one. Use + to signify that the updated branch isn't based on the old one. (Often origin is used instead of upstream.)

    git push upstream +wip-2798-ensuring-rich

Thursday, January 17, 2013

Moving an existing repo to Github

Assuming you already have code in a local repository…

  1. Got to and create a new repository. Remember to create it without a .gitignore or README file so as to avoid needing a merge.
  2. In your local repo run a command like:
    git remote add origin
  3. Then run:
    git push -u origin master

Via Stack Overflow.