technology

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 php.net

I wrote a small explanation of a call-by-reference problem. Taken from php.net'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.


<?php
$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.

Drupal code formatting for Zend Studio or Eclipse

I modified David Kent Norman's Drupal.xml code formatter for Zend Studio/Eclipse PDT so make arrays look nice. It's minor stuff, but such a relief to give up inserting spaces and indenting. I think Turing said that computer programming should always be an interesting task, because any trivial activity could be automated.

PHP development IDEs and why you should have one

I've been doing a lot of development in PHP recently. I started programming in C/Codeworks, but it wasn't until I did some work in OpenCV and Visual Studio that I started seeing the value of IDEs. Having a good debugger is essential to resolving bugs in a timely manner. While it's possible to integrate a text editor, profiler and version control system with a debugger, it takes time to setup and maintain this tool chain, time that I'd rather pay someone else to spend.

Linux shutdown command variants

shutdown -r now
resets and restarts the computer

shutdown now
turns some machines off (which is technically called a halt)

shutdown -h now
shutdown and halt/turn machine off

Can't call arguments.slice() in JS

Javascript is a wonderful language, full of twists and turns. I was surprised that I could:


arguments.length

but not


arguments.slice()

It turns out it's because arguments is not a real array, but a function, which you can access like an array, e.g.:


arguments[0]

To do a slice() op on it:


var args = Array.prototype.slice.call(arguments, 1);


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