Posted: September 18th, 2011 | Author: naduism | Filed under: Uncategorized | 2 Comments »
Here are my 2 hacks at the Foursquare Hackathon
Accessible NYC is mashup which gives information about which Subways, Parks, Playgrounds, Restrooms (the usual Public places) around you are accessible (meaning accessible via wheelchairs). This was built using Foursquare, which has a wealth of data on places in the city and the NYC Gov data, which has information about which public places like parks, subways are accessible. It was a good challenge (need to make to more robust) trying to harmonize the NYC Gov data and the Foursquare Venues data.
Accessible NYC Demo
The second hack was more of a quick 2-hour effort, which was to be able to come home and talk to your computer and check into your house. Has been tested only Chrome (on Windows) and uses the HTML5 speech input feature and the Foursquare checkin API.
Talk In
Feedback from the people.
This was fun
Posted: September 5th, 2011 | Author: naduism | Filed under: Uncategorized | Tags: corruption, data-viz, india | 6 Comments »
This is an effort to compare and contrast the amount of money lost by the Government in various scams to that of the money exchanged when the country’s citizens take the shortcut or the easier path to get things done quickly, or in some cases where they are forced to pay bribes to Government officials.
Bribes exchanged in the Passport process
In Passport issuing process, there are couple of police verifications that are done. Basically, a policeman would come to your residential address and ensure that you are physically present there at the given address. Of course, that’s not always possible because say you are studying in a college in Chennai and your Passport has been applied at the Passport Office in Mumbai (because your parents stay there). So, the policeman might be happy to take a bribe to help you out in this situation. This might be the same with the “CBI verification process”. In other cases, sometimes citizens are required to pay extra “chaai-paani” so that the file is passed from the Police officer’s desk to the next Officer in the Passport Issual process.
As per this article, Pune issued 1.29lakh passports in 2010. Lets take an estimated figure of 15 lakh Indian passports total being issued in 2010. Assuming 75% of the people pay Rs. 100 each bribe for the police verification and the CBI verification. So the amount =
15 Lakhs * 0.75 * 200 = 2250 Lakhs = 22.5 Crores of money in bribes for issuing a passport. This amount is about 1/8th of the amount of money lost by the Exchequer in the Taj Corridor scam.
Driving offenses and bribes
Now lets take the case of driving offenses in India. According to this article, a total of 2,41,392 challans were issued in Haryana during 2010 while Rs 6,36,10,640 was recovered as fines. Now, assuming that 70% of the time challans were issued and the rest of the time, people got away paying a bribe. The loss to the Government ~= 2.725 crores in Haryana, extrapolate it to 10 major states of India, we will reach a ballpark figure of 30 crores – which is around 1/3 of the amount of money that the Exchequer lost because of the bungling of contract terms for setting up the Timing, Scoring and Results System during the Commonwealth Games 2010. (Source)
Bribes exchanged in the Registration process (land registration, birth & death certificates etc)
On the site ipaidabribe.com, under the registration category, the amount of bribe reported to have been paid is around 809 Lakhs of rupees. We can take say, 75% of that figure as the bribe paid per year (as it is spread around 1.5 years) and then extrapolate the amount of bribe paid in the entire country for registration. So 75% of 809 Lakhs and then say around 10 times for the entire country. Why 10 times? ipaidabribe.com is accessible to only to educated people with an internet connection to submit their grievances. So, 10 is a good (conservative) estimate for the entire country.
So, the ballpark amount paid in registration bribe per year is ~= 60.67 Crore rupees. That is around 70% of what was the loss to the Exchequer in the Kargil Casket Scam (around 85 crores).
Ticket-less travel
As per this article in the Financial Express, the Indian Railways loses around 1000 crore rupees in ticketless travel in a year. 1000 Crore is a huge number. To put it into perspective, it’s about twice as big as the Telgi Stamp paper scam.
It’s interesting to observe that the amount of money that is exchanged/lost in the bribing process or say taking short cuts to get our work done quickly, can at times compare to some of the pretty big scams in our country. Sidin Vadukut phrased it pretty well – “Anti Corruption begins at home”
References
- http://www.financialexpress.com/news/fine-on-1cr-ticketless-travellers-helps-rlys-rake-in-rs-399-cr/640191/1
- http://articles.timesofindia.indiatimes.com/2011-05-23/gurgaon/29574000_1_challans-road-accidents-gurgaon-traffic-police
- http://www.ndtv.com/article/india/cwg-scam-first-cbi-chargesheet-likely-today-kalmadi-may-figure-107065
Posted: September 2nd, 2011 | Author: nramakrishnan | Filed under: Uncategorized | Tags: javascript, technical | Comments Off
It has taken me time to fully understand the concept of closures in JavaScript. Here is an example of code that I rewrote so that we can use closures and get the thing to work the way we actually want it to.
The situation:
We have a set of buttons and we have to attach on-click handlers to them. These handlers should be called with parameters that are button dependent i.e., the innerHTML of the text box next to that particular button or say we need some attribute of the button (data-value, or some custom attribute).
We want to attach a function inviteUserToGroup with the specific parameters as event handlers to all the buttons.
So we initially wrote :
//add event handlers to invite buttons
var inviteBtns = $$('.inviteBtn'); //Prototype to get an array of elements with this class name
var len = inviteBtns.length;
var i;
var groupIdForUser;
var detailsForUserInGroupName;
for(i=0;i<len;i++){
groupId = $('groupIdForUser'+i).innerHTML;
details = $('detailsForUserInGroupName'+i).innerHTML;
//Protoype syntax to attach event handlers
//Event.observe(element,event,handler)
Event.observe(inviteBtns[i],'click',function(){
inviteUserToGroup(groupId,i,details);});
}
function inviteUserToGroup(a,b,c,d){ doSomething();}
So, we attach inviteUserToGroup method with the parameters. Since we enclosed the handler as a function, one can assume that due to the scope of the function, it should work fine and the event handler will be called with the correct parameters. That doesn’t work that way. All the event handlers get called with the value of i = len. You thought closures would work here, but it does not.
So what do you do? Create a real closure. The following code does that
/* DOES NOT WORK
Event.observe(inviteBtns[i],'click',function(){
inviteUserToGroup(groupId,i,details);});
*/
Event.observe(inviteBtns[i],'click',
(function(gId,i,dtls){
return function(){
inviteUserToGroup(gId,i,dtls);
}
})(groupId,i,details)));
So what is happening?
1) Create an immediate anonymous function which takes in the parameters that you want in your handler.
2) In the anonymous function return the actual function with parameters that you want to call. In this case we return inviteUserToGroup() with the parameters.
The important point to understand is that, the immediate function will execute and hence have the current values of groupId, details and i, which are passed to it. Due to the closure, the inner function (which is returned) has access to these values even after anonymous function has completed execution. So, inviteUserToGroup is attached to each button with the correct parameters.
For completion, another way of doing this is
Event.observe(inviteBtns[i],'click',
'inviteUserToGroup('+groupId+','+i+',\''+details)');});
Not recommended by many people as this uses the eval function to evaluate the JavaScript inside the quotes.
Is there a better (maybe more legible) way of doing this? Let me know!
Posted: March 27th, 2011 | Author: nramakrishnan | Filed under: Uncategorized | Comments Off

I have started painting using watercolors again. It’s a beautiful feeling. I realized that I could create different skin colors using the paint and that can either lead to a cartoon like these or something different. Just loved this idea!
Disclaimer – This is the first time I tried drawing Tux.
Posted: January 28th, 2011 | Author: nramakrishnan | Filed under: Uncategorized | Tags: json, json_decode, json_encode, php, utf8_encode | Comments Off
Wanted to share this with the group since it took me 3 hours to figure this out.
I was trying to retrieve JSON data from a third party service using a PHP.
In PHP , if you use curl_exec() functions to retrieve JSON data, it returns it in a string form. You can do json_decode($string, true) to retrieve it in an associative array form.
$url = "www.example.com/data.json";
$curl = curl_init();
curl_setopt( $curl, CURLOPT_URL, $url );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
$result = curl_exec( $curl );
curl_close( $curl );
$return = json_decode( $result, true);
echo $return["description"];
All is fine if your json data doesn’t have special characters like “é”, for example
{
"description":"Eric Benét performs.",
"origAirDate":"2011-01-27",
"stationId":11269,
"endTime":
"Thu Jan 27 11:00:00 EST 2011","startTime":"Thu Jan 27 10:00:00 EST 2011",
"title":"The Wendy Williams Show",
"isVisible":true,
"rating":"TV-PG"
}
To handle these special characters make sure that you do
$result = utf8_encode($result); // before json_decode
$return = json_decode( $result, true);
echo $return["description"];
Source
Hope this helps
Posted: September 17th, 2010 | Author: nramakrishnan | Filed under: technical, Uncategorized | Comments Off
Setting up ns2 on Ubuntu (Lucid Lynx 10.04),
$ sudo apt-get update
$ sudo apt-get install build-essential autoconf automake libxmu-dev libxt-dev libxt6 libsm-dev libsm6 libice-dev libice6 vim
Download ns-allinone.2.34.tar.gz – http://sourceforge.net/projects/nsnam/files/allinone/ns-allinone-2.34/
$ tar -xvzf ns-allinone.2.34.tar.gz
$ cd ns-allinone.2.34/
$ ./install
You might hit the error
otcl-1.13 make failed! Exiting
Solution
in otcl-1.13/configure file -
replace
Linux*)
SHLIB_CFLAGS="-fpic"
SHLIB_LD="ld -shared"
SHLIB_SUFFIX=".so"
DL_LIBS="-ldl"
SHLD_FLAGS=""
;;
with
Linux*)
SHLIB_CFLAGS="-fpic"
SHLIB_LD="gcc -shared"
SHLIB_SUFFIX=".so"
DL_LIBS="-ldl"
SHLD_FLAGS=""
;;
This should work now.
Note for this to work the CC value in Makefile.in inside otcl folder should be @CC@. It did not work when I changed it to gcc 4.3
Hope this helps