My first bit of Mootools and centering a Google Map in a hidden div

Started a new job last week for a really cool agency in a place I really want to work* – but they are Mootools users not jQuery folk, so I am been thrown headlong into (among other things) the world of Mootools. I’m used to just sitting down and being able to make things work quickly and painlessly with jQuery and it is funny being back to basics again. Today I wrote my first useful bit of Mootools code, which in the grand scheme of things is nothing – just a nice fading toggle to show and hide a Google Map – but it still felt good.

Along the way I had to ran into a problem with my map – when I showed it the centre-ing was gone – I tried all sorts of things… map.checkResize() didn’t work and map.setCenter() didn’t work.

Eventually I deduced that first you actually need to call both functions – reset, then centre e.g.

 
    map.checkResize();
    map.setCenter(new GLatLng(51.90568, -1.33214));

Along my way I have found a great article comparing jQuery and Mootools – which I would recommend to anyone going either way.

*But it is a kind of a personal philosophy not to ever say on my blog where I do work, just because. I’ve taken over a big project running on a Cloud server written by a load of other people, the sort of thing that is hard but very rewarding.
** I have no idea where those coordinates are. Maybe Up North somewhere?

I feel stupid blogging about a vacuum cleaner but…

We have just bought a new vacuum cleaner (I hate it when people (e.g. my girlfriend) call them hoovers)) to replace the beaten up old piece of junk we inherited from one of our grandparents.

Anyway other people we know did loads of research (like Which) and apparently the best vacuum cleaners you can get at the moment are Miele vacuum cleaners. So a few people we know bought them – and we’ve just got one…

And it really is amazing. It is awesome. It actually sucks the carpet up of the floor creating a kind of carpet wave as you hoover the room. Our house is considerably cleaner now than it was a few days ago.

Miele S 5211 Vacuum Cleaner

Miele S 5211 Vacuum Cleaner (on Amazon)

Ernest Marples postcode lookup is disabled

A while ago I came across a great UK postcode lookup service http://www.ernestmarples.com/ and wrote a post about it here.

Just went back to it a few days ago and unfortunately the service has been suspended. Luckily I didn’t have any applications using it (I mostly use the Google or Yahoo) – but it was a damn fast way to just get the co-ordinates of a UK postcode.

It’s just a shame that such a useful service has been shut down – obviously postcode data is worth a lot of money to Royal Mail – but surely more economic value could be extracted if postcodes were free.

If you are interested in how this pans out there is a blog.

Green Man Photos

A few photos from the Green Man music festival earlier this year. I always love night photos even if some of them are a bit out of focus…

(click on the photo to view the gallery)

Setting TinyMCE configs in Django settings.py

Working with the Django Filebrowser and TinyMCE I have just spent quite a while with an utterly frustrating problem.

I want to set all my my inserted image paths to absolute e.g. /media/uploads/someimge.jpg – in TinyMCE the way to do this is to set “convert_urls”: false

The relevant part of my settings.py file looked like this:

TINYMCE_DEFAULT_CONFIG = {
    'plugins': "table,spellchecker,paste,searchreplace",
    'theme': "advanced",
    'theme_advanced_toolbar_location' : "top",
    'theme_advanced_toolbar_align' : "left",
    'theme_advanced_statusbar_location' : "bottom",
    'theme_advanced_resizing' : "true",
    'convert_urls' : "false"
}

But nothing worked and my images were all being inserted as ../../../media/uploads/someimge.jpg

Eventually looking at the generated source of my page I realised that the problem was this was rendering “convert_urls”: “false” it should be rendering “convert_urls”: false

The solution is pretty obvious – but then they usually are:

TINYMCE_DEFAULT_CONFIG = {
    'plugins': "table,spellchecker,paste,searchreplace",
    'theme': "advanced",
    'theme_advanced_toolbar_location' : "top",
    'theme_advanced_toolbar_align' : "left",
    'theme_advanced_statusbar_location' : "bottom",
    'theme_advanced_resizing' : True,
    'convert_urls' : False
}

The reason it took me so long to figure out was that I tried to use ‘convert_urls’ : false – which just resulted in syntax error – coming from PHP I’m used to booleans being case insensitive – in Python they aren’t. It also explains why my ‘theme_advanced_resizing’ didn’t work either.