Here is random code I've written for the Raspberry Pi. Apologies for the ugly coding and lack of comments. Since it's just for projects around the house, I do it quick and dirty without much thought to doing it right.
None the less, may still be helpful to someone.