A PEM Backed Keystore for Java SSL

For Thumbslug, we needed to open a number of SSL connections to the same server, each with its own X.509 client certificate. Thumbslug grabs the certificates from Candlepin, which stores them in PEM format. Rather than teach Candlepin to also store these certificates in a different format, or to load them first into a format that Java deals with nativley (like PKCS #12), I figured it would be best to create an SSLSession backed directly by an X509Certificate and PrivateKey loaded from the PEM file. »

HOWTO Make a USB Y Cable for Host Mode

Many smartphones or tablets support USB host mode (or On The Go mode) with an adapter. Unfortunately, a lot of those devices don’t supply power to their client USB devices; you can’t just plug a host mode adapter into an HP TouchPad, for example, then plug a keyboard into the host mode adapter, and expect everything to work. I put up a video on youtube explaining how to build and use a USB Y cable to inject power to the client devices. »

An Access Logger for Netty and HTTP

We needed to do CLF style HTTP access logging for Thumbslug, which is implemented in Java + Netty. I couldn’t find any code to do this with a quick google search, so I wrote my own. If you need such a thing, try here or here (backup). »

Measuring Network Speeds with Netcat and Dd

I’ve seen a few posts on the web about testing your network speeds with netcat, but they all seem to not work with recent versions of netcat. On one machine, run: nc -v -l 2222 > /dev/null (Make sure you’re not blocking connections to 2222!) On a second machine, run: dd if=/dev/zero bs=1024K count=512 | nc -v $IP_OF_FIRST_MACHINE 2222 dd will give you your speed: 536870912 bytes (537 MB) copied, 4.87526 s, 117 MB/s Yay, gigabit! »

Converting SVN Commits to Git Patches

In case you find yourself in need of a way to turn an svn revision into a git patch that can be applied with ‘git am’, keeping the commit message and authorship information, here’s a script I used recently: #!/usr/bin/python # # svnrev2git.py - Convert an SVN revsion to a Git patch. # # Author: James Bowes <jbowes@repl.ca> # # Usage: # $> cd my-svn-repo # $> python svnrev2git.py [AUTHORS_FILE] [REV_RANGE | REVSION [REVISION..]] # # AUTHORS_FILE - a CSV of svn username, full name, email # REV_RANGE - an svn revision range, like 100-700 # REVISION - a single svn revision # # You may specify either a revision range, or a series of individual # svn revisions # # Output: # A series of git style patch files, one per svn revision, which can then be # applied with 'git am' # # Why use this instead of 'git svn'? »

DIY Velcro Cable Ties

Making your own velcro cable ties is a great idea. $2 in materials made as many cable ties as Wal- Mart was selling for $13. Thrifty! I’d suggest sewing the velcro together vs stapling, especially if you have cats that are far too curious about staples. »

Shell HIstory Meme

[jbowes@laptop ~]$ history | awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}'|sort -rn|head 211 git 148 fg 107 ls 99 cd 89 python 43 make 26 vim 23 sudo 20 nosetests 19 player/swfplay [jbowes@workstation ~]$ history | awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}'|sort -rn|head -n 12 163 ls 156 cd 115 svn 76 vim 70 screen 55 fg 47 exit 35 sudo 30 git 21 yasql Seen on Adrian’s and Mike’s blogs. »

2% Genius

Agile Tsar Dmitri Dolguikh pointed out Project Euler yesterday, which is a website containing a series of short programming problems. It reads a bit like bonus questions on a math exam, which is actually quite refreshing compared to the day-to-day problems at work. For added fun, I’m trying to run through the problems in Common Lisp. So far I have completed 4 out of 179 problems, which makes me 2% genius, according to the site. »

Mission Accomplished!

A lot of people are linking to this article about the state of the practice in CS curriculum and its use of Java creating dull replaceable drones. mdehaan points out a wonderful section wherein the authors relate Java programming to a plumber in a hardware store, finding pieces and putting them together to solve a problem, rather than their unmentioned alternative (maybe an artist molding clay?) If this is true, then we, the software industry and software engineering fields, are done. »