Sunday, March 27, 2016

How similar is Lalu Prasad Yadav and Donal Trump?

Its amazing how two people continents apart could be so similar. We recently analysed personality of Mr Lalu Prasad Yadav and Donal Trump and the results are:

Comical Character:

Both these personalities are favourite of Caricature Artist. See the images below:

Both of these characters have been favourite of SitCom and Standup Artists. Check out the video below:

Both indulge in "polarization of masses" for politics:

Lalu Prasad have always supported caste based politics in India, and have divided the country based on caste and have supported Reservation in the Country based on the caste. Thats one of the major reason of his popularity. 

Laloo have gone to the extent of using a look alike of Osama bin Laden in an attempt to woo Muslim voters. Luckily enough this move backfired.

On the similar lines, Donald Trump is trying to polarise the US metropolitan society by going against  muslim comment and Mexican immigrants to gain popularity. He is advocating banning of Muslims from US.

Speaking irrationally without thinking:

Donald Trump Heaps Insults on Lindsey Graham, Jeb Bush, Hillary Clinton, Other Foes. 

Laloo on other end have accused LK Advani of a conspiracy to assassinate Md Ali Jinnah and described him as an international absconder.

4.5 billion Rich...

Donal Trump has a current net worth of $4.5 billion. He had inherited around US$200,000 from his father. 
While Lalu Prasad Yadav have siphoned around Rs 4.5 billion in fodder scam. 

Lots of Children

Donald Trump have 5 children with 3 wife.

While Lalu has 9 children, google faces problem to fit answer to this question in single screen ;)

Legal Cases:

Lalu have been convicted in corruption case. He has been charged for Fodder Scam, Disproportionate Asset cases. He had lost his parliamentary seat for being convicted for Fodder Scam. Though lots of cases against him are been closed by a plea from Nitish Government.

Donald Trump have been involved in various legal battle through out his life though case of corruption have been registered against him.

Media Painting Wrong Picture of Bihar

In recent discussions with a friend who being a die hard Laloo and RJD supporter came up with a claim that crime have gone down in Bihar since the government came into power. I doubted his claim, for this he pulled out some articles which were a mockery of data analysis.

The author of this article is comparing 6 months of data to 2 months of data. Which is wrong. Moreover, the swearing in ceremony was on 20th November, so I am not sure how can this month be included in the average.

Moreover crime rate is very seasonal so the month to month comparison needs to be done or equal amount of months must be taken in analysis. Taking average is skewed for crime.

So I have done the analysis on above principles and found the following:

The crime rate has increase in Bihar since the Government have come to power:

And if i see the seasonal crime rate in Bihar, then following is the anlysis:

Both the analysis has data from Police Department. I seriously wonder whats the state of reporting or how much advertisement fees of DailyO comes from RJD?

Wednesday, December 16, 2015

Determining image file size in Javascript

After a lot of googling and searching, I realized the best way to do this is to create a service call to the backend witht he url of the image whose size needs to be figured out.

This service should make a HEAD call to the server to get the content - length. And pass it along as a response.

Not all servers support HEAD calls so as a fallback make a GET call to the get the request and determine the file size from the headers.

We need to set few headers for this to work universally. One of them is user-agent.

Code for the same is :

private void makeRequest(@FormParam("url") String url, Map response, String requestMethod) {
    try {
        HttpURLConnection urlCon =
                (HttpURLConnection) new URL(url).openConnection();
        urlCon.setRequestProperty("User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0");
        //urlCon.setDoOutput(true);        urlCon.setDoInput(true);
        urlCon.setConnectTimeout(2*60*1000); // 2 minute        urlCon.setReadTimeout(5*60*1000); // 5 minute
        if(urlCon.getResponseCode() == HttpURLConnection.HTTP_OK)
            String contentLength =  urlCon.getContentLengthLong()+"";
            String contentType = urlCon.getContentType();
        else        {
    catch (Exception e)

Monday, December 14, 2015

Most expensive product on Amazon India By Category

Amazon India today has become the most visited e-commerce site in India. So, I decided to analyze the most expensive products that Amazon India Sells across various category.

So lets start.

Book worth Rs 53,46,000.00

This is quiet modest. I think its a must in every library!

DVD worth Rs 40,045.23

My kids are gonna die uneducated :(

A Flip Cover worth Rs 255,255.00

I would get around 40 actual Micromax Juice phone at the same price.

A pen worth Rs 1,700,000.00

"No doubt a pen is mightier (worthier) then a sword"

Telescope worth Rs 896,000.00

This might actually be a fair price. Should understand technical part of it to comment. Help!

Spoons worth Rs 2,183,731.00

I might by a house with a kitchen at the same price. Though each spoon would just cost you mere 33,000. Thats a relief!

A Game worth Rs 868,434.00

That might be correct again, with import duty on all. I don't know.

MultiGym worth Rs 2,950,000.00

Someone from gym community should comment on this

A bath cereal worth Rs 2,010,000.00

Just 20 lacs for it. I am not sure it would be most expensive breakfast ever or bath ever.

A pair of Socks worth Rs 200,997.98

Ahem! my feet feel warm.

A Shoe worth Rs 102,035.00 

(One of the variants with size 44)

Just for one variant price shoots up 5 times, can't a computer catch that.

A Bag worth Rs 90,000

I am not a fashionista. This might be fair.

So if you are feeling rich today then dare buy one of the above products. My favorite in the list is the flip cover.

Intent of the post is to show disparity in the pricing on the most visited E-Commerce site in India, and need for a AI based Anti-Spam engine on such e-commerce sites to keep a check spam pricing. Some people might actually end up ordering these by mistake. I hope not.
Jeff Bezos, are you listening!

Update 1: Amazon have responded to the query raised by this post. They have accepted that they do need a mechanism to detect price spam. Yoohoo! I love there Customer Service! Snippet of the response is below:

Fixing Deployment.AddInAlreadyInstalledException.

If you are building any VSTO for any of the office applications, then its quite common to run into this issue.

The error message would say that

"The customization cannot be installed because another version is currently installed and cannot be upgraded from this location. To install this version of the customization, first use Add or Remove Programs to uninstall this program: TestUpdatedVersion. Then install the new customization from the following location: file:///D:/Samples/TestUpdatedVersion/bin/Debug/TestUpdatedVersion.vsto ********** Exception Text ********** Microsoft.VisualStudio.Tools.Applications.Deployment.AddInAlreadyInstalledException: The customization cannot be installed because another version is currently installed and cannot be upgraded from this location. To install this version of the customization, first use Add or Remove Programs to uninstall this program: TestUpdatedVersion. Then install the new customization from the following location: file:///D:/Samples/TestUpdatedVersion/bin/Debug/TestUpdatedVersion.vsto at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.VerifySolutionCodebaseIsUnchanged(Uri uri, String subscriptionId, Boolean previouslyInstalled) at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.InstallAddIn()"

So let me explain a fool proof way to troubleshoot this. Would be quite useful for Support Engineers.

  1. Go to Control Panel and search for this application plugin. If its listed then try to uninstall this and then re run the set-up. If its not listed or re-running the setup.exe fails then continue with step 2.
  2. Try cleaning up registry and installed file list by using a "Fix it" package from Microsoft, available here
  3. Now most probably the application is uninstalled but it has left behind some registry. So let clear them. 
  4. Press Start+R. In run command prompt type regedit and press enter.
  5. Clear any application related keys from 
  6. In registry editor go HKEY_CURRENT_USER\Software\Microsoft\Office\/Addins/
  7. to HKEY_CURRENT_USER\Software\Microsoft\VSTO\SolutionMetadata\{GUID} and clean up the entry for the VSTO. Check on the right side of the screen to figure out the right registry entry.
  8. Then check if there is an entry for HKEY_CURRENT_USER\Software\Microsoft\VSTA\Solutions\{GUID}. If there exists an entry then clear this up too. 
  9. Now First you would have to install Visual Studio 2013 Community edition from here,
  10. This should result in download of mage.exe with its dependencies. Then going to C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin you should see mage.exe there.
  11. Then cd into the location for mage.exe in commandprompt.
  12. Run the following command there: mage.exe -cc. It should produce an output "Application Cache Cleared"
  13. Now reinstall the VSTO by running the setup.exe. This time it should go through for sure. If it does not then please do leave a comment.