Email Heaven

I have just migrated my email over to a new VPS. Okay, a not-so-new VPS. I’ve had it for a while, but it’s only now that I’ve gotten around to taking care of the email migration. I love IMAP. I seriously don’t think that I could ever go back to using POP for my email.

I love the Maildir format too. Just tar the the Maildir directory, copy over to the new server, untar it, change the A record for mail.node.mu to point there, and BAM – everything works transparently. There’s no need to reconfigure the email client.

I got a Sony Ericsson M600i on Tuesday, and it’s making me appreciate IMAP even more. I usually receive emails from two high traffic lists: the moodle.org forum posts, and the Moodle cvs commits list. I have these emails filtered to different folders. My phone is not subscribed to these folders. There’s not much value in having these emails go to my mobile phone because:

  1. I’ll have to pay more for the data transfer
  2. If I’m reading emails on my phone, it means that I don’t have my notebook with me anyway.

Now all I need is for Apple to release an updated version of iSync with the coming OS X 10.4.8 update, and I’ll be a happy M600i user.

Moodle 1.6.1 Released

Moodle 1.6.1 has been released four days ago. See the release notes for the change log. 1.6.1 is mainly a bug fix release. You can grab it from download.moodle.org.

Apache 2.2, MySQL 5.0 and PHP 5.1 on FreeBSD 6.1

Way back then, I wrote a tutorial on how to set up a FAMP server. Some things have changed since then, and this tutorial gives a quick run down on how to do it today. I have tried to explain the whys as well as giving the steps. Installing FreeBSD is beyond the scope of this tutorial. So let’s wave our magic wand and say that your server has just rebooted into a fresh minimal installation of FreeBSD 6.1.

There are three ways to install software on a FreeBSD system. You can do everything from ‘first principle’: download source code, compile and install. The second way is to use pkg_add to install pre-built binary packages. pkg_add is able to resolve dependencies and it will automatically download and install these as well.

The third way is to use Ports. The Ports Collection is a set of makefiles, patches and description files placed in /usr/ports. To install a port, you just need to browse to the relevant subdirectory and type ‘make install’ For example:

cd /usr/ports/editors/vim
make install

This will tell the Ports System to download the vim source code, compile and install it on your system. You are given the chance to choose from a set of compile time options if there are any. The Ports System is able to resolve dependencies too.

We will be installing the required software from ports because it gives us both flexibility (we are able to select compile time options) and convenience (it resolves dependencies and fetches the source code for us). Software installed from Ports can also be upgraded easily.

Let’s use Portsnap to make sure that we have the latest snapshot of the Ports Collection. Portsnap is a system for securely distributing the Ports tree. On a brand new installation of FreeBSD 6.1, as root:

portsnap fetch
portsnap extract

You now are the proud owner of an up to date Ports Collection. From now on, if you want to update your Ports tree, just do:

portsnap fetch update

More information on Portsnap can be found in the relevant section of the excellent FreeBSD Handbook.

You can use cvsup as an alternative to Portsnap. However, Portsnap snapshots are cryptographically signed and the system uses less bandwidth. You can use pkg_version to check whether you have any outdated ports on your system:

pkg_version -v

To update all the outdated ports with one command:

portupgrade –a

portupgrade –ai will ask for confirmation before updating each port. If you don’t have portupgrade installed, you can install it by doing:

cd /usr/ports/sysutils/portupgrade
make install

It is also a good idea to do

make clean

This gets rid of the working subdirectory that contains the temporary files during compilation. This can be shortened to ‘cd /usr/ports/sysutils/portupgrade; make install clean’. More information on how you can keep your system up to date can be found here. Now that we have an updated Ports Collection, let’s get down to business.

Install Apache:

cd /usr/ports/www/apache22
make install clean

Install MySQL:

cd /usr/ports/database/mysql50-server
make install clean

Configure the php5 port:

cd /usr/ports/lang/php5
make config

Deselect option CLI. Selecting to build the CLI version rendered php apache module unsuable for me for some reason. A quick googling around told me that I was not alone in having this problem.

Install PHP:

make install clean

Install PHP extensions:

cd /usr/ports/lang/php5-extensions
make install clean

Just choose what extensions you want to install. Install the php5-mysql extension:

cd /usr/ports/databases/php5-mysql
make install clean

Let’s start our new daemons:

/usr/local/etc/rc.d/apache22.sh start
/usr/local/etc/rc.d/mysql-server start

You should now be able to browse to your web address and see the cheerful exclamation: ‘It works!’ To make sure that Apache and MySQL start whenever the server is rebooted, add these lines to /etc/rc.conf:

apache22_enable=”YES”
mysql_enable=”YES”

Software installed through ports will have their configuration files in /usr/local/etc. The base system configuration files live in /etc. This makes for a clean, consistent filesystem layout. Let’s configure our newly installed software.

To make Apache PHP-aware, add the following lines to /usr/local/etc/apache22/httpd.conf:

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Go through the configuration file and customise to your needs. The PHP port has created a php.ini-recommended file for us in /usr/local/etc/. Let’s use that as a starting point:

cp /usr/local/etc/php.ini-recommended /usr/local/etc/php.ini

Now edit /usr/local/etc/php.ini to suit your needs. Restart Apache to apply the configuration changes:

apachectl graceful

By default, no password is set for the MySQL root user. You should set a password for that user at this point:

mysqladmin -u root password "newpassword"

Replace “newpassword” with your own. MySQL comes with two anonymous accounts set up. These accounts don’t have any passwords assigned by default. It is a good idea to just delete them. Use the MySQL client that came with the database server:

mysql –u root -p

When asked, type in your newly created database root password. At the MySQL prompt, issue the following command:

delete from mysql.user where user = '';
flush privileges;

To exit from the MySQL client, just type ‘exit’.

That’s it! I now suggest that you take a look at the output of phpinfo() to make sure that everything is in order.

Moodle 1.6 Released

After going through five beta versions, the wait for Moodle 1.6 is finally over. Martin released 1.6 last Tuesday (download, release notes).

Moodle is an open source Learning Management System (LMS). Here are some resources to get you started:

The best way to get involved in the community is to create an account on Moodle.org and join the Using Moodle course. If you want to test drive Moodle, I have set up three test/demo sites that I keep up to date with the latest code from the corresponding CVS branches:

Site Description
Moodle 1.5.4+ Moodle 1.5.4 is the previous stable release. This site tracks the 1.5 stable branch in CVS.
Moodle 1.6+ Moodle 1.6 is the current stable release. This site tracks the 1.6 stable branch in CVS.
Moodle 1.7 This site tracks the development branch of Moodle, the latest bleeding edge stuff from the CVS HEAD branch.

Feel free to create user accounts and to poke around.

Catching Up on My Reading

Recently I have accumulated a number of bookmarks “to be read later”. Tonight I sat down to read some of them. I revisited CakePHP and I also read a nice article about storing hierarchical data in a database.

I first thought about trees vs RDBMSes when we were designing the Bam CMS. Websites are inherently tree-like in structure. However, a CMS will usually be storing data into a relational database.

The article describes the Modified Preorder Tree Traversal algorithm. The main attraction of this algorithm is that retrieving a node in the tree (a page in the website) requires only one query to the database. Updating the nodes is more expensive, but in a CMS situation, you tend to have many more page requests than page moves/additions/deletions.

I also wandered over to the CakePHP website and read through the new documentation. It seems that a lot has happened since I last looked at the framework. 0.10 Final has been released and the documentation and overall activity has picked up. It is now much easier for a developer to get up to speed with the framework. For those not familiar with CakePHP, here are the goodies:

  • MVC Pattern
  • Sane file layout
  • Pretty URLs
  • Easy installation and upgrade of the framework
  • Convention over configuration
  • Scaffolding
  • Access control lists
  • Helpful helpers: html, ajax etc.
  • Add your own helpers easily

Like Ruby on Rails, but need PHP? Look into CakePHP. It may be a steep learning curve if you are not familiar with the MVC pattern, but it is worth it. Since the framework, like RoR, favours convention over configuration, it takes a while to get used to the way things are done. Hint: it is easier to go with the flow. Work with the framework, do not fight it. The net gain is consistency and discipline. PHP is a great language, but it is so easy to write crappy code with it if one is not disciplined. A good framework will encourage good habits and highlight best practices.

CakePHP essentially takes the pain out of writing PHP. The framework takes care of sessions, has object relational mapping, makes form building and validation easy, and makes data sanitisation a breeze. The small headaches of day to day PHP fade into the background, leaving you with the more interesting tasks to concentrate on.

Two Weeks with a PowerBook

I have now had my PowerBook for a little more than two weeks. Like I said in my previous post, I am very impressed with the design and build quality of the machine. First, the obligatory photos.

PowerBook with lid closed.

PowerBook with lid open, from left hand side.

I bought an STM glove and a booq Mamba XS laptop bag to carry the notebook around. If you own a 12″ PowerBook, you should make sure that the glove is actually made for the PowerBook. Don’t buy the gloves that say they fit both the 12″ iBooks and PowerBooks. The PowerBook is smaller than the iBook and these gloves won’t fit nicely.

PowerBook, STM glove, booq bag.

Everything is outstanding, except for the screen quality, which is pretty average. I usually plug in an external monitor when at work and at home. On the move, the 12” lcd is adequate. The 12” PowerBook shares the same screen as the 12” iBook. The other PowerBooks have better quality screens. The MacBook Pro apparently has Cinema Display quality screen. I knew all this before I bought the notebook, but I was not willing to carry a bigger laptop around. Here’s to hoping for a better screen on the 13.3” (or whatever it ends up being) MacBook Pro. The arrow keys are also too small and it takes a while to get used to them. If you look closely at the following photo, you will notice that the arrow keys are half-height so that they are flush with the lower end of the keyboard.

PowerBook from top, right hand side.

There are a few things that I had to get used to:

  1. To go to the end of a line, you need to press command+right arrow key. Likewise, to go to the beginning of a line, you need command+left.
  2. The delete key is basically backspace. To delete to the right, you need fn+delete.

For my usage pattern, the 512MB of RAM that the notebook ships with is the bare minimum to run OS X comfortably. I have since upgraded the memory to 1.25GB and things really fly now. The UI in general feels a little slower than Windows XP and KDE, but faster than Gnome. Purely subjective, of course. Windows XP would be more bearable on a machine with 256MB of RAM than OS X. However, throw more RAM at OS X, and it seems to make better use of the extra memory. Once you start having lots of applications running, OS X doesn’t seem affected whereas the hard disk starts trashing in Windows. Anand Shimpi attributes this to the more aggressive caching in OS X.

Window management is completely different in OS X. There is no taskbar, and any attempt to use the dock as your window management tool is likely to slow you down and lead to frustration. Instead, you should manage windows spatially. Get over the fact that any application that you are not using should be minimised, and get over the fact that you should maximise the application that you are currently using. Let the screen(s) clutter up, and use exposé to find the window that you need. With the higher resolution displays it makes more sense to adopt this approach anyway. You can also alt-tab you way through the windows. However, unlike in Windows, you can use your mouse to select the relevant application while doing that. Another way to manage your windows is to close (command+w) any application window that you don’t immediately need. Closing a window will not quit the application. Some applications I never quit – they just remain closed out of sight if I am not using them: the terminal, safari, mail.app, iTunes and IM clients. I will still be alerted if an email or an IM message comes in. And accessing them again is instantaneous since they are still running in the background.

Shortcuts are also plentiful and are the recommended path to nirvana. Some shortcuts that are used in Windows, KDE and Gnome have equivalents in OS X. Except that you use the command key instead of ctrl. Command-c copies, command-v pastes, command-q quits, etc.

Command+space will bring up spotlight. Spotlight is basically instantaneous, system-wide search. It’s so fast because it indexes meta data every time you create, save, move, copy or delete a file. Spotlight can search through your applications, system preferences, as well as documents, emails, IM messages, etc. You can use it to quickly launch applications without having to touch your mouse. Hit command+space, type in “ter” and spotlight instantaneously finds the terminal app. Just arrow down and hit enter. Quicksilver is also a nice application launcher. I have bound option+space to bring up Quicksilver and I have it configured to search for applications first. I use Spotlight as the general search tool and Quicksilver as my application launcher. The following screenshot shows Quicksilver in action.

Quicksilver in action.

If you come from a *nix background and want a pager, Desktop Manager is a nice, free pager. The transitions while switching desktops are cool too.

My new editor of choice is TextMate. I still had 17 days remaining out of the 30 day trial when I decided to buy the license. I love the fact that it can be launched from the terminal. I don’t use the finder while coding these days. The terminal is faster and I can also use grep & co. to boot. TextMate has a minimalistic UI and does not get in the way. You won’t find tons of menus/toolbars. As you grow into the editor, you learn the shortcuts and start using macros. Think vim with a modern GUI that has code folding, tabs and project directory browsing. I won’t get into too much details. Raving about TextMate is a bit like raving about Ruby on Rails. It’s all over the web. Okay, maybe I’m exaggerating, but I’m sure that this would be true if TextMate was also available for Windows and *nix. Here’s a screen grab of TextMate:

Screen grab of TextMate.

If you are a long-time Windows user and you miss having the start menu to launch applications, just add your Applications folder to your dock. You will then be able to right-click (or ctrl+left-click, or left-click and hold) on its icon to get a menu with all your applications. This will also enable you to keep only the most used applications in your dock to keep things tidy. You can add any folder to your dock by dragging it between the trash can and the dark line that separates the trash from the rest of the dock icons.

I don’t consider myself as an OS X power user yet. Feel free to drop me a line if you have any tips or any suggestions for killer apps :-)

Bought a PowerBook

I bought a PowerBook G4 12” on Monday. I’ve been meaning to buy a mac for a while. My old PC is a PIII (600MHz, overclocked to 800MHz) that dates back to the year 2000. It’s served me well, but I suspect that it will now turn into a test development server or a box where I throw in the Linux/BSD distribution du jour.

I like my notebooks portable – but no integrated graphics please. The 12” PowerBook is the smallest laptop that Apple makes that I can buy right now. I thought about waiting for one of the small MacBooks or small MacBook Pros when they become available, but I really need a new computer now. It could be anything from a few months to up to a year before Apple ships a small intel based notebook. I considered the 12” iBook, but the slow hard disk deterred me. I also anticipated that I would be plugging in a monitor both at work and at home to extend the desktop space. iBooks can mirror the notebook display, but not extend the workspace to both displays. Not without a hack anyway. The 12” iBook is also bigger.

I looked at the VAIOs for a while. The 13.3” S58GPB has better specs, a better screen, is lighter than the 12” PowerBook and does not compare too unfavorably in the looks department. However, the VAIO is also AU$1000 more expensive. Despite being more expensive, it does not feel as nice. The plastic used does not do justice to the notebook. Looking at the pictures I thought what a gorgeous machine. But actually using the VAIO was a hugely underwhelming experience. The PowerBook feels much more expensive despite being significantly cheaper. The PowerBook actually looks better in real life than in the pictures. The VAIO looks better in the Sony marketing material than in real life.

The Apple logo, like the VAIO logo, is upside down when you sit in front of the notebook with the lid closed. However, both logos stand upright when you open the lid, showing to the world that yes, damn right, this notebook is worthy of attention. Except that the Apple logo glows white when the machine is in use. This actually illustrates quite well the similarity and difference in philosophy. While Sony, like Apple, puts in a lot of design effort in its notebooks, the PowerBooks still go the extra yard in the direction of the wow factor.

There are small details everwhere. When the PowerBook is in sleep mode, a small white light glows on the lid release button. The light slowly glows stronger and weaker, almost as if the laptop is indeed asleep, breathing slowly. It is at this point that one stops comparing specs. Apple products tend to produce an emotional reaction in the user. Wonder why iPods outsell the competition by such a big margin? It’s certainly not because they have the best specs, nor because they offer the best value. Apple will go to the length of having a speaker in the iPod, just to generate the click sound when the user navigates the menus. iPod owners love their iPods because of the way the devices feel and behave.

However, any specs, or otherwise comparison was pretty much moot point in the end. The main reason for getting the PowerBook was of course OS X. I’m finding it faster to work on UNIX-like systems, but Linux and BSD systems tend to involve too much maintenance when used as workstations. OS X fits the bill perfectly. More on that, plus pictures, later.

Thank You Bam Creative

Friday was my last day at Bam Creative. I am starting a new job tomorrow, as a developer at Moodle. It’s pretty exciting. I am an avid consumer of open source, and here’s my chance to contribute while getting paid to do that.

Thanks Miles, I am grateful for the opportunity that you gave me, and for believing in me when I was a rookie developer starting out. I have learned so much during my time at Bam; not just the technical stuff, but also how to be more confident and assertive, how to take on more responsibility, how to multi task and prioritise better, and yes, it has to be said, how to manage stress :P I have learned a lot just by looking at how you interact with clients and by being around everybody at Bam. I loved the high-energy atmosphere and all the fun.

Time really flies. It seems like it was only yesterday that I was about to finish university and was worrying about finding a job in a foreign country. I did have a part time job at Subway as a sandwich artist, but that was more to help me earn some pocket money while studying.

For those who are wondering, a sandwich artist is what Subway calls the person who (hopefully) smiles as you walk in and engages in chitchat while you stare blankly at the hundreds of possible combinations of ingredients that can go into any given sandwich. Luckily, help is at hand. First you get asked what kind of bread you would like, then what cheese, what main filling(s), whether you want everything from the salad bar, whether you would like salt and pepper, and finally what sauce(s) you would like. If you are lucky, the sandwich artist would be skilled enough to make all that fit into the roll. If you are not, everything just falls into your lap while you attempt to take that first bite. I got pretty good at filling sandwiches, mainly because we were each allowed a six inch during our work shift. When you are hungry, you learn pretty quickly how to pack enough ingredients for a foot long into a six inch! The sandwich artist also does everything from preparing the ingredients, to mopping up the floor and taking out the trash at the end of the day. Still sounds artistic and glamorous? Didn’t think so.

I discovered port80 through a lecturer at ECU and I had been reading the forums regularly. Then one day I saw that Bam Creative were looking for a web developer. I applied and was lucky enough to sign an employment contract two weeks later. I got a missed call from Perth Web during my last exam. I rang them back and they asked me whether I could go in for an interview for a regarding a position that I’d applied for a few weeks earlier. It was then that it actually sank in how lucky I was that I already had a job to go to after uni, that I didn’t have to keep looking up job advertisements on seek.

The first few months were basically sink or swim – learn how to interface with SMS gateways, credit card gateways, learn how develop applications of bigger and bigger scope. There was so much to learn, so many things that I had never done before. I will always remember the night that Adam dropped me home at 4:30 AM. He went back to the office, fell asleep on his keyboard, and woke up with a screenful of junk.

There is still so much to learn. The more I learn, the more I discover how little I actually know. For a while I thought that I was pretty good with OOP until I discovered OO design patterns. I’ve been looking at quite a lot of resumés lately, and every time I see a list of technologies and the applicant’s familiarity with each technology, I have to try and put myself in the shoes of the applicant. A fresh graduate’s idea of “expert knowledge of PHP” would be different to someone with 5 years of commercial experience with the same technology. These lists are mostly useful to gauge the applicant’s familiarity with a technology relative to another technology.

Bam Creative has been good to me. I hope that my contribution has benefited Bam as much as Bam has benefited me. I’ll miss you guys – Miles, Drew, Basil, Patima, Teresa, Johanna.

Do Kids Still Play LEGO?

Do kids still play LEGO these days? This one (yours truly) still does. I don’t have a LEGO set over here in Perth, but I’ve found myself building stuff with my old sets every time I go back to Mauritius. I did that recently when I went back for two weeks. I find it relaxing to sit down, start digging into the big box of parts, shifting through the plastic to find the appropriate bits, and putting them together. My dad once bought me a LEGO set for Christmas, and I asked for a new one for every Christmas and birthdays for the following few years until I had a sizable collection of parts. I would follow the instructions to build whatever the new set was supposed to build – once. After I’ve satisfied my curiosity, I would never build it again. I prefer mixing parts from all the other sets to build original stuff. Back then the LEGO parts were pretty simple. You didn’t get all the weird and wonderful shapes that you do today. Building something from the simple primitives was more challenging and rewarding than it is today. And a LEGO set was more versatile as a result too. I tend to build vehicles rather than buildings – wheeled vehicles, ships, aircrafts, spacecrafts, bots. It’s always sad tearing down something you’ve spent a couple of hours building, but there are never enough parts, and the fun is in building new things. So the finished product must be dismantled so that the parts can be recycled into new creations.

Later on I got into drawing stuff on the family’s 286 PC. Unlike LEGO parts, there are plenty of pixels to go around and one never runs out of it. The software was pretty limited and I found myself building things pixel by pixel – a process not dissimilar to building something using LEGO. Except that I only had one primitive. I did have a huge amount of possible colours to choose from though – a whooping 256 different colours! These days they call this pixel art.

Eventually I discovered that QBASIC was also installed on the machine. I started playing around with code, but I confess that I must have written awful stuff. I didn’t know how to use functions. I guess reading help files is pretty limited if you haven’t been taught any programming concepts. I played around with fractals and started a simple battleship game which I never completed. Back then there was no internet, no WWW and no Google. These days I can’t imagine myself coding without Googling around for stuff every now and then.

I also used to enjoy technical drawing at school and at one point wanted to be an architect. Then I found out that it usually takes 7 years of tertiary schooling before one can become an architect. So I forgot about that. I decided that I would become a programmer. Aiming to work for LEGO seemed to be too much of a gamble. What if they didn’t want me? I would be stuck with no skills other than putting plastic bits together!

While on my way to become a programmer, I discovered web design and was hooked. I still liked creating graphics, but I confess that I was never much of a drawer. I can draw pretty good renderings of vehicles and buildings, but I totally suck at drawing organic shapes. Eventually I studied Multimedia (that’s so a 90′s term) and Computer Science.

Today I’m a developer. I do some web design now and then, but I see myself primarily as a developer. This is where I want to go. Until LEGO offer me a job :D

Mauritius, here I come

Woohoo, dad managed to score tickets to Mauritius for me today. I’m looking forward to being on the beach soon. I think I’ve taken a total of 3 days annual leave – one for my graduation and two after the last big project. It’s been a busy year and I’m glad to get a relaxing break from work and from thinking about work. I am also looking forward to seeing my family. I wish I could stay longer in Mauritius, but circumstances don’t really allow for that.