Imagery is my life and life is something beautiful

To become a great software designer needs passion

A tech blog recommendation

I recently came across this blog in my web travels. The guy is a self described C++ hater, but also a C++ (and many other languages) super-genius, being a developer of compilers and debuggers and stuff for embedded C and C++ developers in the automotive industry. His articles aren’t too focused on C or C++ for those who don’t care about those languages; they range from x86 assembly/memory management to comparisons between Python and Perl. I find his style hilarious and enlightening. He’s something akin to a Bastard Sysop From Hell for the what’s-all-this-Web-2.0-crap generation. Or perhaps what Yahtzee would be like if he reviewed programming languages instead of videogames.

  • On doing OO with plain old C
  • On extreme programming (aka. XP, aka. Agile process) as a religious cult
  • On an evil of distributed revision control systems (and a retraction, but still worth a read)
  • On why global variables are good
  • On why he doesn’t write iPhone apps
  • A lament for long-forgotten days of coding exciting things
Learn More

Stay in Sync with GCal and Thunderbird.

For a long time I have been looking for a rock solid calendaring system. I’ve gotten too used to working for companies who have Microsoft Exchange (or, God forbid, Scalix) installed which allow me to edit and update a calendar from multiple locations and even sync it with my Mobile Phone. When I first heard of Google Calendar I hoped that I would be able to enjoy such benefits again, but I am not a great fan of web-apps, and prefer a nice, solid desktop client to do my email / organisation from.

Queue Lightning, the calendaring extension for Thunderbird which brings the desktop email app one step closer to becoming a viable alternative to Microsoft Outlook. Installation can be a little bit confusing and you must remember that this add-on is still in the 0.x stages, so may be a tad unstable at times (but that’s ok, we love this kind of thing!)

Open up Thunderbird (I am using the 2.0.0.6 release) and on the Top Menu, go to:

Tools -> Add-ons

When the Add-ons window opens, click on the Install button on the bottom left and paste in the following URL to install the latest release of Lightning (Windows Only, Linux / Mac users will need to get this link by copying the XPI download path from the Mozilla Add-on repository, located here.

Win32 Lightning Add-On XPI Download Link:
https://addons.mozilla.org/en-US/thunderbird/downloads/file/20424/lightning-0.7-tb-win.xpi

If you get a warning similar to “Lightning could not be installed because it is not compatible with Firefox” then you are trying to install the XPI directly into Firefox. Instead, you need to either “open” the link from inside the Thunderbird Add-Ons Install Window, or save the XPI to your desktop and then drag it into the Thunderbird Add-Ons Window.

Once you have installed the Lightning Extension, Thunderbird will ask you to restart. Upon restarting you will be greeted with a new Sidebar on the right displaying tasks and events and a tool bar underneath your folder list.

This is all well and good and provides us with an easy to use local calendar, but that’s not much use if you wanted to update it at work, or on the road / mobile device. This is where the Provider Add-on comes in to play.

Provider allows bidirectional syncing between the Lightning Calendaring Extension in Thunderbird and Google’s GCal Service. This is possible because Google, being the lovely chaps that they are, decided to opt for the iCalendar standard in GCal, well done chaps 🙂

Installation of Provider is pretty similar to that of Lightning. Again, go to the Add-ons Window (Tools -> Add-Ons) and Install the XPI available for download from Provider’s Page in the Mozilla Add-on repository.

Win32 Provider Add-On XPI Download Link:
https://addons.mozilla.org/en-US/thunderbird/downloads/file/20552/provider_for_google_calendar-0.3.1-tb+sb.xpi

Again, once installed, Thunderbird will have to be restarted.

Now, the last piece of the Pie is to tie our Google Calendar into our Lightning Calendar. First of all, you will need to log into your Google Calendar account. Once you are at the main page, click on “Settings” from the Top Right Menu:

Once on the settings page, you need to drill down into the “Calendars Settings” screen and then click on your Calendar from the list (I only had a single calendar.)

Now, finally, you need to copy the URL of your Private Address XML Feed into the clipboard.

You’re done in Google Calendar for now and we can head back to Thunderbird to finally wrap this tutorial up ;). Once you are back in Thunderbird, you need to create a new calendar in Lightning. You can do this by clicking on the following Menu item:

File -> New -> Calendar…

Upon clicking the New Calendar menu item, another window will appear. The first option is the location of your Calendar – select “On the Network” and click Next.

The next option allows you to specify the Format of the Calendar, slect the “Google Calendar” radio button (if you don’t have a Google Calendar radio button, make sure your Provider Extension is installed correctly). In the location input box, paste in your Google Calendar Private Address XML Feed that we extracted above, and click Next.

The next window asks you to give your new Calendar a Name and a Colour, I will leave these entirely up to you 😉

Finally (yes, at last) you will have a “Google Calendar Login” window which will ask for your Google Account login. If you only have a single Google Calendar, Provider will have automagically extracted your username from the XML feed you just specified; however, just double check that it reads @GMAIL.COM. Then enter your usual GMail password.

Well done, you can now enjoy the many benefits of being able to view and update your Google Calendar directly from Thunderbird – nice work 😉

Further Reading

Learn More

Software RAID 5 in Ubuntu with mdadm

Software RAID in Linux is a great way to gain massive amounts of disk space which are required for storing digital media, with the added security of data redundancy incase one of the disks in the array fail. Many people still frown upon software RAID insisting that hardware raid is the better option. This may have been true when your 486 CPU was busy trying to load win.exe, but now we have access to multicore CPU’s there is little point in offloading such a ’small’ task. Software Raid in Linux, via mdadm, also offer many advanced features that are only available on the most high end of RAID controller cards such as expanding existing RAID-5 arrays, RAID Level Migration and Bitmap Caching (similar to having battery backed up cache). Finally, Software RAID can move with you, if you decide to change motherboards, or your PCI RAID controller fails then your array may be at risk – not so with Software RAID.

This guide details setting up software RAID 5 on Ubuntu / Debian using mdadm post install. It does not cover everything you need to know about RAID and the knowledge in this document is by no means extensive – please check out the further reading link for more information at the end of this article.

And as a final note before we get started, please remember that no RAID solution is a viable replacement for good backups! If your data is so valuable that you can’t afford to loose it (either due to hardware, or user error) then make damn sure it’s backed up on a remote machine / device.

Step One: Prepare the Disks

as root, issue issue an fdisk -l to bring up a list of available disks.

In my example I have 3, 300gb Hard Disks, sda1, sdb1 and sdc1 that I wish to combine into a RAID-5 volume. The disks are currently unformatted. The first set is to format them as ext3 and set the RAID flag, this can be done easily with gPartEd. If you do not have ‘Gnome Partition Editor’ on your System->Administration Menu, install it by issuing

sudo apt-get install gparted

In the Gnome Partition Editor application, select each disk in turn and opt to format it to ext3. Remember, you will loose all data on the device. Once the format is complete, right click on each new “volume” you have created and select “Manage Flags” – tick the ‘RAID’ flag to indicate the disk will become part of a RAID set.

Once you have your three disks set up, fdisk -l should now indicate that those disks are ready to become members of your new RAID 5 array.
Step Two: Creating the md Device
If you don’t already have mdadm (Mirrored Device Admin) installed, issue:

sudo apt-get install mdadm

You can now create your RAID volume (md0, if this is to be your first) by issuing:

sudo mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sda1 /dev/sdb1 /dev/sdc1

To explain the switches, --verbose will display more information on the screen as the RAID is created (which is useful for debugging and gaining help from others if you become stuck, --level=5 dictates that we want to create a RAID-5 volume, --raid-devices=3 dictates that there are to be three members of our raid array, you then need to list the disks you wish to assign. For more information, you can issue: mdadm --help-options

Upon pressing return, your RAID device (md0) will be created, if you get the following error (as I did with a fresh install of Edgy-Eft):

mdadm: error opening /dev/md0: No such file or directory

Then you need to add the parameter --auto=md to the end of your mdadm create raid command.

Once the build is under-way, you can monitor its progress by issuing sudo watch cat /proc/mdstat, watch is a very useful linux command which will refresh the output of a command ever 2 seconds for you. When you are done watching, you can press CTRL+C to escape back to the command line.

The last stage before you create the file system on your new raid disk is to create your mdadm.conf file. The mdadm.conf file contains information about your RAID array that the mdm daemon will need on boot to “re-assemble” your array ready for mounting. To create your mdadm.conf file, issue the following:

sudo echo "DEVICE partitions" > /etc/mdadm/mdadm.conf
sudo mdadm --detail --scan >> /etc/mdadm/mdadm.conf

Step Three: Creating the Filesystem and Mount Point
Now that you have created a logical RAID 5 volume, it’s time to format it so that we can put some files on it. I personally chose to format my new RAID volume with plain ext3, if you’re feeling a bit more adventurous you could format it with reiserfs or one of the slightly less common disk formats – it’s up to you. If, like me, do you opt for ext3, then you can simply issue the following command to format the disk (note: you can format the disk whilst the array is still sync’ing).

sudo mke2fs -j /dev/md0

This will take a few minutes (especially if your array is re-sync’ing). Once it has completed you need to edit your fstab to make the RAID-5 volume automatically mount on the next boot. I chose to mount mine in /var/media so that all users on my system will have access to it. As a result I added this line to my /etc/fstabfile:

/dev/md0 /var/media auto defaults 0 3

Now all that’s left to do is issue a mount /dev/md0 and, fingers crossed, your RAID 5 array should now mount to your chosen mount point. Now before you go off ans starting copying files to it, I recommend that you let it finish re-syncing. Also, remember, like all new things, it’s a good idea to “run it in” first, keep backups of all data that you put on it for the first few weeks so that you can handle an emergency should one happen!

Further Reading:

This short guide is by no means everything there is to know on the subject of RAID and mdadm. Once your RAID 5 array is up and running there are still plenty more tweaks and obstacles to overcome in the future, as a result I will leave you with the following links in the hope that they may prove useful.

  • The Linux RAID Mailing List Archives
  • Wikipedia Entry on RAID
  • Growing RAID 5 volumes with mdadm

edit: Fixed problems with double dashes!.

Learn More