Archives for September 2010

The first key to programming is to type, not to think

I remember vividly this scene from Finding Forrester, which, in my memory, goes something like this: Jamal is stuck. Forrester grabs the typewriter and proceeds to type furiously. Jamal reads what Forrester has written, amazed. Forrester says, “No thinking – that comes later. You must write your first draft with your heart. You rewrite with […]

15 September 2010 | Software engineering | 1 Comment

PHP whitespace fail

I had a problem with header(’Location: http://example.com’) not redirecting as it should. After fiddling a bit, I discovered that it worked before, but not after, this line:

$x = $this->foo($bar);

So what was in function foo()?

private function foo($val)
{
include_once ‘baz.php’;
$baz = new Baz();
return $baz->get_value($val);
}

I then proceeded […]

9 September 2010 | PHP | No Comments

PHP foreach

The PHP foreach construct is very convenient, except that it creates a copy of the array. This is undesirable in the case of very large arrays. The following is a drop-in replacement for foreach, which operates directly on the array:

$arr = array(”one”, “two”, “three”);
reset($arr);
while (list(, $value) = each($arr))
{
echo “Value: $value<br />\n”;
}

Or

$arr […]

6 September 2010 | PHP | No Comments

Vimperator vs Vimium

Update 15 January 2012
I have switched from Vimperator to Pentadactyl for quite some time. Pentadactyl allows letters to be used as hints out of the box; add the following line in your .pentadactylrc:

set hintkeys=sadfjklewcmpgh

For more Vimium-like highlighting:

highlight -a Hint text-transform: uppercase; padding: 0 2px 0 1px; background-color: yellow; font: bold 11px “Droid Sans Mono”;
highlight -a […]

5 September 2010 | Applications | 3 Comments