Please visit my new campsite listing site ukcampingmap.co.uk


Archive for September, 2009

Clever stuff with tables

Monday, September 28th, 2009

I’ve recently been getting to grips with the zend framework. I’ve been meaning to blog about it for a while, for there is much to discuss: appalling introductory tutorial, a class reference which for some reason is nowhere near as easy to use as others… but I will touch on all that some other time.

But I thought I should post this up before I forget. The site I’m working on at present has three kinds of users: superusers, teachers and students, with a separate database table for each kind. The tables for each could have been slightly different but I decided to make them all the same (with dummy entries in the few irrelevant columns, though later I may discover I can discard these). The reason for keeping the structure uniform was that I had an inkling that if I did I could use just one model in Zend to access all three tables… and the inkling was correct.

It took a little debugging and investigation of the Zend_DB_Abstract class, so for the benefit of others, to have a model that works for a number of tables simply start your class defininition as follows:

class Model_DbTable_GenericName extends Zend_Db_Table_Abstract
{
   protected $_name = '';

   public function __construct($type,$config = array()) {
     parent::__construct($config = array());
     $this->_name = $type;
   }
   ⋮
}

And to instantiate a DB model use the following:

$Data = new Model_DbTable_GenericName('specifictablename');

Whether or not your tables have to have exactly the same structure depends on how you define all your functions for interacting with the data – you might need to use conditionals if some tables have more or less columns than others.

Html 5 will kill us all

Saturday, September 26th, 2009

Being a font-end web developer is looking very interesting/scary at the moment. The web is awash with talk of html 5, how we should all be taking advantage of it now, and the various tools by Google and others for making it possible despite what internet explorer fails to implement.

It is, quite literally, mental!*

The last year of my web life has seen me learn more stuff (php, javascript, jQuery, Google Maps, Zend framework and more), more quickly than ever before, and there’s still a load of things uncompleted on my to-do list, Flash being the most prominent hole in my arsenal…

…until now.

My firefox has about 20 tabs open, most of them containing information about my industry that wasn’t very relevant until a few weeks ago. Now, if I’m to keep touting myself as a front-end developer of any quality I will have to learn about:

  • Vector graphics and animation, which will mean getting to grips with Adobe Illustrator and some vector graphics oriented javascript libraries which make working with Scalable vector graphics and the canvas element easier
  • The not inconsequential lengthening of the list of tags available for use in markup
  • Consider using  lot more javascript libraries as my approach to getting websites to work in ie, which runs contrary to what I’ve always done before.
  • And many more things, essentially revolving around the fact that so many things that designers would always have liked to do on websites have suddenly become feasible.

On the bright side though, SVG and canvas combined with some other subtler features of html 5 could make Flash relatively obsolete, which increases the value of the time I’ve spent learning javascript. The project I’m about to start working on was initially conceived as a Flash game, but as there’s very little animation involved I was able to propose writing it as a javascript game instead. With html 5′s new features there will be very little to elevate Flash above javascript any more in any context. Html 5 can even natively embed video.

Everything’s going to be alright.**

*I’ve been watching peep show this morning and feel constant urges to write a bit like Super Hans or Jeremy.

** or Mark

What is this?

Wednesday, September 23rd, 2009

It can’t be for real, surely. Not even Microsoft is this naff.

On the bright side though, it does mean my wait to get a new laptop is nearly over; no way was i gonna get one with Vista installed.
O

Curried Bream

Wednesday, September 23rd, 2009

Last week I was in Finland. In south-west Finland, in and around Turku, to be precise. One apparently defining feature of the Finnish life is to spend at least some of the summer months in a summer house in “The Archipelago”*. And a great custom it is too. A few days frolicking among the pine trees, taunting bears and finding inexplicable piles of apples.

The archipelago has quite a lot of water, being an archipelago, which is ideal for fishing (and canoeing, but let’s not digress). I haven’t been fishing since about the age of twelve, and even then I failed to catch anything. This time, after spending ten minutes or so digging up worms (and a solitary beetle grub we christened Harold), iida and me headed of to the jetty armed with nothing but a couple of sticks with a bit of fishing line and a hook tied on the end.

Bream/Lahna

A Bream about 1 2/3 the size of a size 10 shoe

So imagine our surprise when, five minutes in, iida hooked a whopper (Having shown this photo to a fisherman friend of mine, he swears it’s “6 pounds if it’s an ounce” – my words, not his (though the sentiment remains unchanged)). We checked with some locals if it was edible and were told hat it was a Lahna, and was good to eat, but full of bones. It looked like a Bream to me, and a Bream it was, and here’s how we cooked it. (Incidentally, it tasted much better when we had the leftovers the day after, so prepare a day in advance and reheat if possible).

Ingredients

  • Some potatoes
  • About half a bulb of garlic
  • A red pepper or two
  • 2 biggish onions
  • A thumb of ginger
  • A sneeze of garam masala
  • Salt as you like it
  • Rice
  • About 5-6 tomatoes (or a tin of chopped tomatoes)
  • Any veg you care to put in
  • As much chilli as you think appropriate
  • A big white fish (or several fish if your angling skills aren’t as impressive as iida’s)
  • A little butter

Cooking

  1. Dice the onion, cut the peppers into strips and cut up the ginger, garlic and chilli fairly thinly, though it’s probably best if you don’t dice them into tiny bits. Cut the potatoes into big-toe sized pieces, or maybe a bit smaller.
  2. Blanch and chop the tomatos. If you don’t know how to blanch you should have got a tin, but never mind – look it up on the internet.
  3. Melt the butter in a saucepan and fry the onions. After they’ve gone pretty soft chuck in the peppers, garlic, ginger, potatoes, garam masala and chilli. A few minutes later, chuck in the chopped tomatoes. Stir and leave to simmer until it’s starts to look like a mixture of soft stuff rather than just bits of different things. No more than 10 minutes.
  4. Put the fish in a baking dish and pour the sauce you’ve just prepared over he fish (if it’s a whole fish make sure you stuff some inside too. Cover with foil and put in an oven (preferably a hot one, though how hot is left up to you).
  5. Depending on the size of the fish it will take somewhere between not very long at all and quite long to cook. Make sure you start checking on it after about half an hour. And remember to cook the rice!

It’s rare I can say something I’ve cooked is one of the nicest things I’ve ever eaten. It’s even rarer I can say that something I caught then cooked is one of the nicest things I’ve ever eaten, but the meal described above is the bees knees. Even though some of the preparation (gutting and killing the fish (which clung to life more stubbornly than you’d think)) wasn’t exactly pleasant, the difference putting in your own freshly caught fish makes to the taste and satisfied feeling in your stomach is astounding.

*The collective noun for the many unconnected archipelagos of Finland is “The Archipelago”

Saving my neck

Wednesday, September 23rd, 2009

I don’t want to end up like the giraffe in the picture: a crick-necked invalid with blotchy skin. As I grow older the blotchy skin is probably inevitable, but the crooked neck/back is avoidable I hope.

The trouble is that for a living I do a mixture of two things:

  1. Bent double over a laptop, twisting my fingers at unreasonable angles in order to reach a keyboard shortcut
  2. Bent double over a guitar, twisting my fingers at unreasonable angles in order to reach a wicked chord

Both these activities lead to my back muscles being tensed in an uncomfortable position, with little movement to get blood flowing to the muscles. As an added bonus, my finger muscles are also generally making the same kind of not particularly relaxed movements every day.

So what’s the antidote to all this physical self-abuse?

The idea I’m trying at the moment is juggling.

I’ve been able to juggle for a little over a year, and several of my friends are fanatical about it (working for little while in a backpackers hostel in Amsterdam is a surefire way to get people to help/force you to pick up the basics), but I hadn’t done very much since the first months when I first picked it up.

Recently, however, I realised that juggling is the antithesis of the activities that are determined to wreck my spine:

  • Rather than crouching forward, to juggle you really need to stand quite upright; if you lean forward you end up throwing the balls forward, which eventually leads to either dropping them or running after them into traffic or something.
  • More related to guitar playing this, but juggling requires very relaxed, fluid movements of the arms and shoulders. While fluidity is essential to playing rhythm guitar well, it’s impossible to avoid tensing up somewhat during the pacy irish reels we play – there simply isn’t enough time between beats to led your arm lollop along. So juggling should hopefully help counteract the stiffness I’ve been getting in my upper back.
  • Despite the fact that you’re constantly grasping in the air to catch a ball, juggling requires you to relax your hand muscles too. Catching a ball when you juggle isn’t about holding it tightly; if anything, it’s closer to forming a cup shape for the ball to nestle into.

So, that’s the summary of why I think juggling might help. I’ll keep you posted on whether or not it is the miracle cure I’ve been looking for.

I am not responsible

Sunday, September 20th, 2009

http://www.timesonline.co.uk/tol/news/uk/article6836257.ece

This phoku thought leaving a train station would be easy

Sunday, September 20th, 2009

Cluttered disco world
Dance moves painted on the road
Please, where’s the exit?

Round and round

About phoku-ing time

Sunday, September 20th, 2009

A few months ago both my camera and camera phone were stolen/lost/victims of a fluctuation in the rules of physics, and since then I wrote phokus based on old photos of mine, eventually petering out to none at all.

But all that is about to change. I have finally picked up a cable for my new camera phone which means I am now able to actually make use of all the photos I’ve been taking.

So there’ll be lots more phoku-ing around from here on in.

PS – while searching for a flickr photo to illustrate this post I came across this hilarious story. Read it.

Not the village idiot any more

Saturday, September 12th, 2009

I’m starting to find that when I ask javascript questions on forums similar to

I’ve been using such and such a method to achieve something, but there must be a better way. What is it?

Then the answer that comes back is quite frequently (though far from always)

Your method is probably the best way.

Which is a nice feeling. As I’m a self-taught programmer I’ve always been very aware that most people I work with have studied and worked as programmers for years and years, and inevitably* have picked up a lot of tricks along the way… and that try as I might I can’t just learn these from a book or a website (though I’ll give it my best shot); it’s just a matter of building up years of experience, banging up against this or that obstacle and learning from other programmers.

So, considering that a year ago I didn’t know javascript, or any programming language, I’m pretty pleased that I can confidently lay claim to not being a complete moron any more.

*though it’s surprising how many exceptions to this rule there are.

Soap

Monday, September 7th, 2009

My local supermarket sells myriad varieties of shower gel but not a single bar of soap.

What’s the world coming to.