Sid Roberts http://www.sidroberts.co.uk Well, hello there! This is the site of Sid Roberts - a web developer in Leeds, England. I'm a 16-year old high school student studying Computing, Mathematics (Mechanics), Further Maths and Economics. Fri, 26 Dec 2008 15:50:24 +0000 http://wordpress.org/?v=abc en hourly 1 A Day Of Video http://www.sidroberts.co.uk/2008/12/21/a-day-of-video/ http://www.sidroberts.co.uk/2008/12/21/a-day-of-video/#comments Sun, 21 Dec 2008 21:47:52 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=139 Having spent the day muxing video, converting it from one format to another and compressing it, I don’t intend to do it again any time soon. There’s just so much you have to take into consideration and even a simple task can become extremely difficult. Because some of the common tasks I had to do were so difficult, I’ll be writing several tutorials to aid anyone else who finds them coerced into the world of video.

]]>
http://www.sidroberts.co.uk/2008/12/21/a-day-of-video/feed/
Microsoft Math http://www.sidroberts.co.uk/2008/12/07/microsoft-math/ http://www.sidroberts.co.uk/2008/12/07/microsoft-math/#comments Sun, 07 Dec 2008 15:36:01 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=127 After a seemingly never-ending torrent of (GCE level) maths homework, I’ve had to turn to Microsoft Math for help. I can’t recommend it enough as it does everything I need it to do. And for $20 (about £10), it’s hardly going to break the bank. Unfortunatley, it’s not received an update for about 18 months and it doesn’t appear to be updated any time soon but it’s still a solid piece of software and definitely worth the price. You could even argue that it doesn’t need updating.

]]>
http://www.sidroberts.co.uk/2008/12/07/microsoft-math/feed/
Tux? http://www.sidroberts.co.uk/2008/11/27/tux/ http://www.sidroberts.co.uk/2008/11/27/tux/#comments Thu, 27 Nov 2008 10:18:10 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=124

]]>
http://www.sidroberts.co.uk/2008/11/27/tux/feed/
Want To Cancel An Account With 1&1? http://www.sidroberts.co.uk/2008/11/22/want-to-cancel-an-account-with-11/ http://www.sidroberts.co.uk/2008/11/22/want-to-cancel-an-account-with-11/#comments Sat, 22 Nov 2008 14:53:04 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=117 Go to http://contract.1and1.co.uk/ and follow the on-screen instructions. Having just spent the morning in the depths of the 1&1 FAQs, I’ve noticed a lot of tutorials and information that is no longer relevant or no longer works so it’s best to check other blogs to see how they did it. The differences between the American and British sites are very subtle and usually just boil down to .com and .co.uk. And as I’ve spent a good hour trying to login into the American cancellation site, I can assure you that the customer IDs (actually Account IDs or a domain name registered with the account) do not work with the wrong site - which, in hindsight, should have been expected.

]]>
http://www.sidroberts.co.uk/2008/11/22/want-to-cancel-an-account-with-11/feed/
WordPress 2.7 http://www.sidroberts.co.uk/2008/11/18/wordpress-27/ http://www.sidroberts.co.uk/2008/11/18/wordpress-27/#comments Tue, 18 Nov 2008 20:22:24 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=108 With the impending release of WordPress 2.7, I thought I’d share some of the new features and styling from the betas.

First thing’s first, the admin pages have seen a big redesign which nicely brings WordPress up to date with trendy drag-and-drop functionality. The new design has a very clean and simple look yet it packs in lots of information, stylishly. It’s not as colourful as 2.6 which worries me in a way as the colours they have used look garish and out of place.

What strikes me most is how integrated WordPress now feels. Once you’ve installed it, you may never need to use FTP again. Plug-in installs and updates can be done within the admin interface - very easily.

Of course, as with many big version overhauls, most plug-ins don’t work and there are quite a few things that I don’t think have been wisely placed. For example, whilst the new navigation strip is a welcome change to the old navigation bar, it is too long and there are quite a few things that I’ll never use. Of course, you can “minimise” it if you wish.

There’s been a big push towards making the interface more customisable and so you are able to remove panes that you don’t like and you can even transform it into a single column display just by dragging the panes into one single column. So in a sense, it feels a lot more like a desktop application.

QuickPress allows you to quickly bash out a post - Twitter-style - and whilst I probably won’t be using it, I can see many who will. Although, with the lack of category selection, its potential is seriously limited.

Added to all these new features, 2.7 also sees a huge number of security fixes and general bug fixes - essentially making this a must-upgrade situation.

Among all the seemingly Web 2.0 traits, 2.7 transforms WordPress into more than just a simple blogging platform. And I dare say that this new version will be one of the major evolutions of WordPress so far.

]]>
http://www.sidroberts.co.uk/2008/11/18/wordpress-27/feed/
Windows 7 http://www.sidroberts.co.uk/2008/11/10/windows-7/ http://www.sidroberts.co.uk/2008/11/10/windows-7/#comments Mon, 10 Nov 2008 20:55:25 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=96 I’ve recently found myself enticed with all the Windows 7 articles demonstrating things to come from the operating system that’s now being dubbed “what Vista could have been”. And already it certainly looks like Microsoft’s attempt at rectifying all the things that Vista fell down on.

All the legacy programs like WordPad and Paint have been updated and are now in fitting with the new look of Windows. Notably, the calculator has received a large upgrade and it boasts features like conversions, a mortgage calculator and a gas mileage calculator. What previously took a few Google searches and a long-winded Excel spreadsheet can now be done with a few clicks.

Everything just seems to integrate better with Windows 7 as well: changing wireless networks just takes two clicks, the sidebar is no more but the gadgets can roam the desktop and things like Aero Shake suggest (nice but potentially annoying) Compiz Fusion-like effects.

Performance seems to be a lot better than Vista too: everything from shorter boot times to longer laptop battery life seems to be the way that Windows 7 is going. As Vista seemed sluggish compared to its predecessors, I’m excited that Microsoft have turned it back around. It can even run with a mere 1GB of RAM although considering memory is dirt-cheap nowadays, there needn’t be a tiff if it were to require more.

The taskbar has also been hugely redesigned and while I’m not too hot on it at the moment, I’m sure it’ll all fall into place in time. Essentially, the new taskbar makes better use of the space and takes the preview window to the next level.

There’s also promise that Windows 7, from day one, will be more stable than Vista SP1. Whilst I’m not so sure myself, as every new operating system faces numerous bugs, I’m fairly confident that Windows 7 will be a strong OS that should see us through for a good few years.

Oh! How could I forget that they’ve redesigned UAC to be insanely less intrusive? You may be able keep it enabled without losing your insanity. Individual applications can be allowed forever and you can also change the ferocity of UAC, presumably inside the depths of the Control Panel.

All in all, Windows 7 has shaped up to be what could be the best operating system the world has seen. I’m interested in what developments other operating systems will see as Windows 7 nears its launch in mid 2009.

]]>
http://www.sidroberts.co.uk/2008/11/10/windows-7/feed/
Virtualisation http://www.sidroberts.co.uk/2008/11/04/virtualisation/ http://www.sidroberts.co.uk/2008/11/04/virtualisation/#comments Tue, 04 Nov 2008 14:32:07 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=85 I’ve been experimenting with virtualisation for the last few days. Being on Windows Vista 64-bit, I can’t use VMWare (because of driver signing) so I had to use to VirtualBox which, I’ve found, is actually better and lighter than VMWare. Despite a few (very minor) bugs, I love VirtualBox’s seamless mode - it essentially allows you to work with two operating systems as if they were one.

It’s also given me a chance to play about with Ubuntu 8.10. Since the release of Ubuntu 8.04, I’ve been set on 8.10 being the definitive version and whilst it does feel a bit stronger and more capable than 8.04, I’m not so sure that it is what I had hoped. The UI is still ugly and OpenOffice is still lack-luster compared to the likes of Microsoft Office. In a nutshell, it needs to take a big step towards Windows in order for it to be a viable option for regular consumers. It is, however, definitively ready as a home server and I’ll definitively be incorporating it into a project. Details to follow…

]]>
http://www.sidroberts.co.uk/2008/11/04/virtualisation/feed/
My Dell, A New Heatsink And Lots Of Problems http://www.sidroberts.co.uk/2008/10/17/my-dell-a-new-heatsink-and-lots-of-problems/ http://www.sidroberts.co.uk/2008/10/17/my-dell-a-new-heatsink-and-lots-of-problems/#comments Fri, 17 Oct 2008 15:47:58 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=81 My Dell Dimension 9200, I felt, was getting a little too warm. It wasn’t anything particularly dangerous, it’s just I felt it could do with a little more cooling. I occasionally clean it out every few months but the heatsink and its fan are hidden away under heavily screwed down plastic so I can’t get to them and dust was clogging them up. Until a few hours ago, I had never even seen them.

I ordered a new heatsink (Akasa AK-965) and today I attempted to install it. Of course, uninstalling the old one was difficult and there’s always that little niggle that makes you think you’re doing it wrong. I continued, though, and managed to vacuum the incredible amount of dust that had amounted over the 2 years.

I was in the final throes of completion, I only had to place the new heatsink into its place, pop the screws and plug the fan in. Of course, in the final stages, something has to go wrong and for this little endeavour, everything did. First, I found that the heatsink didn’t line up the motherboard’s holes. Secondly, I found that the motherboard didn’t have a connection for the heatsink’s fan (rather, a different connection to what the new heatsink needed). Thirdly, I’d already taken all the old thermal paste off the processor at this point and it looked like I’d need to buy some more. And finally, no matter how hard I tried to be careful, I managed to get thermal paste all over my fingers. Sending back the heatsink will cost £5 - for a £10 product. To finish off, as I’ve had to dismantle half my computer, I’ve now got two screws and I don’t know where they went.

It’s not all bad though: I’ve managed to scrape some of the new thermal paste onto the old heatsink (and temperatures have fallen dramatically), I’ve been able to clean the fan and heatsink and I have a spare heatsink for a computer I hope to be building this autumn.

]]>
http://www.sidroberts.co.uk/2008/10/17/my-dell-a-new-heatsink-and-lots-of-problems/feed/
Caught By The Google Street View Camera http://www.sidroberts.co.uk/2008/08/28/caught-by-the-google-street-view-camera/ http://www.sidroberts.co.uk/2008/08/28/caught-by-the-google-street-view-camera/#comments Thu, 28 Aug 2008 09:12:21 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=75 I’ve always wanted to see the Google Street View car ever since it was spotted first in England but thought it would be a while before it photographed Leeds. Having just got out the shower and drying my hair, the black Vauxhall Astra with it’s cameras cruised passed the house. And because my hair was wet, I didn’t have a shirt on - from the car’s point of view, I look naked. Nice.

At least the Jag was in the drive, though.

]]>
http://www.sidroberts.co.uk/2008/08/28/caught-by-the-google-street-view-camera/feed/
AAC Versus MP3 http://www.sidroberts.co.uk/2008/08/21/aac-versus-mp3/ http://www.sidroberts.co.uk/2008/08/21/aac-versus-mp3/#comments Thu, 21 Aug 2008 11:25:12 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=67 I’ve always been cautious of moving my music away from MP3, purely because of incompatibilty. The thing is, though, I use iTunes and an iPod - both of which perfectly handle AAC. And AAC is possibly the best attempt at improving MP3. It’s supported by a number of things - the PS3 and the Nintendo Wii for two.

In short, AAC sounds indistinguishable from MP3 at a lower bitrate. I’ve found it to be the same at about 60% of the MP3’s bitrate (256kbps MP3 would then be 128kbps AAC). Encoding with variable bitrates yields better sounding results.

I recommend anyone who listens to their music collection on devices that do support AAC, to convert their collection to AAC.

]]>
http://www.sidroberts.co.uk/2008/08/21/aac-versus-mp3/feed/
Nissan Cube http://www.sidroberts.co.uk/2008/08/07/nissan-cube/ http://www.sidroberts.co.uk/2008/08/07/nissan-cube/#comments Thu, 07 Aug 2008 18:53:16 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=60

Despite being only officially available to the Japanese market, I’ve seen many of these in England. It’s about as aerodynamic as a block of flats and is just devastatingly ugly. I’ve not looked into the specs but something tells me that it’ll have a small engine with hardly any power and be hugely overpriced for what is essentially a box with wheels.

The most positive thing that struck me about this car was what the size of the boot would be. Sadly, looking at it more closely, all that space is taken up by a second row of chairs. Put it like this, no dog of any size would fit in there without an animal charity chasing you down.

]]>
http://www.sidroberts.co.uk/2008/08/07/nissan-cube/feed/
Image Preloader http://www.sidroberts.co.uk/2008/07/15/image-preloader/ http://www.sidroberts.co.uk/2008/07/15/image-preloader/#comments Tue, 15 Jul 2008 17:48:48 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=47 With Ajax being all the rage, preloading images has become somewhat important. The problem is, loading them with all the other page components adds to the load time and it may not even be used. Enter preloadImage - a function set to stop all that. It’s very simple but can be used to powerful means:

var preloadImage = function(url, callback) {
	var image = new Image();
	image.src = url;
	image.onload = image.onabort = image.onerror = callback;
	return image;
};

Just specify the URL (url) and the callback function (callback) as so:

var callback = function(e) {
	alert(e.type);
};

var image = preloadImage('http://www.sidroberts.co.uk/image.gif', callback);

On the load event, the abort event or the error event, the callback function will be executed. You can distinguish these with the type property which is "load", "abort" and "error" respectively.

Now any image that points to that URL will load almost instantly.

]]>
http://www.sidroberts.co.uk/2008/07/15/image-preloader/feed/
Import Multiple Images Into Powerpoint 2007 http://www.sidroberts.co.uk/2008/07/14/import-multiple-images-into-powerpoint-2007/ http://www.sidroberts.co.uk/2008/07/14/import-multiple-images-into-powerpoint-2007/#comments Mon, 14 Jul 2008 19:43:33 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=46 Having spent the last three days sorting and importing some 300-400 images into Powerpoint, there’s a very useful tip that I learnt. And it meant that a job that could have taken a good week took just a few hours.

Instead of dragging every single image into each slide, go to Insert in the ribbon and click the Photo Album icon. There you can select the images you want, order them and decide how many you want on each slide. It will make a new presentation with all these new slides so you will have to copy the slides back into the original presentation if you want them there.

]]>
http://www.sidroberts.co.uk/2008/07/14/import-multiple-images-into-powerpoint-2007/feed/
Digg’s Recommended Feature http://www.sidroberts.co.uk/2008/07/13/diggs-recommended-feature/ http://www.sidroberts.co.uk/2008/07/13/diggs-recommended-feature/#comments Sun, 13 Jul 2008 14:04:09 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=44 The Digg Recommendation Engine recommends new stories that may be of interest to you, compared with what you have already Dugg. It finds Diggers like you and uses what they have Dugg and recommends them to you. When I saw the video, I didn’t think I’d be part of the selection that would get the feature first.

First thoughts are very promising. You need to be a fairly active member of Digg to keep the recommendations relevant, I should add - it grows in strength with stories you Digg. If the compatibility between you and other users is low, then chances are you’ll get poor results. For me, though, most recommendations were fairly accurate. My compatibility percentages were between 7 % and 13%.

For somebody who rarely uses the Upcoming feature, this brings a welcome change and I’ve already Dugg many stories that I probably wouldn’t have seen otherwise. When the feature hits mainstream, I dare say it’ll be used heavily and the recommendations will be very accurate.

]]>
http://www.sidroberts.co.uk/2008/07/13/diggs-recommended-feature/feed/
Extending Regular Expressions http://www.sidroberts.co.uk/2008/06/28/extending-regular-expressions/ http://www.sidroberts.co.uk/2008/06/28/extending-regular-expressions/#comments Sat, 28 Jun 2008 20:47:09 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=41 You know the problem with regular expressions in JavaScript?: There’s not enough to do. Sure, you can use its methods against strings but there’s nothing that allows you to manipulate the actual expressions. Where is the property for all the modifiers? How can you add or remove a modifier? The simple answer is that it isn’t possible. The long and complicated way says that it is. The only problem is that the code is a little bit ugly:

RegExp.prototype.modifiers = function() {
	return /^\/(.+)\/([gim]+?)$/i.exec(this.toString())[2].split('');
};

Don’t say I didn’t warn you.

In short, that method converts the expression to a string and then executes another regular expression with it. This new regular expression takes away the main pattern and leaves the modifiers in a string. That string is then split into individual characters so you have an array of them (for example: ['g', 'i']).

This magic regular expression can also be used for extracting a pattern, which, in turn, allows you to rebuild it with the RegExp constructor - modifiers included. This is the method for extracting the pattern:

RegExp.prototype.pattern = function() {
	return /^\/(.+)\/([gim]+?)$/i.exec(this.toString())[1];
};

Rebuilding it is as simple as this:

var original = /\s+/g;

var pattern = original.pattern();
var modifiers = original.modifiers().join('');

var better = new RegExp(pattern, modifiers);

So, putting two and two together, if we can extract the pattern and the modifiers, and rebuild it, what’s stopping us from changing it along the way? Enter addModifiers and removeModifiers:

RegExp.prototype.addModifiers = function(modifiers) {
	return new RegExp(this.pattern(), this.modifiers().join('') + modifiers.join(''));
};

RegExp.prototype.removeModifiers = function(modifiers) {
	return new RegExp(this.pattern(), this.modifiers().join('').replace(new RegExp(modifiers.join('|'), 'i'), ''));
};

With the addModifiers method, you may have noticed that I haven’t bothered to check for the existing modifiers. This is because you can duplicate a modifier on a regular expression and it won’t matter as it’ll only be counted once. Both of these methods allow multiple modifiers and require them to be an array (['g', 'i']):

var original = /\s+/g;

original = original.addModifiers(['i']); // /\s+/gi
original = original.removeModifiers(['g']); // /\s+/i

pattern = original.pattern(); // '\s+'
modifiers = original.modifiers(); ['i']
]]>
http://www.sidroberts.co.uk/2008/06/28/extending-regular-expressions/feed/
Scaling Images http://www.sidroberts.co.uk/2008/06/24/scaling-images/ http://www.sidroberts.co.uk/2008/06/24/scaling-images/#comments Tue, 24 Jun 2008 17:07:42 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=40 The power with scaling images is immense but very few people use it on a website. Scalable images are set in either ems or percentages.

For images that you know the width and height of, you can set the dimensions so that the image is not distorted:

img.widescreen {
	height: 9em;
	width: 16em;
}

For unknown image sizes, one side must be set to auto - this will force the correct aspect ratio upon the image:

img.scale {
	height: auto;
	width: 75%;
}

Scaling images are so great because they won’t ruin your layout by going over an edge. If they are set in percentages and have limitations, it also means that they won’t go larger than the boundaries of the page and still remain undistorted, even when the browser is resized:

img.scale {
	height: auto;
	max-width: 100%;
	width: 30em;
}
]]>
http://www.sidroberts.co.uk/2008/06/24/scaling-images/feed/
Real Hard Drive Capacities http://www.sidroberts.co.uk/2008/06/21/real-hard-drive-capacities/ http://www.sidroberts.co.uk/2008/06/21/real-hard-drive-capacities/#comments Sat, 21 Jun 2008 19:25:29 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=39 Ever bought a hard drive only to find you’ve got a smaller disk space than stated on the box? That’s not because your operating system is taking up that space, it’s because you’re not counting it as the hard drive manufacturers did.

Computers count in base two – that is, binary. In binary, a kilobyte is 1024 bytes (2 to the power of 10). Normal people considered a “kilo” to mean a thousand so a kilobyte, to them, was 1000 bytes. If you sell hard drives, the obvious choice is to use the measurement that sounds like more value – the non-geek 1000 was therefore used (1MB = 1,048,576 bytes in binary or 1,000,000 bytes in metric – less is cheaper to make although less in usable capacity). In 1998, the IEC defined 1GB as 1,000,000,000 bytes – using the non-geek/manufacturer method. To avoid confusion, they also decided to rename measurements of binary by replacing the last two letters with “bi” to represent “binary” (kibibytes, mebibytes, gibibytes, tebibytes). The thing is, though, these new names sound terrible and they will never be picked up. In reality, everyone uses the original names and ignores the stated capacities on hard drives.

Stated Capacity Usable Binary Capacity
1GB 952.32MB
2GB 1.86GB
4GB 3.72GB
8GB 7.44GB
20GB 18.6GB
30GB 27.9GB
60GB 55.8GB
80GB 74.4GB
120GB 111.6GB
160GB 148.8GB
250GB 232.5GB
320GB 297.6GB
500GB 465GB
1TB 952.32GB

If you’re mathematically inclined, you’ll notice that the difference is 7%; to find out the real capacity of any hard drive, just take off 7%.

]]>
http://www.sidroberts.co.uk/2008/06/21/real-hard-drive-capacities/feed/
Griffin iTrip SE http://www.sidroberts.co.uk/2008/06/21/griffin-itrip-se/ http://www.sidroberts.co.uk/2008/06/21/griffin-itrip-se/#comments Sat, 21 Jun 2008 12:57:30 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=38 The Griffin iTrip SE was pretty much unusable. The transmission is incredibly quiet - so quiet, that even at high volumes, you still struggle to hear it. To add to insult, it turns itself off every so often due to “power saving functionality”. If it’s a European model, things are made difficult still with a feature to deter pirate radio stations by selecting a random frequency every time the device is turned on. Sadly, it makes life worse for the majority that use it for good and I’d hardly say it deters pirate radio stations (although why use it if it only has a weak signal anyway?).

There can be good things said about the wide compatibility of iPods that it can connect to and the ability to still use the headphone jack whilst transmitting is an added bonus. However, if you appreciate music (and by that, I mean listen), you should avoid it completely.

]]>
http://www.sidroberts.co.uk/2008/06/21/griffin-itrip-se/feed/
getElementsByAttribute http://www.sidroberts.co.uk/2008/06/21/getelementsbyattribute/ http://www.sidroberts.co.uk/2008/06/21/getelementsbyattribute/#comments Sat, 21 Jun 2008 10:52:19 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=37 I wanted to extend getElementsByAttribute to search a specific attribute and whilst some getElementsByAttribute functions exist, none of them feel that fantastic.

Object.prototype.getElementsByAttribute = document.getElementsByAttribute = document.getElementsByAttribute || function(attribute, value) {
	switch(attribute) {
		case 'id':
			return [this.getElementById(value)];
		case 'tagName':
			return this.getElementsByTagName(value);
	}

	for(var i = 0, elements = this.getElementsByTagName('*'), elementsLength = elements.length, b = []; i < elementsLength; i++)
	{
		if(elements[i][attribute] == value)
		{
			b.push(elements[i]);
		}
	}

	return b;
};

First of all, if you can, optimise. That’s why there’s a switch statement that checks for "tagName" and "id" in the cases that you would want to use getElementsByTagName or getElementById. I made the getElementById return in an array so every result from getElementsByAttribute was an array but you may want to change this. If you have a getElementsByClassName function, you could also incorporate it into the switch statement.

Very simply, it runs through an array of all the child elements and adds it to an array if it matches the criteria. That array is then returned.

And because of how it is designed, you can call it with any DOM element:

document.getElementsByAttribute('title', 'Document Object Model');

var content = document.getElementById('content);
content.getElementsByAttribute('title', 'Document Object Model');
]]>
http://www.sidroberts.co.uk/2008/06/21/getelementsbyattribute/feed/
Why A .car TLD Won’t Work http://www.sidroberts.co.uk/2008/06/17/why-a-car-tld-wont-work/ http://www.sidroberts.co.uk/2008/06/17/why-a-car-tld-wont-work/#comments Tue, 17 Jun 2008 16:36:44 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=36 Recently, the ATX Group proposed a new TLD: .car for in-car use.

The .mobi TLD was created because browsers and mobile/cell phones were completely different - different screen sizes, different needs and different input methods. A portable web just wouldn’t work so a new one (or a separate version) had to be created.

The screens in cars are more than adequate to be used to navigate the web and whilst the input devices still need a little work, I see no benefit of this proposed TLD. Touch-screen capabilities can easily be fitted and voice activation can make up for a keyboard-like input.

Drivers wouldn’t be allowed to surf the Internet whilst driving anyway; only passengers would be able to and their attention would be drawn to the device like it would at home. Therefore creating a simpler, easier-to-read version just wouldn’t be worth it.

The idea that you would be able to listen to news headlines or even entire web pages whilst on the move uses the technology of text-to-speech - where text is digitally spoken (albeit a little robot-like) so you can hear the text instead of having to read it. This method directs me straight to accessibility. If your site doesn’t make sense in a logical order then text-to-speech engines are useless or extremely annoying. This isn’t just affecting the in-car users but blind users as well. Preventing them from accessing the web page is against the law and, although very unlikely, you could be sued.

]]>
http://www.sidroberts.co.uk/2008/06/17/why-a-car-tld-wont-work/feed/
Don’t Repeat Yourself http://www.sidroberts.co.uk/2008/06/13/dont-repeat-yourself/ http://www.sidroberts.co.uk/2008/06/13/dont-repeat-yourself/#comments Fri, 13 Jun 2008 19:27:51 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=33 The DRY philosophy is basically about not repeating code when you don’t need to. This isn’t necessarily about shortening functions like getElementById but rather stopping that bad habit where you have two functions that do almost the same job. In return, you get code that is not only smaller in file size but also easier to manage.

Take this as an example:

var getAcontent = function() {
	return document.getElementById('a').innerHTML;
};

var getBcontent = function() {
	return document.getElementById('b').innerHTML;
};

So ignoring that these IDs aren’t semantic, these two functions do exactly the same thing, just on different elements - defined as string variables. Why do you need two functions for this? What will you do when you need to get another element’s contents? By specifying the ID as an argument, you can get the contents of any element:

var getContent = function(id) {
	return document.getElementById(id).innerHTML;
};

This function is not only half the size of the other two functions but it also opens up much more capabilities. By making functions generic, you can keep them DRY.

Another tip is to look at your code and see if you have any strings hard-coded in your functions. Remove them and replace them with arguments, if possible. Some of them will have valid reasons for being there and to use the getContent function, a string will need to be hard-coded in most circumstances.

]]>
http://www.sidroberts.co.uk/2008/06/13/dont-repeat-yourself/feed/
getElementsByClassName http://www.sidroberts.co.uk/2008/06/06/getelementsbyclassname/ http://www.sidroberts.co.uk/2008/06/06/getelementsbyclassname/#comments Fri, 06 Jun 2008 21:26:14 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=32 Seeing as Firefox 3, Safari 3.1 and Opera 9.5b now support getElementsByClassName, it only seems fair to add support for older browsers, thus enabling proper use of it.

Object.prototype.getElementsByClassName = document.getElementsByClassName = document.getElementsByClassName || function(className) {
	className = className.replace(/\s+/g, ' ').replace(/^\s|![A-Za-z0-9-_\s]|\s$/g, '').split(' ');

	for (var i = 0, elements = this.getElementsByTagName('*'), elementsLength = elements.length, b = [], classNameLength = className.length, passed = true; i < elementsLength; i++, passed = true) {
		for (var j = 0; j < classNameLength && passed; j++) {
			passed = (new RegExp('(^|\\\s)' + className[j] + '(\\\s|$)', 'i')).test(elements[i].className);
		}

		if (passed) {
			b.push(elements[i]);
		}
	}

	return b;
};

document.getElementsByClassName works in the 30+ browsers that I’ve tested, apart from Internet Explorer 5.5 or below and Dillo 0.8.6. I’d change it but, to be honest, nobody uses Internet Explorer 5.5 or below anyway and Dillo hasn’t been updated in 2 years.

Something like document.getElementById('content').getElementsByClassName doesn’t work in all browsers, notably Internet Explorer 6 and 7 (see comment by Michael and comment by Sid).

I should also note that it follows the Mozilla spec to the letter - meaning that document.getElementsByClassName('classOne classTwo'); will return any element with class names of both classOne and classTwo. Of course, this function degrades rather nicely with newer browsers or where a getElementsByClassName function has already been defined so by following the spec, you should get on pretty fine.

]]>
http://www.sidroberts.co.uk/2008/06/06/getelementsbyclassname/feed/
Shortening document.getElementById http://www.sidroberts.co.uk/2008/06/06/shortening-documentgetelementbyid/ http://www.sidroberts.co.uk/2008/06/06/shortening-documentgetelementbyid/#comments Fri, 06 Jun 2008 09:25:49 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=34 It’s not a terrible crime, or even a crime at all but continually using document.getElementById, things can get a little repetitive. There are several ways with varying depth to shorten it, all relying on how much work you want to do or how often you’ll use it.

You could just map a short name to it:

var $ = document.getElementById;

var example = $('content');

Put simply, just use the $ function instead and it’ll work exactly the same.

Or if you want to make it easy to get several elements at once, try the Prototype method:

var $ = function() {
for(var i = 0, argLength = arguments.length; i < argLength; i++)
{
	arguments[i] = document.getElementById(arguments[i]);
}

return arguments;
};

var example = $('header', 'content', 'footer'); // Returns #header, #content and #footer in an array.

If you’ll be using the DOM a lot, though, it might be a good idea to write a small selector engine.

var $ = function(selector) {
selector = selector.replace(/\s+/g, ' ').replace(/,\s?,|\s?,\s?/g, ',').replace(/^\s|\s$/g, '').split(',');
var b = [];

for(var i = 0, sLength = selector.length; i < sLength; i++)
{
	var id = /^#([A-Za-z0-9-_]+)$/.exec(selector[i]);
	var tagName = /^([A-Za-z0-9-_]+)$/.exec(selector[i]);

	if(id)
	{
		selector[i] = [document.getElementById(id[1])];
	}
	else if(tagName)
	{
		selector[i] = document.getElementsByTagName(tagName[1]);
	}

	for (var j = 0, siLength = selector[i].length; j < siLength; j++)
	{
		b.push(selector[i][j]);
	}
}

return b;
};

var example = $('#header, #content, #footer, span');

It’s not fantastic by any means but it’s a start and supports for IDs and tag names.

As a side note, Internet Explorer and Opera suffer from a getElementById bug so it may be wise to check this out before you fit all your projects with this.

]]>
http://www.sidroberts.co.uk/2008/06/06/shortening-documentgetelementbyid/feed/
Redesign http://www.sidroberts.co.uk/2008/06/04/redesign/ http://www.sidroberts.co.uk/2008/06/04/redesign/#comments Wed, 04 Jun 2008 15:42:17 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=35 I’ve been busy with my GCSEs so I’ve not been able to blog as much. Ironically, I’ve redesigned the site to give it a cleaner look. Things will still be changing and I still need to finish the design. Give it a few weeks and I dare say it’ll look nothing like it does now.

]]>
http://www.sidroberts.co.uk/2008/06/04/redesign/feed/
Choosing A School Laptop http://www.sidroberts.co.uk/2008/05/01/choosing-a-school-laptop/ http://www.sidroberts.co.uk/2008/05/01/choosing-a-school-laptop/#comments Thu, 01 May 2008 15:12:38 +0000 Sid Roberts http://www.sidroberts.co.uk/?p=28 I’ll be getting a laptop for Sixth Form next year and just wanted to share a few tips with you all:

How Long Will You Have This Laptop?
Laptops are very difficult (or expensive) to upgrade for the average computer user so make sure the hardware will still be OK for the life of the laptop.
Do You Really Need A Powerful Graphics Card?
In most cases of school work, you’ll never need a graphics card. That said, if you may need one, get one.
Can You Risk Low Battery Life?
Using wall sockets when available is obvious but what about when you can’t access mains power? You’ll need to depend on your battery which needs to be fully charged and, where possible, have a lot of power.
Get A Mouse
Even if it’s just a cheap one. Using the trackpad everyday for two years can really be a pain and a time waster. Just getting a cheap mouse can save a little time and it may make it easier for you.
Is That Keyboard Comfortable?
Quietness is an issue but what’s more important is how comfortable you feel typing on it. If you can, try testing it out before you buy. You can always buy an external keyboard but it’s a lot bigger than a mouse and can be a hassle in itself.
Are You Getting The Best Deal?
Shop around and see what prices you can get.
Don’t Buy Unnecessary Hardware
If you’re able to customize your laptop (like on Dell), then begin customizing the cheapest model, only adding on hardware that you’ll need. You’ll save a lot of money this way.
Have You Got A Decent Bag?
It’s best not to advertise your laptop but you need a decent bag to carry it around. Try one with lots of padding - it’ll pay off on your back and maybe if you drop it.
]]>
http://www.sidroberts.co.uk/2008/05/01/choosing-a-school-laptop/feed/