Tag Archives: Tricks

Funny Google Hidden Tricks

  1. Go to http://www.google.comand search:
    • askew
    • Do a barrel roll
    • Number of Horns on a Unicorn
    • once in a blue moon
    • Google Gravity (select I’m Feeling Lucky)
  2. Go to Google Reader, then use your cursor keys thus: up, up, down, down, left, right, left, right, B, A. A ninja then pops onto your screen and into your search box. Still works in the new version of Google Reader.
  3. Set your iGoogle homepage to the beach theme. Wait until 3:14am. What monster this way comes?
  4. On Google Earth click on Tools > Enter Flight Simulator or Ctrl+Alt+A, and you’re off and flying around the planet. Bon voyage!
  5. Play Google Pac-Man (use up, down, left and right keyboard)

http://mrdoob.com/projects/chromeexperiments/google_gravity/

Little PHP Tricks

Casting Arrays to Objects

$jenis = array('avocado', 'rambutan', 'pisang');
$warna = array('hijau', 'merah', 'kuning');
$buah = array_combine($jenis, $warna);
$buah = (object) $buah;
var_dump($buah);

Output:

object(stdClass)[1]
public 'avocado' = string 'hijau' (length=5)
public 'rambutan' = string 'merah' (length=5)
public 'pisang' = string 'kuning' (length=6)

Delete an item from an array

unset($array[$i]);

This will break a “for ($i=0; $i

Select a random item from an associative list

$jenis = array('avocado', 'rambutan', 'pisang');
$warna = array('hijau', 'merah', 'kuning');
$buah = array_combine($jenis, $warna);
$keys = array_keys($buah);
$buah = (object) $buah;
$random = $buah->$keys[rand()%count($keys)];
echo $random;

Deal with complex structures

$pentadbir['kira'][$jumlah['pegawai']] = $val['Hasil'];

Casting the array to an object allows us to use object notation (->) and makes the code more readable:

$jumlah= (object) $jumlah;
$pentadbir = (object) $pentadbir;
$pentadbir->kira[$jumlah->pegawai] = $jumlah->Hasil;