Zen Development

One thing that I’ve found helped me out a lot with development snags is perspective. I know it sounds a little hippy and existential, but it really helps. It always used to frustrate the hell out of me when I’d encounter a bug in my code, but I realized that it was only frustrating me because I was taking it personally – “why the heck isn’t this working! I know I programmed it right!”. Once I realized that this was happening I began taking a different perspective – learning.

I know that I’m going to write some code that will break. I know that something might break because I made changes elsewhere. Knowing this, I take every bug now as an opportunity to learn. So, instead of getting frustrated and pissed at my IDE (Aptana) or my PHP because it isn’t doing what I told it to, I just start from nothing. I assume nothing, and start building up what I can know for sure. I begin throwing a bunch of debug,  exits and echos all over the place and starting from the very beginning I try to discover where it might have gone wrong, establishing a base for what I can be sure of. From that base I can discover what went wrong and learn from it because I’m not distracted by my frustration.

Treat every bug like a puzzle to unravel and a chance to learn something new. In becoming a learning opportunity, it looses its power to piss you off 🙂

Image Upload MIME type handling and IE

I was recently writing a script to handle image uploads from users to an Amazon S3 bucket and discovered one of those great IE quirks. Normally when writing an upload script you check for MIME type validity to make sure that the file that a user is uploading is uploading the correct type of file you are expecting to process. Now, I know that MIME types can be spoofed, but it’s still good to check against them to determine file type and prevent a user from accidentally uploading the wrong type of file. In writing the MIME type validation script though, I ran across a problem where versions of IE less than 9 would not detect my MIME type properly.

Continue reading “Image Upload MIME type handling and IE”