Showing posts from August, 2010

An awesome PHP 5.3 array multi-sort function

The following function is an adaptation of the code submitted by Thomas Heuer and posted here.

function multiSortArray($data, $field) { if (!is_array($field)) { //if the field is given as a string, assume ascending $field = array($field=>true); } usort($data, function($a, $b) use($field) { $retval = 0; foreach ($field as $fieldname=>$asc) { if ($retval == 0) { $retval = strnatcmp($a[$fieldname], $b[$fieldname]); if(!$asc) $retval *= -1; //if } } return $retval; }); return $data; }
The parameters are:

$data - an array of associative arrays. So for example, an array of Book records, where each Book record is simply an associative array with $key=>$value pairs such as array('title'=>'The Golder Compass', 'author'=>'Philip Pullman', 'published'=>'20…

What's wrong with the Kindle

The Kindle is an interesting product. It has a very basic low-resolution monochrome screen which is only really useful for displaying text and not much else. Compare this to say an iPad's high resolution rich-color multi-touch screen and it seems like a century old relic. Yet it sells amazingly well. The only real advantage of this screen is that it has no back-light, which is easier on the eyes (or so they say) and uses virtually no power at all to display a static image. This means you can use the Kindle for weeks on a single charge. And after using it for a short while, you kinda forget you're even using an electronic device (except for the giant keyboard down the bottom which screams geek-gadget at full volume, but more on that later).

The Kindle also has free global 3G data access. This means you can connect to the Amazon Kindle store and download books, magazines or newspapers on the go. You can also use it to check and send emails, to Tweet and even to browse the web on…

Windows Server 2008 R2 as Guest in VirtualBox

Windows Server 2008 R2 only comes in an x64 flavor. To install this in VirtualBox as a guest OS you need to enable the VT-x/AMD-V options in the VM settings dialog. You also need to make sure you have an x64 compatible CPU and that you enable Virtualization support in your BIOS settings.

I had all this done, but whenever I started the VM guest with the Server 2008 R2 ISO mounted, VirtualBox would give me an error saying:

"VT-x/AMD-V hardware acceleration has been enabled, but is not operational. You 64-bit guest will fail to detect a 64-bit CPU and will not be able to boot.
Please ensure thet you have enabled vt-x/AMD-V propert in the BIOS of tour host computer."
I was installing this on a Dell Optiplex 755 with an Intel E8400 which does support x64. My BIOS was revision A12 and already had the Virtualization, VT for Direct I/O and Trusted Execution features turned to On. I tried cold booting and rebooting a couple of times but VirtualBox kept giving me the same error.
What eve…

Complete guide to rooting and hacking the HTC Slide

UPDATE (30 May 2011): Guide is now updated with latest CyanogenMod 7.0.3 and latest corresponding Google Apps package. Also,T-Mobile finally released the official Froyo 2.2 update.Be careful though, because once you install this, the root method given below will not work! You'll need to Google the Gold Card method to root instead, which I know nothing about.

NOTE: I did not come up with this stuff myself. All credits go to the Devs who frequent the XDA forums. If you want to show your appreciation, track them down and send them a tweet or email. I just consolidated lots of information gathered from all over the place into one easy to follow guide for beginners who've never done this before.

WARNING: The method described below will WIPE your phone of all contacts, emails, messages, apps, settings, etc. If you're not prepared for this, and don't know how to back things up, you may want to stop now. It should be impossible to brick the phone with this method, but who knows.…

Portable VirtualBox on USB with cloud backup

You're a web developer and you build PHP web apps. On your machine you have a web server installed with PHP support enabled. You also have a database configured with dummy datasets loaded. You have a UML modeling tool in which you build your ERD and sync to the database. You have a number of different frameworks installed and configured to work with your setup. Your IDE is configured with your project and to push straight to your web server. The IDE is also linked to source control and to your test and production environments. You're happy and productive. Now your machine crashes and you need to get back up and running, quickly. You have backups of all your project files, but good luck setting everything up again. Hope you made really detailed step-by-step documentation.

A virtual machine can prevent this from ever happening. You setup your environment once, make a backup and you're safe. Your machine crashes, you just go on another machine, load your VM backup and you'…

USB Flash disks have very slow write speeds

So I was always under the impression that USB 2.0 Flash sticks were fast. Or at least faster than say a USB 2.0 external 5400rpm hard disk. I just assumed that since Flash was solid state, there would be no latency from moving parts and head positioning, etc.

Based on this assumption I decided to get a 16GB SanDisk Cruzer USB 2.0 stick and put a VirtualBox virtual machine on it for use on any PC. I though this would be an upgrade to keeping my VM on my external drive. I though wrong.

I noticed straight away the VM ran much, much slower on the USB stick. I did some research on this and found mixed suggestions, but it seems common knowledge that USB Flash sticks have slow write speeds. Just how slow though I had no idea, until I tested it out for myself.

I created 10,000 1kb text files on my PC and did some transfer tests between the local internal HDD, my external USB HDD and my new 16GB USB Flash stick. Operating system was Windows 7 Pro. The results are listed below:

TestTransfer rate…

Waiting on Froyo for the HTC myTouch Slide?

I wouldn't hold my breath. Rumors about a Froyo (Android 2.2) update for the T-Mobile myTouch Slide came out early June, before the phone was even officially released. The rumors didn't state a specific date, just that Froyo will be out 'really soon'.

Early July, some T-Mobile road maps leaked and had a myTouch Slide MR update listed for end of July.

Everyone assumed this would be Froyo. It had to be, right? Wrong. The MR update was just officially announced and it's only a minor bug-fix with very little to get excited about. Now if Froyo was still just around the corner, why would T-Mobile release this patch (which won't be fully rolled out till August 19th) anyway? And would they release the real Froyo update soon afterwards? Wouldn't it make a whole lot more sense to include these minor bug fixes in the imminent Froyo update?

There are two possibilities here. The first, Froyo is not coming out for at least a couple of months. I'd be guessing late Oct…

The Frankenstein PC

One of the greatest things about PC is the modularity of hardware. A general PC system will consist of a processor, memory, storage, video card, network interface, power and additional IO devices. Good thing about this is that you can upgrade each component independently based on your needs. Generally all that's needed is for you to pop-open the case, take out a few screws, change a part, put everything back together again and cross your fingers hoping it'll still power-up.

USB has taken this to the next level. You can now get an external hard-disk on which to keep all your files, or an external CD/DVD/BD/Floppy drive, or external modem, external network adapter, etc. This makes the PC even more versatile. You no longer need to open the case to plug in a new device. Which means you can easily take the device and plug it into any PC you want. So you take your portable hard-disk, plug it into your home desktop, copy over some files, put the hard-disk in your bag, take it with yo…