Pither.com

by Simon Pither, freelance developer and systems administrator

Edward and the sunflower

Posted by Simon Pither
Wed, 21 Jul 2010

Over the last few months "Edward" has grown a sunflower.

Edward with young sunflower

It started off with him planting a seed in a little plastic cup at nursery. When he brought it home with instructions to water it and return photos of progress we were expecting to have to start dodging the subject within a week or two! Our track record with plants is rather appalling! In fact I don't think we've managed to keep a single new plant alive since we've been in this house - about two years now.

Despite our assumed failure, Liz decided to at least try. She watered the seed regularly-ish and remarkably, pretty soon we actually had a fairly promising looking start of a plant. It soon got too big for it's little plastic cup though, so Liz (after only a couple of weeks of us saying it was needed!) moved it into a larger pot.

Liz was now watering it quite religiously. We started taking photos (fairly frequently just in case it should suddenly realise where it was and keel over dead) of Edward with the plant and even sent a few of them into nursery.

In summary it is with great delight and complete amazement that we can now present a fully grown and flowering sunflower...

Edward with large sunflower

...does anyone know if/how we can collect seeds from it for next year??

A to B

Posted by Simon Pither
Wed, 21 Jul 2010

I need to get from A to B, how should I do it? My obvious considerations include cost, environmental impact and my non-working time.

There is parking at the destination and a nearby train station so I can choose between car and train.

Option 1 - car

Time

Google maps has plotted a pretty simple route that it thinks will take 31 minutes and is 11.1 miles long. I wont be travelling at peak times, so hopefully the estimate is reasonable. With time to get in and out of the car this will consume about 35 minutes of my day (each way), during which time I obviously can't be working.

Cost

At 11.1 miles and approximately 30mpg (which my new car seems to be managing), the fuel cost is approximately £2.

Environment

My car claims it outputs 124g/km of CO2. I suspect in the real world it's actually slightly higher, but I don't have any better number to use. So for 11.1 miles it will produce about 2.2kg of CO2.

Option 2 - train

Time

National Rail can offer me a fairly well timed train, although I do need to change once during the journey. The total travelling time is 38 minutes. During which I can probably squeeze 28 minutes of work in (ie excluding change over time and assuming I get a seat on both trains).

However the public transport option has an extra time cost - I must walk at both ends of the journey to reach the stations. The walking time for a single direction would total approximately 30 minutes.

So this option, while providing me some working time while travelling, actually still removes about 40 minutes from my working day.

Cost

The train cost for each direction is £6.25 (the return fair divided by two).

Environment

According to the train CO2 calculator at co2balance, my single train journey would produce 2kg of CO2. Although this appears to be to the nearest kg and when I ask it to calculate for a return journey the total is only 3kg, so I will use 1.5kg as a fairer number.

Conclusion

I was expecting to travel by train, however it turns out that travelling by car for the day would save me 10 minutes of working time and £8.50 of real cash. It would however cost the world an extra 1.4kg of CO2.

Going back to co2balance they have a number of projects you can put money towards in order to offset the CO2 you produce. The most expensive project they currently offer is £9.00 per tonne. So the "cost" (if I wanted to offset it with money) of my 1.4kg of CO2 is approximately 1p. Although co2balance appear to insist on a minimum payment of £2.50.

So if I offset the extra CO2 (at £2.50), using the car still saves me £6 of real money, 10 minutes of working time, any risk of getting hot/sweaty/rained-on and all the normal train hassles (changes, late, cancelled, etc)!

This is a fairly local journey so perhaps that's just not where trains excel!?

Envelope senders for Grails mail plugin (Spring Java Mail)

Posted by Simon Pither
Tue, 22 Jun 2010

I would have expected the desire to set a specific envelope sender address for mails from a web-app to be fairly common. However finding information on how to do it with the Grails mail plugin (ie Spring mail (wrappers for JavaMail)) proved much harder than I expected.

In fact, I ended up reading the source code!

It turns out that setting a single, application wide envelope sender is pretty easy (and is actually documented in various places). Simply set a value in Config.groovy such as:

grails.mail.smtp.from = "envelope@domain.com"

In my case though, I was looking to implement VERP for a mailing list, so that wasn't suitable.

From reading the source I discovered that the JavaMail SMTPTransport would actually check if the message it was given was an SMTPMessage and would respect the envelopeFrom property if it was.

To take advantage of this but still make use of the message builder from the mail plugin, I wrote a small service that wraps around the normal mailService:

import com.sun.mail.smtp.SMTPMessage
import javax.mail.internet.MimeMessage
import org.springframework.mail.MailMessage
import org.springframework.mail.javamail.MimeMailMessage
import org.grails.mail.MailMessageBuilder

class AdvancedMailService {
    static transactional = false

    def mailService
    def mailSender

    MailMessage sendMail(String envelopeFrom, Closure callable) {
        def messageBuilder = new MailMessageBuilder(mailService, mailSender)
        callable.delegate = messageBuilder
        callable.resolveStrategy = Closure.DELEGATE_FIRST
        callable.call()

        def message = messageBuilder.createMessage()
        mailService.initMessage(message)
        MimeMessage mimeMsg
        if(message instanceof MimeMailMessage)
            mimeMsg = message.getMimeMessage()
        else
            mimeMsg = message

        SMTPMessage smtpMsg = new SMTPMessage(mimeMsg)
        smtpMsg.envelopeFrom = envelopeFrom

        mailService.sendMail(smtpMsg)
        return message
    }
}

You have to call it as a specific service, but otherwise it's much the same as the normal mail service, eg:

advancedMailService.sendMail("list-recipient=theirdomain.com@domain.com") {
    from 'Mailing List <list@domain.com>'
    to "recipient@theirdomain.com"
    subject "Test mail"
    body(view: "/mails/test1", model: model)
    headers([
        'Precedence': 'bulk',
    ])
}

Now I just need to set something up to process the bounces. I wonder how easy it would be to embed James!?

SparkleShare: self-hosted, git based, DropBox clone

Posted by Simon Pither
Tue, 15 Jun 2010

At the end of last week I came across this article announcing SparkleShare.

As an aside, I am slightly concerned that I can't actually recall how I came across that article! I think the influx of links (and general information) from RSS, Twitter and Facebook will eventually make me melt!

Anyway. SparkleShare is something that I've been wanting for a while. Online storage, including version control, that I can host myself. I already have large amounts of disk space available in fairly well connected servers, so to have a convenient way of using and sharing some of that space is great.

Yes, I've actually been able to do this for a long time already as I could use git directly (and actually I do for one document store), but it's not that convenient. When you're not at a command prompt and not in an editor that's git aware, having to take that extra step means it's often overlooked.

So what SparkleShare is really providing is a fluffy, friendly UI to make it all nice and manageable with a daemon to sit in the background and automatically push and pull changes.

SparkleShare has already declared an intention to create OS X and Windows clients as well, which is another critical part of making it truly useful for me.

The slight downside to SparkleShare is that it's a long way from complete at the moment. Oh, and it's written in C# to run within Mono. :-(

In fact the very first thing I tried to do (well, second I guess after adding a repository) caused it to go rather wrong. I tried adding a few multi-hundred megabyte files to the directory SparkleShare had created for me. Sadly this rapidly resulted in 100% CPU usage, attempts to "git add" before the copy had finished and things generally going wrong.

Thankfully it's Open Source so I decided I may as well fix it, after all it probably wouldn't hurt to at least know a little C#. So I now have my own gitorious clone complete with some fixed code and a merge request pending for the original author.

I've also made a very basic start at building it into a Debian package (Ubuntu 10.04 i386) (see the debian branch in my repository above). It's missing some runtime dependencies and the build process needs lots of fixing, but it does work and I now have it installed and working on a few machines!

Hello Fabia

Posted by Simon Pither
Mon, 14 Jun 2010

Last week I collected my new car:

My new Skoda Fabia

So far, so good. It's quite red (the only non-white, free colour), which I did fear slightly but I actually haven't noticed too much. It seems pretty quick, both accelerating (and I haven't even tried very hard yet as the manual tells me I must be patient!) and cruising happily at 70 on the motorway.

The leg room in the back is slightly less than the Prius but the boot space is much more and overall the Fabia is a few centimetres shorter. I've found a comfortable driving position much faster than I did with the Prius, although I am still tweaking it a little.

The only downside I've found so far is that there is a noticeable delay between pressing the accelerator and the gear engaging. This is only when initially pressing the accelerator at low speeds or from stationary. When returning to the accelerator at higher speeds or just pressing harder it's very responsive.

I've found that pressing harder, faster seems to get things going sooner. Although you do then have to ease off again quite quickly so as to avoid going nowhere due to wheel spin instead of going nowhere due to lack of engaged drive. I'm still working on it, but hopefully I'll get the balance right soon!

Follow the FIB Final on SupaJam

Posted by Simon Pither
Tue, 8 Jun 2010

Today is the Fast Track to FIB 2010 final. For the first time there will be live footage uploaded to SupaJam as the day and night progresses.

This means I get to spend the day in London editing, preparing and uploading photos and videos.

Thankfully I've spent the last couple of weeks preparing the SupaJam site to make my job nice and easy - if it all goes according to plan I might even get to enjoy some of the entertainment!

If you want to see what's happening and witness my hard work, keep your eyes on The Fast Track to FIB 2010 Final page on SupaJam.

Bye Bye Prius

Posted by Simon Pither
Tue, 8 Jun 2010

Last week I said good bye to the Toyota Prius I've been driving for the last two years. I'm actually pretty indifferent to see it go. Which is quite a change from my last car, which I still miss! The Prius did at least have a little LCD with pictures of which motor is currently powering the wheels though! Despite it's inability to excite, the Prius has still served our purposes well over the last two years.

Toyota Prius

It's managed to carry a family of four with all their luggage, although sometimes with a squeeze, and keep us all quite comfortable.

For possibly the first time since I learnt to drive (over a decade ago!!), I'm now spending about a week entirely car-less. This wasn't exactly deliberate but the build and delivery of my new Skoda Fabia Estate has taken rather longer than first estimated.

Remarkably the Fabia has roughly the same fuel economy as the (old model) Prius yet has a quicker 0-62 time. Unfortunately it does have higher CO2 emissions though, so the tax is a bit higher.

The Fabia model I'm getting is brand new - they only started building them in April, so I've not actually driven a car with the exact model, engine or gearbox, so I do hope it will be reasonable. Sadly I'm not really expecting anything more than reasonable as it only needs to be a sensible, cheap family car.

One day I'll have a sports car again!

Older posts