Sorry for the huge gaps between posts. I’m trying to find time to prepare and write up posts about my various projects. The big one, that I hope can benefit lots of people, is my MySQL Advanced Class. It’s basically a PHP class that allows static one-line access to MySQL with proper parameter binding and exception throwing.
I’m shooting for finishing the write up tonight, but I’m terrible with timing.
I’ve also started teaching a graduate level CS-640 Web Development with PHP/MySQL class at Sacred Heart University in Fairfield, CT. This is the first time I’ve taught this class, but not my first time teaching. So far, the students are doing quite well!
A few years ago, when I was sitting at my moving sale, I came up with some crazy variations on the basic word/letter based CAPTCHA for my senior project, SHUGamer.com. Most of the ideas I had were either impossible to implement or difficult to answer. I eventually decided to implement a system based on a simple mathematical problem converted into a word problem:
If you have two apples in one hand and three oranges in the other, how many fruit do you have total?
This way, the number of variations would be very difficult (never impossible) for a bot to automate. Because of the difficulty in translation (natural language processing), there wouldn’t be a heavy need for warping (annoying to a user). The chances of guessing a correct answer are ~1/100 (not terrible odds, but decently bad for a bot). Finally, the problem would have a clear answer (not trying to guess if it’s a 0 or a O) leaving less room for human error. The resulting image looks like this:
This implementation isn’t perfect (nothing ever is), but it was a fun experience to build and can be easily added to any PHP based website.
PHP Mathematical CAPTCHA Class
Just so you know, SHUGamer.com and the later AreYouAG33k.com heavily relied on Adobe Flash, so visually disabled users wouldn’t be able to fully experience the site (sorry). This meant I didn’t need to implement an audible option for the CAPTCHA.
Hey, it’s been a while since I posted last. After getting certified, I felt like I needed to push my programming skill further. That’s where the Facebook Engineering Puzzles came into play. I completed the first two training ones last August ("Hoppity Hop!" and "Meep meep!"). I also worked on the first easy puzzle, "Liar, Liar," but was unsuccessful in optimizing the solution to meet the requirements of the Puzzle Bot. Finally, in March I had an epiphany and realized that I was going about the puzzle all wrong. In less than a day I solved "Liar, Liar" in PHP with 3998.623ms as my longest test case. After that, I solved "Date Battle" in 142.191ms and "Breathalyzer" in 19167.797ms.
Finally, I spent an entire week working on "It’s a Small World" with no success. I did everything I could. Without giving too much away, I created a balanced kd-tree and used a kNN search but it still ended up being WAY to slow. I’ve optimized it into the ground, everything is running as fast as PHP can get away with. Even after code profiling, I found all of my time is spent calculating SQRT (using BCMath) and I can’t figure a way to speed that up (stupid 20 decimal places).
So I’ve taken a break, hoping for that moment of enlightenment again.
Yesterday, I was explaining basic built-in streams. Today I’ll be covering the advanced modes. The first thing is basic network access (http, ftp, etc). Normally, you would just use fopen() or file_get_contents(). Well what would happen if you wanted to provide additional parameters to that call, like user agent? Meet stream_context_create():
Now that we’ve talked about files, it’s time to talk about directory access. PHP has a whole variety of functions designed just for this! Here are the important ones: