Living on the Edge

December 31, 2011

Found lately that my second last blog post was about year ending and new year wishlists. That implies - either I have not done anything mentionable this year or I was busy enough not to post. LOLz.


But the fact is it was the combination of both cases.


There was a lot thing happened to me this year:


1) Booked a flat for my family - a place of dream. Took huge risk letting everything at stake - that gave an added responsibility but contentment at my mind.


2) Once again switched my job :-( Literally I had to. I couldn't manage everything with the old job and the job itself was not managable. So I had to quit. I joined www.loosemonkies.com, the company with the motto "putting the world to work", as Project Manager.


3) My mother got retired from her job. This thing left huge impact on herself and the whole family. She is sufefering from IBS from quite a long time and rest was the only thing that was required for her. Everyone is happy that she is at home now.


4) I started photography more seriously. I'd attended a numerous photography events (photowalk, tour, exhibitions) this year. One of my photo got exhibited at the event "Featuring Chittagong" arranged by PGBD. Another shot of mine got mentioned in a review at MIT journal which I submitted at the competition "Globalization: a bipolar story". It was quite an honor for a starter like me. At the end of the year, I got a film SLR (Yashika) which I dreamt since 2001. It was a great feeling to have that.


5) At the end of the year, at december 4, I got the lady of my life - I got married at last. It was just a day but that single day changed my life forever. The story began.


With so many things in my mind, I have planned for quite a few things for the next year (which is due in a few hours). Donno how far I can go with that.


1) Finding a groom for my kid sister.

2) Arranging  sweet home at Dhaka as well as at Mymensingh.

3) Attending some course on project management, scrum and people managemet.

4) Being more active in travelling and photography.

5) Being less active at professional communities and online activities.

6) Taking some serious steps towards attaining my ultimate goals of my life - putting up an agricultural farm where i will spend rest of my life with my family.


I am not really sure whether I can attain this goals or not. I am not even sure how I am gonna get those - planning is the last thing I like to do generally. But one thing I am quite sure that I never stop dreaming and never will and I will of course go for those.


HAPPY NEW YEAR

or

GET SOME FUCKING BALLS IN 2012 (copied from Hasin vai).


Published with Blogger-droid v2.0.1

Life is not a race ... It's like a prepaid card with fixed balance and validity ;-)

May 25, 2011

I heard the name of Chetan Bhagat after watching the bollywood dark-humerous film "3 Idiots'' which was adaptation of his book "Five Point Someone ...''. I heard about the controversy about the screenplay credit issue but didn't pay attention as that was none of my business -- but the central point of my attention was to the message of the film which criticized education system. I agreed to the message to almost every points. I read about the film, the author in the wikipedia and that was all till then.



Today I have found a picture where the author Chetan Bhagat is showing with some quotes from him on Facebook feeds. I am thankful to প্রসূন মজুমদার for sharing that. There was a source at the end of the file. I googled a bit following the quote and found the complete text. It was actually a speech from Chetan Bhagat given at the orientation programme for the new batch of MBA students at Symbiosis, Pune. I was amazed once again at the depth of his thinking and felt that I think the same, at least similar. Here I am sharing some parts of the speech, the complete one is large enough for not sharing.


Imagine the spark (spark shining. Or to put it another way, how to be happy most, if not all the time.) to be a lamp’s flame. The first aspect is nurturing – to give your spark the fuel, continuously. The second is to guard against storms.

To nurture, always have goals. It is human nature to strive, improve and achieve full potential. In fact, that is success. It is what is possible for you. It isn’t any external measure – a certain cost to company pay package, a particular car or house.
Most of us are from middle class families. To us, having material landmarks is success and rightly so. When you have grown up where money constraints force everyday choices, financial freedom is a big achievement. But it isn’t the purpose of life. If that was the case, Mr. Ambani would not show up for work. Shah Rukh Khan would stay at home and not dance anymore. Steve Jobs won’t be working hard to make a better iPhone, as he sold Pixar for billions of dollars already. Why do they do it? What makes them come to work everyday? They do it because it makes them happy. They do it because it makes them feel alive Just getting better from current levels feels good.

Nature designed with a random set of genes and circumstances in which we were born. To be happy, we have to accept it and make the most of nature’s design. Are you? Goals will help you do that. I must add, don’t just have career or academic goals. Set goals to give you a balanced, successful life. I use the word balanced before successful. Balanced means ensuring your health, relationships, mental peace are all in good order.

There is no point of getting a promotion on the day of your breakup. There is no fun in driving a car if your back hurts. Shopping is not enjoyable if your mind is full of tensions.

You must have read some quotes – Life is a tough race, it is a marathon or whatever. No, from what I have seen so far, life is one of those races in nursery school, where you have to run with a marble in a spoon kept in your mouth. If the marble falls, there is no point coming first. Same with life, where health and relationships are the marble.Same with life, where health and relationships are the marble. Your striving is only worth it if there is harmony in your life. Else, you may achieve the success, but this spark, this feeling of being excited and alive, will start to die.

One last thing about nurturing the spark – don’t take life seriously. One of my yoga teachers used to make students laugh during classes. One student asked him if these jokes would take away something from the yoga practice. The teacher said – don’t be serious, be sincere.

Life is not to be taken seriously, as we are really temporary here. We are like a pre-paid card with limited validity. If we are lucky, we may last another 50 years. And 50 years is just 2,500 weekends. Do we really need to get so worked up? It’s ok, bunk a few classes, goof up a few interviews, fall in love. We are people, not programmed devices.

I’ve told you three things – reasonable goals, balance and not taking it too seriously that will nurture the spark. However, there are four storms in life that will threaten to completely put out the flame. These must be guarded against. These are disappointment, frustration, unfairness and loneliness of purpose.

Disappointment will come when your effort does not give you the expected return. If things don’t go as planned or if you face failure. Failure is extremely difficult to handle, but those that do come out stronger. What did this failure teach me? is the question you will need to ask. You will feel miserable. You will want to quit, like I wanted to when nine publishers rejected my first book. Some IITians kill themselves over low grades – how silly is that? But that is how much failure can hurt you. But it’s life. If challenges could always be overcome, they would cease to be a challenge. And remember – if you are failing at something, that means you are at your limit or potential. And that’s where you want to be.

Disappointment’ s cousin is Frustration, the second storm. Have you ever been frustrated? It happens when things are stuck. This is especially relevant in India. From traffic jams to getting that job you deserve, sometimes things take so long that you don’t know if you chose the right goal. After books, I set the goal of writing for Bollywood, as I thought they needed writers. I am called extremely lucky, but it took me five years to get close to a release. Frustration saps excitement, and turns your initial energy into something negative, making you a bitter person. ... ... ... Remember, nothing is to be taken seriously. Frustration is a sign somewhere, you took it too seriously.

Unfairness – this is hardest to deal with, but unfortunately that is how our country works. People with connections, rich dads, beautiful faces, pedigree find it easier to make it – not just in Bollywood, but everywhere. And sometimes it is just plain luck.Merit and hard work is not always linked to achievement in the short term, but the long term correlation is high, and ultimately things do work out. But realize, there will be some people luckier than you. In fact, to have an opportunity to go to college and understand this speech in English means you are pretty damm lucky by Indian standards. Let’s be grateful for what we have and get the strength to accept what we don’t. ... ... ... It’s ok. Don’t let unfairness kill your spark.

Finally, the last point that can kill your spark is Isolation. As you grow older you will realize you are unique. When you are little, all kids want Ice cream and Spiderman. As you grow older to college, you still are a lot like your friends. But ten years later and you realize you are unique. What you want, what you believe in, what makes you feel, may be different from even the people closest to you. This can create conflict as your goals may not match with others. And you may drop some of them. Basketball captains in college invariably stop playing basketball by the time they have their second child. They give up something that meant so much to them. They do it for their family. But in doing that, the spark dies. Never, ever make that compromise. Love yourself first, and then others.

My Wishlist for 2011

January 11, 2011

I am a little bit late on wishing Happy new year through this tiny blog. But better late than never. I have been passing on a hell busy time now-a-days with so many things on my mind. Moreover I have started another blog related to my recent activities in software testing. All these things are making me giving less time for myself. At last I am back to my own place to note down my wishlists for this year.




For this I will first analyze my last year wishes and then make wishes for 2011 ;-)
Last year my wishes and the current situation regarding the issues are as follows:




1) I will be devoted to established our own concern this year ... I will set my goal to do that effectively and I
      will perform my part (God Willing).

[As this is an ongoing process -- we can say we are a little bit advanced in this year as we have secured a workplace for us and we have almost closed the pending issues of last year. Now we are R&Ding for something ;-) So this can be treated as partially fulfilled and miles to go still!!!!]


(2) I will try to develop my career in Technical Project Management this year. So personally for me there will
     be more time for project management and less in just Coding.
[I have been working as Manager of SQA Line from December 2010 in my present company. So this wish has been starting to be fulfilled!]


(3) This year there is a huge chance for me to get myself involved in serious business actions. I am looking forward for challenges.
[Unfortunately, this wish is not even close to be fulfilled :-( Currently I am engaged in too many affairs other than serious business. May be this is for the time being -- but the wish will still be on this list -- unprocessed!!!]


(4) This year there is a huge chance for me to get hitched! Please pray for me!
[Unfortunately, this wish too is currently unprocessed and still in the list!!!]

(5) I am taking oath to help as many distressed working children (who can't goes to school) as I can. Please help me as this is not possible to get this thing done. 
[I have helped a rickshaw puller boy to get himself admitted in a school and  other related stuff. Though this is a very tiny help --- I am willing to do more this year.]






So now -- wishes for 2011 becomes as -------
(1) This year there is a huge chance for me to get myself involved in serious business actions. I am looking forward for challenges.
(2) This year there is a huge chance for me to get hitched! Please pray for me!
(3) This year I want to continuing helping distressed children (as many as I can)
(4) I want to keep learning new things and prospects of Software Quality Assurance and want to see myself as a Top Level QA Engineer.
(5) I am new to technical management, too. I want to keep learning and implementing new ideas and new processes to make the information system of the company better.
(6) This is the second year of Inversionz Garage --- I hope we can make it better than previous year.








Wish Everybody in the world a very happy and prosperous new year!

Bought a Digital Camera!

July 27, 2010

I had lost a camera of Canon when I was at university. It was back in 2003 and that was a film camera. Since then our family has a family camera (one from Samsung) which is semi-digital but uses films but I didn't dared to buy one as I had lost a precious item of family. Since then I used to use my Nokia 3110c mobile camera for candid shots and even tour photography.

But recently I was in need of a camera as I had to do some serious photography for one of my client. I had to manage a digital camera which have at least good resolution and a good lense. But I was saving money and was prepared to (I am still) buy a DSLR after a few months. So in this situation, I thought for the prior lose of family due to my foolishness and thought for sacrificing my DSLR fetish for some more months. I went through google and talked with one of my coleague-friend and decided to buy a 'cybershot'.

I have gone through several items and found models like DSC-W370DSC-W350DSC-W320. The prior two has great facilities like - panorama shots and great deal of optical zoom! W350 and W320 has similar optical zoom (4x) but their lenses are of different manufacturers (W350 lense is made of sony and W320 lense is a Carl Zeiss® Vario Tessar lens). There are difference of price between the models.

As I did not have much budget, I decided to go with relatively cheaper one. Besides money the thing that helped me taking this decision is the lense. I googled a bit about the lense and found some positive reviews. So at last I decided to buy Sony CyberShot DSC-W320.

I went to a camera shop near my workplace and lokked for that and found that they are taking extra charges for memory card and camera case (later I found that it is the common scenario here in Bangladesh). Everything else was going nice except I didn't 
got the black one as you can see in the picture - instead I got silver one. However that is gorgeous too. I took 4GB of memory stick and a nice black bag. In total the package cost me 15K (approx).

Now lets see what I have got:

  • Carl Zeiss® Vario Tessar lens
  • BIONZ Image Processor
  • 14.1 Mega Pixels
  • 26mm Wide angle lens
  • Advanced Face Detection
  • Smile Detection
  • Intelligent Auto Mode
  • Supports ISO : Auto / 100 / 200 / 400 / 800 / 1600 / 3200 standards. 
  • offers ability to record video in VGA resolution (640 x 480 pixels) 
  • built-in flash has extended range of up to 3.3 meters
  • It offers auto-focusing to  5-cm at wide angle or 50 centimeters at telephoto. 
  • The camera captures 4:3 aspect ratio images at up to 4,000 x 3,000 pixel resolution, and 16:9 aspect ratio images at up to 4,000 x 2,248 pixels.
  • But Still it weighs only 101 gm.
I feel like I just gained a great thing and I am happy that finally I have got my family a digital camera.  Now for my personal use I will try to get a DSLR soon.

;-)

Experiencing Facebook Javascript SDK with graph API - II

May 17, 2010

Previous post:

http://nagbaba.blogspot.com/2010/05/experiencing-facebook-javascript-sdk.html 

Here goes the link of the first part. In this post I will share (or better to say note down about further experience in FB Javascript API).

Here I will try to focus on :::

(2) get fans count and their feed on page's wall to promote and to share the page.

 (3) post to wall (to my page or profile) from my site. 

 

Steps for task (2) :

[1] Facebook fan pages are awesome tools for marketing or promotion. They are attached to facebook open graph. SO it is very much easy to access their public info like feed stream and fan count. But for the other info there should be nneded to logging in.

[2] If we hit to https://graph . facebook. com/ we will get all the public info like -- id, name, username(if any), page profile picture, link, location, hours open. For other info we have to use metdata tag. for this purpose we may hit https://graph . facebook. com/ ? metadata= 1. We may find links for feed, posts, tagged, statuses, links, notes, photos, albums, events and videos. Among them feed, posts, photos and albums are publicly accessible.

[3] So using this protocol we can find and fulfil our needs as mentioned above.

[4] We have called javascript api for getting fancount and for feeds we have used php as this is easy to maintain a multilevel data structure like array in php than javascript.

[5] So the frame of our code goes like as below :


<!doctype html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  </head>
  <body>
    <div id="user-info" style="display: none;"></div>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    <div id="fb-root"></div>
    <script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>

    <script type="text/javascript">
            $(document).ready(function(){
                FB.init({ apiKey: 'XXXXXXXXXXXXXXXXXXX' });
            });
    </script>
 </body>
</html>

[6] Here the FB.init is used to initiate the api call. Now to get the fan count we will add the following function after document.ready block and call the function from document.ready.

function getUpdate () {
var htmls = '<div style="background-color:#77A1CD:color:#EAAA00;">';

FB.api('/224365082363', function(response1) {
                        total_members = response1.fan_count;
                        name = response1.name;
                        link = response1.link;
                        htmls += 'Total <i>'+total_members+'</i> persons likes '+'<a href="'+link+'">'+name+'</a><br>';
                        htmls += '</div>';
                        $('#user-info').show();
                        $('#user-info').attr("style","width:450px;height:auto;background-color:#E4E9EE");
                        $('#user-info').html(htmls);
               });
}

[7] Now to find the lates feeds we have used php. From php we have called the same graph protocol and used file_get_contents. the returned datatype is json. SO we used json_decode to parse the data. Then the data type becomes an stdclassobject. The code goes as follows:

<?php
 $myObj = json_decode(file_get_contents("https://graph.facebook.com/224365082363/feed"));
echo "<br>";
$i = 0;
        foreach ($myObj->data as $aData){
                $user[$i]['from'] = $from = "<a href=\"http://www.facebook.com/profile.php?id=".$aData->from->id."\" >".$aData->from->name."</a>";
                $user[$i]['msg'] = $message = $aData->message;
                $created = $aData->created_time;
                
                
                $html  = "<div style=\"background-color:#F9F9F9;color:#000000;height:auto;width:500px;\">";
                $html .= $from.": ".$message;
                $html .= "<font size=\"1\">   ".$created."</font>";
                $html .= "<hr style=\"border-style:dotted; border-color:#6D84B4\"/>";
                $html .= "</div>";
                echo $html;
                $i++;
        }
?> 

[8] Here the time returned is on 'yyyy-mm-ddThh:mm:ss' format but normally and specially our application demands time difference from now liek as how many mniutes ago the feed was posted. So for these reason we have used a function that calculates the time difference in days, hours and miniutes. the code block for the function and the calling will be as follows:

<?php
 $myObj = json_decode(file_get_contents("https://graph.facebook.com/224365082363/feed"));
echo "<br>";
$i = 0;
        foreach ($myObj->data as $aData){
                $user[$i]['from'] = $from = "<a href=\"http://www.facebook.com/profile.php?id=".$aData->from->id."\" >".$aData->from->name."</a>";
                $user[$i]['msg'] = $message = $aData->message;
                $created = $aData->created_time;
                $createdtime = date('Y-m-d h:i:s', strtotime($created));
                $now = date('Y-m-d h:i:s', time());
                $user[$i]['ago'] = $difference = get_time_difference($createdtime, $now);
                
                $html  = "<div style=\"background-color:#F9F9F9;color:#000000;height:auto;width:500px;\">";
                $html .= $from.": ".$message;
                $html .= "<font size=\"1\">   ".$created."</font>";
                $html .= "<hr style=\"border-style:dotted; border-color:#6D84B4\"/>";
                $html .= "</div>";
                echo $html;
                $i++;
        }

function get_time_difference($start, $end){

        $tempstart1 = explode('-',$start);
        $startyr = $tempstart1[0];
        $startmon = $tempstart1[1];
        $tempstart2 = explode(' ',$tempstart1[2]);
        $startday = $tempstart2[0];
        $tempstart3 = explode(':',$tempstart2[1]);
        $starthr = $tempstart3[0];
        $startmin = $tempstart3[1];
        $startsec = $tempstart3[2];

        $tempend1 = explode('-',$end);
        $endyr = $tempend1[0];
        $endmon = $tempend1[1];
        $tempend2 = explode(' ',$tempend1[2]);
        $endday = $tempend2[0];
        $tempend3 = explode(':',$tempend2[1]);
        $endhr = $tempend3[0];
        $endmin = $tempend3[1];
        $endsec = $tempend3[2];
        

        $start1 = mktime($starthr, $startmin, $startsec, $startmon, $startday, $startyr);
        $end1 = mktime($endhr, $endmin, $endsec, $endmon, $endday, $endyr);

        $dateDiff = $end1 - $start1;
        $fullDays = floor($dateDiff/(60*60*24));
        $fullHours = floor(($dateDiff-($fullDays*60*60*24))/(60*60));
        $fullMinutes = floor(($dateDiff-($fullDays*60*60*24)-($fullHours*60*60))/60);
        
        $ret = "";
        if($fullDays > 0){
                $ret .= "$fullDays Days ";
        }
        if($fullHours > 0){
                $ret .= "$fullHours Hours ";
        }
        if($fullMinutes > 0){
                $ret .= "$fullMinutes Minutes ";
        }

        if($ret!= ''){
                $ret .= "ago";
        } else {
                $ret .= "A Few Moments ago";
        }

        return $ret;
}
?> 

[9] so the final out put will be as the following screenshot -


So we will be back soon with posting to wall steps. ;-)

Experiencing Facebook Javascript SDK with graph API - I

May 11, 2010

This is the first time I am using Facebook Javascript API. In fact this is the first time I am using any facebook api. So I am excited to some extend. I have heard that the api and documentations are easy enough to understand. I read the facebook release of graph api and f8 and they looked coooooool to work with.

The basic purpose of my work was three things -
(1) Get Home page feeds and present them as scrolling in my site
(2) create custom buttons with friends and/or fans count to promote
(3) post to wall (to my page or profile) from my site.

To the experts these are definitely piece-of-cake but for a first timer like me they are the basic things to work with.

So in this post I will discuss  how i learned to get the home page feeds.

Steps for (1) Get Home page feeds and present them as scrolling in my site:

[a] I have created an canvas application called testfbapp (this is just to get an api key) from http://developers.facebook.com/setup . I have set my site name as testfbapp and my site url as http://localhost/testfbapp (as i am planning to test my codes on localhost).

[b] Now from the next page that comes after creating the application I have clicked the developer dashboard link. There all the application that just have been created will be shown. I have copied the API Key, the secret key and the application ID for the app and kept that somewhere.

[c] Then I have searched for Javascript SDK and found it on http://github.com/facebook/connect-js/ . I have downloaded the sdk and copied that to my local directory which is testfbapp under my web root.


[d] In order to get used to it i have roamed around the files I have downloaded and found that it the sdk supports a lot variety of popular javascript libraries like dojo, jquery, mootools, prototype, yui2. Because of previous little experience in jquery I have chosen that.

[e] Now I have created a file named index.php at the project root. I have copied contents from the login.html from examples/jquery directory and pasted it into the index.php page.

[f] Then I have removed the contents of handleSessionResponse() after the following code block

if (!response.session) {
          clearDisplay();
          return;
        }

So the page looks like as follows:
<!doctype html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  </head>
  <body>
    <div>
      <button id="login">Login</button>
      <button id="logout">Logout</button>
      <button id="disconnect">Disconnect</button>
    </div>
    <div id="user-info" style="display: none;"></div>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

    <div id="fb-root"></div>
    <script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>

    <script type="text/javascript">
      // initialize the library with the API key
      FB.init({ apiKey: '.....' });

      // fetch the status on load
      FB.getLoginStatus(handleSessionResponse);

      $('#login').bind('click', function() {
        FB.login(handleSessionResponse);
      });

      $('#logout').bind('click', function() {
        FB.logout(handleSessionResponse);
      });

      $('#disconnect').bind('click', function() {
        FB.api({ method: 'Auth.revokeAuthorization' }, function(response) {
          clearDisplay();
        });
      });

      // no user, clear display
      function clearDisplay() {
        $('#user-info').hide('fast');
      }

      // handle a session response from any of the auth related calls
      function handleSessionResponse(response) {
        // if we dont have a session, just hide the user info
        if (!response.session) {
          clearDisplay();
          return;
        }
      }
    </script>
  </body>
</html>

[g] Now I have read about the graph api of facebook from http://developers.facebook.com/docs/api and for our purpose (i.e. to get home page feeds) I found that
https://graph.facebook.com/user-name/home link is helpful. So I have tested on the browser address bar putting my FB user name and some of my friends FB user name and found that it works only for current user that the logged in user. but https://graph.facebook.com/user-name works for self and friends information. It fetches only publicly viwable information. So our next step should bego through the javascript api reference to utilize the graph api.

[h] I have gone through http://developers.facebook.com/docs/reference/javascript and found that FB.api  API call is the right method to use as it can directly call to graph API.

[i] I have put my API key for my application in the FB.init() method and following this guide I have written the following code in the handleSessionResponse() method. I have checked https://graph.facebook.com/user-name?metadata=1 url in my browser to find the proper link for home feeds. I have used

for(property in response){
   alert(property);
}

to check the properties of the response object. And then for output I have written --

var user_id = FB.getSession().uid;
FB.api('/'+user_id+'/home', function(response) {
  var total_feed = response.data.length;
   var htmls = '<ul style="list-style-image: none; list-style-position: outside; list-style-type: none;">';       
 for(var x = 0; x < total_feed; x++) {       
  name = response.data[x].from.name;       
  id = response.data[x].from.id;       
  message = response.data[x].message;       
  created_time = response.data[x].created_time;              
  htmls += ""; 
  htmls += '<a href="http://www.facebook.com/profile .php ?id='+id+'>'+  name+'</a>:';
  htmls += message;
  htmls += " created at ::: "+created_time+""; 
 htmls += "";   
}      
htmls += "</ul>";
  $('#user-info').show();
  $('#user-info').attr("style","width:450px;height:auto;background-color:#E4E9EE");
  $('#user-info').html(htmls);
});


[j] Here FB.getSession() holds all the session variables after authentication. If some user visiting my page is not logged in the FB.getSession() is null and it will not return any feed. To login there is a login button at the top of the page (at the top of my code). After clicking that button there will be an iFrame dialogue box appeared and will ask permission from the user to login and then to allow the application to fetch  profile data.

[k] Now if we run http://localhost/testfbapp and login using FB credential and allow this application we will see the recent homepage feeds.

[l] Now to automate this script that is to get live updates we may modify the codes like as follows and this is our final version of this code.

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  </head>
  <body>
    <div>
      <button id="login">Login</button>
      <button id="logout">Logout</button>
      <button id="disconnect">Disconnect</button>
    </div>
    <div id="user-info" style="display: none;"></div>

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

    <div id="fb-root"></div>
    <script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>

    <script type="text/javascript">
      // initialize the library with the API key
      FB.init({ apiKey: 'XXXXXXXXXXXX' });

      // fetch the status on load
      FB.getLoginStatus(handleSessionResponse);

      $('#login').bind('click', function() {
        FB.login(handleSessionResponse);
      });

      $('#logout').bind('click', function() {
        FB.logout(handleSessionResponse);
      });

      $('#disconnect').bind('click', function() {
        FB.api({ method: 'Auth.revokeAuthorization' }, function(response) {
          clearDisplay();
        });
      });

      // no user, clear display
      function clearDisplay() {
        $('#user-info').hide('fast');
      }

      // handle a session response from any of the auth related calls
      function handleSessionResponse(response) {
        // if we dont have a session, just hide the user info
        if (!response.session) {
          clearDisplay();
          return;

        var user_id = FB.getSession().uid;
        var access_token = FB.getSession().access_token;

        getUpdate();

      }

      function getUpdate () {
              var user_id = FB.getSession().uid;
              //alert(user_id);
              var access_token = FB.getSession().access_token;
              //alert(access_token);
              FB.api('/'+user_id+'/friends', function(response) {
                 var total_friend = response.data.length;
                 //alert(total_friend);

              });
              FB.api('/'+user_id+'/home', function(response) {
                        var total_feed = response.data.length;
                        var htmls = '<ul style="list-style-image: none; list-style-position: outside; list-style-type: none;">';                         
for(var x = 0; x < total_feed; x++) {        
name = response.data[x].from.name;        
id = response.data[x].from.id;        
message = response.data[x].message;        
created_time = response.data[x].created_time;               
htmls += "";  htmls += '<a href="http://www.facebook.com/profile .php ?id='+id+'>'+ name+'</a>:';
htmls += message;
htmls += " created at ::: "+created_time+""; 
htmls += "";   
}
                        htmls += "";
                        $('#user-info').show();
                        $('#user-info').attr("style","width:450px;height:auto;background-color:#E4E9EE");
                        $('#user-info').html(htmls);
                });
               

                t = setTimeout(getUpdate,15000);
        }

        

     </script>
  </body>
</html> 


Now this will be the ned of part 1 getting FB homepage feed.
[cont...]

Experiencing Python :: Part I

April 27, 2010

I was getting bored with working on similar tasks/projects. I had a drive in my mind to do something that can get myself charged up and on the other hand a new thing will be learned. Thinking about programming languages the first two things came in my mind was - Python and Ruby on Rails. I decided to start with python.




Installing : 
[I am on Red Hat Linux. I will add to this post or on a separate post the experience on my ubuntu and windows]
(1) I visited http://www.python.org/download/  and downloaded Python 2.6.5 as it was told there that if I was not sure of which version to get it will be the choice.

(2) After downloading, I have placed the Python-2.6.5.tar.bz2 to home/myUser folder and extracted it there. The folder name will be Python-2.6.5

(3) now in the terminal, i wrote the necessary commands and waited for them to be executed like as follows --

[root@localhost nagbaba]# cd Python-2.6.5
[root@localhost Python-2.6.5]# ./configure
... ... ... 
[root@localhost Python-2.6.5]# make
... ... ...
[root@localhost Python-2.6.5]# make install
... ... ...
(4) Now the installation has been completed. To go back, i typed -
[root@localhost Python-2.6.5]# exit

(5) Now python is installed and ready for use. To check the installation location
[root@localhost ~]# which python
it yields ---
/usr/local/bin/python


(6) To run python from command prompt we type --
[root@localhost ~]# python

(7) Then I opened my Eclipse 3.4.2. I went to
     Help >> Software Updates >> Available Softwares
In the textbox, i have written python and the IDE searched the available pydev plugins for eclipse. I checked the check boxes and installed them.


(8) Then in the "navigator perspective" i created a python project, but it wanted the path of the interpreter. I showed the path browsing (the path is /usr/local/bin/python as we have found it earlier).

(9) Then I right-clicked on the project icon at the navigator and clicked
new >> pydev module

(10) I left the package name blank and select src as the package. I named my project as 'testPY'. After creating the module, i searched google for "hello world" type code in python and luckily found one. I typed the following code and saved the file as testPY.py
def add(a,b):
     return a+b

print add(1,2)
(11) Then I right clicked the file on navigator and clicked
run as >> python run

in the small output window it gives the output 3.

I will be posting stuffs as I will be approaching to learn things. But for my irregular nature I guess it will not be an easy stuff.