All the code here is stuff I have used, and thought "Hmm. I might need this again sometime."
Some of the stuff is based on other peoples' stuff. I will try and find out where I got it from, and credit them via comments in there.
If it works, hurrah. If not, if it blows up your nuclear submarine, or crashes your space probe - boo hoo.
If you know how to make these better, let me know.