jump to navigation

A beautiful prayer August 24, 2008

Posted by razasayed in general.
add a comment

Where the mind is without fear
and the head is held high;

Where knowledge is free;
Where the world has not been broken up into fragments
By narrow domestic walls;

Where words come out
from the depth of truth;

Where tireless striving stretches its arms
towards perfection;

Where the clear stream of reason has not lost its way
Into the dreary desert sand of dead habit;

Where the mind is led forward by thee
Into ever-widening thought and action

Into that heaven of freedom,
My Father
Let my country awake.

— From Rabindranath Tagore’s “Geetanjali”

The Zen Of Python August 22, 2008

Posted by razasayed in programming.
Tags:
add a comment

Heres a list of 19 aphorisms which serve as guiding principles for any python hacker . In the python community, a solution or piece of code conforming to these principles is said to be “pythonic”.

  • Beautiful is better than ugly.
  • Explicit is better than implicit.
  • Simple is better than complex.
  • Complex is better than complicated.
  • Flat is better than nested.
  • Sparse is better than dense.
  • Readability counts.
  • Special cases aren’t special enough to break the rules.
  • Although practicality beats purity.
  • Errors should never pass silently.
  • Unless explicitly silenced.
  • In the face of ambiguity, refuse the temptation to guess.
  • There should be one– and preferably only one –obvious way to do it.
  • Although that way may not be obvious at first unless you’re Dutch.
  • Now is better than never.
  • Although never is often better than *right* now.
  • If the implementation is hard to explain, it’s a bad idea.
  • If the implementation is easy to explain, it may be a good idea.
  • Namespaces are one honking great idea — let’s do more of those!

These principles are also distributed with python (ofcourse its “batteries-included” 😉 ), hidden like an easter-egg . Just type the following at the python interpreter prompt to view it.

import this

Linus uses Fedora August 18, 2008

Posted by razasayed in general.
Tags:
add a comment

I recently came across an interesting interview of Linus Torvalds, where he says that the distro he uses is Fedora Core 9 . Being a person who has a very specialized area of work i.e. the Linux kernel, he says he doesnt care much about distros as long as they are easy to install and use, so that he can focus on his core line of work instead of bothering with the rest of the details.

He also added that as far as user friendliness goes there are others also like Ubuntu, and now Debian also, but the reason he uses Fedora is purely historic as it had good support for PowerPC back when he was using one.

You can check out the interview at http://www.simple-talk.com/opinion/geek-of-the-week/linus-torvalds,-geek-of-the-week/.

Hope u enjoy reading it 🙂

PageRank Vs. BrowseRank . The algorithm wars August 12, 2008

Posted by razasayed in general.
Tags: , ,
2 comments

I talked about Yahoo! revamping its search service in my previous post.Now can Microsoft be far behind ?. Well, according to Microsoft, the formula behind Googles success in the search area is their “PageRank” algorithm . The PageRank algorithm rates the relevance of a page based on the number of pages that link to it, and how many pages link to those pages so on and so forth….

Microsoft says it has come up with a better algorithm which it calls “BrowseRank” . Now instead of relying on the number of links between pages , this algorithm determines a page relevance by the actual number of hits it receives by users . So, the more visits of the page made by the users and the longer time periods spent by the users on the page, the more likely the page is important. So BrowseRank brings a human touch to the assessment of a pages relevance.

Now, whether Google or Microsoft or Yahoo! will have the final word in search technology only time will tell, but so far Google no doubt leads with Yahoo! at number two and Microsoft at number three 😛

You can read more about this algo war here

Yahoo! India creates ‘Glue’ August 11, 2008

Posted by razasayed in general.
Tags:
2 comments

Well, heres something that caught my eye lately . Yahoo! India RnD has come up with a brand new avatar of their search codenamed ‘Glue‘. Launched only in India as a test market, it combines traditional search with visual and relevant data from the web collated from multiple sources in a very intuitive manner.

Intuitive because it has smart algorithms which figure out what you’re looking for – so if you search for ‘Sachin Tendulkar’, you are thrown up his player profile from Cricinfo, stats etc. Search for ‘Maldives’ and you’ll see photos from the honeymoon destination, a map and other relevant data. Similarly, an entry for ‘Infosys’ gives you stock quotes, company info and such. Very clever. Interesting to see how much different search providers are ramping up their technology to compete with “The Great Google” in the search business.

How to write your own IM program/GTalk client in Java August 7, 2008

Posted by razasayed in programming.
Tags: , , ,
64 comments

Here i will show you how you can write your own simple gtalk client using an open source java library called “Smack“. Smack is a cross-platform Open Source XMPP (Jabber) client library for instant messaging and presence , and as you will see it actually makes writing your own client to connect to any jabber service a breeze 🙂 . The library is extremely versatile but to keep things simple, here we develop a program to exchange messages with a buddy of yours in GTalk.

But before we start, what the heck is XMPP and Jabber ? . If you already know this you can skip to the next part.

You see there are many, many IM clients around. Companies such as Microsoft, and Yahoo provide IM services based on proprietary messaging protocols, and also provide popular client software (Microsofts MSN Messenger and Yahoos Yahoo Messenger) using these protocols. Many third-party clients also work with these protocols. However, these protocols remain proprietary and closed, which tends to make them difficult to work with for a developer.

Jabber is an open, XML-based “standard” for instant messaging and is an open source alternative to the proprietary messaging protocols . Jabber uses XMPP (Extensible Messaging and Presence Protocol), which is an “XML based protocol” , for transferring messages. Since the Jabber messages are transmitted in XML form it makes it easy for developers to work with them. Googles instant messaging service uses the Jabber protocol .

OK, now lets get our hands dirty with some code, shall we ? 🙂 . Alright, here we go .

Step 1) To start with download the Smack API

Step 2) Create a folder for your project. Create a lib subfolder . Unzip the downloaded zip file and copy the following files to the lib subfolder : smack.jar, smackx.jar,smackx-debug.jar.If you want you can also copy these files to any other location of your choice and then add the location of these files to the classpath.

Step 3) Now we write the actual code for implementing our gtalk client. To do that first create a file MyGTalkClient.java in your main folder, or anywhere else if you have added the location of the jar files to your classpath.

Step 3.1) The first step is connecting to the GTalk service  The code below does that :


ConnectionConfiguration config = new ConnectionConfiguration("talk.google.com",5222,"gmail.com");
XMPPConnection connection = new XMPPConnection(config);
connection.connect(); /* Connect to the XMPP server  */
connection.login("username","password"); /* Login to the IM service */

“talk.google.com” is the host. 5222 is the port number and “gmail.com” is the service name.

Step 3.2) To send a message to a buddy we use the Chat class as follows :

Chat chat = connection.getChatManager().createChat("friend@gmail.com",new MyGtalkClient());
chat.sendMessage("Hi"); /* Send the message  */

The first argument to createChat method is obviously the email id of your buddy in GTalk . The second argument is an instance of a class that implements the org.jivesoftware.smack.MessageListener interface . This listener interface receives incoming messages and calls its processMessage method to process the message.

Step 3.3) Now, the next step is making sure that we receive the messages that our friend sends . To do that we implement the processMessage method of the MessageListener interface as follows :


public void processMessage(Chat chat,Message message) /*Callback method from MessageListener interface . It is called when a message is received */
{
        System.out.println("Received message: " + message.getBody());
}

Step 3.4) After you are done chatting with your friend you can disconnect from the server as follows :


connection.disconnect() ; //Disconnect 

There we are . A simple bare-bones Jabber client to connect to the GTalk service is ready ! .The final code looks like this .

Step 4) If you have not added the locations of the jar files to the classpath , you can compile and run your chat client as follows :


javac -cp lib\smack.jar;lib\smackx.jar;lib\smackx-debug.jar MyGTalkClient.java

java -cp lib\smack.jar;lib\smackx.jar;lib\smackx-debug.jar;. MyGTalkClient
(Note the ;. at the end of the classpath)

Thats all there is to it ! . From here on you can explore the API, and try to come up with really cool ideas for using instant messaging and presence in your applications.

Happy Hacking !! 🙂

Isn’t RoR scalable ? August 5, 2008

Posted by razasayed in programming.
Tags:
add a comment

A recent piece of news doing the rounds is that Twitter , the microblogging service provider is moving away from Rails framework, due to outage problems,and planning to start from scratch with PHP or Java . However, Evan Williams the co-founder and CPO of Twitter has denied this .

RSS Feeds for GMail ! August 4, 2008

Posted by razasayed in Hacks.
Tags:
add a comment

I recently discovered another thing which separates GMail from the rest of the webmail service providers out there . It provides an rss feed for your mails , which you can access using any rss aggregator/feed reader ! . All you need to do is visit https://mail.google.com/mail/feed/atom , and enter your credentials to subscribe.

However, a point to be noted is that not all aggregators support GMail . For an aggregator to access GMail rss, it must support Atom 0.3 and SSL/HTTPS . Google provides a list of aggregators supporting GMail on Windows , Mac and Linux platform.As for rss aggregators available as firefox extensions ive seen that “Brief” does not support GMail but “Sage” does .

The GMail help center article for this feature is located here . However,  make sure that you double check the privacy settings for your aggregator before using GMail with it, as you might accidentally end up making your contents public !.

If you want to be really safe , but at the same time also get alerts for your mail in gmail , including the ones you have labelled , check out “GMail Manager” , a super cool extension for firefox which allows you to display your account details including unread messages, saved drafts, spam messages, labels with new mail, space used, and new mail snippets 🙂 .

In the beginning was the command line…. August 3, 2008

Posted by razasayed in general.
Tags: , ,
add a comment

I stumbled across an interesting piece of essay called “In the beginning was the command line” by Neal Stephenson . It deals with the ongoing clash between proprietary and free software and also analyzes the corporate/collective culture of the Microsoft, Macintosh, and free software communities .

This book was published in 1999, even before Mac OS X came out, so it does not deal with things as they are today, but it does induce some nostalgia in the reader by offering an interesting glimpse into the past of proprietary and free software  . I havent read it completely yet, but its been pretty engrossing so far 🙂

This essay has been published in the form of a book, and has also been made available online for free download .To whet your appetite , you can check out the Wikipedia entry for the book.

To download it visit http://www.cryptonomicon.com/beginning.html

Brief-A cool feed reader extension for firefox with feed notifications August 3, 2008

Posted by razasayed in Hacks.
Tags:
add a comment

I was looking for a good feed reader extension for Firefox . There are some excellent “online” feed readers like Google Reader, but i needed something i can use from within firefox without the need to login to some online service. While searching for feed reader extensions i was initially overwhelmed with the number of choices out there . It was difficult making a pick, but finally i decided to go for an extension known as “Brief“, which most people have voted as one of the best feed reader extensions for firefox .

It is simple yet powerful at the same time . The interface resembles that of google reader with features like  single click bookmarking and tagging . It also has the feature of providing notifications of updates in your list of feeds. This notification feature is what i found missing in the other feed readers i looked at , including “Sage“, which is another good feed reader for firefox.

You can install Brief by visiting https://addons.mozilla.org/en-US/firefox/addon/4578

P.S. : For all Google Reader fans out there , if you want to get notified of any updates in your list of feeds without having to login to Google Reader check out a nice firefox extension called “Google Reader Notifier