Tuesday, December 31, 2013

[Travelling Raconteur] My trip to New York City

NY skyline from empire state

To be frank I do not know how to write a travel blog, and this "wikiHow to write a travel blog" is of not so much help here. Anyways I would just start blabbering, So I went to New York with so much excitement and hope that I am going to "World's awesomest city". I took "Greyhound", with an 8 hour journey, and it was too tiring. Seats were not so comfortable, I used to travel with better seats in India. The only good thing was it having a restroom, giving my bladder a good time during the journey.
We reached NYC around 7 AM at Times square, but we were not able to find a Subway, so a guy came up to me and asked if I want any help, I said, "Sure, can you tell which direction is Subway station". He said come with me, and took me towards a street outside bus station and told me the direction. Just when I thought how good are NYC people, he shouted "Aye man!! Don't you think you owe me a tip" in an intimidating tone. I replied that I didn't have any money, and kept moving. So, I got this recollection where, if I had asked the same thing in India, many people would have come forward and helped me, trust me, telling direction is passion in India. 

Food cart guy selling falafel
First day, I went to Columbia University, my dream destination as a student (Anyways it rejected me). The university at first look was really beautiful, though a bit small and compact. One awesome thing I observed was, there was a Japanese family taking pictures there, as soon as the father clicked a beautiful picture of the rest of the family, his both daughters bowed and thanked him for clicking it, got amazed and moved at the same time. 

Before reaching Columbia we got lost and walked all over the streets and reached to Morningside Park (it was beautiful). After all this walking I got really hungry, and ate Falafel from a roadside food carts. 
In the evening we had an amazing dinner at Dhaba on Lexinton AV. The chilling wind made our life hell, while waiting outside for table getting cleared for us. 
On Christmas day (next day), we just went to see lightnings, on TSq. Let me share a few Google Awesome pics with you:

 



We also had an amazing time eating "chicken over rice" from halal food cart. It got special due to cold weather, we had to move into the subway, and ate sitting on the subway floor. If you visit NYC do not miss eating from here, one of my friends told that he had seen several Bollywood celebrities eating from here, sitting right there next to the cart, who knows you might get lucky.

I was damn cold on that day, but still it was one of my best Christmas. Last to last year on Christmas this was how I celebrated with family, which was equally special. We decorated Neem tree. I was too tired at night due to all the walking so we just bought this NYC pass, which helped us next day visiting almost all the awesome places in NYC at cheap rates. Do not forget to buy this before you are planning to visit NYC, would save you a load, and "Aye man! You can tip me later" (*wink*).

26 December, 2013 would never be forgotten because of two reasons, one I had an awesome time sight seeing NYC, and secondly walking almost 16 miles. In the morning after taking a NYC pass card we went straight to the Hudson River bank near "Pier 83". Where we got water taxi and we hopped in, went near the WTC. I really regret not visiting the WTC memorial pool, do not miss this if you are going to NYC. Anyways, from there we went to Liberty island, and got mesmerized by its beauty. It was a clear beautiful day, and we got the best shots in my camera. Unfortunately, I could not place a Chinese couple, by taking their pics. They were certainly not impressed.
Our last destination was Empire state building. I have no words to write how beautiful it was, looking down from the sky, watching tiny bulbs coherently creating an artful scenery. It was the moment which I would never forget. Just a piece of advice, visit ESB only after sunset, the night lights and the scenery is beyond words awe-inspiring. I have deliberately skipped writing about "Madame Tussauds", it was good too, and one must not forget to visit this. But there is not much to share about its experience, except the 4D show which was quite amazing.

In the end, there were many more moments I wanted to share but don't want to stretch my blog too far. All I would say is this was a refreshing visit I doubt I would ever forget. I would like to thank a few friends who helped me stay and have fun, making my trip as enjoyable as it can be, Amit and Prateek for helping me stay, Neha and Akshat for coming down and enhancing the fun factor, Arpit for giving me an awesome treat and conversation, Rahul for boring me to death as well as sticking out with me almost everywhere. 
Let me leave you with a few pics, and since this post is my last blog of 2013, happy new year to all, have a nice time ahead.
Times Square
A guy getting angry for taking his pic while I just wanted to
take picture of street with roadside shops just like we have in India













Not that different from India, eh!













Christmas Lightning


Saturday, December 14, 2013

[How To] Write a script which notifies and alerts you in Linux

Finally I got free from my End-Sem exams, phew! But not so fast, I have to manage many things in my one and half months of winter holidays and that too in this chilling weather of Buffalo.
One of the most important things on my priority list is to pay my next semester's fees. Now here is the problem, it is really hard to track USD to INR rate. I had to go to XE or Yahoo Finance to know the current exchange rate. This gave me hard time, when the rate is changing continuously with high variability. So I decided to write a script and run it as a daemon or cron job which will notify me if the Dollar falls or rises from a particular threshold.
For this purpose, I have chosen Elementry OS/Ubuntu which is installed in my system (and BTW, my laptop can almost serve as a server, as I rarely switch in off. At best I would just make it go to sleep mode for a few hours). I would use Python and Perl for this purpose.
So let me show you how I did it. First, let's make a script which would notify me on desktop if I am The rate falls below a threshold, we will call this a notifier script:


notify.py


#!/usr/bin/python
import sys
import pynotify

if __name__ == "__main__":
    if not pynotify.init("icon-summary-body"):
        sys.exit(1)

    n = pynotify.Notification(
        sys.argv[1],
        sys.argv[2],
        ##dont remove the below line
    "notification-message-im")
    n.show()

This script would simply use the Ubuntu notification system and would notify you on top-right corner of your screen. (See screenshot)

Now we are ready to make a script which would continuously fetch the current exchange rate, but before that I also want that if I am not at my desk or not using the computer I must be notified through email. For that I would install, sendmail. It is really easy to install sendmail in Ubuntu, just fire this command:
sudo apt-get install sendmail
also create a filter in your mail box which would not send mails sent from your computer to spam folder, and test everything works properly by firing this command:
echo "Dollar Rate" | mail -s "Rate is at 61.67, just to inform you" your.mail@gmail.com 
Now you must check your mail box, you would have received  a mail like this:

I wrote a Perl script which uses Yahoo Finance API and keeps check of current exchange rate:

check_dollar.pl


use strict;
use warnings;
use LWP::UserAgent; 
use LWP::Simple;
# my $url = "http://rate-exchange.appspot.com/currency?from=USD&to=INR";
my $url = "http://finance.yahoo.com/webservice/v1/symbols/INR=X/quote?view=basic";
my $oHTTPAgent = new LWP::UserAgent;
my $oRequest = HTTP::Request->new('GET'); 
my $i =0;
my $old_fh = select(STDOUT);
$| = 1;
my $rate;
select($old_fh);
while(1)
{
 $oRequest->url($url);
 my $sResponse = $oHTTPAgent->request($oRequest);
 if ($sResponse->is_success) {  
     my $sPage = $sResponse->content; 
     ($rate) = $sPage =~ m/price\">(\d+\.\d\d)/g;
     $i++;
     print $i."\t".$rate."\n";
     if($rate<61)#set your threshold
     {
      my $xpl = `python /path/to/notify.py "Rate is" "$rate for 1 dollar"&>/dev/null`;
      my $yoyo = `echo "Dollar Rate" | mail -s "Rate is at $rate, just to inform you" everlasting.puneet\@gmail.com`;
     } 

 }
 sleep(60);#set ping frequency, right now it would check in every 60 seconds
}

Now we are all set, all we need to do now is to start this process. If you can observe I have used an infinite while loop, if I want to make a cron job of this script I need to remove this loop.
Now either run the script as it is by inserting right path to "notify.py", or if you want you can remove while loop and write cron job like this:
Run
crontab -e
This opens an editor. Therein you type :
*/1 * * * * perl /path/to/check_dollar.pl
We are all done, I hope you can be creative and add more type of notifications, and alerts. 

Tuesday, December 10, 2013

A note on AAP's Success - Part 2

Source: Wikipedia
The problem with frivolous intellectualism is it always hyper-reacts. Before the Delhi election everybody was busy under-estimating AAP and now everybody is busy over-estimating and over analyzing the AAP phenomenon. We get to hear such humungous theories from TV studios as to how AAP would now be a national party and how Arvind Kejriwal would be the PM candidate of the third front! Nobody bothers to tell us how AAP will replicate its limited success of a rootless city like Delhi in other metros; for instance, how will AAP gather votes in Mumbai where the fault-lines are between Maharashtrians and outsiders, or say in Hyderabad where there are agitations for and against Telangana or even in say, Lucknow, where the politics of identity is foremost.

Even the success of the AAP in Delhi is a one-off phenomenon that has come about through a string of coincidences – a very unpopular government, agitations of the past year on a range of issues from corruption to women’s safety, passionate participation of youth (who have long-term attention deficiency as always) and a moribund opposition which woke up much later in the day and yet managed to be the single largest party. Arvind Kejriwal is making a classic mistake once again. He is taking this one-off support of the people of Delhi for granted and wants to go to the polls once again based on some ludicrous suggestions that AAP has the momentum and will gain a 2/3rd Majority in a re-poll.

What is more likely to happen is quite the opposite;
  • Voters passion would have come down a couple of notches in about 3-4 months and AAP would never be able to get the same kind of volunteer participation as they got this time, no matter what kind of funds they manage (this is exactly what happened to the Anna movement which eventually fizzled out despite the huge initial success) 
  • With the passage of time, basic every day governance delivery issues will become important and the greenhorn MLAs of AAP would be answer less to voters queries especially in a situation where there is no government 
  • The Voter anger against Sheila Dixit would also be much reduced in a few months’ time and all Congress needs to do is regain some 3-5% of the vote share to overtake AAP 
  • If Delhi elections are held along with LS polls, which is the only practical possibility as far as the EC policy on re-polling is concerned, then AAP would come a cropper as it is a well-established fact that almost 65% of AAP voters want to vote for Modi in the LS polls 
  • Even if Delhi elections are held separately, all that BJP/Congress has to do is manage better ticket distribution by giving more tickets to young professionals rather than tired old faces and AAP would lose its only USP 
  • At least half a dozen seats are such where AAP has won by a very narrow margin and as such it won’t be sustainable in another election 


At the end of the day, far from going national, AAP stands vulnerable in the only state that it has performed, as we move closer towards the 2014 elections.


[PS:
  1. I am not the Author of this blog. This blog is taken from excerpts of: http://5forty3.wordpress.com/2013/12/11/what-2013-means-to-2014/comment-page-1, Please go and read the amazing and neutral analysis of 2013 election done by DR PRAVEEN PATIL on this blog.
  2. This blog represents exactly what my opinion is about AAP's success. Not that I don't want it to succeed but the media are overdoing everything. AAP is important to the nation, it changed political discourse, but let's keep in mind that we must not overestimate in excitement.
]