Moving to GitHub

I've started to move some home projects to GitHub. https://github.com/retroredge/

Make Hudson Fail Maven builds when tests fail

By default Hudson marks a build as unstable if unit tests fail. If you'd rather it marked it as failed use this Maven switch.

-Dmaven.test.failure.ignore=false

Prevent SSH session from timing out

In
/etc/ssh/ssh_config

Set
ServerAliveInterval 120

SSH Tunnelling

Creating a tunnel via a gateway or 'jump off' server to a target server:

ssh -f -N -L 10022:target-host:22 user-on-gateway@gateway

-L sets up the tunnel from local port 10021 to remote port 21
-N no command, simply tunnel
-f run in the background

gateway and target are both server hostnames.

Then sign in the the taget server:

ssh -p 10022 user-on-target@localhost

Creating a SOCKS proxy via a gateway

ssh -D8888 user-on-gateway@gateway

Then you can use localhost:8888 as the proxy for any application that supports SOCKS, e.g. a browser.

Unmaintainable Code

Excellent piece of geek humour -

How To Write Unmaintainable Code by Roedy Green

A Swing Chess Clock

I decided to have a look at the NetBeans IDE as it is now available in the Ubuntu repo'. I'd heard it has a very good GUI designer tool so wanted a small project to try it out on.

Son #2 has been getting into Chess lately and I was going to buy him a chess clock so that we could play 'blitz chess' however I thought that a chess clock would be a nice simple application to try out the NetBeans GUI tool on.

Here's the result.

 

The application has three simple spinners to choose hours, minutes and seconds. Once the clocks are started the only active control is the button that switches players. 

Over the two evenings that I spent creating the application and tinkering with NetBeans features I was very impressed with it. Everything was super intuitive including connecting to my Subversion repo and using the designer tool. It had a very low memory foot print too (~150Mb).

Next step is for the chess clock is to package it as a Java Web Start project and maybe convert it to a Midlet.

To implement the clock thread I used a Java Timer and TimerTask class which made things very neat.

Adding a new node to an XML file in Groovy

Whilst working on a Grails plugin I needed to add an extra import statement to the Spring resources.xml config file, here's how I did it.


def parser= new XmlParser().parse(new File('resources.xml'))

if (!parser.'import'.'@resource'.contains('foo.xml')) {
def newNode = new Node(res, 'import', [resource: 'foo.xml'])
res.'import'.add(newNode)
}

def writer = new FileWriter('resources.xml')
new XmlNodePrinter(new PrintWriter(writer)).print(parser)