Skip to main content

Posts

An Exercise in Form Validation using JavaScript Prototyping

Form validation is an important part of most websites and more specifically client side validation is an important contribution to the the user experience. In the brave new world of "Web 2.0" we have access to tools like JQuery to help developers to do this sort of jazz with AJAX and the like. This however (regardless of how straight forward it actually is) is still scary and complicated for anyone not already familiar with JavaScript. The code I want to talk about here is of my own creation. I'll be the first to admit that "I am not a developer", and so the code itself may not be technically perfect, for this I make little apologies. What I set out to do is create a reusable code class; a class which can be reused to validate any form without modification or an excess of additional javascript. I also took the opportunity to tinker with 'prototyping' to take a true object orientated approach to the code; this makes it fast and hopefully easy to fo...

If you were an animal what would you be and why?

Recently I was asked to be involved in the recruitment process at my place of work and had to, with the help of two of my team members, spend half an hour interviewing prospective job candidates. Now I've had a few interviews in my time and seem mostly to do quite well in that kind of situation, but this would be my first experience on the other side of the table. I remember having read interview guides before now that had warned me to be prepared for silly questions like 'If you were an animal what would you be and why?'. So with the simple intention of using this very question as an icebreaker (and partly becaused I'd enjoy using such a cliché) we decided I could kick off with it. We weren't hoping to get anything useful out of it at all, but in hindsight the animal question proved way more valuable than I could have ever expected, not because of any in depth analysis into the answers, such as lions as leaders or any crap like that, but purely on how the inte...

Spawning many VirtualBox machines from a single VDI

What I'm taking about here is a way to have many VirtualBox machines based upon a single hard drive image. There are many reasons why you might like to do this, but the most compelling is probably saving time by not having to install an OS over and over again, especially useful if you do anything like software testing. Our goal is a single vdi (virtual disk) file which contains a vanilla installation of our favourite OS which we can then use to conjure up a fresh new machine in a jiffy. Assuming you already have VirtualBox installed our first step is (maybe for the last time ever!) to install our OS into a new virtual machine. Now I shan't go through this as it's pretty straight forward and if you're reading this it's the sort of thing you have probably done a hundred times before. One thing of note during the initial setup is the 'Virtual Hard Disk' configuration. Be sure to allocate enough space to allow for all potential applications of the image. It wou...

Cloning VMs with Multiple Snapshots in VirtualBox

I'll keep this short and sweet. I needed a way to backup a VirtualBox machine with multiple snapshots to a single detached VDI. ' VBoxManage ' is the command line tool with all the useful VirtualBox tools, and I had used its ' clonehd ' to good effect before now to clone existing VDI files. However as you may already know, when you snapshot a VirtualBox you end up with multiple VDI files; so how can we consolidate these into one VDI without having to mess around merging existing snapshots on a live service? Quite simply use the UUID of the state you wish to clone, this will create a new VDI of the associated snapshot, merged with ALL previous states... cool huh? You can get this out of the virtual disk management tool in the gui, or from the XML definition file for the machine, it'll look a bit like: c6804c54-a8ca-4829-9eaf-132f8b1dd38a So to make a spanking new single VDI for this saved state, run: $ VBoxManage clonehd c6804c54-a8ca-4829-9eaf-132f8b1dd38a MyN...

Banana Bread!

Just for a delicious change from geek speak, here is my recipe for Banana Bread (more of a cake really). 225g self raising flour ½ teaspoon salt 100g butter or margarine (unsalted) 170g soft dark brown sugar 75g raisins (or sultanas) 2 ripe bananas ½ teaspoon vanilla essence 1 egg, beaten 3 tablespoons milk (or dark rum!) Oven: 160 oC, 325 oF, Gas Mark 3 If you have time, or are prepared far enough in advance, it's extra tasty if you can soak the raisins overnight in dark rum, any rum that doesn't get adsorbed can substitute the milk in the recipe. 1)Line the bottom of a loaf tin with greaseproof paper and grease it up. 2)Put the flour and salt into a bowl, cut the butter up and add. Rub in until it resembles fine bread crumbs. 3) Stir in sugar and raisins. Mash banana with a fork (Well duh) and add to the mixture with the vanilla essence, egg and milk. Beat. 4) Put in tin. 5) Sift or sprinkle some of the dark sugar over the top of the mixture to give it a delicious sweet crisp...

Getting Debian to email with exim4 and Google Mail

There are may reasons why would might like to run a headless Debian server on your home network. I have mine primarily as as file-store, serving video, music and pictures to my Windows MCE PC (you see I'm not one of these Windows hating Linux nerds, use the right tool for the right job I say!). Being headless and tucked away in a dark corner it's important to be able to manage the system with little fuss, and I use ssh to login and administer the system remotely. The question here though is 'When do I know that I need login and do something?'. I ideally want to know asap if there are some important security updates ( apticron ), or that the raid ( mdadm ) has run into some trouble or if some important cron job has spewed some helpful output. Lucky for me is was fairly straightforward to configure the server to email my google mail (gmail) account whenever it has something important to say, and here's how I did it! I have this working on both Lenny and Squeeze. ...

USB Flash Drive Encryption

Securing data on a USB pendrive can allow you to carry around useful, yet sensitive data with very few concerns. This post outlines a way of cryptographically securing a USB pendrive using crypsetup and LUKS in such a way that a drive may be unlocked on most Linux system without the addition of extra software (e.g. TruCrypt). As an added bonus it's possible to mount the drive in a Windows environment as well. Hurrah! The first thing to decide is how you are going to partition your drive. I find it useful to have an unencrypted partition as well as the encrypted as this affords the convenience and functionality as well as offering security. The primary consideration here is that natively Widows will only recognise the first partition on the pendrive, so if you wish to have an open data partition let it be the first. Below shows how an 8GB pendrive (in this case the device is /dev/sdh) is split roughly is half with an ~4GB FAT32 partition at the front. Use you favorite partition...