Archive for June, 2010

Get latest bleeding edge gfx drivers in Ubuntu

Friday, June 18th, 2010

Want the latest of the latest updated bleeding edge graphic drivers in Ubuntu?

Open /etc/apt/sources.list:

sudo gedit /etc/apt/sources.list

Add these lines at the bottom:

deb http://ppa.launchpad.net/xorg-edgers/ubuntu lucid main
deb-src http://ppa.launchpad.net/xorg-edgers/ubuntu lucid main

Update and upgrade:

sudo apt-get update
sudo apt-get upgrade

If you don’t use Lucid (Ubuntu 10.04) just change “lucid” to what ever you use, for example ‘karmic’.

Enjoy :)

Generate random string in PHP

Friday, June 18th, 2010

Here’s a function to create a random string with the chars ‘a’ to ‘z’, ‘A’ to ‘Z’ and 0 to 9 in PHP.
I have seen many people asking for this, so here it is:

<?php

function randStr($length, $str='') {
	$array = array_merge(range('a', 'z'), range('A', 'Z'), range(0, 9));
    for($i = 0; $i < $length; $i++) {
        $str .= $array[rand(0, (count($array) - 1))];
    }
    return $str;
}

?>