Tuesday, 7 December 2010

Alpha transparency

So I'm looking at 8 increments between 0 (Hex 00) and 255 (Hex FF)... except that there's really 9 because of numbering starting at 0... adding 32 (256/8 = 32) each time worked a treat... especially when I knocked the 1 off of each result:


Which allowed me to create this PNG image via SVG:

Sunday, 5 December 2010

Wampserver & Symfony

  1. http://www.wampserver.com/en/download.php for WampServer 2.0i. download and install
  2. WAMPSERVER (System Tray) » Apache » Apache Modules » rewrite_module
  3. WAMPSERVER » PHP » PHP Extension » php_xsl
  4. remove ";" from line ;extension=php_xsl.dll in C:\wamp\bin\php\php5.3.0\php.ini
  5. Add C:\wamp\bin\php\php5.3.0\ and C:\wamp\bin\mysql\mysql5.1.36\bin\ to PATH in ENIVROMENT VARIABLES
  6. Cmd to C:\wamp\bin\php\php5.3.0\ and "php -d phar.require_hash=0 ./PEAR/go-pear.phar
  7. Execute C:\wamp\bin\php\php5.3.0\PEAR_ENV.reg
  8. pear channel-discover pear.symfony-project.com
  9. pear install symfony/symfony

Thanks to Anand Sharma and michoz.

Thursday, 2 December 2010

Bloody Cold...

Me and 'er-indoors spent most of the evening arguing about who'd be wearing my hap last night... just a shame that it looks like I'm wearing a cat on my head!

One for #3 son (check the originals here):

Thursday, 25 November 2010

Move Window & SendTo Menu

I'm not sure why but I'm forever finding Windows just at the edge of the screen so I can't see what's on them... a quick Google always find a solution but in the interests of not making Google my brain I've decided to write down here the solution:,/p>

  1. Hold down the ALT key.
  2. Press SPACEBAR.
  3. Press M (Move).
  4. A 4-headed arrow will appear. When it does, use your arrow keys to move the outline of the window.
  5. When you are happy with its position, press ENTER.

Another thing I keep having to Google is the location of the SendTo Menu, so here it is:


Nuff said about this!

The other thing I need to remind myself is the SendTo.

It's relatively easy to get a Visual Studio Installer to create a shortcut within the SendTo menu directory (see above), if a little convoluted but to get that shortcut to show is less easy... in fact it's a bit of a killer! Which is where Orca comes in handy (Orca - The Killer Whale... geddit?).

Open the msi, select the Property table and add another row with a Property of DISABLEADVTSHORTCUTS and a Value of 1. Save and exit and the next time the installer runs then the shortcut will appear in the right-click context menu.

Tuesday, 23 November 2010


My weekend watching:

Skyline: brilliant special effects but a story with more holes than my Dad's vest and characters you can't care about. If you've watched Independence Day, The Matrix and Cloverfield you've seen it already!

Harry Potter and the Deathly Hallows: Part 1: Miserable as sin but not as much fun! Felt like an obvious lead-up to the last film. A filler like The Empire Strikes Back was a filler - can't be blamed for that though - Part 2 wouldn't be as cool as it's promising to be without it. Life is a narrative and sometimes the middle act needs to be a bit boring and mundane.

Predators and The Tournament on DVD, both marvellous in their own way. Predators was a astoundingly well-made homage to all the previous films and managed to make me forget all the other, less-well-made sequels to the original film. Whereas The Tournament was a non-stop, action-filled exercise in gorgeous sillyness! Excellent and worth a watch!

Thursday, 18 November 2010

Devilishly good!

Got this for an early Xmas present and used it yesterday with #3 son. We only had cheese and veggie ham with some veggie worcester sauce (what’s going on with the spelling there, I thought it was Worcestershire – it is!) or cheese and prosciutto with some baked beans and coleslaw - but it was lovely. One of the things I miss about living on dry-land is the lack of mains electricity, no Microwaves, toasters or sandwich toasters (or TVs for that matter) but this makes it all okay as I can still have toasted sandwiches! Yay!

It comes with a leaflet full of recipe ideas but I can’t bring myself to do the sweet recipes… toasted sandwiches should be savoury and not sweet! As should, thinking about it, French toast – though Wikipedia doesn’t agree. I find there is little better in life that French toast covered in Ketchup or Brown Sauce. I’ve a theory about the age of children and their taste in French toast condiments: when they’re young they invariably choose Ketchup but you can chart their maturity by the propensity to opt for HP. I’d be interested in your opinion of this theory as I’ve a limited dataset with which to work.

Also finished Doctor Who: Evacuation Earth yesterday. A lot like the Professor Layton DS games but with somewhat easier puzzles, which is why it only took me a couple of days to complete it. Didn’t like the Sliding Puzzles though managed them, more than likely due to brute force attacks rather than any strategy.

Wednesday, 17 November 2010

Not Kitkat

Pub quiz score = 30/60... valdy poor!

Knew I'd seen this advert just not where... knew it was advertising something long, sticky (as in stick like) and brown and thought it was Kitkat or Pepperoni... forgot about the chocolate fingers!


Sunday, 14 November 2010

Web Designers vs. Web Developers (Infographic)

free website builder

Web Designers vs Web Developers is brought to you by Wix.com
Use creative design to make a Free Website
You are most welcome to share this infographic with your audience.

Wednesday, 10 November 2010

Windows 7 hosts file

So Windows 7 uses the hosts file like nigh on every other OS and, thanks to lots and lots of messing around with servers, my hosts file was messed up. All I wanted to do was set up localhost to point to!

I use Boxer but every time I edited the file and tried to save it it wouldn't let me, telling me that Access was denied!

I guessed that this was down to not running Boxer as an administrator so instead of using the nice shortcut I usually use to launch Boxer I found it in the Start menu and right-clicked it as chose "Run as administrator", this let me save properly and now localhost points to the IP address! Yay!

Monday, 8 November 2010

Brain not working

I'm not sure why it is but my brain has crashed today. It could be the weather (which is dull and wet), or the odd Camelot liqueur that my Ma brought me back from Ibitha. Whatever it is, my brain's just not working! Woke at 7:30 after going to bed at 21:30 last night and I'm still tired! That after getting up at 10:00 yesterday morning!

Shame really as WordPress is defeating me - or should that be that my previous hacking of wordpress is defeating me when I'm trying to rationalise a theme I'm working on - ohh woe is me!

Did hear something interesting over the weekend though... someone said, "put a backslash on that". How cool!

Saturday, 6 November 2010

Luke’s Parrot

Professor Layton and the Unwound Future has some cool Parrot mini-games. After getting stuck I did some research and found these images (Thank you Isenet via this post):


Tuesday, 2 November 2010

Disposable Panda

// The instance field Name pertains to an instance of a particular Panda,
// whereas Population pertains to the set of all Pandas:

public class Panda : IDisposable{
  public string Name;                     // Instance field
  public static int Population;           // Static field
  public Panda (string n){                // Constructor
    Name = n;                             // Assign the instance field
    Population = Population + 1;          // Increment the static Population field
  void IDisposable.Dispose(){
    Population = Population - 1;          // Decrement the static Population field

static void Main(){
  Panda p1 = new Panda ("Pan Dee");
  Console.WriteLine (p1.Name);            // Pan Dee
  Console.WriteLine (Panda.Population);   // 1
  using(Panda p2 = new Panda ("Pan Dah")){
    Console.WriteLine (p2.Name);          // Pan Dah
    Console.WriteLine (Panda.Population); // 2
  Console.WriteLine (Panda.Population);   // 1
  Panda p3 = new Panda ("Zi Chi");
  Console.WriteLine (p3.Name);            // Zi Chi
  Console.WriteLine (Panda.Population);   // 2

I'm working through the examples in C# 4.0 in a Nutshell, Fourth Edition and I got to thinking about how to erase an instance of a class... using seemed to be the way to go so I implemented the IDisposable Interface and now I've got disposable Pandas!


Now after years of working in the NHS the idea of an appraisal fills me with dread. I worked nights, you see, and no one could be arsed to appraise the night staff. Every so often some nice, well-meaning, newly-appointed and probably almost terminally-naive DCN would suggest checking how I was getting on.

What with my great hatred of getting there earlier than I needed to (except, of course, to give me enough time to make a coffee and have a fag before hand-over) - and their soon-waning desire to stop later than they absolutely needed to in order to listen to my rants - I very rarely left work in the morning with a new set of aims and objectives.

Cool ehh?

That is/was the case anyway… except when something had gone pear-shaped… then I was bombarded by enquiries about how I felt about the job (hated it), how I felt I was getting on (hadn't killed anyone, so not so bad) and, every-so-often, what I wanted out of the future (NASA has unfortunately stopped taking applications from balding, fat Yorkshire men who drink like fish and smoke like chimneys so I'll be waiting until the aliens come before I can visit space shall I? (I did say about the ranting above)).

All very usual really… but now I'm in a job I enjoy and the idea of an appraisal fills me with dread for a different reason… what if they ask me how I feel about the job (love it), how I fell I’m getting on (flashes of pure genius and then long periods of slog (everyone who's worked with me will know how much I swear at the computer and then, every-so-often, how I wake up from introspection and declare myself the GREATEST!)) and what I want from the future (more of the same but with shorter periods of slog and more flashes of genius - ohh, and the raise in retirement age isn't a problem as I'd happily do this forever)?

What if they say they need to speak to me because, horror of horrors, something I’ve done has gone pear-shaped (surely not, I now check everything I do in IE6 as a matter of course)?

But it was all actually very civilised, they did just want to know what I’d enjoyed, what I’d not enjoyed. What they could do to make things better and all that sort of stuff… I left feeling as though something had been accomplished rather than as if someone had had an awful thought in the middle of the night and realised that the night staff hadn’t been appraised for the last five years… and what would the Care Quality Commission think of that?

I’m not sure how long my dread of appraisals will last though, I think it’s going to take a fair few in order to get over my phobia of them and for me to appreciate that they don’t just happen because someone's got a bee in their bonnet or because something’s gone wrong.

We’ll see.

Friday, 29 October 2010

Very, very cool... but is it art?

Came across this via Who killed Bambi and I think it's lovely but it did get me thinking.

I've heard criticism of Banksy's work which states that it isn't art but is simply playing. I'm not sure that I'm qualified to judge that (Banksy is careful not to call himself an artist anyway) but I know what I like… and I really like Lipstick Enigma. That might be the juxtaposition of something so soft, curvacious and feminine as lipstick with something like a bitmap font.

Lipstick Enigma from Janet Zweig on Vimeo.

Anyway, I think that this is cool and should I be loaded I'd certainly buy it… in the meantime I'll keep on trying to figure out how it's done so I can recreate it myself.

Monday, 25 October 2010


I've been learning C# for a week or four and a lot of the examples I've looked at deal with Point values… these are to do with Co-ordinate systems. I like co-ordinate systems generally - I'd not like SVG as much as I do if I didn't - but I'm not totally au fait with the lingo in this respect so when I came across this:

The easiest way to construct a Point is to pass two integers as the abscissa and the ordinate parts of the coordinate...

I nigh on shat!

After a bit of judicious define:ing though, I discovered that the abscissa is the “the value of a coordinate on the horizontal axis”… cool ehh? The ordinate is simply the other number.

Having said this I do get a little confused with these systems as I’m pretty sure that SVG and the Canvas use different co-ordinate systems (Nope, that’s wrong, they both count down from the top, as does Processing (the next thing I need to play with))… wonder what I could have been thinking of…?

Thursday, 21 October 2010

Beer Isle

Despite #3 son having the opinion that anyone who drinks, even if it's a solo port and lemon at Christmas, is an alcoholic he's got the eyes of a SHR when it comes to the beer isle in Tesco's. Once he's gone and got his pre-tea nuts, and I've got the fixings for that nights tea, we wander down the beer isle and he checks to see if they've got Poacher's in yet... when we see that they haven't his eyes start roaming the shelves. Yesterday he found Tesco Finest American Double IPA. A very fine beer if enough to make you go crossed-eyed (9.2%), truly a beer on steroids!

I found Greene King Very Special India Pale Ale all by myself, that's tasty as well!

Tuesday, 19 October 2010

The problems with tea-tree and gravity

I love the feeling of tea-tree shampoo on my head... a bit like having a million pins pushed into my scalp slowly, exciting and just on the nice side of painful (now that does make me worry). So I got all excited when I found some nice tea-tree shower-gell. I thought that that, along with a buf puf, might make for a lovely, invigorating shower!

Unfortunately, the astringent property of the buf puf combined with the aforementioned "million pins" qualities of the tea-tree led to some little discomfort. A scrotal sac has, even at my advanced age, a lot less surface area than a scalp (especially at my advanced age - interesting thought there: if the number of wrinkles increases on your scalp, does that mean that the surface area of your scalp increases... and does that rate of increase match the rate of increase of the old scrote caused by gravity?), but quite probably the same or even many, many more nerve endings.

Needless to say I stopped using it!

Except that on Monday I thought I'd try to wake myself out of a nigh on terminal case of man-flue with a hair wash using the tea-tree shower-gell, and some nice, gentle stuff on the rest of me... I didn't count on gravity - and the action of the water rinsing off of me - to transport the god-forsaken tea-tree oil down the rest of my body though! It woke me up all right, but it was a bit of a rude awakening!

It's in the bin now!

Thursday, 14 October 2010


Who'd a thunk it! From the divine Programming C# 4.0 (p25).

Earwigs in my handlebars

Most mornings I get a tickle on my left hand while I'm cycling along Midsummer Common, it's not a creepy tickle but certainly noticeable. I look down and there's an Earwig scuttling along the back of my hand, so I flick it off. Monday morning there were three: two on my left hand and one on my right hand. Last week I saw one half in and half out of the little hole at the end of the handlebar so I'm guessing they live there or something...?

Wednesday, 13 October 2010

Talent book profile

POTENTIALSeeks new ChallengesEnigmaGrowth EmployeeNext Generation Leader
Potential growth / role expansionDilemmaCore EmployeeHigh Impact Performer
No / Limited GrowthUnder PerformerEffectiveTrusted Professional
 Does not / partially meets expectationsMeets expectationsExceeds expectations

The jQuery plugin that ate the world!

So I was looking at placing a Wordpress pages content flow into columns as I was using the YUI 2 to format the page… I thought about using jQuery and worked up an example using some of Karl Swedberg's work as a basis along with inspiration from Adam Wulf. But… the script worked by looking at each element… each p, each hr and each and every h2. After it counted 'em all it divided 'em by 3 placed that number in each column… which is cool except that a hr is a lot shorter than a paragraph (generally) and the layout broke.

I then started pondering getting the computed style (and don't get me started on how this is a bugger when IE is involved) of an imaginary page with the same width of the columns and then splitting that in 3 and somehow getting that chunk of elements (and perhaps splitting the odd p in the process) and putting them in the place where they're supposed to go… but that get problematic when you start to ignore hrs, you might end up getting the hr, which I was using as an underline to the h2, at the start of one column when it should be at the bottom of the other… or even better, beneath the heading at the top of the next column because the script was smart enough to know where headings - as well as horizontal rules - should properly go. Needless to say, it was getting far too complicated!

I had visions - nay, nightmares - about this plugin. I dreamt it got more and more complex, that I managed to write some weird, otherworldly, algorithm to predict where the breaks should occur, that it began to read the minds of the authors to such an extent that it'd correct the content on the fly, that it became… to all intents and purposes, the jQuery plugin that ate the world!

So I looked at something else before the weird little plan that I had in my head started to develop it's own form of consciousness and looked at the Wordpress Codex again.

I found some stuff on shortcodes (which are a simple set of functions for creating macro codes for use in post content). and so I wrote these:

function basic_leftcolumn($atts, $content = null) {
  return '<div class="yui-u first">'.$content.'</div>';
add_shortcode("leftcolumn", "basic_leftcolumn");

function basic_middlecolumn($atts, $content = null) {
  return '<div class="yui-u">'.$content.'</div>';
add_shortcode("middlecolumn", "basic_middlecolumn");

function basic_rightcolumn($atts, $content = null) {
  return '<div class="yui-u">'.$content.'</div>';
add_shortcode("rightcolumn", "basic_rightcolumn");

Which, when placed in the functions.php file in my theme worked a treat except that extra brs were introduced... after some research I found this code from Adding Column Layout Shortcodes to Your Wordpress Theme:

function webtreats_formatter($content) {
  $new_content = '';
  /* Matches the contents and the open and closing tags */
  $pattern_full = '{(\[raw\].*?\[/raw\])}is';
  /* Matches just the contents */
  $pattern_contents = '{\[raw\](.*?)\[/raw\]}is';
  /* Divide content into pieces */
  $pieces = preg_split($pattern_full, $content, -1, PREG_SPLIT_DELIM_CAPTURE);
  /* Loop over pieces */
  foreach ($pieces as $piece) {
    /* Look for presence of the shortcode */
    if (preg_match($pattern_contents, $piece, $matches)) {
      /* Append to content (no formatting) */
      $new_content .= $matches[1];
    } else {
      /* Format and append to content */
      $new_content .= wptexturize(wpautop($piece));
  return $new_content;
// Remove the 2 main auto-formatters
remove_filter('the_content', 'wpautop');
remove_filter('the_content', 'wptexturize');
// Before displaying for viewing, apply this function
add_filter('the_content', 'webtreats_formatter', 99);
add_filter('widget_text', 'webtreats_formatter', 99);

Which also got added to functions.php and everything worked a treat!

Everyone is now happy and they can use a simple mechanism to split the content between the columns and the plugin is safely locked in the back of my head… never to menace the world again!

Monday, 11 October 2010

Suppression of IE Tooltips on an imagemap area

So I was messing around with image-maps so that I could get a visualisation to work properly on Internet Explorer... Except the tooltips which the browser threw up interfered with my own tooltips!

There seems to be masses of debate about whether or not it's a good idea to show the alt text for an image as a tooltip and the way around it generally is to have an empty title attribute suppress the alt text tooltip in Internet Explorer... except that that doesn't work in the context of image-maps...

Now I was looking into this as I was using javascript to generate a tooltip so I had to add event listeners (don't get me started on how that's a pain in the arse for Internet Explorer).

So within my code for the event handlers I simply used javascript to create a name attribute for the area and then populate that attribute with the alt text before clearing the alt text for the onmouseover event. For the onmouseout event I nigh on reversed it by adding the name text to the alt attribute before removing the name attribute.

Simple ehh?

This is the code, truncated to show what I mean:


function doSomething(event){
  // ...loads of code here...
    event.srcElement.setAttribute("name", event.srcElement.alt);
    event.srcElement.setAttribute("alt", "");


function doSomethingElse(event){
  // ...only a little bit of code here...
    event.srcElement.setAttribute("alt", event.srcElement.name);

Friday, 8 October 2010

Tories are wrong!

After news of Jeremy Hunt's pronouncement that the workshy should stop having children if they cannot afford them one is minded of the words of Jonathan Swift when he said:

I have been assured by a very knowing American of my acquaintance in London, that a young healthy child well nursed is at a year old a most delicious, nourishing, and wholesome food, whether stewed, roasted, baked, or boiled…

Food for thought indeed ;-)

How long will it be before he's slapped down by his superiors and the children of the poor are sent to schools where they are taught valuable skills a la Children of Earth and are never to be seen again? Except, perhaps, as a tasty pie…

Thursday, 7 October 2010

IE8 and SVG

So I've been working on and off on a visualisation for a few weeks now... I was really quite happy with the result too. Except that the client was demoing on IE8, which is a huge improvement on IE7 and IE6 etc but still sucks!

Everything was working fine in Opera, Firefox and Chrome but what with the client using, as I've said, IE8 I needed to think of something else.

So I looked at Raphael and other libraries but then I got to thinking how IE8 was an improvement because it could handle alpha-transparency.

Now the visualisation involved transparent layers upon a map. This got me thinking: The map could be a suitably sized div with a jpeg background-image and then layering the different images atop that div by setting their position as being absolute in regards to the absolutely positioned map div.

The original visualisation used the SVG in order to trigger some pop-ups that gave further information, but that wasn't now possible so instead I looked at something really rather old school and thought about image-maps.

Image-maps used to be really quite popular but have recently lost ground to more modern approaches, I'm not totally sorry to see them go but I did find them a little useful at times... if a bit of a bugger to sort out by hand!

This is where Mapedit comes in useful though! What with the ability to zoom and having pixel-perfect control of the points of the image-map (and the judicious use of my Wacom tablet), it makes making an image-map a joy, and only $15!

So now I'm not quite so naffed-off with having to support IE8, that is unless future versions of browsers stop supporting image-maps!

Speaking of maps, prettymaps are cool, especially this one:

Wednesday, 6 October 2010

Bradford Factor

I've been doing a fair bit of work on the Bradford Factor for work... it's really quite nasty. I've had to generate some figures but couldn't clock what valid numbers there were so I created this spreadsheet to look up valid figures (no prime numbers allowed... except you can up until a certain number). If it help then please use it. It's got the number of periods of time off along the left and the total number of days off along the top.

Also had to do some stuff on the Myers-Briggs Type Indicator and I wanted to know what they were, the table below has a title attribute to each cell which'll show a tool tip for each type:


Friday, 17 September 2010

JavaScript 'if' shorthand

I'm not generally a fan of shorthand but the code I'm working on at the minute has loads and loads of if... else statements and they're making the code look bloody ugly so I thought I'd look at the shorthand for if... else. Turns out that it involves a ternary operator.

Anyway the code I'm working on looks like this:

  newColour = red;
  newColour = red;

Which becomes:

newColour = $('#reverse').attr('checked') ? red : green;

One line instead of five is a big improvement. And it works like this: condition ? result1 : result2;

Thursday, 16 September 2010

Shocking Ice Cream Commercials

Thanks to a post on Dvorak Uncensored:

I'm not sure about what message they're trying to give and I'm sorry about the ordering, I'm not sure what that's trying to say either...

M255 TMA 04 is in the bag!

Finally finished the latest and last TMA about half an hour ago thanks to insomnia and caffeine so today I get to play with maps of the RBWM. Yay!

As an aside there seemed to be an issue with the Bach/Chill interface (how often does one get to say that? (Twice now)).

Thursday, 9 September 2010

JavaScript getBackgroundImage(myDiv)

function getBackgroundImage(myDiv){
  // string to be returned
  var returnString = "";
  // Grab the offending element by id
  obj = document.getElementById(myDiv);
  // IE Opera
  if(obj.currentStyle) {
    returnString = obj.currentStyle.backgroundImage;
  }else{ // Firefox 
    returnString = getComputedStyle(obj,'').getPropertyValue('background-image');
  // this gives is something like: "url(someDomain.com/someImageDirectory/someImage.someFormat)"
  // so we get everything after the last "/" which leaves us with "someImage.someFormat)""
  returnString = returnString.substring(returnString.lastIndexOf('/') + 1);
  // so we get rid of the last 2 characters leaving us with:
  returnString = returnString.substring(0, returnString.length-2);
  // "someImage.someFormat"
  return returnString;

With thanks to this post on WebmasterWorld. So much for being a birdbrain!

Monday, 6 September 2010

JavaScript isEven(value)

Nice easy function to tell if a number is even:

function isEven(value){
  return value % 2 == 0;

Thursday, 2 September 2010

Seperate and Different

I though I needed to split the functionality of some similar pages depending upon the name of the page... I should explain better! I have some pages that all do pretty much the same thing on a given set of data... but not all of the pages react in the same way to events. So I got to thinking about how I could branch the code depending upon which page was calling the JavaScript, so then I got to thinking about how to find the name of the page and came across this code:

var sPath = window.location.pathname;
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);

But then that got far too complex and the JavaScript kept getting bigger and bigger and uglier and uglier so instead I had a different version of the same basic file for each page... but that got far to complicated in terms of remembering what I'd updated and where as I was developing... so I got the thinking about PHPs include() but JavaScript doesn't have one, it does however have fantastic DOM support so, thanks to a little research, I found this code from the really rather excellent Stephen Chapman. Now I've still got the separate JavaScript files for each page - but these pages are far smaller and concentrate on the differences rather than having to keep abreast of the similarities - but all the common functionality is kept in a separate file so that I don't need to hunt down each function in each file and update with the latest version. Cool ehh?

Wednesday, 1 September 2010

createLink(text, uri, img, alt)

So I've been working on a breadcrumb navigation where I'm using JavaScript to generate a number of CSS styled HTML list elements. Each of these elements are made up of a text element and an image so that in terms of the DOM they look like this:

  <a href="someUrl.html">
    someText <img src="someImageLocation.png" alt="someAlternativeText"/>

There were 3 of these links and the function was getting longer and longer, so I got to thinking about having to repeat so much redundant code so I pulled the 3 list items out of the function and created another function:

function createLink(text, uri, img, alt){
  var li = document.createElement("li");
  var a = document.createElement("a");
  a.setAttribute("href", uri);
  var liText = document.createTextNode(text);
  var liImg = document.createElement("img");
  liImg.setAttribute("src", img);
  liImg.setAttribute("alt", alt);
  a.appendChild(document.createTextNode(" "));
  return li;

Then I called that 3 times thus:

breadCrumb.appendChild(createLink("someText", "someUrl.html", "someImageLocation.png", "someAlternativeText"));

And Bob's your Uncle and Fanny's your...

Tuesday, 31 August 2010

beating the game

According to this post on the googlereader blog I'm beaten the game by reading more than 300,000 posts. YAY!

Older Men Scam

(Thanks to this post on uk.rec.waterways - I'm pretty sure that this has made it's way across the pond but I found it funny ;-))

Women often receive warnings about protecting themselves at the mall and in dark parking lots, etc. This is the first warning I have seen for men.

A 'heads up' for men who may be regular customers at Sainsburys, Tesco, Costco, or even Asda. A man can become a victim of a clever scam while out shopping. Simply going out to get supplies has turned out to be quite traumatic.

Here's how the scam works:

  • Two nice-looking, college-aged girls will come over to your car or truck as you are packing your purchases into your vehicle. Both start wiping your windshield with a rag and squeegee, with their breasts almost falling out of their skimpy T-shirts.
  • When you thank them and offer them a tip, they say 'No' but instead ask for a ride to McDonald's.
  • You agree and they climb into the vehicle. On the way, they start undressing. Then one starts crawling all over you, while the other steals your wallet.

I had my wallet stolen May 4th, 9th, 10th, twice on the 15th, 17th, 20th, 24th, & 29th. Also June 1st & 4th, twice on the 8th, 16th, 23rd, 26th & 27th, and very likely again this upcoming weekend.

So tell your friends to be careful. What a horrible way to take advantage of us older men. Warn your friends to be vigilant. Asda has wallets on sale for £2.99 each. I found even cheaper ones for £0.99 at the pound shop. Also, you never get to eat at McDonald's. I've already lost 11 pounds just running back and forth from Sainsburys, to Tesco, to Asda, Etc.

Please send this on to all the older men that you know and warn them to be on the lookout for this scam. (The best times are just before lunch and around 4:30 in the afternoon.)

JavaScript trim functions

These are from: Shailesh N. Humbad, and they are really rather cool, check out his site.

function trim(stringToTrim) {
  return stringToTrim.replace(/^\s+|\s+$/g,"");
function ltrim(stringToTrim) {
  return stringToTrim.replace(/^\s+/,"");
function rtrim(stringToTrim) {
  return stringToTrim.replace(/\s+$/,"");

arrayValueExistsAdapted(anArray, aValue) JavaScript

 * Tests to see if aValue exists in anArray. Doesn't check to see if the whole of aValue exists but instead looks at the 
 *   string which comes before a colon punctuation mark (":") within each string element within the array.
 * @param anArray - an string array which is parsed, the element which is tested is anything before a colon in each 
 *   element of the array.
 * @param aValue - a value which is compared to the part of the element of anArray which comes before the colon 
 *   punctuation mark.
 * returns true if aValue is found within anArray, else return false. 
function arrayValueExistsAdapted(anArray, aValue){
  var found = false;
  for (var i = 0; i < anArray.length; i++){
    var crumb1 = anArray[i].split(":");
    if (crumb1[0] == aValue){
      found = true;
  return found;

Adapted from arrayValueExists(anArray, aValue):

 * Test to see if aValue is present within the elements of anArray, returns true if it does, 
 *   else returns false.
 * @param anArray
 * @param aValue
function arrayValueExists(anArray, aValue){
  var found = false;
  for (var i = 0; i < anArray.length; i++){
    if (anArray[i] == aValue){
      found = true;
  return found;

valueToInt(value, up) JavaScript

 * Function which accepts two parameters.
 * @param value - value passed into the function either a float, int or string (containing a number).
 * @param up - boolean value which defines whether returned integer should be rounded rounded up or rounded down
 * If "up" isn't present then the number is rounded, if "up" is true then the number is rounded up 
 * else it's rounded down.
function valueToInt(value, up){
  var returnValue;
  // From: http://joeyjavas.com/2007/06/25/javascript-how-to-remove-all-commas-from-a-number/
  // If we have a number that's in the format 123,456.00 this removes the commas and gives us 123456.00 
  // which can subsequently be parsed as a float.
  if(typeof(value) == "string"){
    value = value.replace(/\,/g,'');
      returnValue = parseFloat(value)
      returnValue = 0;
  if(typeof(value) == "number"){
    returnValue = parseFloat(returnValue)
    returnValue = parseInt(Math.round(returnValue));
    if(typeof(up) == "boolean"){
        returnValue = parseInt(Math.ceil(value));
        returnValue = parseInt(Math.floor(value));
      returnValue = parseInt(Math.round(returnValue));
  return returnValue;

And to add them back:

function commaFormat(amount){
  var number = '' + amount;

  if (number.length > 3) {
    var mod = number.length % 3;

    var output = (mod > 0 ? (number.substring(0,mod)) : '');

    for (i=0 ; i < Math.floor(number.length / 3); i++) {

      if ((mod == 0) && (i == 0)){

        output += number.substring(mod+ 3 * i, mod + 3 * i + 3);

        output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);

    return (output);

  else return number;

As per CodeColorizer or here.