Tuesday, 28 February 2012

This won't mean anything to anybody but Australians over 40...

To be sung to "The Screaming Jets" by Johnny Warman ...
A classic known only to over 40's...
If you're not in that group go look it up on YouTube.
Or follow this link: http://www.youtube.com/watch?v=Q26zl7x_EFE

Monday night, as I was dreaming.
I saw, the caucus was screaming.
I got the screaming shits.
Kevin-dumb-dumb-da-dumb.

Last night, Australia was crying.
I heard, the ALP dying.
- chorus -
I got the screaming shits.
Kevin-dumb-dumb-da-dumb.

No more, no more.
- again -
No more, no more.
Kevin-dumb-dumb-da-dumb.

Monday night, I was crying.
I heard, the NBN was dying.
There's a ring around the sun.
And it looks as the dawn of winter.
Where it all begun.
- chorus -

I got the screaming shits.
No more, no more.
- again -
No more, no more.
Kevin-dumb-dumb-da-dumb.

I got the screaming shits.
- again -
I got the screaming shits.
- again -
I got the screaming shits.
Kevin-dumb-dumb-da-dumb.

Ama-Julia Ama-Julia HA!
[repeat to fade out]

Thursday, 23 February 2012

Unbelievable - Telstra chat line broken.

As readers may know we've had endless issues with our phone line.

We live in a small group of units and I tried to get Cable from Telstra.
1km from exchange and CBD.
We have Foxtel cable in street pit, but Telstra says it can't provide any service and gives no explanation.
So I decided to try the Telstra live chat thingey to ask why.
This is what I got:

You gotta be joking.

Tuesday, 21 February 2012

IntelliJ Idea 11 and groovy/gradle projects fun and games


Part 1: That darned case when you lose all your gradle 'external libraries' stuff.

I tend to create groovy/gradle projects like this:

COMPANY=mycompany
GROUP=service
PROJECT_NAME=someProject
mkdir com.${COMPANY}.${GROUP}.${PROJECT_NAME}
cd com.${COMPANY}.${GROUP}.${PROJECT_NAME}
mkdir -p src/main/groovy/com/${COMPANY}/${GROUP}/${PROJECT_NAME}
mkdir -p src/main/runtime
cp /global/log4j.properties src/main/runtime
mkdir -p src/main/resources
mkdir -p src/test/groovy/com/${COMPANY}/${GROUP}/${PROJECT_NAME}
cp /global/build.gradle .
cd ..
svn add com.${COMPANY}.${GROUP}.${PROJECT_NAME}
svn -m Creation commit com.${COMPANY}.${GROUP}.${PROJECT_NAME}
cd com.${COMPANY}.${GROUP}.${PROJECT_NAME}
svn propset svn:ignore -F /file/with/.gradle/and/build/in/it.txt .
svn -m Upload commit .
gradle

That's overblown, but you get the idea.
My dev style tends towards floating back and forth between IDEs and just plain vi/cmd line.
Sort of like companies floating between out/in sourcing.
I get pissed off with Eclipse, switch to Netbeans, get pissed off, switch to IntelliJ, get pissed off, switch to the cmd line, get pissed off, switch to Eclipse... Round and round we go.

Recently I decided to commit myself to IntelliJ Idea 11 (for a while).
And ran into problems with library dependencies.
First up I have two offices.
So If I committed the blah.blah.iml to SVN at the office and then tried updating at home, Idea11 had issues.
The reason is the:

jar://$USER_HOME$/.gradle/caches/artifacts-7/artifacts/56865c09425cc6ecda8606d7e6035ceb/blah/blah...

Stuff in the blah.blah.iml file.
Your hash key won't be the same as the one in your ~/.gradle/caches/artifacts-7/artifacts/... folder.
The trick is to make sure your global build.gradle has 'apply plugin: idea' in it, and run 'gradle idea'.
This will create a new blah.blah.iml file.
(along with an .ipr and iws file which you can safely delete)
Your project will now open and correctly load all the dependencies.
Just remember not to commit your 'at-home' .iml file unless you feel inclined to do the same thing at your office...

Part 2: You've created a plain groovy/gradle project and you just can't get Idea11 to open it.

This is probably because you're using some external build.gradle with the 'apply from: /some/global/build.gradle'
You just get this annoying 'unable to resolve' popup and you're stuffed.
The reason is that Idea11's module IS the .idea folder, and you don't have one.

The trick is the similar to the above.
Do the 'gradle idea' trick at the cmd line, then create a NEW project BUT DON'T CREATE A MODULE.
Then once you have the project loaded, add the module by pointing at the .iml file.

Monday, 20 February 2012

Movie Review: Vampire Girl vs Frankenstein Girl

Yes really.
Normally when we watch a sci-fi or horror movie that is bad and takes it self seriously, I rip on it.
But this movie is just plain insane.
And hilarious.

So how would I describe it? Well. Take Bob the Builder, then add:
  All the Troma films
  Hannibal Lecter
  The Banana Splits
  Reanimator
And:
  Film it in Japanese
  Snort coke
  Laced with acid
Now you have a sense for the movie.

Things I learned:

  1. Vampires have flip top heads with 3,000 teeth.
  2. Japanese people have around 6,000 liters of blood at high pressure.
  3. Stiches are so last century - why not use philips head screws - which are alive.
  4. Blood is sneaky - a single drop can chase you around the room and charge up a mop handle.
  5. All nurses are sex starved sluts.
  6. Sumo warriors have head mounted cannon.
  7. Vampires have built-in blood powered roller skates.
  8. St Francis was a psychotic nutso-bong vampire killer.
  9. High school chemistry teachers follow in the footsteps of Herbert West - but with feelings and full Kabuki kit.
  10. Janitors are never involved with the killings.
  11. Frankenstein girls can fly but only by bolting their arms to their heads and spinning them.
  12. And have interchangeable flesh lego/meccano parts.
  13. Igor (the janitor) can explode into dust for no apparent reason.

YOU HAVE GOT TO WATCH THIS MOVIE.
Admittedly you'll get a hernia from laughing, but it's worth it.

Wednesday, 15 February 2012

It's 5am and I'm awake and bored

I woke up with IAAS, PAAS and SAAS models spinning in my head and needed a break.

So I went to www.fishpond.com.au and browsed the science books "new releases" and "coming soon."
It never ceases to amaze me how many real physical books there are still left to read.
Here are some gems:

Oxford Handbook of Oral and Maxillofacial Surgery (Oxford Medical Handbooks) (Can I have new teeth buds now please?)
This Will Make You Smarter: New Scientific Concepts to Improve Your Thinking
Calculus Diaries: A Year Discovering How Maths Can Help You Lose Weight, Win in Vegas and Survive a Zombie Apocalypse (The last bit is what I'm after)
Non-Toxic Avenger: What You Don't Know Can Hurt You
The Conundrum: How Scientific Innovation, Increased Efficiency, and Good Intentions Can Make Our Energy and Climate Problems Worse (Soooo getting this one)
How to Survive in Anaesthesia: A Guide for Trainees (Wait. What?)
Watermelons: How Environmentalists are Killing the Planet, Destroying the Economy and Stealing Your Children's Future (Getting this one too)
Pocketbook of Emergency Care: A Quick Reference Guide for Paramedics (For your Go! bag perhaps?)
Making Your Home Sustainable: A Guide to Retrofitting (Arduino to the rescue!)
Think Like a Pancreas: A Practical Guide to Managing Diabetes with Insulin
Chronic Illness: Impact and Intervention
The Quantum Universe: (And Why Anything That Can Happen, Does)
Catholic Bioethics for a New Millennium (Say what?)
Self Comes to Mind: Constructing the Conscious Brain
The Great Disruption: How the Climate Crisis Will Transform the Global Economy
A Universe from Nothing: Why There Is Something Rather Than Nothing
Moby-Duck: The True Story of 28,800 Bath Toys Lost at Sea and of the Beachcombers, Oceanographers, Environmentalists, and Fools, (Remember them?
The Happy Atheist: Dancing on the Graves of the Gods
Beautiful Ducks (I love ducks)
Silent Spring Revisited (loved the first version...)
The Manga Guide to Linear Algebra (Yoikes)
Engineering Principles of Combat Modeling and Distributed Simulation (fascinating)

I've actually ordered some of these...

Seriously Odd Results from Google

We had KFC last night. One of the most frustrating things about having a fresh Bucket'o'Bits in the car is that I can smell chlorine or ammonia or bleach or something.
B can't smell it, but it bugs the hell out of me.
So I went to Google and entered "why does kfc smell of chlorine"...

Gods teeth and little chickens! People are just plain weird!
On the first page of results I got these gems:

"My girlfriend won't let me smell her period blood..."
"Rotten Chicken Industry-What The Non Muslims Say"
"Chlorine and your Thyroid, the good and the bad..."

No. No she won't. Why? Because you're weird. Seek help.
So I switched from chlorine to ammonia.
And would you believe it!

"My girlfriend won't let me smell her period blood..."
"Top 10 Most Gross & Disgusting Foods"
"My store bought salmon smells like ammonia?"
"Why does my urine smell like chicken gravy?"

Chicken Gravy? Gack... See a doctor.
So I switched from ammonia to bleach.
You gotta be kidding me:

"Daily Life of the KFC Killer Freaky Creeps, a Bleach and Vampire ..."
"Does anyone besides me love the smell of car gasoline?"

After some adjustments to the search terms I did eventually find out that the smell was probably the Sulfur Dioxide they use to whiten the fries before cooking.
But seriously, those first two pages made me worry about Googles search algorithms.

Book Review: "Future Science - Essays from the Cutting Edge"

I'm trying to be charitable here. Problem is that I'm a crotchy old sod.
My problem is that I expected something more.
Of the 18 essays, only a few actually stood out as being "cutting edge" for me.
The reason is that I consume technical and science books and magazines continually.
And this book is not intended for that kind of audience.
It's intended for the casual reader who wants a glimpse into what's happening across a broad spectrum of scientific disciplines.
I just did some checking of other reviews on this book and (apart from the fact that most seem to be puzzlingly similar to each other) they all praise the book for exactly the reasons I'm not.

Most other reviews seem to fixate on a specific essay about infinity as being an example of difficult 'out-there' science.
Hmm. Having studied Brian Greenes descriptions and visualizations of the inflaton field I found that essay slow and not difficult at all.

In general I'd suggest that if you read New Scientist or visit http://www.sciencedaily.com/ or http://www.physorg.com/ at all, then you probably don't need to read this book.

In any case, the book would be a good primer for people wanting a peek into what's new.
For anyone who regularly reads scientific journals or books, not so much.

Tuesday, 7 February 2012

Using a groovy script to ssh tunnel to a host and execute a command and saving the result

Using a groovy script to ssh tunnel to a host and execute a command and saving the result


Long title...
Anyway, recently need to use groovy to ssh tunnel to a remote host to execute commands.
Here is a rather convoluted and contrived example of how to do it.

Create x.groovy somewhere.
First we import jsch:

import com.jcraft.jsch.JSch
import com.jcraft.jsch.Session
import com.jcraft.jsch.UserInfo
import com.jcraft.jsch.Channel
import com.jcraft.jsch.ChannelExec

And properties..

import java.util.Properties

Now we create some variables defining the ssh firewall server, localhost and the target host:

def sshHost = '192.168.1.1'
def sshUser = 'ssh_user'
def sshPass = 'ssh_password'
def sshPort = 22

def localHost = '127.0.0.1'

def targetHost = '172.16.1.1'
def targetUser = 'target_user'
def targetPass = 'target_password'
def targetPort = 22

We start first by setting up the properties.
You don't strictly need properties as a HashMap would do.

println "Opening connection to ${sshUser}@${sshHost}:${sshPort}"
Properties config = new Properties()
config.put("StrictHostKeyChecking", "no")
JSch jsch = new JSch()

Now we get our session to the firewall:

Session sshSession = jsch.getSession(sshUser, sshHost, sshPort)
sshSession.setPassword(sshPass)
sshSession.setConfig(config)
sshSession.connect()
println "Connected"

Now we get a free port and forward localhost to the target machine:

println "Forwarding connection to ${targetHost}:${targetPort}"
def assignedPort = sshSession.setPortForwardingL(0, targetHost, targetPort)
println "Got port $assignedPort"

Now we have two choices. Use AntBuilder with the sshexec call, or do raw InputStream reads:

1 - Use AntBuilder:

def result = ''
def ant = new AntBuilder()
// This bit is to stop ant hijacking stdout.
logger = ant.project.buildListeners.find { it instanceof org.apache.tools.ant.DefaultLogger }
logger.messageOutputLevel = 0
logger.emacsMode = true
// Ok. Do it...
ant.sshexec(
  host: localHost,
  port: assignedPort,
  trust: true,
  username: targetUser,
  password: targetPass,
  command: '/bin/hostname',
  outputproperty: 'result',
  verbose: false
)
// And show the result
println ant.project.properties.'result'

2 - Use raw InputStream handling:

Session targetSession = jsch.getSession(targetUser, localHost, assignedPort)
targetSession.setPassword(targetPass)
targetSession.setConfig(config)
targetSession.connect()
println "Connected"

// Could use "shell"
Channel channel = targetSession.openChannel("exec")
// Let's just get the hostname
((ChannelExec)channel).setCommand("/bin/hostname")
// Spew errors to console
((ChannelExec)channel).setErrStream(System.err)
// We're not sending anything
channel.setInputStream(null)
// Get the input stream
InputStream is = channel.getInputStream()
// Connect
channel.connect()
// This could be written better and groovier...
byte[] tmp = new byte[1024]
// Uh oh. We really need a better way out of the loop... :-(
while (true) { 
  // But it's just an example... :-)
  while (is.available() > 0) {
    int i = is.read(tmp, 0, 1024)
    if (i<0)
      break
    System.out.print(new String(tmp, 0, i))
  }
  if (channel.isClosed()) {
    // All done.
    System.out.println("exit-status: " + channel.getExitStatus())
    break
  }
  // Ugly: You might want to change this
  try{Thread.sleep(1000);}catch(Exception ee){}
}
// Close channel and session
channel.disconnect()
targetSession.disconnect()

And finally disconnect:

sshSession.disconnect()

Now how do you run it? You have to tell groovy where the jars are...

groovy -cp /path/to/jsch-0.1.46.jar:/path/to/ant-jsch.jar x.groovy