Friday, February 27, 2009

Fun with PHP implicit scoping on static calls

class a {
public $a = "yay!";

func call_b()
{
b::b();
}
}

class b {
function b()
{
echo $this->a;
}
}

$a= new a();
$a->call_b();


Prints:
yay!

This is because if you statically call a method that is not declared as static in PHP, it inherits the class scope of the caller. Note that if you had declared function b as a static method, you'd get a different behavior.

Wednesday, February 25, 2009

Apple Wireless Keyboard + Ubuntu Intrepid

I had some trouble pairing at first, but found this to work:
  1. Turn keyboard off
  2. Open up the new bluetooth device wizard
  3. Turn the on
  4. Select the keyboard
  5. Click Next
  6. While the wizard is waiting, enter 0000 and Enter on the keyboard
  7. Enter 0000 and Enter a second time.
The main issue seems to be that the OS doesn't prompt you at the correct time to enter the pairing password.

Tuesday, February 10, 2009

Fun with implict type conversions in PHP

PHP requires extreme care while programming. For example:
'1,234' * 1 == 1
0 == false
false == ''
0 == '0'
false != '0'