Wednesday, August 22, 2007

Tips for new Samsung Sync Users

As I mentioned earlier, I recently acquired a Samsung A707 which is provided by at&t/Cingular. In this article I'm going to recommend some software and other customizations to make it more useful.

  1. Access high-speed Internet everywhere
    I described this in my earlier article, Enjoying High Speed Wireless Connectivity Anywhere, so I won't do so again, but the important tip from that article is to download at&t Communications Manager to connect your laptop to the Internet via Bluetooth or USB.
  2. Easily manage address book, calendar, email, multimedia, and more
    You may think you need to buy a USB cable in order to connect with your phone and synchronize your address book, appointments, music library, etc., but the good news is that you don't! If you're laptop is equipped with Bluetooth (like mine is), simply download Samsung PC Studio (it's free!). It will run through a simple wizard to connect to your phone either via Bluetooth or USB (it also supports Infrared and Serial connections, but since the phone doesn't, that doesn't help).


    Once you're connected you can manually manage your address book, email, etc. or you can synchronize them with Outlook/Outlook Express. You can use this application to configure an Internet connection as well, but it's easier with the at&t application (see tip 1).
    The "Manage Multimedia Files" option allows you to copy music, photos, and videos to/from the phone -- including Podcasts.
  3. Add useful apps to your phone
    • Google Maps
      Other than making phone calls, one of the most useful thing a cell phone can do for you is help you find businesses while on the road. Google Maps is a "must have" application for this. Not only can if find local businesses by name or keywords, with a click of a button you can call them You can get directions to them including step-by-step instructions to get you there. It also adds real-time traffic information, can display satellite imagery, and provide navigation to move around the map and zoom in/out.
    • GMail
      Yes, the Sync comes with a mobile email program which connects to Yahoo!, AOL, Windows Live Mail (aka Hotmail), Juno, NetZero, and more. However, the one service it lacks it my preference, GMail. Fortunately, Google has provided their own application which can be installed on your phone to access GMail accounts. Unfortunately, I haven't found anyway to make it the default email program so that your phone will tell you when you get new mail like it will for the other email types.
    • Opera Mini
      The built in browser works fine for WAP/WML content, but when you need a more powerful browser, Opera Mini is the way to go. If you have iPhone envy and want a browser like it demonstrates showing the whole page and zooming in on pertinent sections, try the beta of version 4 which can do that too.
    • mWebPlayer
      The Sync includes "XM Radio Mobile" which allows you to stream XM Radio content to your phone. The only problem is, you have to pay for the service. As an alternative, mWebPlayer will stream radio stations off the Internet (for free!). The free version of mWebPlayer doesn't save changes you make to the station list, however, since you can load your Live365.com favorites, it's quick and easy to just load that list each time you start the application.
    • Instant Messaging
      The Sync includes an instant messaging application which can connect to either AIM, MSN, or Yahoo! However, it has two drawbacks. You can only connect to one at a time, and it uses your text messaging count for each message (which when you have unlimited data but limited text messages is rather stupid). Fortunately, there are a large number of IM clients out there which can connect to multiple IM communities at once and don't waste your messaging total. The biggest drawback is that, like the email, when you're using one of these apps you won't get notified when you're not using the phone and you get a message. You have to be running the application at the time. Since there are lots to choose from, I'm not specifying a particular one since I haven't evaluated them all, just follow the link and pick the one that sounds best to you.
    • Games
      There's going to be plenty of times when you're waiting in some lobby and need something to do to pass the time. Here are a few staple games that are both free and well done.
      • Backgammon
        This is a nice implementation of an old favorite. The LITE version is free and fully functional except that you can't play against other people online.
      • Chess
        Another nice (and free) rendition of a timeless classic.
      • Tetris
        A good way to waste time.
  4. Add useful URLs to add to your browser favorites
    • Google
      Who can surf the net without Google?
    • YouTube
      You too can watch everyone's homevideos on your cell phone (who needs an iPhone? -- the Sync can toggle between portrait and landscape too!)
    • TV Guide
      Who wants to flip through a paper guide and translate it to the correct station number? Get a customized list of what's on right now for your TV provider.
    • Bible
      Don't want to carry the Bible with you to church, no problem, get it online.
    • Weather (NOAA)
      I happen to live in a hurricane zone, so when a hurricane it coming, I want to be able to get up-to-date weather reports.
    • Java Applications
      Many of those aforementioned Java application, and many more can be downloaded from GetJar.com
    • Palm Mobile Portal
      True, this isn't a Palm, but Palm does have a nice portal site for other mobile sites.
  5. Free 411 Information
    Add a contact to your address book for 1-800-GOOG-411 (1-800-466-4411) to get local business information.
  6. Customize appearance
    Using pictures you take or upload with PC Studio (tip 2), be sure to set the "Caller ID" field for your address book contacts to pictures of them which will show up when they call. Until you get a picture of your friend, the Dilbert characters work nicely. Also, customize your ring tone and wallpaper. To the right is a picture I took at Clearwater Beach (Florida) which has been resized to fit the screen (240x320) in case you don't have a picture of your own.

Friday, August 17, 2007

Automatically Minimize (Minify) JavaScript

One of the 13 Simple Rules for Speeding Up Your Website is to Minify your JavaScript.

Sidenote: These rules can be easily checked using the YSlow add-on to Firebug.

The recommended tool to minify your JavaScript is JSMin. However, the default use of JSMin is to minimize your JavaScript in a separate step before you deploy your code and then have two JavaScript files - the original JavaScript you use to develop the code and the production "minified" version. For me the problem with that is the fact you have two versions to keep track of and keep in sync. Plus before you deploy your code, you need to make sure all your HTML pages use the minified filename not the original version.

Fortunately, there's a port of JSMin to PHP which allows you minify your JavaScript on the fly, but the usage instructions make it appear that you need to change your script source to point to separate PHP file for each JavaScript, or have a single PHP with all your JavaScript files hard-coded in it -- which is a nice option to get multiple JavaScript files with a single request.

What I'm going to show in this post is how to use jsmin-php to create a filter on your server so that all your JavaScript files are transparently minified as your retrieve them.

First off, download the current version of jsmin-php and save it in your directory. As the current version at the time of this writing is jsmin-1.1.0.php, I'll assume that is the file name.

Next, save the script below as jsmin.php:

<?php
// PHP filter to invoke JSMin on all JavaScript files
// see http://code.google.com/p/jsmin-php/
require_once('jsmin-1.1.0.php');

$js_file = pathinfo($_SERVER['ORIG_PATH_INFO']);
$js_path = substr($js_file['dirname'], 11);
$js_file = $js_file['basename'];

$charset = "utf-8";
$mime = "text/javascript";

header("Content-Type: $mime;charset=$charset");

// Output a minified version of JavaScript file
if (file_exists($js_file)) {
echo JSMin::minify(file_get_contents($js_file));
} else {
echo JSMin::minify(file_get_contents($js_path . '/' . $js_file));
}

?>


Note: If you change the name of this script, you'll probably need to change the 11 on the $js_path definition. That rips the script name (/jsmin.php/) off the beginning of the incoming path on the request so I can use a relative path to find scripts in a subdirectory. It should be the length of the script name plus 2 (for the leading and trailing '/'s).

Now, update your .htaccess file and add the lines:

# make all JavaScript files be minimized via JSMin
AddHandler jsmin .js
Action jsmin /jsmin.php


That should be it! If you fetch a JavaScript file from your server, it should now be minified.


Here are a few quick additions you could add to make YSlow happy.

At the beginning of jsmin.php, adding the line:

ob_start("ob_gzhandler");

should GZIP the output for you.



Also, where the Content-Type header is set, adding the following lines will add an expiration of 49 hours (needs to be > 48 hours to by sufficiently "far future" to make YSlow happy. If you really want to cut it close you could use (60 * 60 * 48) + 1):

$offset = 60 * 60 * 49;
$ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
header($ExpStr);

Wednesday, August 15, 2007

Enjoying High-Speed Wireless Connectivity Anywhere

In the interest of providing other technology posts other than just JavaScript code snippets, I thought I'd summarize my experience using at&t's 3G+ network. More than basic 3G, I actually get to utilize their HSDPA network here in Tampa where I live.

What's the difference? Well, according to the Wikipedia sources I linked to above, the standard 3G allows the transmission of 384 kbit/s for mobile systems whereas current HSDPA deployments support down-link speeds of 1.8, 3.6, 7.2 and 14.4 Mbit/s.

I recently acquired a Samsung A707 (aka Samsung Sync) which is a considerable improvement over my prior Motorola V180 -- though the V180 served me well as a basic phone, and even survived a fall into a river. I don't intend to review the A707 as there are plenty of other reviews out there (1, 2, 3, 4, 5), nor do I care to discuss the merits of one carrier's wireless technology over another's (ex HSDPA vs. EV-DO). All I want to talk about is my experience utilizing my phone to access the internet, particularly on my laptop and PocketPC through my phone, and what kind of performance I've seen.

Once I got the phone, I signed up for a MEdia Max bundle which gave me unlimited data on the phone. I plan on doing LOTS of data with the phone, so I can't have some sort of puny 1MB or 5MB limit.

To see what kind of bandwidth I could get on the cell phone, I pointed my Opera Mini browser to The Speed Test* and got results such as:


In the interest of full disclosure, that was one of the higher scores, however several other tests were in the same vicinity (ex. 2801.8kbps) so it could not be dismissed as an anomaly. The lower end of the scores were around 1913.5kbps. These are all respectable scores and inline with the statement that the initial HSDPA networks deployments support 3.6 Mbit/s peak with phase one deployments to eventually reach achieve peak data rates of 14.4 Mbit/s. Who says internet access on cell phones is slow!?

Now, it's all well and good that the phone can attain that high bandwidth and it certainly makes streaming videos off of YouTube or at&t's Cellular Video service to your cell phone work smoothly, but at some point, you just want a full size screen and keyboard for your internet access.

The A707 doesn't come with a USB cable, so I utilized its built-in Bluetooth. To me, the Bluetooth is actually nicer since I can leave myphone in my pocket or in my belt click and still connect your laptop to it. Plus, I can connect my laptop and PocketPC to it simultaneously which is nice too. However, it does drain the battery faster.

To use the phone for internet access via Bluetooth, you need to pair it to your laptop (or other Bluetooth enabled device). So, enable Bluetooth in the phone settings. I won't provide my own instructions for this as at&t has a nice tutorial online. Then you need to pair your phone and laptop together. Again, at&t provides vendor specific instructions for this. at&t has made a simple client called at&t Communication Manager which allows you to easily connect with the phone. Setup instructions are provided on the download page. The only thing I had to do special was manually select the GSM device (see Tools -> Settings... -> GSM -> Device Selection and select the Bluetooth Modem that was setup for me when I did the Bluetooth pairing). Once the Communication Manager finds your device, you simply click on the "Connect" button and you're in business.

My laptop is a few years old, so I believe it's built in Bluetooth is version 1, not version 2 which significantly limits it's bandwidth potential (see Wikipedia entry on Bluetooth). By accessing the internet via my cell phone via Bluetooth, I got speeds varying from around 274kbps to 347kbps.



These results are significantly reduced from the cell phone alone, though still tolerable for common internet tasks (reading email, viewing typical web pages, etc).

The results for my laptop are comparable to the results I saw on my Dell Axim x51v as well. I had to do a little more manual configuration to get the Axim connected to the internet through the phone, but once I got it working, I got results such as:



Just for comparison, the bandwidth I got at a local WiFi hotspot was around 1Mbps:


So the conclusion is that if WiFi is available, it's still the faster option (at least for me without a USB connection nor Bluetooth 2.0 speeds), but having the ability to have broadband speed internet access ANYWHERE I go (in the city) is certainly a convenience! And possibly it's more secure if you're in a public hotpost with packet sniffers lurking around.

I'd be interested to here if anyone has similar experience but using Bluetooth 2.0 instead. Is it faster? Is a USB connection faster?

*Note: I also verified my laptop speed results with Speedtest.net which has a really nice interface. However, since it's Flash based, it doesn't run in the cell phone browser.

Update - December 19, 2007:


I have replaced my laptop and am now running Red Hat Enterprise Linux on my new one. Therefore, I could no longer use the at&t Communications Manager to make a connection. Fortunately, I found these instructions for How to use a Bluetooth phone as [a] modem in Linux which were very helpful.

Tuesday, August 14, 2007

Synthesizing Events in JavaScript

According to JavaScript: The Definitive Guide (4th ed), section 19.2.9 on Synthesizing Events, it says,

Unfortunately, at the time of this writing, the synthetic event API is not supported by Netscape 6, nor by the current version of Mozilla



But, it does work in the current version of Firefox (and IE). I had a situation where I needed to simulate events, so I wrote the following function to make it simple:


// simulateEvent
//
// simulate a user action
//
function simulateEvent(eventType, targetElement) {
var event;
targetElement = $(targetElement);

if (targetElement) {
// check for IE
if (window.ActiveXObject) {
event = document.createEventObject();
targetElement.fireEvent("on"+eventType,event);
} else {
switch (eventType) {
case "abort":
case "blur":
case "change":
case "error":
case "focus":
case "load":
case "reset":
case "resize":
case "scroll":
case "select":
case "submit":
case "unload":
event = document.createEvent("HTMLEvents");
event.initEvent(eventType, "true", "true");
break;
case "click":
case "mousedown":
case "mousemove":
case "mouseout":
case "mouseover":
case "mouseup":
event = document.createEvent("MouseEvents");
event.initMouseEvent(eventType, true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
break;
}
targetElement.dispatchEvent(event);
}
}
};