Uditha Atukorala's blog

HTTP chunked transfer-coded data read / decode example in C++

I was writing some code for the bitz-server project the other day and I wanted to read data passed in using the Chunked Transfer Coding (RFC 2616, section 3.6.1). I did some quick googling but I couldn't find a coding example in C++ (or in C).

In the RFC 2616, section 19.4.6, there is a pseudo-code example on how to decode "chunked" transfer-coding, which seemed simple enough. So I thought of implementing it myself.

This is my approach to implementing a "chunked" tranfer-coding decoder in C++.

FormCheck with MooTools v1.3

FormCheck is an awsome MooTools class that allows you to validate XHTML form fields on cliet side. It has a nice UI touch and the validations are pretty good. I have been using it for some time now but the latest version (at the time of this writing), version 1.6, was released back in March 2010 and it only works with MooTools version 1.2. 

How to mount ext2/ext3 Linux Volumes in Mac OS X (Snow Leopard) with Read/Write access

I was actually surprised to find out that there is no native support for popular ext2/ext3 Linux Volumes in mac OS X. So if you are like me and have ext2/ext3 drives lying around and want to access them using OS X then here is a compact guide to sort things out in Snow Leopard. 

 

How to Set Up PHP mail in Debian

Note: This is tested and proven to work on Debian Lenny (stable)

If you are a web-admin or a PHP developer hosting on your own servers you might have found out that PHP mail() function does not work out of the box in Debian unless you have installed Exim (default MTA for Debian Lenny), sendmail or some other MTA. Most of the time this is OK, but when you really don't want to mix a mailserver with your webserver this is going to be a problem.

In php.ini file there is a SMTP configuration value that you can set which is misleading. Even though you set the SMTP value, PHP mail() function will not connect directly to the SMTP server and relay emails rather it depends heavily on sendmail program which can be set via the sendmail_path configuration value. In conclusion you'll have to have a working sendmail program if you want to use PHP mail() function.

Linux chroot - things to remember

When you are creating a chroot jail, before you chroot make sure that you have mount the following;

1 - /proc
# mount -o bind /proc /mnt/chroot/proc

2 - /sys
# mount -o bind /sys /mnt/chroot/sys

3 - /dev
# mount -o bind /dev /mnt/chroot/dev

Finally when you are done,

# chroot /mnt/chroot /bin/bash

Linux Kernel Modules - Some useful commands

Some useful commands to get information about kernel modules.

To get a list of loaded modules,

$ lsmod

Get more information about a module,

# modinfo

Load a module,

# modprobe

List PCI hardware with more information.

$ lspci -v

HDMI Video tweaks for nVidia

After messing around a lot I learned through trial and error that you have to set two options in your X Config file to get proper video through HDMI. This is specially true if you are trying to connect a TV to your box and getting small fonts that you cannot read.