Skyfire Review

June 1st, 2009

Skyfire 1.0 is the new kid on the block in the mobile browser war. Its not a kid per se but there are some big boys like Opera Mini and Opera Mobile who don’t give up all too easily. I have been a beta user of it from India since 0.6 ;-) and it was fun all this while to keep track of this superb browser. Their main aim is to bring desktop like browsing experience to the mobile browser and they are almost there. So near, yet so far.

Like all other reviews about this browser until now, its safe to tell that it is able to play flash videos pretty well inside the small screen. Here are some notable differences between the earlier betas and this 1.0 version:

  1. While watching any videos on youtube, my Nokia E51‘s rear would just heat up quickly & few minutes down, it would be difficult to hold the phone. This problem has been nearly solved in 1.0. That’s possibly due to power optimization techniques.
  2. When you scroll very quickly on long web pages, Skyfire usually shows a checkered screen with gray squares (screenshot below), which disappear as and when content appears. Pre 1.0, this checkered screen would take a long time to disappear. With 1.0, this problem has been solved. Same problem used to occur during zoom in/out. Now zoom happens at blazing speed. Neat!
  3. The checkered placeholder
  4. Its able to handle basic javascript very well. For e.g. its able to display the hover menus that are present on top of my blog. Its also able to show alert boxes.
  5. Video quality is maintained even during zoom in and zoom out. This was a major drawback in pre 1.0 versions.
  6. The initial loading and shutdown of the browser would take a long time in pre 1.0 releases. Not so in this current release. This has been drastically improved.
  7. File downloads happens excellently. Kudos for this. This is a major drawback with the E51’s native browser.

Read the rest of this entry »

This one could save you lot of time :-) In short, the answer is to “return false;”. That’s it. If you want to know more details, read ahead.

Say, you have an awesome page where you want to disable right click and also disable Ctrl+C (copy), Ctrl+S (save page). The process is simple. Just register an event for right click and when the event fires, just return false. Since false is being returned, the browser will cancel the event.

Same goes with keyboard. ‘onkeypress’ event is fired whenever a key is pressed. To reject any key, just capture that event and return false. If you want to do anything special, just do it before returning false. Ctrl+S is interesting. In most web browsers (notably google chrome), it brings up the default Save Dialog. Most web apps have keyboard shortcuts these days & oh! 99% of them don’t return false, only to find the user experience irritating when the save dialog pops up; when something else should occur. Hence, if you wish to customize the functionality of the default browser specific keyboard shortcuts, do the following:

  1. Create an event handler and capture the event.
  2. Do something.
  3. “return false;”

That’s all. Have fun!

Here’s the trick below to open multiple gmail accounts with the same version of firefox.

  1. Open the Run dialog. In linux, press Alt+F2. On Windows, press WinKey+R.
  2. In the dialog box, type “firefox -p -no-remote”. This will bring up firefox’s profiles dialog box.
  3. Click on “Create Profile” and follow the wizard. Lets assume you named the profile as “gmail2“.
  4. Now close the dialogs and return to desktop.

Now, open the Run dialog again. In the dialog box, type “firefox -p gmail2 -no-remote“.

“-no-remote” option is very important because it creates an isolated session that is different from the currently open firefox windows of other profiles. If -no-remote option is not given, then a new window of the currently running profile or the default profile is opened, where session sharing happens (which we don’t want).

Now, since sessions aren’t shared between different profiles, you can open two accounts and happily have them.

Suggested Improvement for Firefox:

Internet Explorer 8 has this amazing option in the File menu where you can open a completely new session of IE. Sessions are completly isolated and gives lot of relief. Its available at File->New Session. Hope this feature is brought into Firefox as well. Or if this feature is already available as a plugin, please let me know in the comments. Actually speaking, this feature was available in IE since IE 6 (AFAIK). In IE6/7, you can open a completely new session by clicking the IE icon on the desktop.

Top 5 Gmail Lab Features

April 3rd, 2009

Ever since Gmail launched its Gmail Lab, I have been its fan. Some of its features are so awesome I use them day in and day out. Mentioned below are my favourite lab features:

1. Go to Label

If I were asked to pick one best lab feature from all of them, this would be it. I have set up filters extensively to mark labels to most of my emails. I’m also a keyboard shortcut junkie & expect web apps to have keyboard shortcuts. Retrieving emails based on a given label had never been this easier. Just type ‘g‘ followed by ‘l‘. A small dialog opens and offers suggestions as you type the label names. This is an awesome feature that saves loads of scrolling and clicking.

2. Search Autocomplete

This is an Excellent lab feature that was announced yesterday. I have enabled it and searching mail using its operators has been made very easy. This also offers suggestions from your contacts as you type. For each letter that you type, if there’s an available search operator, it lists that as well; neatly separating the operators from the contacts with a black line.

3. Tasks

Less is more. This tasks features offers very little features, almost mimicking it to a paper to-do list. Just list the tasks and strike them as you are done with it. There are of course some advanced features tucked in. But they don’t appear at first sight. This is a well executed Labs Feature. There are times when you do not need a full blown task manager & this feature comes in handy. I hope they bring this feature to their gmail mobile app.

4. Youtube, Picasa, Flickr Previews

Recently, I have been trekking/touring a lot. People from the trekking gang send emails with links to Picasa/Flickr albums. They also add youtube video links to the email because there’s no way to actually embed a video inside an email. With this labs feature, I’m able to enjoy all the related photos/videos in one place. Really cool.

5. Quick Links

This is one awesome feature. Many months ago, I posted a question on a mailing list asking for suggestions for buying wireless routers. After a week since the discussion, I was searching high and low for that email but couldn’t find it. Lots of people had given valuable suggestions and how can I lose them all? As soon as I found the email, I activated this quick links feature and clicked on “Add Quick Link” button in its dialog box. Voila! Now I can reach this email directly with a mouse click. 

There are also times when I search for “in:inbox is:unread“. This search operator retrieves all mails in your inbox that have not been read yet. I didn’t want to type this operator every time to check for unread messages that are buried somewhere. I just added a Quick Link for this operator and now its just a click away. Happy times!

What are your favourite Gmail Lab features? Let me know in the comments.

Two days ago, as I switched on my computer, I got this error message; “A disk read error occurred. Press Ctrl + Alt + Del to restart”. It is the dreaded Black Screen of Death. The most probable reason for this message is that the hard disk on which the computer is booting would have crashed or its in the process of crashing.

The best you *must* do at this point is that, remove the faulty hard disk, connect it as a slave to another computer and take backup of all data. After data is safe, you can try and find out the point of failure. After all, that error message doesn’t necessarily mean that your disk has crashed.

Probable Points of Failure

  1. The bus connecting the hard disk to the mother board is faulty.
  2. The master boot record (MBR) on the hard disk got corrupted.
  3. SMPS (Switch Mode Power Supply) failure. In this case, your computer may not boot at all. But there are times when only one of the power plugs may fail.

If anyone has encountered any other points of failure, please let me know in comments and I will add them here.

Answers

  1. For the faulty bus, you can grab another bus cable from the secondary drives, connect it to the mother board with the faulty hard disk and try booting. If it works properly, head straight to the electronic store to get a new cable.
  2. To replace the corrupted MBR, pop in your operating system’s installation CD/DVD and follow the on-screen instructions. For Windows, boot in from the installation CD, press ‘R’ for recovery console, give your administrator password, and type the following the commands: fixboot, fixmbr. For linux, you must reinstall the boot loader (grub). Restart the computer now. If all is well, it should reboot properly.
  3. Remove the power plug connected to the faulty hard disk and connect one of the other plugs that are attached to the SMPS. Reboot the computer now and try.

In my case, my hard disk had crashed. But thankfully, I had proper backup of all data.

Free SMS Web Service Updated

February 12th, 2009

Hello friends, the due to recent changes at way2sms, our SMS web service has undergone major changes.

If you had downloaded the PHP scripts or java library and if you are facing problems while sending SMS, try downloading the new version of the library at the relevant links below.

  1. SMS Web Service (PHP library + web service) – http://www.aswinanand.com/blog/2008/07/send-free-sms-web-service/
  2. Java Library to send SMS – http://www.aswinanand.com/blog/2009/01/free-sms-web-service-java-library/

Hope you enjoy using it.

HttpURLConnection in the JDK has a bizarre bug. When it receives a HTTP response code in the 3xx range, it performs redirection to the web page mentioned in the “Location” header. However, when it does this, it forgets to send all the cookies with the request. Therefore, if you are working with any of the web 2.0 APIs which perform redirection and require this authentication cookie with each request, you are doomed because the server will redirect to the login page thinking that this is an unauthenticated request.

The solution for this is pretty simple. If you have written code like below:

URL u = new URL(“http://www.example.com”);

HttpURLConnection conn = (HttpURLConnection) u.openConnection();

You have to add one more line that sets redirection to “FALSE” & do the redirection yourself with the cookies, which becomes like:

URL u = new URL(“http://www.example.com”);

HttpURLConnection conn = (HttpURLConnection) u.openConnection();

conn.setInstanceFollowRedirects(false); // do not redirect

String locHeader = conn.getHeaderField(“Location”); // get the location

String cookies = conn.getHeaderField(“Set-Cookie”); // get the cookie

u = null; conn = null;

u = new URL(locHeader);

conn = (HttpURLConnection) u.openConnection();

conn.setRequestProperty(“Cookie”, cookies); // set the cookie yourself

….

Done! That should solve the bug. If this seems too much to do, then you should consider using this excellent HttpClient library from Apache.

I did the above mentioned stuff for this Free SMS Java Library because:

  1. The library has to be very small because it is just one file.
  2. Eliminate external dependencies that will bloat the library.
There you go! Now, if you have encountered this bug you have the solution to squash it. Have fun!

If you have used the Free SMS web service already and craved a java version, it is here :) . You can now send SMS from within your program by calling a simple method. Just download this JAR file and include it in your class path. Java source code for the class file is present in the JAR archive itself. So, if required you can browse through it.

How to use:

Please note that you need to create a free account at www.way2sms.com before attempting to use the library.

Here’s a simple program on how to use the JAR.

import com.aswinanand.sms;

public static void main(String… args) {

SMS.send(“9933445566″, “password”, “9001122334;9887712345″, “message”);

}

SMS should be sent now. If there are any errors then an exception will be thrown.

License:

This Java source code, the class file and the archive is licensed under “Creative Commons Attribution-Noncommercial”. License terms are here. Downloading the files means you agree to the license terms.

Download:

Download the sms.jar here.

Improvements:

Some immediate improvements are underway right now:

  1. Code cleanup.
  2. Organize the code in methods. Right now everything is in one big method.
  3. Invalid login notification.
  4. Support for authenticated proxy servers.

Change Log:

Version 0.2, 0.3:

  1. Implemented the major changes that happened at way2sms. Download here.

Version 0.1:

  1. First release with working code base for sending SMS through way2sms.

Please take it for a test drive and give feedback.

There are a number of use-cases for which you would want to browse a mobile-optimized website on your PC. When you visit the mobile website on your PC’s web browser, the website displays the full content much to your dismay. However, when you visit the browser on a mobile, it displays a perfectly mobile optimized page.

In these cases, there are some simple steps that you can follow to open mobile websites on your PC:

  1. Download and install the latest version Firefox from http://www.getfirefox.com/.
  2. Visit Firefox Add-ons page and download the Modify Headers addon.
  3. Install the addon and restart firefox.
  4. From the firefox window, select “Tools” menu & click on “Modify Headers” option (Tools -> Modify Headers).
  5. The window will open as shown:
    Modify Headers Addon Window Click to enlarge
  6. Below the title bar, there’s a drop down. Select “Add” from the drop down box.
  7. Now in the text box next to the drop down, type “user-agent”.
  8. In the third text box, paste this string – Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 NokiaE51-1/100.34.20; Profile/MIDP-2.0 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413.
  9. Click on “Save”.
  10. The screen should look like as shown in the screen shot below:
    Filled screen of the addon Click to enlarge
  11. Using the buttons on the Modify Headers addon window, you can enable or disable particular items.
  12. That’s it! Whenever you want to view a mobile website, just go to Tools->Modify Headers and enable the user agent you added in step 8. When you don’t need it, just open this window and disable it.
  13. You can close addon window after you have enabled/disabled items.
  14. Enjoy! :)

Behind the Scenes:

Most mobile websites make use of the HTTP header called “User-Agent”. This header tells the server what kind of web browser the user has. So, mobile websites usually look for the name of the device manufacturer in the User-Agent header. If it matches one of the manufacturers then the mobile optimized web page is sent.

That’s about it! Hope you enjoyed this brief.

Now go and figure out how to display the iPhone version of Facebook on your PC ;)

Recently I needed a way for Threaded Tweets to do HTTP basic authentication to try out some stuff. As you probably know by now, it is written in javascript and uses no server side code. So, I had to find out some way to pass basic authentication credentials through the XMLHttpRequest object so that I could be authenticated with the Twitter server.

Turns out that it is pretty simple. If you use FireBug on any website that supports Basic Authentication, you will note that a new HTTP header called ‘Authorization’ is added. It looks like:

Authorization: Basic aDkdjfZy==

Now all you need to do is somehow pass on this header to the XMLHttpRequest object. If you use the native XMLHttpRequest, you can use the setRequestHeader method to do this:

xhr.setRequestHeader(“Authorization”, “Basic aDkdjfZy”);

What if you are using jQuery? Then also its pretty simple. jQuery’s AJAX object allows us to change the XHR object before the AJAX request is sent by setting the “beforeSend” callback; which is done as follows:

$.ajax ( {
url: “http://abc.com/”,
beforeSend: function (xhr) { xhr.setRequestHeader (“Authorization”, “Basic aDkdjfZy==”); },
succes: function(val) { alert(val); } } );

Base 64 Encoding:

One important part of Basic Authentication is that, you need to encode the username and password into Base 64. There are tons of Base 64 encoding tools written on javascript, which you can use. Example below:

xhr.setRequestHeader(“Authorization”, “Basic ” + encodeBase64 (“username:password”) );

That’s about it. Hope this was useful to you !

Some Updates

Cross-domain GET requests work all the time. The problem is with POST requests. Most browsers don’t allow XHR to POST data to a domain that’s different from the one in which the page is loaded. For this to work correctly, the ‘document.domain’ property must be set correctly.

The second best way to POST to another domain is to use an iframe and submit the form with the iframe as the “target”. Again, to read the result of the iframe, the “document.domain” of the parent and that of the iframe should match. This can be easily set through javascript. Thus, when the form post is done and the page is loaded, its value can be accessed.

Note: Chrome and Safari don’t allow access to iframe’s DOM if its document.domain is different from that of the iframe’s parent.