Friday, January 28, 2011

Here's an interesting test Rob and I did today at i.tv trying to figure out the best way to replace html entities (&amp;) with their equivalent (&). We were hoping to basically replace the html_entity_decode function in php, but we're only worried about a limited subset of characters.

We needed to do many search and replaces and compared two methods. Loop through a list of characters and replace them individually or use a big regular expression and do only one match. I wasn't sure what would be best, but from the results clearly the regex wins.

I recently started here at i.tv and began using MongoDB extensively. I realized pretty quickly I'd need to get some new tools for exploring the database. While the JavaScript interface is fantastic, sometimes you just want to browse through and see what's there. Sequel Pro did a great at this for MySQL databases. SDB Explorer works alright for exploring Amazon's SimpleDB, but I couldn't find anything at first for Mongo. Finally I found this experimental project, which does well enough at poking around your Mongo collections. It's Mac Only and called Mongo Explorer: https://github.com/francois/mongo_explorer

After playing with both for a few minutes. Mongo Explorer seems much easier to use if you just want to go in and look at the data. Mongo Hub is much fancier, prettier and seemingly more complicated / powerful.

Best of luck to all the new Mongo users out there, so far it's really cool!

Friday, January 14, 2011

Flash uploaders have a notorious problem maintaining sessions. CakePHP doesn't have any built in way to solve this problem, so here are some notes about how I dealt with it. To make matters worse I also had HTTP Basic Authentication and the Suhosin PHP security module enabled, which added additional layers of complication. Hopefully the last day and half of my working life will make your lives easier.

Here are the 3 steps I had to take to enable Uploadify on a site I was working on.

2. Disable HTTP Basic Authentication. I know there are several possible solutions, but in my case I still have not figured out how to enable authentication on everything except for the file upload service, so for now we've disabled authentication site wide. Will post if I can come up with something better.

3. If your server has Suhosin (PHP security module) installed, you will need to perform this extra step.

Edit your config file, in my case it is /etc/php5/apache2/conf.d/suhosin.ini. And set these to variables to off.

suhosin.session.cryptua = off
suhosin.cookie.cryptua = off

In my case that meant changing them from this state (commented out showing defaults):

After focusing on only US statistics however, which makes sense for most of the brands I work with at Rain, as expected Blackberry, iOS and Android were all looking pretty competitive by the end of the year with iOS at 37%, Android at 27% and Blackberry at 26%:http://gs.statcounter.com/#mobile_os-US-daily-20100101-20101231

As a mobile developer it's really important to focus my energy and time on the browsers that people are actually using. As much as its a feel good to support Opera Mini, Palm and others, it may not be very a practical use of time and money. Unfortunately for us though, BlackBerry is a little bit of an unknown. While BlackBerry 6 includes a cutting edge web browser, older versions offer very little support for the latest standards. To make matters worse their emulator has historically only run on a PC. Thankfully frameworks like JQuery Mobile have gone out of their way to accomodate BlackBerry. Hopefully that will be enough to support it until BlackBerry 6 adoption becomes the norm. On one of the mobile-web mailing lists I follow much discussion goes on about supporting even much older and less capable devices than the BlackBerry. Clearly in the United States that doesn't seem like a good use of time.

It's been an exciting year for browser growth, both in mobile and in the desktop realm. HTML5 has hurled itself to the forefront of browser innovation and this year IE9 promises to add mainstream support for some of the most exciting technologies out there. Right now it's a good time to be a web developer. In 2011 web developers can start applying HTML5 technologies without a lot of worry about supporting older browsers, because looking at the statistics people just aren't using them anymore!

Thursday, January 6, 2011

Finally, thanks to Joyent's sweet SmartMachine service I'm able to show off my silly HTML5 mobile web app for collaborative painting. Works best on iPhone, but also works on Android and desktop browsers. It's a fun example of using web-sockets, node.js and canvas! Check it out now!