Software dev, tech, mind hacks and the occasional personal bit

Author: James Page 11 of 21

Simple REST Client

While preparing for my upcoming REST talk, I made a basic REST client. It’s nothing special but allows you to set the verb, request body and see the status code and all the headers on the response. It’s quite handy for debugging and exploration of RESTful services.

Feel free to download the:

Hope it is useful and saves you having to whip up your own little client!

UPDATE: Source now available on GitHub!

RiskAssess – Risk Assessments for Schools

I’ve been developing RiskAssess, an online risk assessment system for schools. RiskAssess helps teachers and lab assistants to quickly and easily produce risk assessments for laboratory experiments which meet Australian standards. RiskAssess should help decrease the number of accidents in school laboratories, and also help schools meet legal requirements.

I’m pleased to say that the site is now well and truly launched and we have schools doing risk assessments every day using RiskAssess. There’s still much to do and many new features to add, but so far we’ve had very positive feedback from the schools using the system.

On the technical side, RiskAssess is a Ruby on Rails site.

Tech Ed Talk: REST Patterns and .NET

I’ll be giving a talk at Tech Ed this year on REST and how it can be implemented in .NET, much inspired by the thoughts of Jim Webber on good RESTful web services, and Garr Reynolds on the “Zen” presentation style. Here’s some more info:

REST Patterns and .NET

Sydney Convention Centre, Darling Harbour
5 September 2008
10:15am – 11:30am
(ARC306)

REST has sparked furious debate, and reactions from fan-boy adoration to hate. As the arguments quiet and the dust settles, it is becoming clear that the RESTful style is a viable choice for the Enterprise. Framework support is growing rapidly. WCF now provides basic REST support. Meanwhile, the budding MVC framework opens the door to building services which leverage hypermedia. This talk will leave you with an understanding of the RESTful architectural style and provide you with recommendations on designing and building both simple and hypermedia driven web services in .NET.

Hope to see you there!

F-Secure Optus Internet Suite – To be avoided!

Optus, my ISP, is kind enough to give subscribers a free copy of F-Secure’s security suite which offers anti-virus, anti-spam and firewall. I read some half decent reviews of the product so I thought I’d install it and give it a go. Unfortunately, it was fraught with problems. First of all, after installing I got a blue screen on reboots. After uninstalling AVG (my previous anti-virus) in safe mode, my computer could boot. Next, I tried to do a full system scan, but the F-Secure automatic update kicked in at the same time and it crashed the scanner. So, I rebooted, and tried a full system scan. I tried twice, but each time, it hung on a random .class (compiled Java) from GlassFish. Not great. So I went to the F-Secure website to submit a bug report. I filled in the form, and couldn’t submit it because one of the drop down lists which was mandatory was disabled in Opera. I then thought I’d try the site in IE7, but IE7 just hung, presumably thanks to F-Secure’s firewall.

Overall, I would strongly suggest that you do not bother to try the F-Secure product suite, even if it is offered to you for free.

Wedding Reception in Sydney

On 10 May, we had our “second wedding” in Australia! It was awesome and we had a really good time with friends and family 🙂

More photos here:
http://flickr.com/photos/soosun_and_james/sets/72157605121741281/

The Long Tail by Chris Anderson

Just finished reading “The Long Tail – How Endless Choice is Creating Unlimited Demand” by Chris Anderson. In summary, the long tail is about selling small volumes of a vast variety of items instead of large volumes of a small number of “hits”. This possible when the cost of distribution to geographically distant customers is low and the cost of storage for stock is not a concern (eg, intellectual property in electronic format, JIT manufacture). Popular companies capitalising on the long tail include eBay, Amazon, Google Adwords and Lulu.

The book has a lot of interesting stories and statistics but tends to repeat itself often. The long tail idea is probably not new to most readers these days, and I think if you’re familiar with Amazon, there’s little that comes as a surprise. However, I did find an interesting section in the book about the tyranny of choice. Anderson suggests that choice is good, customers want choice, and choice is only a problem if you don’t know what to choose to suit your taste. Hence, an important part of a long tail business is helping people find what they want (ie, filter out noise) in all the vast array of choices. He suggests using user reviews, rankings, sorting etc as means to help people find the “best” choice for them. I also hadn’t come across Lulu before – looks worth checking out, a site for mini self-publishing.

Ginger Beer Recipe

Ginger Beer BottlesHome made ginger beer is awesome, and not hard to do at all. It takes a few hours to prepare all the ingredients, then several days fermentation, then another hour or two for bottling. Usually I make about 8 or 9 1L bottles of ginger beer in a batch, and I like to make it less sweet than the commercial stuff. It is slightly alcoholic (1-2% approximately) and has a really nice gingery bite the goes well with pizza, spicy food or just about anything else! I use a recipe adapted from the Ye Olde Ginger Beer Recipe. It is as follows:

Ingredients

  • 4 lemons
  • 900g sugar
  • 9L of water (enough to fill a demi-john)
  • 1 packet / 2 teaspoons of Ale yeast (you can use bread yeast if you’re desperate)
  • 200g fresh root ginger
  • 4 heaped tea spoons of tartaric acid (Cream of Tartar)

Equipment
Carboy

  • A large pot that can boil four litres of water
  • A jug
  • A glass
  • A coarse cheese grater
  • A wooden spoon
  • 10L carboy (10L water container does nicely) washed & sterilized with bleach
  • A bubble seal for the carboy
  • A lemon juicer
  • A lemon zester / fine grater
  • A fine sieve
  • 9 X 1.25 litre soft drink bottles, empty, washed & sterilized with bleach

Method

1. Fill pot with water and put on to boil

2. While the water is coming to the boil…

  • scrape the zest from one of the lemons
  • grate the ginger on the coarse cheese grater
  • add the sugar to the ginger and lemon zest in a bowl
  • cut the lemons in half and squeeze the juice into the jug
  • add the tartaric acid to the lemon juice
  • put the yeast into some warm water with a little sugar in a glass

3. When the water has boiled ….

  • add the sugar, ginger and lemon zest to the water, turn off the heat and
    stir
  • allow the water to cool to roughly blood heat, stirring occasionally
  • add the lemon juice and tartaric acid to the water
  • add the yeast mixture

Carboy with bubble seal

4. Use the jug to pour the mixture into the carboy and top up to 9L with boiled water (cooled to blood temperature)

5. Seal the demijohn with the bubble seal (I use salt in the water to sterilize the seal)

6. Stand the demijohn in a warm place for 48 hrs or for several days in a cool place

7. After 48 hrs pour the mixture through the sieve into the jug and fill the bottles leaving an air gap for the pressure to build up in (1L into each bottle). Screw the caps tightly onto the bottles

8. Leave the bottles at room temperature for 24 hrs (to generate the C02 fizz)

9. Put the bottles in the fridge for 2-3 days to allow the yeast to settle

10. Drink and enjoy 🙂

Notes
If you ferment the mixture in the carboy for longer before bottling, it will be less sweet and more alcoholic.

Photos from Sapa, Vietnam

I put holiday photos on my screen saver, and these favourites just came up. I thought I’d share them with you…

Exploring Sapa

Sapa Guides

Bounded Actions Using Lambda – IDisposable is old and ugly!

In .NET 2, it was all the rage to make hand-crafted, clever IDisposables that let you do a bounded action with clean up. Eg,

void SomeMethod()
{
        using (new SetCursorToWaitEggTimer())
        {
            VerySlowOperation();
        }
}

void VerySlowOperation()
{
    ... etc ...
}

This was kind of cute – you could make sure that, even if an exception was thrown, your clean up (eg, changing cursor back to normal) would occur. Implementing the IDisposable was a bit ugly but consuming it wasn’t bad.

Now, with the sexy C# 3 syntax, you can do something similar much more elegantly. Eg,

void SomeMethod()
{
       DoWithWaitEggTimer(VerySlowOperation);
}

void DoWithWaitEggTimer(Action action)
{
    try
    {
        Mouse.OverrideCursor = Cursors.Wait;
        action();
    }
    finally
    {
        Mouse.OverrideCursor = null;
    }
}

If you’re feeling like more adventures, you can also start passing these delegates around and injecting them. For example:

class SomeClass
{
    public Action RunSlowCode 
    {
    	get { return runSlowCode ?? new Action(a => a.Invoke()); }
    	set { runSlowCode = value; }
    }
    Action runSlowCode;

    void DoSomethingSlow()
    {
         RunSlowCode(PullDataFromExternalSystem);
    }
}

This approach allows you to inject the delegate for what happens when slow code is run. So you could inject DoWithWaitEggTimer() or something new like DoWithWaitMessageDisplayedToUser(). Similarly, it could be used for unit testing or injecting between layers in your application.

C# Default Access Modifier for Class Members – and drop that private habit!

The default access modifier for the members of a C# class (eg, fields, methods, and properties) is ‘private’. As such, I recommend never using the redundant ‘private’ keyword for class members. Leaving off the private nicely separates your privates from your public/inheritable interface in syntax highlighting. It also saves people having to read redundant code – you wouldn’t want your code to be full of un-needed casts, or redundant ‘this.’ references, would you?

Page 11 of 21

Powered by WordPress & Theme by Anders Norén