Saturday, February 13, 2010

Playing with Javascript Closure, JSON, & YQL to Visualize upcoming Android Version Names

Hi There,
As you know that First version of android was named "cupcake" and then it was "Donut" and current version is "Éclair".
People found a pattern in naming; they are alphabetical names of cake. Now many people on internet came up with the names up to the Z.
Here they are

  • Cupcake
  • Donut
  • Eclair Cake
  • Frosting
  • Gelato
  • Honey
  • Icing cake
  • Jelly
  • Kiwi
  • Lemon
  • Marshmellow
  • Noodle
  • Orange
  • Pudding
  • Quince
  • RockyRoad
  • Sundae
  • Taffee
  • upside-down-cake
  • Vanilla
  • Waffle
  • Xmas Cookies
  • Yogurt
  • Zebra Cake


I am completely unaware of some of these names; I really don’t know how they look like. So here i made a small YQL hack to get images with these names to visualize them.


Here is the YQL Bing table query to images





function get_images_from_bing(query,callback){
var yql_url="http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20microsoft.bing.image%20where%20query%3D%22"+query+"%22&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=callbacks."+callback;
var div_ele=document.getElementById("myscrpts");
var scrpt=document.createElement("SCRIPT");
scrpt.src=yql_url;
div_ele.appendChild(scrpt);
}

Here I am using closure to get a call-back function which will render the my images.




function GetCallbackFunction(element){
/*
element will be accessible to inner returned function
even after outer function has returned
*/
return function(data){
/*Get randomely from top 3 images*/
var index=get_random(3);
index=index%data.query.results.ImageResult.length;
element.src=data.query.results.ImageResult[index].MediaUrl;
};
}

Wednesday, February 10, 2010

What is "Inbox Zero problem"? How To solve it by Twitter-way?

Inbox Zero problem is a usability problem, of which every mail system is infected with. Let me try to explain what it is?

Today, we get at least 40-50 mail every day, and our mail system marks every mail as unread when it arrives to your inbox. Now problem is, you are tempted to read all those mails to bring your inbox to zero unread count. This goes into a never ending loop often because by the time you will be able to finish each and every mail, you’ll get some new ones. 

This is a problem many other social networking platforms are infected with, may be not with the unread message count but by some other ways.

This is the only problem twitter is not infected with, because its always flowing timeline of short messages and you need to just look for few recent items posted by people, because of 2 reasons
1. Those items are not specifically posted to you (not talking about @replies).
2. Tweets are very spontaneous status update from people; significance of (most) tweets expires after sometime.
This is how people on twitter able to manage more and more people. I personally follow more than 600 tweeps around the world. Now, there is a problem!! Different people tweet at different pace, and many tweeters are so frequent on twitter is that they literally flood my timeline and kick other's tweets (from people whom i care more) out of my visible timeline. This problem is solved by lists, I group important tweeps in a list. Concept of list itself came from people and twitter client like TweetDeck & Seesmic. Think lists like this, On twitter you have public timeline which is the fastest moving timeline, and you filtered some of them to bring in our "friends" timeline by following them. When things became messy you sorted them into few smaller lists.

Twitter evolved from people's behaviour, like @replies, retweeting and many more became the built-in feature of twitter because we tweeps started using it.

So none of my time line is actually having inbox zero problem.

Now let’s come back to e-mail system, every day in office i really get more than 100 emails including companywide mails, group mail , mails from an on-going thread of discussion (where I don’t have anything to do).  Now what?? My mail client (outlook) is so cluttered with e-mail that finding the right email becomes very difficult. Ok , we have a solution “make rules to skip inbox for some known group & automated mails” BUT creating rule is not going to solve my problem because I am very lazy and don’t want to create rules even once in a six month (yes, that lazy i am). Last rule i created some 6 months back : P.

So what is the solution? Solution is simple; I call this solution "@actionItem". Which is like this, every mail which has some action item for me as individual then please include my name in a field called Action Item (like CC & To list). That’s It i will give priority to those mails first and then i will move to all other mails, and choose to skip if i don’t have much of time to spend. Inbox zero problem solved.

Twitter specific Terms : 
  • Tweeps: people who use twitter.
  • Tweeters:  twitter+ user
  • Tweet:  Every small status update (post ) is called tweet.
  • ReTweeting: when you post oneones update again is called re-tweeting. often done in "RT @TweepName : blah balh format".
  • @replies : pronounced as 'at replies', are tweets which has your name mentioned, preceded with a '@' sign. 

Here is Merlin Mann Slide



Here is video of his lecture

Saturday, January 30, 2010

I know what you read on dzone last summer

You should know that depending upon how CSS is coloring your links; I can figure out that what are the links you visited already.
This is a nice hack, many people use it for knowing user interests e.g
  • What social networking site you use.
  • What banking site you use.
  • And many more what you can think of.
I have created a hack to show all popular links from dzone, I am sorting the links based what you have read already. Before you read further Check This, (will not work in IE8)

Here is how you can inspect CSS color of a link in your browser


document.write('<style>');
document.write('
#linkID:visited {color: #FF0000;}");
document.write('
</style>');

/* quickly add and remove the link from the DOM with enough time to save the visible computed color. */
document.body.appendChild(link);
var color = document.defaultView.getComputedStyle(
link,null).getPropertyValue("color");
document.body.removeChild(link);

/* check to see if the link has been visited if the computed color is red */
if (
color == "rgb(255, 0, 0)") {

/*visited do something*/

}
else {

/*not visited, do something else*/

}




Read More about How I brought All Dzone links on 1 page

Read More About How This CSS hack works?

Read Rest of My Hacks


Thursday, January 28, 2010

Understanding C#.net Border-less Form, when you maximize it

Hi There,
Have you ever created, a borderless window in C#.net?
There is problem with borderless window, if you maximize it, it goes FullScreen (over the taskbar).

Here is an analyis of how to achieve maximized borderless window.




If  you first set the border(anything other than FormBorderStyle.None) for the window and then set WindowState to maximize, You will get a standard maximized window, you can make it border-less there after.





private void btMaximize_Click(object sender, EventArgs e)
{
this.FormBorderStyle = FormBorderStyle.FixedSingle;

if (this.WindowState != FormWindowState.Maximized)
{
this.WindowState = FormWindowState.Maximized;
}
else
{
this.WindowState = FormWindowState.Normal;

}

this.FormBorderStyle = FormBorderStyle.None;
}





If you maximize a window after making it borderless it goes beyond the task-bar. You will get complete full-screen.



private void btFullscreen_Click(object sender, EventArgs e)
{
this.FormBorderStyle = FormBorderStyle.None;
if (this.WindowState != FormWindowState.Maximized)
{

this.WindowState = FormWindowState.Maximized;
}
else
{
this.WindowState = FormWindowState.Normal;
}

}





Sunday, January 17, 2010

Hacking Google maps AJAX API to use in C#.Net

Hi,
As you know “Google Maps API” is available only for AJAX developers. Using it in C#.net is not possible. One of the great things about Google maps API is it gives you turn by turn direction almost anywhere on earth. I wanted to exploit this feature of turn by turn navigation on my mobile, that too offline, because when i go to remote places its highly probable that i will not be having connectivity on my phone. Or connectivity will be so poor that using maps is highly impractical.

So I have created a pair of application.
1. A Desktop app to retrieve turn by turn navigation data + static images.
2. A Mobile app to read this data and to give me turn by turn navigation on phone (offline).

Certainly this is something not allowed in TOU of Google, so i cannot release this app commercially.

How to Mix AJAX and C#.net??
1. I created a web page (html+JavaScript), which dumps the direction info data in DOM.
2.In C#.Net Form, I kept a web-browser control, which loads this page.
3.When page is loaded, using webBrowser1.Document.GetElementById stuff I extracted the direction info.
4.Then I downloaded Static Images using "Google Static Maps API", & hacked to get the latitude and longitude positions on the static images. see code for detail.


How I exported data on mobile??
1. Serialized whole object in an XML file, including direction info and static images.
2. De-serialized on mobile to get that data back.


Source Code
http://code.google.com/p/pocketnavigator/


Screen-shot Of Mobile Version.



Demo of Desktop App (6 minute).

Thanks, Feel free to ask question, & share on twitter + digg & blah blah.