Sunday, October 16, 2011

Angry Birds For Chrome Browser

Hi,

Want to play the much hyped game "Angry Birds".
Thanks to Google for giving the people who don't own andriod / apple devices.


Cheat Available ::

For unlocking all levels : In the browser window ( the one in which game is opened) place this javascript and press enter
javascript: var i = 0; while (i<=69) { localStorage.setItem('level_star_'+i,'3'); i++; } window.location.reload();

For relocking all levels :
javascript: var i = 0; while (i<=69) { localStorage.setItem('level_star_'+i,'-1'); i++; } window.location.reload();




For checking the cheat source click here.

ICallBackEventHandler Mystery

Hello,

I was working on a project in which I needed to use call server-side code to get data after the page load.
Instead of the latest jquery ajax I preferred to use the old sword for ajax call ICallBackEventHandler.
On reading certain history on Ajax Calls to server, I found that there are many techniques which can help me. But after exploring more about ICallBackEventHandler I thought that will suffice my purpose and the amount of data travelling on wire is also less in this as it uses raw ajax. Some MVP's says that ICallBackEventHandler was a failure, they suggest to use ASP.NET Ajax instead.
But I already had a POC which was giving me expected results. So I didn't bothered to explore that front much.

The requirement was, there were two controls in my page which needed to show data after the page load.
I made two CallServer methods, binding each control.

I tried to call server methods on a button click.

function ServerMethods() {
   CallServer1();
   CallServer2();
}
And the load methods as:

function CheckforContent1() {
    alert('function 1');
}

function CheckforContent2() {
    alert('function 2');
}
On debugging both the functions are called, but at the time of response only the latter CallServer method's CheckforContent method is executed. In my case only CheckforContent2 method gives the alert. Not the first one. It got me confused that why is that happening.

As the deadline was closer I found a workaround for the problem but the original issue kept bugging me.
Workaround:

function ServerMethods() {  CallServer1();  }

    function CheckforContent1() {
    alert('function 1');
    CallServer2();
}
The workaround solved the problem the page to become idle was increased as the second server call was after the first get completed instead of being in parallel which I expected. I kept searching for the answer but couldn't find one. All I can get was the way to do it is the way I did it. When ICallBackEventHandler was designed it was taken into consideration of multiple simultaneous callback's. Since I only needed small data in string format so this served the purpose this time but now I think I may need to explore better options for calling server asynchronously.

Sunday, October 9, 2011

jQuery .data

Hi,
 Recently I faced an issue regarding Global variables in Javascript.
 I had to save a lot of data regarding many DOMElements and do manipulation later on them.
 I had declared about 10 global variables. Getting them was fast but remembering which is related to which DOMElement was difficult.
So had to name them with ID's of the DOMElements prefixed to variables names. But I searched for an elegant method to do this job and yes I found that. jQuery again came to rescue here.

There is a method name .data which can be used to save values related to an DOMElement in form of a key-value pair. Can read the documentation of the method on the this link... jQuerydata I am going to give you a small implementation which explains how this works.

Sample HTML

<span class="yes" id="save">Click to Save Value</span>
<span class="no" id="get">Get Value</span>
jQuery Scripts

$(".yes").click(function() {
    var v = $("#save");
    $.data(v, "key", "value!!!");
    alert($.data(document.body, "bodyKey")); 
});

$(".no").click(function() {
     var v = $("#save");
    if($.data(v, "key") != null ) {
    alert($.data(v, "key")); 
    }
});

$(function (){
    $.data(document.body, "bodyKey", "Global Body Variable");
});


I have also saved some value in document body, giving a way to declare global variables. Hope this helps..

PS: The code in this post won't work. You can save the scripts and html to try it out.

Saturday, May 14, 2011

Google Changed Colors

Hi,

The search results page on Google has a lighter shade of blue color on them in recent time.
As per the PixelPick; the shades are gone from #2200C1 to #0042DA.

I think people now a days just don't post about this stuff; or my feeds are not following some awesome people on internet. Since I didn't get it in my feeds so thought let me be the one to spread the news around.

Will try to post more under this tags.
Ciao.

Wednesday, March 30, 2011

*insert title here*

Not great feeling when this happens. Recently gave interviews for 3 great companies; but alas all I got could get was "All the Best in your future endeavors".

The after effects of the first interview was with me and someone told me the results of second are also out.
Have been sad and started reading "Brida".

The book tells the story of a girl in search of learning the tradition of sun. I have completed the book but their are parts in it that need to be re-read for better and deep understanding. I really like the way author has described how a small thing in life can be too significant later. A new perspective towards thinking and many learning form small wonders.
If you like books with magic, philosophy than only I recommend this. Otherwise for rest it will serve as a good sleeping pill.

Enjoy Reading / sleeping.

Monday, February 7, 2011

jQuery Solution - Rich Text Box in Sharepoint

Hi
Recently faced a problem with Jquery and Rich Text Box in Sharepoint.
I had to get the value of the Rich Text Box into a variable and manipulate / use it.

Searched internet a lot for the possible ways to do it. No luck there.
Finally turned to MSDN, Rich Text Box documentation. Spent 3 hrs reading it and than finally came up with a working solution.

Here is the link for stackoverflow of my posted question followed by a solution ::

Hope it helps someone else also. :)

Sunday, January 30, 2011

Variable X

It sucks in life when a error comes at the compile time of the code.
Some variable names have specific significance in programming world. Like as the title of this post "x".

From the start of when I started learning about programming I first see the variable x. And the repeated use for it as a temporary variable for storing values or as in a for loop; has fascinated and carved an ever lasting impression in my mind for that.
Whenever I need to choose a variable the first choice always pops in "x". Being in a professional environment, got some learning regarding the names of variable; or as the I call it, I have learnt some design patterns.
But still when coding for small programs (practice programs); the love for "x" again grows significant.

Was walking down a road today in Mayur Vihar - Phase 1. That road is best known for morning/evening walks as someone told me. That patch of the road walked through the villages and finally end at the banks of river Yamuna. I was enjoying the walk, as it has been quite a while when I have seen the sunset. The smell of the villages, kids playing along side the road and the small temple in the neighborhood. Was upset a bit after being rejected at an interview. Need to find where did I lagged and what needed to improve for that a quite alone time was most necessary. So in here where did the "Variable X" fits?
As per thinking I thought, since the love for variable X is divine and ever lasting. So what is the variable X in my life. Variable X has been the inspiration, have stored many outputs. What give the inspiration, what gives the kick to do things. Since variable x has served throughout this programming career as an awesome friend, who can take the place of that in real life.

So still thinking for it, I have come on the conclusion that Variable X, is still undefined in life. Getting that error now give me more pain that I miss it in my code as well as in real life.
----
Still in search of the variable x.