Groovy Koans Project

The Groovy Koans project is a collection of small exercises in the form of unit tests, designed to get Java developers up to speed on Groovy features and common idioms. It starts by teaching you basic Groovy building blocks, and gradually builds your knowledge towards metaprogramming, slurpers, and all the goodness Groovy has to offer !

Getting Started

  1. Make sure you have JDK 1.6+ installed
  2. Download and unzip the Koans (or clone the GitHub repository with $ git clone
  3. Remove the solutions from the Koans using $ ./gradlew removeSolutions
  4. Execute Koan01 with $ ./gradlew koan01 and fail (or any other Koan using $ ./gradlew koan##)
  5. Fix code, and execute again
  6. Keep going until you’re fluent at Groovy 🙂


I like IntelliJ. How can I use it to debug/edit the Koans?

I am forced to work behind a proxy. Can I still run the Koans?

The gradlew script downloads Groovy and Gradle for you, so you don’t have to set up anything by yourself.
To allow gradlew to work through your proxy, simply add the following parameters:

$ ./gradlew koan01 -Dhttp.proxyHost=[http proxy] -Dhttp.proxyPort=[http proxy port]

The answers are already there! What’s the point?

One of the perks of learning through Koans is that once your Koan is solved, you can compare your solution with
the ‘official’ solution and perhaps learn from that comparison as well. It is also a way to make sure that the Koans
are indeed solvable by filling in the blanks.

For optimal learning experience, however, you should first try to solve the Koans without those solutions as reference.
To remove the solutions, run $ ./gradlew removeSolutions from the root of your unzipped Koans.

Are there more Koans planned? How will I know?

These are the Koans that are currently planned:
* Embedding Groovy
* Creating your own DSL
* Creating your own builder
* Transformations
* GPars

Follow me on Twitter or GitHub for updates.

Credits and License

The Koan concept started way back in Zen practice. It was then adapted by the good folks of and perfected by Neo4j. The Groovy Koans project is licensed under the

Please feel free to leave comments and pull requests 🙂


How Gradle Makes Windows and *nix App Deploy Scripts

Thanx to Mk Yong for this idea:

Assets for this post are held here:


Here is a skeleton gradle project template to build an executable java jar plus all distributable assets for a ‘HelloWorld’ java source. This is to deploy your app as a stand-alone app on a client system, something like a GUI, or batch job app – NOT a web service.

The tasks to do this are a freebie when a build.gradle file includes a plugin module named ‘application‘ courtesy of

> apply plugin:’application’

Gradle Build Tool

This project includes a full gradle build tool as a ‘wrapper’ bit inside this download. So there’s no need install gradle on your system. You can run this app once you’ve done a git clone.

Git Source Code Control

Yes, you need Git installed on your system to get started. So change into a new folder/directory on your local system and do this:

git clone

This makes a project directory folder named gradleMakeWindowsBat so cd into that.

You could use this approach as a foundation to create several brand-new projects. Sure you would need to change gradleMakeWindowsBat to something else and the main class names would change too, but a lot of the setup work is done for you here.

Build / Check

Now you can just run the gradle wrapper like so:

> gradlew check


> bash ./gradlew check

This will ask gradle to download any dependency bits it needs to make it happy, and check that everything is cool on your installed version.


Ok, to make it all happen, run gradlew again without options.

> gradlew


> bash ./gradlew

The default tasks are run. These are:

defaultTasks ‘clean’, ‘build’, ‘javadoc’, ‘installApp’, ‘startScripts’, ‘fatJar’, ‘distTar’, ‘distZip’, ‘run’

Tasks to Deploy An App

clean – gradle cleans the environment before starting

– build – when javac – compiles the HelloWorld module

javadoc – the javadoc API document is created with any source code comments

– installApp makes a folder named install and a sub-folder of gradleMakeWindowsBat containing /bin, /docs, /lib folders with all the pieces to do a full install on a client system. Ship the gradleMakeWindowsBat folder and change the client’s OS path variable to include gradleMakeWindowsBat/bin then on the command line you/they can run this job by typing the name of this  batch script file as gradleMakeWindowsBat  – easy-peasy !

startScripts – makes a folder of identical windoze and unix batch script files. These scripts will run the core job noted in the build.gradle file as

mainClassName = "com.jnorthr.DateUtils"

– yeah, you can change that for your own needs. Be sure to add the .jar files in build/libs to the system CLASSPATH variable.

fatJar – my favorite ! makes an executable jar file of the java/groovy/scala/jvm language classes and bits. You can just double click on the gradleMakeWindowsBat-all-1.0.jar file to run your app.

Alternatively from a command line with the jar in the same folder, you can do this:

> java -jar gradleMakeWindowsBat-all-1.0.jar

Everything needed has been included in this ‘fat’ jar !

Tasks to Transfer The Project Build Environment

When we need to move/copy/transfer a complete project that includes all the development tools, build stuff and source code controls, we can use either of these two tasks depending on the target computer system’s OS:

distTar packages up the full folder directory and makes it ready for shipment to a target computer system running Unix/Linux/Ubuntu etc.

– distZip packages up the full project folder directory in a compressed archive format. This is useful as a general-purpose tool to move a complete project around to target computer systems where the OS is unconventional like, say, Windows, IBM, DEC.

Both tasks run as a default set of tasks. Project build times may seem excessive as so many solutions are being produced. To speed things up you could alter the build.gradle file to remove these two tasks if you do not plan to move the project to another system.

Task to Run This App

– the run task starts execution of an app. The app name is declared in the build.gradle file as

> mainClassName = "com.jnorthr.DateUtils"

change to suit your own requirements.

(L)Ubuntu 14.04 Quick Un-Erase / Un-Delete Tip

An open source utility that i had installed on my Lubuntu 14.04 system, decided to blitz several of my precious folders. I can look into the ‘Trash‘ folder and see them all there, but the installed system utilities would not let me open them or copy them out. How to do that ? Well googled for a while to find there were a bunch of open source linux tools to help un-delete / un-erase deleted file partitions, and disks etc. 

Well, ok that’s useful, but what about if we just have a few precious files that ended up in Trash by mistake ? How do we get those back ? After reading this: Location of Trash onUbuntu 14.04 well that gave me the location of where ubuntu stores the trash. So had to open a terminal session to get to the command line. Then it all became rather simple.

 The first time i ran this i needed to include the ‘sudo’ prefix to make ubuntu happy enough to let me into this trash folder. Then on my system, my trash is held in my home folder so i changed directories to it here:

sudo cd ~/.local/share/Trash/files/.trash 

then i could use 

ls -al

to see all the stuff in the trash. Ok, it’s there but how do i get it back to my side ? Well simple enough, we have the move command named ‘mv’ and that was the trick. I first tried to move a file as i did NOT want to try moving a valuable directory just in case it all went wrong. So in the trash folder tried this:

~/.local/share/Trash/files/.trash mv DSL.adoc ~/Desktop

press the enter key and voila! My precious DSL.adoc file is moved back onto my ubuntu Desktop. I opened it with a text editor just to confirm it was all there – and it was !!!!

Folders Too ?

So did that for each file i wanted to restore, but what about folder directories ? Could those be retrieved ? Well, tried a non-valuable folder with the MV command and again success !!!

Then did moves for each of my precious folder to get them back to my desktop. Here is screenshot of some of this session: 

recovery sessoin on ubuntu 14.04


Have not checked permissions or ownership bits but am not fussed, as i have my valuable data back again – no big tools, utilities, etc. just knowing where the trash is on your system, the ability to change directories into that location and use of the mv command.

Note that your trash may be located at a slightly different address so you may need to hunt a little to find it. But i’ll bet your files might still be there waiting for you if you just know where !

Hope this helps you – give this post a LIKE if it does ! Happy recovery !!!


IETF – Internet Engineering Task Force Documents


Screenshot 2014-08-13 23.45.21

Internet Engineering Task Force Docs

Completely forgot this was written several years ago to access all the IETF documents. It was Oct. 2012, and the tons of IETF documents were/are online for public consumption.

This app runs on Google App Engine  and has been running for several years. It stills has daily hits so if you need to review or research features and engineering documents about how th einternet came into being, then look here:

Cloud Foundry Performance Testing

Have been wondering for sometime how we can measure the overall response of a known Cloud Foundry PaaS target. What kind of metrics can we use ?

As a first attempt, let’s review the PAT tool as reviewed by Dr. Nic. Look here:

and if you are really keen, you can hack your own version of PAT from the Github repo here:

My ideas involved a test harness to hit several/many CF targets simultaneously and let it all run for a few days. This would give a larger overview across a wider time span. We could see the highs and lows using some metrics – which times of day are bad/good – which days of the week are good ?  Do background tasks on the target CF influence or results ? Are they doing backups while we push our app to them ?

Maybe another test harness to bang our app on each CF target every n seconds/minutes/days ?

Then we could publish those metrics so we all have a better of of which PaaS is rubbish like CloudBees and which ones are sterling like IBM BlueMix and 🙂



Asciidoctor Admonition Icons Missing

Been writing some reference documents in my new ‘best friend’ – the asciidoctor markup syntax. For some time now i get puzzled when i want an admonition icon to appear in my document but it won’t. Ok my markup looks good to me and i have installed the ruby asciidoctor version:

jnorthr@jnorthr-EC548AA-ABU-a1128-uk:~/Desktop$ asciidoctor -V
Asciidoctor 0.1.4 []

So a typical document like this works fine except that the beautiful image icons do not show up. I thought at first i had to lug around a folder of ./images/icon/*.png and all that stuff but it irked me somewhat.

My text of

= Notes About Asciidoc Sample Applications
jnorthr <>
v1.0, 2014-06-01 updated 7 June 2014

:icons: font

NOTE: Asciidoctor now supports font-based admonition icons, powered by Font Awesome!

== Overview

Caelyf lacks a template servlet for markup documents written using the asciidoctor markup syntax.

== Sample Application

You can find most of our sample applications on our github anynines account at[]. 

WARNING: You will need to signup with a cloud foundry PaaS provider before running any of these samples.

looks ok and renders as html quite nicely.



So that’s not what i need is it ? Where are my awesome icons ? Well, it turns out that i needed to add a bit of code to pull down the awesome.css stylesheet that has all the magic. So on the line just above

:icons: font

I added a passthru comment that renders in the final html document. That passthru comment looks like:


v1.0, 2014-06-01 updated 7 June 2014

<link rel="stylesheet"  href="">

:icons: font

So we need an external css link specification between the document date line and the icons font line. See my <LINK code above, and yes you do need to include ++++ lines above and below it too.

If you put that line into your .adoc script, so should experience the joy and pleasure of visible awesome fonts for all asciidoctor admonitions !   🙂



Gradle Properties in Cloud Foundry Closure

See notes here:

1. according to gradle documentation, we can put our PaaS cloud foundry target credentials into


like this:


with single quotes. If we do that, we get this result:

 Authenticating to '' with username ''''
 POST request for "" resulted in 401 (Unauthorized); invoking error handler
 :template-project:cf-login FAILED

FAILURE: Build failed with an exception.

but removing the single quotes makes it work.

NOTE: Gripe !! the credentials in take precedence over those declared in our gradle script closure !!! So if we deploy the same app to several different PaaS targets we can not declare credentials in we just need a build.gradle script for each PaaS target  😛

2. plugin cf-push where there is already an existing service leaves orphan services that were originally attached. Is this because of the “rediscloud-${randomWord}” random word declaration in the cloud foundry closure ?
3. same as 2. but also looses the uri as there is no/or a faulty rebind of uri to our app


4. cf-push of new app that does not already exist appears to work, correctly builds services and binds the uri correctly.


5. also note that ~/.gradle/ needs a password too, so: