Category Archives: software

How to access your app engine dev server from another machine

I keep forgetting how to do this so I’m writing it down in the vain hope I may commit it to memory.

The problem

You want to access your locally running dev server on another machine on your local network or maybe even from a virtual machine. whatevs.

The solution

Start your dev server with this extra program argument (you can find this under “debug configurations” in eclipse):


Now remember it you stupid brain.

Gradle users

If you’re using Gradle then you need to set it in httpAddress like this:

appengine {

    httpAddress = ""
    httpPort = 8888
    downloadSdk = true

Head First Servlets and JSP Errata

I’m sitting another Sun* Certification exam tomorrow to become a Sun Certified Web Component Developer (SCWCD). I’ve done a bit of revising but I’m writing this post mainly as a way to procrastinate. I should take more exams really if only as a way to get other things done. Procrastination during my final year of uni enabled me to learn how to speedsolve a Rubik’s Cube.

I’ve just read the study guide for the SCWCD exam; Head First Servlets and JSP.

It’s quite long, and pretty good at sending you to sleep in the evening, but as programming books go, it’s good in the sense you can just read it without being sat at a computer.

I made a list of mistakes I spotted whilst reading the book almost like a game that made sure I read it thoroughly. O’Reilly offer a page for people to submit errata for this book but to be honest, I can’t be bothered. They should give people free books as a reward. Maybe if I mention the name “Kathy Sierra” in this post, she’ll find this from Google and post me a book herself 😉

p140 – in bullet 6 it should be “mostly
p315 – It says only four attributes are on the exam, but if so, it’s not clear which four.
p555 – an design principle
p557 – the size attribute disappears
p580 – directional quote marks are a problem throughout the book but the sample code in question 3 tries to concatenate a String that contains un-escaped quotes that can only end in tears.
p587 – valid uses of these tags
p590 – answer E is ticked even though it is incorrect.
p598 – the reason for Q17 option D is just badly phrased.
p599 – I don’t remember reading anything about the “variable” directive, did I fall asleep at that bit or have a got a page missing?!
p654 – A Brew Master gets special descounts
p677 – Missing T – CLIENT-CERT
p694 – Q1, option C has a space in front of it. This isn’t the only example in the book either
p710 – The book randomly applies ligatures for adjacent F and I characters. Annoyingly however, it does this in the “courier new” code examples which is chosen because it is a fixed width font. Blending F and I into a single charater width looks really strange to me. I picked p710 as an example because the first line doesn’t use a ligature, but the first bullet point does.
p747 – other client components
p777 – in the bottom right, the sentence doesn’t count all 5 jars
p787 – I don’ remember there being any talk of the Composite Delegate pattern in this book

Well, that kept me busy for a few minutes, I better take the mock exam and see how badly I’m going to fail this exam…

*I’m sure the Sun certification exams will be deprecated by Friday by a bigwig in Oracle towers.

Convention ÷ Configuration

I’ve long been sold on the concept of Convention Over Configuration. For me it’s a no-brainer, not only am I lazy, but when I am forced to make a decision about something technical, well, let’s just say the number of times I get it wrong is > 0.

Recently I’ve been playing around with Maven, something I should have done years ago. Maven seems pretty sold on the convention idea too and so I just expected a simple project to work “out of the box”.

Unfortunately, when I tried, I hit a problem with my first simple project. As you can see from the “reconstruction” screenshot, I had problem with recognising simple java 5 features.

I was using the latest copy of eclipse, on a fresh install of Ubuntu using OpenJDK. I’ve not developed with OpenJDK and so blamed that at first, it couldn’t possibly be Maven… So, I downloaded the Sun JDK, and as you can guess, I realised it was a Maven thing.

When you create a simple Maven project using the m2eclipse eclipse plugin it defaults to a Java 1.4 compliance level. What kind of sensible convention is that? I like to think there is a good reason for that because I imagine it has cost the community quite a few potential Mavenees.

Once you realise this is the problem, just change the project specific Java compiler settings to whatever makes sense for you.

I’ve not got any research or references to hand, but my gut tells me that the convention should be to use whatever the majority of the programming community agrees is the best version of the best tool for the job. If someone wants to use Maven for a project that needs to support backwards compatibility, then let them do the configuring, not me.

It also defaults to JUnit 3.8.1, another warning sign in my head. Everything else in Maven I have done so far has been a pleasure and m2eclipse looks like a great plugin, I just wish the defaults were not so 2004.

To fix this within the POM you need to add the following:



Keep your filling knife clean

I’m no expert when it comes to DIY. Enthusiastic amateur I’d say.

I fumble my way along, guessing how things should be done, and generally learn the hard way.

I needed to do some more filling today to plug the holes I’d left from my poor skirting board fitting skills.

My filling knife however was caked in gunk after a few years of not being cleaned properly. I kept it clean when I first got it, it was new and I took good care of it. Somewhere along the line though I got lazy, and did a half-assed job of cleaning that knife. The first bit of dirt that stuck proved to be a perfect home for future gunk to bind and the effort of cleaning that knife just grew exponentially.

I spent a bit of time trying to clean it but it didn’t take me long to realise that I could spend an hour trying to clean it and there’s every chance it would still be too dirty to do a good job. I just had to bite the financial bullet and buy a new one.

I’m writing this as a reminder to myself that if I can just keep my knife clean, I may never need to buy one again.

Like I said, I’m no expert at DIY.

I’m a software engineer so I don’t face these kinds of problems.

Voucher codes and promo wotsits

It’s 2009! Our digital lives are a breeze and online shopping is just one more option to the newly empowered consumer. Right?

I’m sure I’m not alone in finding the process of buying anything a little tedious now:

  1. See something in the shop you like
  2. Decide not to buy it because you don’t know if that’s a good price
  3. You get home and look on the internet
  4. Now you have to poke around a few websites and try to work out which is cheapest when you consider postage and tax etc.
  5. Maybe one of the sites gives you rebate if you go through a referal like quidco
  6. Maybe the site would give a discount if only you had a voucher code

If you ask me, It’s all a pain in the ass.

My brother emailed me yesterday:

Anyway you can crack into this site to find some good discount codes?

BR20 for 20% as expired.

I recognised this. He’s at stage 6 I thought (or at least I would have done if I’d numbered the stages in my head like I have above). He’s googled for a code but only found one that’s out of date.

I started to pen my reply:

I know I work with computers but there’s no way I can find out what the codes are, they’ll all be validated server-side when you try a code…

Then it hit me. Why not just brute force the code? Worth a shot right?

I cobbled together a littler bit of java to try various combinations of 2 characters followed by 2 digits based on the fact that the expired code was BR20 for 20%. The code below uses JWebUnit which is simply a convenience wrapper for HtmlUnit.

Long story short, it found several codes! One of which was for quite a substantial discount. I’m not going to post the codes (don’t bother asking). If you want a code, you’re welcome to run the sourcecode below or write your own. If the voucher code gets posted on the internet, it’ll probably get disabled pretty quickly too.

Has anyone else written similar things? I’m curious to what other approaches people may have taken. I also think it wouldn’t be too hard to make this a generic application that rattles through all possible codes for a user-supplied regex.

My advise to web developers for anything like this would be to introduce a delay after a few invalid guesses and then start doubling the length of the delay with each invalid guess. This would quickly make any brute force technique pretty useless.

[code lang="java"]
import net.sourceforge.jwebunit.junit.WebTestCase;

public class CodeFinderTest extends WebTestCase {

    public void setUp() throws Exception {

    public void test1() {

        for (int perc = 20; perc <= 100; perc += 5) {
            for (char firstLetter = 'A'; firstLetter <= 'Z'; firstLetter++) {
                for (char secondLetter = 'A'; secondLetter <= 'Z'; secondLetter++) {

                    // generate the next code to try
                    String code = Character.toString(firstLetter)
                            + Character.toString(secondLetter) + perc;
                    System.out.print(code + ",");

                    // basket_campaign_code is the html id of the text field
                    setTextField("basket_campaign_code", code);

                    // if the response didn't say "invalid code" then it must have said something else...
                    if (!getPageSource().contains(
                            "You have entered an invalid code")) {
                        System.out.print("\nWAHOO!: " + code);
                        // lets get greedy and bump up the percentage discount...
                        firstLetter = secondLetter = 'Z';