Rest in Peace Steve Jobs

Posted: October 6th, 2011 | Author: | Filed under: technical | Comments Off

The man who was and always will be an inspiration to everyone. Rest in Peace.

Steve Jobs

Image Credit: Diana Walker


Hacks @ Foursquare Hackathon NYC

Posted: September 18th, 2011 | Author: | 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 :)


My new friend Marvin

Posted: September 6th, 2011 | Author: | Filed under: technical | Tags: , | Comments Off

Given my anti-social tendencies (read not logging on to Facebook for 3 months at a stretch), I decided that I needed a new friend.

My Friend Marvin

My Friend Marvin

Marvin (the paranoid android) is built out of waste thermocol (that came with the packing of my monitor). It has a small red breadboard attached as it’s heart. The light on the heart glows green if there are more tweets with positive sentiment going around in the (All izz well) and glows red if there are more tweets with negative sentiments going around in the virtual world. (I took about a handful of words like “environment”, “plastic”, “global warming” etc. as the baseline hashtags to be analyzed for sentiments) More on the implementation of the Arduino controlling the LEDs can be found in the Project Cycles post here

My last Labor Day weekend project was drawing this, I am happy that the trend of doing something I love during the long weekend has continued.


A perspective on bribes, scams and corruption

Posted: September 5th, 2011 | Author: | Filed under: Uncategorized | Tags: , , | 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

  1. http://www.financialexpress.com/news/fine-on-1cr-ticketless-travellers-helps-rlys-rake-in-rs-399-cr/640191/1
  2. http://articles.timesofindia.indiatimes.com/2011-05-23/gurgaon/29574000_1_challans-road-accidents-gurgaon-traffic-police
  3. http://www.ndtv.com/article/india/cwg-scam-first-cbi-chargesheet-likely-today-kalmadi-may-figure-107065

Project Cycles

Posted: August 13th, 2011 | Author: | Filed under: technical | Tags: , | Comments Off

The weekend of August 5th -7th 2011 was one of the most memorable weekends in recent times. I was participating at the Art Hack weekend organized by the Creators Project at Eyebeam. It was a  two-day, open-source hackathon (hacking+marathon) that celebrates new artistic experiences.

The goal: We were to design, code and prototype projects that re-imagine the way people create, consume, and interact with media.

tl;dr – Jump to straight to video
The participants (around 75 in number) met up on Friday at Eyebeam to socialize and form teams. Each of us introduced ourselves and talked about our skill sets (what we brought to the table) and also mentioned any ideas they had in mind for the weekend. It was very exciting for me as it was the first time I was participating in a hackathon that involved people other than just developers. It was a wonderful way to understand and see things from a different perspective. After the round of introductions we were “left loose” to mingle around and talk to people with whom we wanted to collaborate for the weekend. I had no particular idea in mind, but my criteria was 4-fold.

  • Work on something interesting for the weekend
  • Get out of my comfort zone
  • Work on something that would increase social awareness and make people think
  • Have :awesome: fun

One of the participants, Mark Stafford, a fine artist by profession, said that he wanted to work on an art installation made up of waste material. That triggered a bell for me as I am interested in waste management, recycling and all that good stuff. Soon, Mark, Meredith and me were sitting and threshing out our idea for the weekend. It took us to about 5-10 minutes to decide that the idea was something all of us wanted to invest our time and energies in.

So here is the idea and what we wanted to build -

We as a race are progressing at pretty good speed on the technology front. We keep building more and more devices, connect more and more in the virtual world, get more and more impacted by the technology around us. All this progress does leave something behind. Project Cycles, is an attempt to describe the life cycle of our digital, virtual and physical environments.The installation – a dying rabbit, signifying the flip side of technological progress, would be a living, breathing form that conveys this message. It carries the burden of the ill-affects of technological progress. We wanted to create an interactive art installation that would react to the environment around it as well as well to the virtual world beyond it. When people would come near it, it would start breathing heavily. The ears of the rabbit would twitch based on the sentiments of the tweets going around the virtual world about things like #recycling, #electronic waste, #environment.  The legs would move involuntarily would be depending on how the leading technology companies are doing on the stock market that day. The eyes would play a flashback of the dying rabbit’s life, when it used to live in a more greener and cleaner planet.

We started sketching some of our ideas on Friday night itself and Saturday morning we had started to put the pieces together. Mark and Saaid (he joined us on Satuday) started building the exoskeleton of the model. Meredith and me were handling the movements of the rabbit based on its sensing of the environment.

If the details below get too technical for you, you can jump to the end here.

The “technical” parts of building the model consisted of mainly 4 things -

- Getting the sentiment analysis of the tweets on relevant topics like environment, recycling etc., pushing those values to an Arduino controlled motors so as to make the ears twitch.

- Using a sonar sensor to sense proximity of the people around it. If someone is very close by, the rabbit would start breathing heavily.

- Connecting a 2nd generation iPod to show the “flashback” of the dying bunny’s life. The iPod would be playing scenes from Animal planet.

- Getting the live stock market feeds of leading technology companies and control the movement of the legs based on their fluctuations.

We were able to implement the first 2 ideas above in the given timeframe of 24 hours and left the other 2 for version 2.0. I was in charge of the getting the sentiments of the tweets and passing to an Arduino and this is how I built it -

Googling for “twitter sentiment analysis” gives out a lot of results and the one that I used was this. What this does is take the last 100 tweets and run a supervised learning algorithm on them to analyze the tweets. The tweets are marked as “positive”, “negative” or “neutral” and then the final sentiment index is calculated based on them.
They have a super simple API call and all I had to do was write a php script to call their API with the parameters. It returns a JSON object which has the analysis of the individual tweets:

{
    "sentiment_index": 22,
    "results": [
        {
            "created_at": "Mon, 15 Aug 2011 00:26:55 +0000",
            "from_user_id_str": "360406363",
            "profile_image_url": "imgUrl"
            "from_user": "alissawehingec",
            "id_str": "102899029364588544",
            "sentiment": -1,
            "metadata": {
                "result_type": "recent"
            },
            "text": "Rain gardens: A practical solution for water pollution"
            "to_user_id": null,
            "id": 102899029364588540,
            "from_user_id": 360406363,
            "geo": null,
            "iso_language_code": "fr",
            "source": "http://twitter.com",
            "to_user_id_str": null
        },...
        //99 more such elements
        "positive": 16,
        "negative": 72,
        "neutral": 12,
        "tweets_analyzed": 100

This is what my php script to make the call looked like

		$topics = array("recycle","plastic","ewaste", "environment","planet","global%20warming","prakriti", "risaikuru", "earth");
		$max = count($topics)-1;
		$index =  rand(0 , $max );
		$url = "http://data.tweetsentiments.com:8080/api/search.json?topic=".$topics[$index];
		$curl = curl_init();
		curl_setopt($curl, CURLOPT_URL, $url );
		curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
		$result = curl_exec( $curl );
		curl_close($curl);
		$result = utf8_encode($result);
		$data = json_decode($result, true);
                // to get the actual values of the sentiments
                $sentiment_index = intval($data["sentiment_index"]);
		$negative = intval($data["negative"]);
		$positive = intval($data["positive"]);
		$neutral =  intval($data["neutral"]);

Once I had the values, I needed to push these values to the Arduino over the Serial port. I was able to use the guide here (I am running Ubuntu) to connect the Arduino and send data over serial using php.
It took me a long time to get this running. All I needed to do was to send 4 key value pairs (index,value). Finally the way I got it to work was to send data encoded in ASCII format (well now it sounds so obvious!). The Serial.read() command of Arduino reads the values that it gets as ASCII values. So for example, the character ‘a’ sent over serial would be read as 97 by Serial.read(). So I had to send numbers (the values) which I encoded in ASCII and sent. So if the value was 62, I sent the value as if it was the character ‘>’ (using the chr() method of php). Here is the code -

                // the protocol followed was s/p/g/n preceded the values
                // the characters s,p,g,n acted as flags
		$serial->sendMessage('s');
		$serial->sendMessage(chr($sentiment_index));
		$serial->sendMessage('p');
		$serial->sendMessage(chr($positive));
		$serial->sendMessage('g');
		$serial->sendMessage(chr($negative));
		$serial->sendMessage('n');
		$serial->sendMessage(chr($neutral));

Final php file can be downloaded here and the Serial class can be found here.
On the Arduino side, this code below reads the bytes sent over the Serial port and if it gets an ‘s’, it reads the next byte which is the value of the sentiment index, if it gets a ‘p’, then reads the next byte which is the value of the positive tweets,.. so and so forth


int neutral, positive, negative, sentiment;
void loop() {
   if(Serial.available() > 0) {
    number_in = Serial.read();
    if(number_in == 112){ //p
      // its the positive number of tweets
      positive = Serial.read();
      Serial.println(positive, DEC);
    }
    if(number_in == 115){ //s
      // its the sentiment index of tweets
      sentiment = Serial.read();
      Serial.println(sentiment, DEC);
    }
    if(number_in == 110){ //neutral - m
      // its the neutral number of tweets
      neutral = Serial.read();
      Serial.println(neutral);
    }
    if(number_in == 103){ // negative - g
      // its the negative number of tweets
      negative = Serial.read();
      Serial.println(negative);
    }
  }
  else{
      Serial.println("Still waiting for serial");
  }
    delay(300);
    number_in = 0;
}

The final Arduino file
Now that I have the values on the Arduino side, I can manipulate the rotation of the servo motors that control the movement of the ears.All we wanted to achieve was to move the left ear slowly (harmoniously) and the right ear violently. Due to lack of time I did not do any great mathematical manipulation, so it was just random servo movements in a loop.
PS -The final php and arduino files can be downloaded here. I wrote a similar version for sending data over serial in python (but it runs only once)
Meredith handled the part of the proximity sensing and making the dying rabbit breathe faster. Mark and Saaid were instrumental in building the model. It was fantastic work in limited amount of time. In the end, the 4 of us were happy to have been a part of it!

Here is the final video of Project Cycles that we presented

Yes, it was indeed one of the best weekends ever! I happened to meet a whole variety of people – artists, designers, developers and actually spent time building something tangible. There was this sense of elation even though we did not win. These were the other projects in the Art Hack.