Saturday, March 28, 2009

Komodo Edit dark theme

For some time now, I developed some computer related eye fatigue, which kinda sucks and I believe this is related (in part) with the white background of my text editor(s). That's why I decided to try a dark theme in Komodo Edit. The one shipped with the editor is a bit ugly, I wanted something more like Twilight for Textmate and any Google search for Komodo themes returned pretty much nothing. So, here's my creation, inspired by all those dark themes out there, especially Twilight.


If you like it, you can grab the theme file from github. You don't need to know/use Git, there's a download button somewhere on that page.

It only supports PHP and JavaScript syntax for the moment. More to come when I'll have some time. Update: There's Python and XML support right now.

After you download it, put the .ksf file in your Komodo Edit application data folder, more precisely the schemes directory. On my Windows machine this is: C:\Documents and Settings\{user}\Application Data\ActiveState\KomodoEdit\4.3\schemes.

Friday, March 20, 2009

XHTML no matter what!

metropotam.ro changed their layout. Here's what XHTML obsession means (look after IE conditional comments):


<base href="http://metropotam.ro/" /><!--[if IE]></base><![endif]-->

I simply cannot see the reason for such a useless hack. Too bad they forgot to do the same thing for script tags. But I see the reason for the one below (again, look after IE conditional comments):


<li class="selected">
<!--[if lte IE 6]><table><tr><td><![endif]-->
<ul>
...
</ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]-->
</li>

But then again. What's this? (look after IE conditional comments):


<li><a href="http://metropotam.ro/Unde-iesim-index/"><strong>Unde iesim</strong><!--[if gte IE 7]><!--></a><!--<![endif]-->


Regardless of the above nitpicking though, I like the new layout.

Wednesday, March 18, 2009

PHP's ErrorException class

Did you know PHP has an ErrorException class that solves the problem of throwing exceptions from an error handler function?

What problem?

Well, if you throw a normal Exception from such a handler, the file name and line number of the Exception will be set to match the file and line where the Exception was actually thrown and not the place where the error happened. There was no way to extend an Exception class and provide the correct information as Exception's $file and $line properties are private and there are no setter for them, only getters.

ErrorException solves this problem by overriding the Exception constructor, allowing us to pass up to five arguments. From these five arguments, four have the same meaning as the four arguments passed to the error handler function: $errno, $errstr, $errfile, $errline. By passing along these arguments to the ErrorException constructor we get a more meaningful exception from our error handler.