Wednesday, February 16, 2011

How to get rid of the annoying new photo viewer in Facebook

Two ways:

1. Press and hold ctrl + shift and click on the thumbnail of the photo.

OR

2. If this is the URL in the address bar while you are viewing a photo: http://www.facebook.com/#!/photo.php?fbid=XXXXXXXXX&set=at.XXXX.XXX.XXXX.XXXX.XXXX&theater lose the "&theater" at the very end.

There you go, good riddance bad photo viewer. Facebook, follow the golden rule: if it ain't broke...

Friday, February 11, 2011

Excerpts from SMW Keynote @ Google


(L-R): Erick Schonfeld - Co-Editor of TechCrunch, Josh Harris - Producer of Wired City, Douglas Rushkoff - author of Program or Be Programmed

"Facebook's days are numbered", the title itself is provocative enough to draw social media junkies to listen to Doug Rushkoff, the author of Program or be Programmed. The location - Google, the epicenter of most of the activity that goes around on the web and seemingly the antagonist in this discussion.

How do you use Facebook? Or does Facebook actually use you? You may have over 500 friends but how many of them are really your friends? Are many of them actually your business contacts? Is the "friend" word being used very off-handedly by Facebook? These were some of the rhetorical questions posed by the author.

The key takeaway from his discussion was the author's take on the centralized information flow model being used by Google, Facebook. Seamlessness, though very lucrative, has its own drawbacks. Imagine the case with Google, you have Gmail, Google Voice, Google Latitude, Google Talk. These are just four apps and they already cover almost every synchronous and asynchronous form of communication that possibly happens between two individuals. Same is the case with Facebook. Both Google and Facebook thrive on the "AdSense" model which provides them with income to fund and increase their infrastructure at the cost of users' personal information. The part which bothers author the most is that we have accepted this model and are being very passive and non-resistant to this change. We are giving complete autonomy to Google/Facebook and are happy simply to be able to share/tweet/connect without knowing how it would affect us in the long run.

The author emphasizes on the need to have a more decentralized and consumer-focused social media architecture. He believes to be sustainable in the long-run, social media would have to incorporate for a mix of both centralized and decentralized approaches. Decentralized approach means giving more importance to the consumer. He quotes the example of Apple who provide every service at a premium but are very consumer-centric in doing so. Decentralization also corresponds to growth of the open source community. In fact open source technologies are probably the final bastion in this fight to keeping it simple and peer-to-peer based.

Thursday, November 11, 2010

Load time animation for AJAX

While using AJAX for fetching data there is always a lag (as there is for any other data request). More importantly, as this request happens behind the scenes, meaning that the page is not refreshed, the user is sometimes unaware of the data pull. A rule of thumb is to show an animation or at least some text which indicates user that data is being fetched. This can be achieved as follows:

Your AJAX function:

function ajax_request(url, target){ //url -> URL of the file that will provide the requested data, target -> the div or span element that displays the data
....code to check the HTTP status and until it is 200 and the readyState is 4 do:

document.getElementById(target).innerHTML = ' Fetching data...';
OR
document.getElementById(target).innerHTML = '../path-to-image/';

....code to perform action upon status/state change
}

A good resource to find free-to-use gif loading animations is: http://www.ajaxload.info/

Thursday, November 4, 2010

UTF-8 characters get garbled in AJAX response

This problem is often experienced in websites dealing with multiple languages and special characters. Characters are unicode characters and there are many ways in which they can be encoded. UTF-8 is just one way of the ways of doing it.

Consider an AJAX request that fetches HTML text from a database:

xmlhttp.open("GET","get_html.php",true);

The response to this request could possibly contain special characters (entered through a WYSIWYG editor) which will get rendered as "junk" characters as there is no natural way for the response to know the encoding. As a result the output fetched by the response needs to be encoded. One of the ways of getting HTML text rendered correctly in an AJAX response is by encoding it using utf8_encode() and then using html_entity_decode() as follows:

//code to fetch response data from db into a var, say $db_data
$utf8_encoded_char = utf8_encode($db_data);
$html_text = html_entity_decode($utf8_encoded_char);

Hello WWW!

Hello readers and fellow web developers,

Welcome to Spider-Eye - the blog dedicated to providing solutions to challenges encountered in website development. Every day I come across some interesting problems and many a times the solutions get lost into oblivion once I have moved past those problems. I am sure the same happens with most of the other web developers as well.

Through this blog, I look forward to interacting with you and sharing my insights and breakthroughs in web development. Here's to building better websites!

Cheers,
Tejas