Archive for the 'Articles' Category

From Best to Good - Re-evaluate your practices again

When looking to improve your work environment or pushing to use a new method, it’s not uncommon to go looking for what might be considered Best Practice in that area. It’s as natural and common as it is problematic and dangerous.

First of all, the very notion of a Best Practice is that there is some way of performing a task or method that is superior to all other possible ways of performing that task or method. It is also suggested that the practice is superior in all aspects, meaning it delivers the most value and costs the least resources (if applicable).

So, what’s the problem with wanting to find, and ultimately putting to use, best practices? Wouldn’t it be a great thing if we could find more best practices and let all interested parties in the world share as many best practices as possible? In theory; yes. In practice; no thanks.

The problem with many things marketed as best practices is that it’s not. It is extraordinarily uncommon for a technique och method to be so absolutely, overwhelmingly better than all other ways in which you could perform a task that it could be declared a true and undisputed Best Practice. That’s not to say there aren’t any Best Practices, I’m believe there are at least a few lurking about in this great universe of ours, it’s just that they’re not so common as we would think.

Take the field I’m working in (and probably you as well, since you’re stuck reading this): IT. Software Development. What’s the best way to develop software? What’s the best way to handle source code? What’s the best way to make sure we stay on track, do the right thing and always deliver maximum business value for the least amount of resources while boosting the user and developer experience and maximizing shareholder profits? Please let me know the best practice for that! No really, please do!

The obvious answer is that IT is a way to complex field to have any large, powerful Best Practices that all can agree upon. If you don’t agree, tell me the best computer language the world agreed upon. Or the best web framework. The catch being here that different people and organizations have different best practices, which serves to make them anything but unequivocally best. Of course, there is no single best computer language or web framework that is best for all cases.

So, if best practices are super-rare, bordering on non-existant, what should we do when we want to know how people smarter than us have solved a recurring problem we have just faced? We should do like other industries, look for Good Practices. In many industries there are several agreed upon Good Practices that form the basis for making sure we do not all spend obscene amount of times reinventing an inferior wheel.

Focusing on Good Practices instead of the mythical Best Practices has many benefits: A practice that has proven to work in a good fashion for a team doesn not have the burden of proof as to wether it is also the absolute best practice concievable meaning there should be more good practices to choose from. As there are many, competing good practices you are encouraged to constantly inspect, adapt and revise any decisions to go with any particular practice, which is great since that causes you to pay ongoing attention to how you work and how your practices are working for your particular environment and people. Focusing on good practices also removes the stigma of trying on a Best Practice and finding it doesn’t deliver for your needs. If it truly was best, you must be doing something wrong. If the practice you tried was merely good, you can just keep looking or adapting the practice.

To round up: stop looking for Best Practices and embrace imperfection and ongoing improvement by going for Good Practices. I’ll follow this up by posting some good practices I’ve used in projects over the following months. Stay tuned!

Adding DSPAM to my mail setup

It’s about frickin’ time that I added support for DSPAM to my mail server. I use a Postfix+Courier+IMAP+MySQL combination for mail administration as I have a fair deal of domains and users in the system (Read more about the mail setup here).

I will document my steps in trying to fit DSPAM into this mix on this page in the hopes that it will help me or you! :) Btw, I’m doing this on a machine running Fedora Core 1, but I guess it’d work fine with most Linux setups.

Firstly, download DSPAM (I choose the latest beta, v3.4-BETA 1, always living on the edge)

I tested my luck with ./configure, but it just threw an error my way:

checking sqlite.h usability... no
checking sqlite.h presence... no
checking for sqlite.h... no
configure: error: Required version of libsqlite not found

So, I actually had to RTFM, at least the README.

Figured I would use MySQL as the backend and I tried the following: ./configure --with-storage-driver=mysql_drv --enable-daemon --enable-virtual-users --enable-preferences-extension. This gave me a new error:

checking where to find MySQL headers... compiler default paths
checking mysql.h usability... no
checking mysql.h presence... no
checking for mysql.h... no
configure: error: Required version of libmysqlclient not found

Oh well, using ./configure --with-storage-driver=mysql_drv --enable-daemon --enable-virtual-users --enable-preferences-extension --with-mysql-includes=/usr/include/mysql/ --with-mysql-libraries=/usr/lib/mysql/ *puuh*, made all the difference.

Now just run make && make install and watch the magic happen.

Next, create a new database in MySQL and create a new user that has privileges to this database. Run the enclosed .sql-scripts (found under src/tools.mysql_drv/. Which ones you run will depend on your version of MySQL and whether or not you want to use virtual users with DSPAM. I chose to use mysql_objects-speed.sql and virtual_users.sql.

Next I chmod‘ed and chown‘ed the /usr/local/var/dspam/ directory so both the postfix and the apache user can use the files therein.

Also made sure to edit /usr/local/etc/dspam.confset trusted user to myself, root, apache and postfix and also set the correct MySQL settings:

MySQLServer     /var/lib/mysql/mysql.sock
MySQLPort
MySQLUser               dspamuser
MySQLPass               secretpassword
MySQLDb                 dspam
MySQLCompress           true

Next we create /etc/maildroprc like so:

SHELL="/bin/bash"

if (/^X-Spam-Status: Yes/:h || /^X-DSPAM-Result: Spam/:h)
{
        # See if the Spam folder exists.
        `test -d "./Maildir/.Spam/"`
        if ($RETURNCODE != 0)
        {
                # If not, create directories
                `mkdir ./Maildir/.Spam/`
                `mkdir ./Maildir/.Spam/cur`
                `mkdir ./Maildir/.Spam/new`
                `mkdir ./Maildir/.Spam/tmp`
        }
        to "./Maildir/.Spam/."
}

Now chmod and chown the file so the postfix user can run the file.

Add dspam_destination_recipient_limit = 1 to /etc/postfix/main.cf.

init script for HLstats

abstract

This is an init.d script for Linux (originally Red Hat and Fedora, since that’s what I’m using mostly) for controlling the HLstats statistics program for Half-Life.

The most recent version of this document can be found at http://palbrattberg.com/.
You can also get the script as text on a page of it’s own.

Continue reading ‘init script for HLstats’