Posts Tagged web apps

Announcing Ping Brigade

Ping Brigade is my latest project. It allows you to measure ping, web page load times and web server latency from multiple servers I run around the world. Give it a try!

Tags:

Proper way to send e-mail from PHP

Depending on your setup, PHP might not be sending properly encoded e-mails if you just use the mail() function. Specifically, headers might not be properly encoded, and this includes the subject, the To, and Reply-To, etc.  Just give it a try using some non-ASCII characters and see if it works. If it doesn’t, here’s a better way:

// At the beginning of each page load, set internal encoding to UTF-8
mb_internal_encoding('UTF-8');

// ... rest of initialization code

// Headers are an associative array, unlike the original mail() function
function better_mail($email, $subject, $body, Array $headers = array(), $additional_parameter = NULL) {
    // Make sure we set Content-Type and charset
    if ( !isset( $headers['Content-Type'] ) ) {
        $headers['Content-Type'] = 'text/plain; charset=utf-8';
    }

    $headers_str = '';
    foreach( $headers as $key => $val ) {
        $headers_str .= sprintf( "%s: %s\r\n", $key, $val );
    }

    // Use mb_send_mail() function instead of mail() so that headers, including subject are properly encoded
    return mb_send_mail( $email, $subject, $body, $headers_str, $additional_parameters );
}

better_mail( 'example@example.com', 'Résumé with non-ASCII characters', 'Résumé content.', array( 'From' => 'noreply@example.com' ) );

For more information see:

Tags: , ,

Web apps don't have the "push"

Recent debate about web apps vs native apps has stirred me up enough to throw my two cents out there. You see, I am a web developer and I think that the web as a platform certainly has a future. However, I am not going to say that web apps have already won. They haven’t. They are very far away from winning and the biggest problem with them is the lack of ability to exchange data to their environment.

Case 1: GMail

GMail is an excellent web based interface. I use it whenever I am on someone else’s computer, but when I am in my home environment I use Thunderbird and IMAP. Why? Because I normally have several Firefox windows open, with several tabs each. If one of them has GMail open in it, I have to consciously open that window and check the title of the GMail tab to see if I have any new messages. Unlike Thunderbird, GMail cannot push a new mail notification into the notification tray of my desktop. With GMail, I have to consciously bring up the window and check for a particular tab. Of course I could use something like Prism from Mozilla, but notice then GMail will not be a conventional web app in the sense that they are being debated.

Case 2: Hulu

Hulu is one of the best video streaming services out there. Recently, Hulu has released native app clients for all three predominant operating systems (Windows, Mac OS X and Ubuntu Linux). What are the advantages of the native clients? For one, currently no browser supports remote control devices. On the other hand the Ubuntu version of the client plays nice with the standard LIRC straight out of the box. This is one of the steps necessary to take Hulu from a geeky web based streaming service to the living room media center big screen TV. Another advantage is that the native client gets to control the window size, making itself full screen not just when a show is playing but also while you browse for your favorite show. Unless you create your entire web app in Adobe Flash (yuk!), you cannot get this functionality.

Case 3: Google Latitude on the iPhone

Google Latitude is usable on the iPhone. Sort of, kind of. First of all, there’s the address bar which pops up every now and again and covers the top portion of the screen. Next, it cannot take advantage of push notifications, so I cannot push an update of my location to a friend, the way HeyWAY does. I stopped using this app a month ago because the native app I replaced it with was much better.

Possible options

To have web apps catch up with their native bretheren, we would need to extend the browser to tie it in much closer with its native environment. We could even make some sort of an operating system that only runs web apps. This will, however, limit you in what kind of hardware you can run on and what peripherals you can support. For example how would you like it if you landed on a rouge web app that started printing hundreds of car insurance ads on your printer because it had access to the device? Or how would you feel about the web app taking control of your microphone and web cam and recording everything you are doing? Clearly some sort of a security policy would need to be in place to allow certain apps access to the browser environment, the same way that Safari on the iPhone can ask you if you want to allow Google Latitude to use the GPS.

As I mentioned web apps have a future. Their specific strengths already make them ideal for certain types of uses. The challenge is to expand those strengths so that they can be used in more cases.

Tags: , , ,