Note: comments

Tags:

I’ve noticed that the increase in spammy comments to this blog has made the comment spam protection sometimes a bit too moderate-happy, and it has marked some legitimate comments as spam.

If you write a legitimate comment to one of my posts, and your comment doesn’t immediately show up after submitting, you can drop me a mail. The chances are the script ate your comment and I’ll have to mark it as not spam.

Never trust the user-agent header

Tags:

Something I just have to share: an entertaining and informative read on the history of the browser user-agent string.

I always did wonder why all browsers claim to be Mozilla when they are not… And clearly, the advice given by many JavaScript gurus to never use user-agent sniffing to determine browser capabilities is very good – just look what kind of a mess it will lead to, not to mention that if someone someday changes their UA string or comes up with a new browser, everything will break – just like the frames.

Theory vs. Practice in coding

Tags:

When working on a project, I sometimes find myself stuck – thinking about some implementation detail, such as how to tell my admin-module which other modules are installed in my CMS (but that’s another story) – and being stuck, unable to get anything done, just thinking of the problem at hand, because I want to find the best possible way to solve it…

Read More

On HTC Touch Diamond

Tags:

I received my HTC Touch Diamond from Opera earlier this week. It’s an interesting phone – and despite what people seem to say about Windows Mobile, it doesn’t seem to have any problems.

I’m sure you can find lots of proper reviews of the device, so I’ll just mention a few things I found nice and things that haven’t been brought up in anywhere else.

Read More

Understanding Doctrine’s NestedSet feature

Tags:

The Doctrine library comes with a feature called nested set, which makes saving trees in a database easy. However, it’s quite easy to accidentally cause a lot of extra unneeded queries if not being careful.

Here are some pointers to keep in mind while working with the nested set, and some example queries to make understanding it easier.

Read More

Database helper for PHPUnit

Tags:

When testing code which uses the database, you would usually want to make sure the database stays pristine for each test – All tables should be empty, as any extra data could interfere with the tests.

You could probably write an extended Testcase class which automatically does this before each test in setUp and afterwards in tearDown, but it may have some issues. For example, Zend Framework’s Zend_Test Testcase class also extends PHPUnit’s one, and you might need to extend the Zend_Test one as well… and so on.

Luckily, PHPUnit has a way to add event listener that react to certain events.

Read More

Implementing swappable authentication methods

Tags:

I’ve mentioned a CMS I’m working on in a couple of occaions. Lately, I’ve been tinkering with the user authentication part of it, and stumbled upon a small obstacle: How to make it easy to change authentication methods?

Most of the time you probably would like to use a database to store your users, but at work, I had to create a way to authenticate users from Windows Active Directory using LDAP. Another case could be unit testing – you might want to test your authentication code without a database.

Read More

How I got into programming

Tags:

While browsing around some old files on my computer, I came across some old files from 1998 (I think): An old text-game by some of my elementary school friends.

It reminded me of how I got started in programming. It was probably when I was 11 or 12 years old, when a friend told me about a text adventure game he had made and showed me how it worked…

Read More

Zend_Form decorator tips

Tags:

It seems a lot of people are struggling with Zend_Form decorators. They want to know how to modify the markup, but they can’t figure out how to do it with the bundled decorators or how to write their own.

Since I’ve done some decorator-stuff myself, I thought I’d share some tips on making the output a bit nicer. For example, how to make Zend_Form use <ul> and <li> tags instead of <dd>, <dt> and <dl>. I also wanted some inputs appear side by side (date from and date to in my case).

Read More