Backbone.js requires underscore.js to be in the global page context

I was loading underscore.js then applying the .noConflict(). When Backbone (0.5.1) was loading, it couldn't find Underscore (window._). This manifested as a Firefox console error "f is undefined".

Once Backbone has loaded, you can safely clean up both libraries without disrupting either:

var b, u;
b = window['Backbone'].noConflict();
u = window['_'].noConflict();

ZendServer upgrade includes MySQL 5.1 but breaks logfile size

I recently upgraded my ZendServer (development) from 5.0 to 5.6.0. This includes PHP 5.2.17 and 5.1.50. Everything worked very smoothly, but when I restarted my machine MySQL failed to start (Error 1067). I googled my way to this post, then found the .err file in MySQL's /data directory:

InnoDB: Error: log file .\ib_logfile0 is of different size 0 45088768 bytes
InnoDB: than specified in the .cnf file 0 56623104 bytes!

synchronising time between two linux servers using SSH

NTP is a fantastic protocol, but there are cases where you don't want to have another daemon running on a server. This script connects from machine A to machine B using SSH, reads the time from B and applies it to A.

# fetch time from machine B
time=`ssh -p522 "date +'%m%d%H%M%Y'"`
# apply date to local machine (A)
echo "Setting time to "$time
date $time

Make Skype start minimised

Every time I restart my computer, Skype (5.5) loads, logs in and opens a window. I discovered how to make it load minimised:

  • Find the Skype program files folder(C:\Program Files (x86)\Skype\Phone)
  • Create a new shortcut
  • Modify the target to read /secondary /minimized
  • Find the Windows startup folder
  • Delete or move the old Skype shortcut out
  • Move the new shortcut in
  • Run Skype, select View -> Compact mode

The value of a good backup

I've got a 2TB Western Digital drive that's showing the early signs of failure. It corrupted a 1GB file the other day. The thing is that corruption could be caused by the NTFS driver (Tuxera NTFS for Mac), or even the media encoding software that produced the file (Handbrake). Only time will tell when either a second file is corrupted, or the drive entirely fails.

Firefox showing spinner indefinitely for HTML 5 (video.js) .ogg embed

One of my sites uses HTML 5 to show video on the homepage. The VfE embed worked fine in Safari/Chrome/IE but had stopped working in Firefox. It just left the loading spinner spinning indefinitely and refused to play. I tracked it down to the source=".../video.ogg" line.

Google Maps tile display bug for KML layers

I've encountered a problem with the Google Maps API, specifically with the KML layers on my Surfy Survey map. The KML-enhanced tiles occasionally fail to load and default back to the normal tiles. This produces a map that shows part of a heatmap, as the two images below illustrate. This behavior is non-deterministic.

array_walk snippet on

I wrote a small explanation of a call-by-reference problem. Taken from's array_walk description, it reads:

I wanted to walk an array and reverse map it into a second array. I decided to use array_walk because it should be faster than a reset,next loop or foreach(x as &$y) loop.

$output = array();
array_walk($input, 'gmapmark_reverse', $output);
function gmapmark_reverse(&$item, $index, &$target) {
$target[$item['form_key']] = $index;

Can't test if a non-image file exists on a remote server

I've been messing around with javascript, trying to find out if a javascript file exists on a remote server before loading it. It turns out the same origin policy thwarts my ajax attempts and <img> tags can only test for images.

Vertical centering in CSS for content of unknown height

I read this excellent article on centering and as the comments are suspended, I thought I'd post about it instead.

I think the floater div position is inconsistent. In 'Which Method?' the floater is a closed tag above the content. In Method 3 the floater wraps the content.

Also a potential con for Method 3 is that you need to know the height of the content, where as you don't for Method 1.

I went with Method 1 as IE9 supports it, though for wider compatibility I should include the IEx hacks.

Alex Stanhope is a Technology consultant to the UK Creative Industries and Venture Catalyst. This is my personal website.
Bristol | Lightenna | ManKind Project | goodkarma
All material copyright (c) 2006-2010 | Website by Lightenna, featuring N.Design's GlossyBlue theme.
Syndicate content