Wednesday, January 02, 2008

Assistant v1.0

There are many things that I want to know quickly and opening firefox and querying the information sucks! I want to know the meaning of a word, I open firefox (Ok. I open a new tab. fine ?) I go to google and say define:word. Those who don't know this its worser they have to go to dictionary.com, enter the word and wait for it to load. Another common thing is a reminder and a snoozer. There are cool gadgets available but still they suck (atleast for me). So whats the solution ? Simple appoint an assistant!
Already google talk has become famous with many users already using it. Its simple, rich and does exactly what you want. Also, gtalk uses XMPP underneath the hood. So any XMPP client can login to gtalk and chat. This is what poor linux users have been doing for long ;-). A few days back I started experimenting with XMPP and Gtalk using Smack api. I know java sucks for me now a days, but an equivalent python api has some problem and hence I stuck myself with java. So how does all this fit into the big picture ? Simple, I created a dummy gmail id added it to my gtalk friends list. Then using smack you can listen to the messages that I send to this dummy id and ask it to process. The good thing is I have written an interface and hence you can write any bot you want by implementing that interface. Here is a quick glance on what my bots can do for me.

* echo - simplest of all. You say 'echo hello world' it will return 'hello world'
* random - You say 'random 1 100' it will return a random number between 1 and 100
* remind - You say 'remind have to book a ticket WED:9:30' it will ping you at 9:30 to remind you for booking tickets.

Here are is a screen shot of my assistant in action :-)























So how can we extend this ? Don't ask me 'coz there are zillion. A few could be
cricinfo - get score

topcoder - next event

snooze - snooze

define - define word

irctc - ticket
Current problems :
Since I did all these in a days time there are a few issues that have to be addressed so as to provide a smooth functionality. Firstly, sometimes the connect call of the XMPP fails for unknown reasons. Secondly, the class design can be still more better. Finally have to provide an interface for adding new bots. So will be posting the complete API with documentation. Watch out..


Saturday, December 22, 2007

Why should we learn lisp, scheme or brainf**k

Lately, I have found myself venturing into learning new programming languages. After python I added Lisp and Scheme (a language similar to Common Lisp) to this list. I have read several articles on them and almost every person who have programmed in these holds them in great regard. I never understood the reason. Whenever I see someone's LISP code I used to wonder why people are taking so much pain in parenthesizing every possible expression they write. Brainf**k is yet another language that I explained in my previous post. A simple hello world program in brainf**k may look like this.
>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++. But all these gibberish never stopped them from writing programs in these obfuscated languages. Today I went to landmark and bought SICP. The author introduces the book with Scheme. He then goes on to explain how expressions are constructed and how procedural abstractions can be incorporated into the language. I have been programming in Java, C and C++ for so many years but I never really thought about understanding how the Java compiler works. The reason is simple - "I just cannot". They have so many inherent complexities that one can hardly comprehend them. In simple words, they don't tend to motivate a programmer to write code that can interpret them. No hard feelings though :-) But this is not the case with LISP, Scheme or BrainF**k. One common thing that you can notice while learning these languages is that they all motivate you to write your own implementation of its interpreter ( may be an ugly one ) and it is not a false motivation. Infact, the book goes on to implement metacircular evaluator, writing interpreters using the language that it is going to interpret. If understanding such ideas is one kind of bliss, then implementing them is another. I presume that understanding these interpreters serves a better understanding to the notion of programming languages and thus elevates one to a better programmer. It was once again srid's blogs and code that motivated me to learn LISP :-)



Thursday, December 13, 2007

In love with python.....

During my school and college days, I remember wasting time trying to think of something that won't let me waste time. Believe me I have never been successful. There were a zillion things that I could do, but still I was trying to do a linear search on those zillion things and eventually got TLE. From my college days I have been a constant visitor to Sridhar's web page, though he hardly knows me. The sheer simplicity of Sridhar's page has always attracted me. Whenever I used to visit his web page, I used to see some new code. It might be something very simple like a solution for one of the problems from ProjectEuler but still it was an addition. I also found that many of his code were in python and lisp. When one of my good friend told me about python I wasn't really interested in learning partly because I din't like variables being declared without mentioning type and partly because I was in love with Java. Java gave me almost everything I asked it. Then suddenly one fine day in the office, when I was getting really bored something told me to learn python. I downloaded a ebook and started reading it. Thanks to the author, the book really kept me awake. I started doing some simple code like matrix addition and permutations and unbeknown to me I started liking python. When python code started looking familiar to me, I re-visited Sridhar's site and I saw boa and boalisp. They are actually tools aiding the conversion of lisp to python. I hardly knew lisp but I felt like doing something similar. Thats when I remembered about BrainF**K. BrainF**K can be thought of an extension to Turing Machines. It has only eight characters {<, >, +, -, . , [, ] } and a comma. You can learn more about it in the above link. So, I thought of writing an interpreter for BrainF**K. Its actually a very simple one but still it was one hell of an enjoyable thing to watch when you see your code work the first time. The experience was simply awesome. I also wrote some code on ProjectEuler too. Now, the next thing I am planning to develop is a tool that can aid blogging for individual websites in python.
So my rule of thumb is :
* Don't waste time thinking crap.. you will never come to a conclusion.
* If you find free time, just grab it.. you won't get it again..
* If you have grabbed it, do something useful.. anything.. if you feel like adding two numbers in BrainF**K go ahead.. you want to learn lisp.. do it.. Make sure you enjoy it..

You can find my BrainF**K interpreter here.

Sunday, November 05, 2006

Aha! Iam secured :-)

Yesterday at around 12.30 AM, while I was travelling in a markov chain (Its the geeky way of telling - 'jumping from one page to another' :-) , I stumbled upon this blog which was very informative and had the information that I was looking for. But I had certain queries regarding his posts and additional information and so I wanted to send him a mail. Why not just comment him dumbo ? Well, thats a good question but the problem is that blog was inactive for almost a year and so I wasn't sure about whether he will see the comments. I wasn't able to get his email-id anywhere on the blog, so I moved one step up the path and found out his personal page. No.. no.. even then I wasn't able to get his email-id. At the bottom of the page I found out a note saying that...

If you want to communicate with me securely, here is my GPG public key. The finger print is:
5819 1940 26C1 C384 F7E6 478E 611E B7AD 0030 3DBF

Now what the hell in this world was that ? When I clicked that link I was shocked to see half a page of gibberish. So after around 10 mins of googling about this GPG key, I found out that its actually GnuPG - which provides secure data transmission and storage using public key cryptography. I was working in windows box, so I downloaded GnuPG for windows and started fiddling with it. Now, I have my own secret key-public key pair. All I need to do is import his public key and it shows his email id. To send a encrypted mail, I type in the mail and encrypt it using his public key and send it to his email.

Here is my PUBLIC - KEY and my finger print is :
2277 A64F 901A 9E14 5ADC 0AEE 86DB 97A9 FC70 B8C2


Tuesday, October 24, 2006

Iam back with my first J2ME mobile application

Time is always against me and it took me a while to elude from its vicious loop and here I am, back at blogville, with yet another facinating experience of mine.
A couple of days ago I bought a small, slim and one hell of a powerful device called a bluetooth dongle. Its really surprising to know that, such a negligibly small thing could do much more than one could expect from it. All my life I have been trying to slaughter the boredom and this time it was once again programming that helped me. Its not the same programming that I was acquainted with for the past few years. This time it is programming on J2ME (Java 2 Micro Edition). I knew long before that J2ME is a platform for developing applications for mobile devices but the very reason that I din't have a Java enabled mobile phone prevented me from trying it out. After I became the owner of a Nokia 6111 there weren't anymore valid reasons. But to be honest, I got the idea of making my own game (although the game is very simple, it isn't that easy) only after dissecting an existing game's jar file. When I was going through the code most of which was greek and latin, I realized that it wouldn't cost me much to build an unsophisticated game like 'cows and bulls'. So with this I tried my hands on J2ME.

Screenshot of my game running in Wireless Toolkit's Emulator-


















Source Code-
Game.java - Program that simply performs the task of 'Cows and Bulls'
GameMain.java - Program that connects the J2ME framework and Game

Soon I will post a small tutorial on how to get started with a J2ME application, althought Iam not a pro at it.

Friday, June 23, 2006

"Eternal Desktop" using TightVNC

Ever wondered as how to access your desktop when you are out of town ? How good it feels when you watch someone troubleshooting your system remotely ? YES! All this is possible with TightVNC. TightVNC is a software tool that enables you to access your desktop remotely from anywhere in the world.
What attracted me the most while using TightVNC is its simplicity. Its very easy to install and configure. For those who don't have a TightVNC viewer( A default viewer provided along with the installation kit ) can use the internet explorer provided you have a JRE. Here are the steps for installing and running TightVNC.
  • Download TightVNC by clicking here
  • Install the application
  • Launch TightVNC Server
  • Enter a password in the password box
Thats it! All you have to do now is, ask your friend or colleague to open their web browser and type in the address http://:5800/ and tell them your password.

Saturday, May 06, 2006

TCO '06 tempest is abated!

TopCoder 's contests, even if its a SRM(Single Round Match), always creates a feeling of thrill and excitement in the hearts of many programmers. Although I din't participate in many contests, I recently had the previlege to watch the TCO '06 live in the topcoder arena. TCO also known as TopCoder Open is a contest that is conducted annually by topcoder to pick the top programmers from the world. This time it was conducted in one of the coolest and the most loved city of USA - Las Vegas! 48 topcoder members competed in 3 semifinals and one wildcard round. 8 of them reached the finals. Most of them, including me, were expecting Tomek to win the event but Petr emerged as the champion. Although there are many such programming events like ACM ICPC, the experience & knowledge that you can extract from TopCoder is something that cannot be explained within this margin.
I will cover about TopCoder rules and its Arena in the forthcoming posts.
Check out the photos, videos and blogs for TCO '06.

Saturday, April 29, 2006

Atlast Yahoo realized its Stupidity!

When it comes to business, its very difficult to thrive unless you keep your products meeting the latest technologies. A very good example is Yahoo mail. Google brought GMail long ago and I was wondering why yahoo din't bring cutting edge technologies like AJAX and its Microsoft counterpart ATLAS. Infact, yahoo was surviving due to its "antique" customers and ofcourse its "conventional messenger".
But I think, yahoo realized lately that it can't continue satisfying its customers with its old mail interface. So it finally brought "Yahoo Mail Beta". I don't think it has given the options for .co.in users. But for others(.com) here are the steps to be followed to upgrade your account.

>> login to your account
>> Click on the Options on the top right corner
>> In the new window, Click on the account information to your left
>> Enter your password once more
>> Click 'edit' in member information
>> In the resulting window, find out what you have in the "preferred content"
>> If it is something other than, "yahoo! united kingdom" then click it and select "English-United Kingdom" in the drop downlist box
>> Then re-enter your password and click "I Accept"
>> Finally, click "Finished" in the bottom of the page

Here is a snapshot of my upgraded account!



But I still feel GMail rocks!

Thursday, March 23, 2006

Don't ever run your system for more than 49.7 days!

What is the maximum time do you think that a normal windows operating system can run ? Theoritically, there can't be a limit. But windows do have a limit of 49.7 days after which it may restart(mostly it will). The reason is windows uses the EAX register(32 bit) for storing the time in milliseconds elapsed since the system booted. When this value gets larger than 2^32 - 1 the clock resets. This value, the one present in the EAX register, can be retrieved by the system call GetTickCount API and is used by many core dlls and exes running in a normal windows session.
When you conver this 2^32 - 1 into days, it comes to 49.7 days and thus the whole story.
The problem persists in windows 98 and 95. I don't know whether it exists in XP.
For more details click here.

Tuesday, March 21, 2006

Its time for migration!

Long since I got a free space from bulldog.mutt.in I was planning for migrating there, but somehow I wasn't able to do so. Finally, I have decided to use that space for something meaningful. I have a miniature website residing in my server space. Although I am blogging in my own site, Blogspot will remain my official blog.