Today is Wednesday
February 21, 2018

July 6, 2017

Using Browser plugin to crowdsource against fake images

by viggy — Categories: internet, social, software, tech — Tags: , , , , Leave a comment

Recently we have seen an exponential increase in circulation of fake news and images. Fake images play a major role as with some simple image editting, a completely different context can be conveyed. This menace has been used by various political parties to spread their propaganda.
With Google Image search being so powerful, I propose that it should be possible to use a browser plugin to verify the originality of the image. We can use Google Image Search to find other sources where the image is used and hence get different contexts of the image. Once this is developed, a repository of responses from the users may be created where they can easily report images which they feel are being used in wrong context on a particular website. As this repository improves, what we will see is that most of the images can be captured in the repository so that for the same image, we do not have to depend on Google Image Search everytime but rather use the repository itself.

Let us now look at how a common user would use the plugin.
A user who has the plugin installed browses a webpage with different images on it. Suppose he/she is interested in understanding the source of the image, the user right clicks on the image and selects the option, “Search For Source”. Initially, this should cause a Google Image Search Query and the results along with the websource of the images found should be displayed in a dailog box. The user should be given an option of reporting the image as original or fake based on the results shown along with option of marking what the user thinks is the original source of the image along with some comments.
This usecase seems to be a good starting point to release the plugin as version 1.

In the next version, we should be able to first look at the repository of all the reported images and give a much better information about the image based on all previous reportings of the image. As the community grows, we would ofcourse want moderation of reportings to ensure that false reportings by the very people spreading false news is avoided. An open structure similar to Wikipedia would be needed to ensure a fair community is developed to keep the system unbiased and trustworthy.
An API of the repository can also be created so that social networking sites and messaging platforms can develop support in their platform so that when images are shared on their platform, users automatically get the information from the repository. For example, a simple bot for telegram messaging platform can be developed which can be asked to show the information from the repository based on a certain command when a image is shared in a group. Ofcourse we need to ensure that private images from people’s chat is not shared in the repository and necessary checks and balances are put in place for the same.

June 29, 2017

What went wrong with the perfect society that once was?

by viggy — Categories: social — Tags: , , Leave a comment

Every religion seems to claim that there once was a perfect society where people followed the religion perfectly and hence now they claim to take the current society back to such a perfect society. It is always the initial period of the religion which they claim was perfect but then for some reason people stopped following the religious ‘way of life’ and hence we have the current society with all its evils. However, they never say why a perfect society disintegrated to such an evil society. If a perfect society existed, how is it then that it could not protect itself from disintegrating.
While I look at different religions, my claim is that each perfect society if at all it existed under any religion, disintegrated because of the rigidity imposed by the people following the religion. Any religion makes a certain section of the society very powerful, those who claim to understand the religion, who claim to implement it amongst the general public. If a perfect society existed, then the way it would disintegrate is when such people who became powerful thanks to the rules of the religion used it to their own advantage to keep their position of power, thus polluting the society and the religion.
Here I should add a disclaimer that while making such a claim, I am assuming that a perfect society as governed by the religion existed in a certain past. I ignore the claims made by many that religion itself was created to keep the powerful in their position of power.
Now, if you agree to the premise that the perfect society disintegrated because the powerful people misused it to keep their position of power, then couple of questions definitely arises.
Firstly, if a perfect society existed due to following of religion, then how is it that it could not protect itself from the very own people it made powerful through its rules. Can such a society claim itself to be perfect society that it cannot itself control the people whom it gave the power.
Secondly and more importantly for those who make such a claim of perfect society of the past, what are the rules/dogmas added in the religion by the people in power to keep themselves in power. How do you identify between the true tenets of the religion against the ones inserted by the people to suit their needs? Is not it important to make such a study if you are trying to bring back the concept of perfect society by making use of the religion.
Caste system followed in Hinduism seems to be a perfect example. Now many followers of Hinduism and apologists of caste system, claim that caste system was more based on work rather than by birth. There is no doubt that it is one of the most corrupt system designed to keep the power of the society in hands of only certain sections of people. Can a follower of Hindu religion, claim to have come out of the caste in which he/she was born into. If not, then how can he/she claim to implement the perfect society of the old times without fixing the very basic tenets which corrupted the system.

June 2, 2017

Hindi Medium validation of my thoughts

by viggy — Categories: experience, social — Tags: , , Leave a comment

I have always strongly felt about spreading education amongst all children. I am amazed how underrated is the importance of education for a person’s overall growth. For all the issues that are grappling India, there hardly is any noise about giving quality education to our kids, while I believe that needs to be number one priority for any society. Half-hearted attempts and empty promises are what we have been accustomed to. In words of Ravish Kumar, the zero TRP anchor of PrimeTime, NDTV India, ‘Amongst politicians, Education in India just revolves around giving of free books, uniforms or shoes’.
There is hardly any discussion on implementation issues, ideological issues related to education. While everyone wants to emulate USA in every aspect in India, no one talks about their county school system.
In the name of modernizing our education system, what we see in private schools are just different avenues of taking money from parents. It can be swimming pool fees, computer fees, annual festival fees, etc.
Hindi Medium as a commercial movie brings out these aspects very subtly. It brings out the concept of Right to Education Act, something which we are used to only hear as a news item. It also talks about the upper middle class hypocrisy where we would go to any extent to get good education for our own children but hardly talk about government schools where most of the children from poor economic backgrounds study. The film brings attention to the deteriorating condition of government schools. The constant repeating of the concern of the mom that if her child does not get good education, then she will become drug addict keeps telling the audience of the importance of the education for the child at its young age.

Personally for me, the fact that a commercial movie was made around these ideas itself is very heart whelming. Though I had read about the movie before watching it along with my mom in theater, every scene in which the audience including my mom was applauding, laughing or sighing was giving me goosebumps. It was like validating everything that I have had in my mind, something which I have always wanted to work on, make at-least a small impact. Hopefully, we will see some political movement around the issue of education. Its about time we had one.

May 3, 2017

Pepsodent to Patanjali transition of the society

by viggy — Categories: social, Uncategorized — Tags: , , , Leave a comment

Can you remember the era of toothpastes ad with actors dressed as doctors certifying that they would recommend this or that toothpaste to their patients. Do you remember the claim made by almost every toothpaste that 99% of members of some Dentist’s association has suggested them as the best toothpaste, etc. While the Indian society was changing to be a consumerist society, we accepted any garble from the idiot box and bought the products. From toothpaste to toothbrush, soap to fairness cream, everything was sold based on how much it was marketed and how much it made the buyer have a feel good factor. None of the claims were questioned, it was never verified, just broadcasted on all mediums.
They said the toothpaste had salt, we thought it must be good. They said it had neem, we accepted it. The put logos of all the certifications that product had obtained. What those certifications meant, why it mattered was never asked, never answered. As long as the product had the feel good factor, it was bought. Ask anyone the difference between one or other toothpaste, what mattered was only the offers it had or whether it had some taste or smell which they preferred, nothing to do with how it helped the teeth.
Then comes Patanjali, which also said that their toothpaste also had neem but now with certification of being nationalist, being swadeshi. People accepted it also. They again never questioned anything. While the marketting team of big FMCG companies are trying to understand why people are accepting Patanajali, where as they had themselves trained the society to accept anything with a feel good factor, not with any value in it.
Question still remains as to why do we need a toothpaste, why do we need a soap? What properties should the soap have? While we have never asked this question, we can see how a similar ignorance plagues our politics also.

In 1990s, while we were told to accept globalization as the answer to all our problems, we hailed the ones who were called as the architect of liberalized India, PV Narsimha Rao to Manmohan Singh. Everyone accepted that this was the way forward for the nation to leave the clutches of poverty. A grand vision of development, with roads, flyovers and skyscrapers was shown to everyone. Everyone accepted it, they had known of one or other who had benefitted from it. The cousin abroad, far relative who had a white collared job, industrialists in the town, everyone seemed to be benefiting and there was ‘development’ everywhere. No one was interested in trying to understand the fundamentals of the politics they were propagating. This idea of development made them feel better, brought a hope of a change which was more easy to accept.
Than came the nationalist forces which had been brewing silently in the country side making their base stronger. When they bought forward the same idea of development with nationalist way of implementing it, people have accepted it in the same way they shifted from Pepsodent to Patanjali. After all if the feel good factor is the criteria, all it takes is to show a vision which is more tempting than the current one.

If we accept this analogy, the natural question to ask is what would be the next direction for the society. In case of toothpastes, my guess is that very soon we will have local gurus and babas coming up with their own version of toothpastes. While the nationalist layer peels off from the society, society may well be painted with a layer of regionalism. As the efforts of nationalism fails, it may just be too easy to make the society to blame one region to other as the cause for all its problems. Some of the states already have a very good established regional party which would gladly accept this opportunity. Also the glaring economic divide between the south and the north will also make it possible for people to pass the blame on each other. Close to a decade ago, a friend of mine had suggested that India should get disintegrate into all the different states to solve its problems, I had laughed at him as an absurd idea. I wont be surprised if our political parties use such absurd idea to try their luck to political power.

April 22, 2017

Explanation of vectorized form of the for loop calculation of gradient descent in Exercise 1 in ML class in couresa

by viggy — Categories: Uncategorized — Tags: , , , Leave a comment

Source: Storing this for future reference

If you are wondering how the seemingly complex looking for loop can be vectorized and cramped into a single one line expression, then please read on. The vectorized form is:

theta = theta – (alpha/m) * (X’ * (X * theta – y))

Given below is a detailed explanation for how we arrive at this vectorized expression using gradient descent algorithm:

This is the gradient descent algorithm to fine tune the value of θ: enter image description here

Assume that the following values of X, y and θ are given:

m = number of training examples
n = number of features + 1


m = 5 (training examples)
n = 4 (features+1)
X = m x n matrix
y = m x 1 vector matrix
θ = n x 1 vector matrix
xi is the ith training example
xj is the jth feature in a given training example


h(x) = ([X] * [θ]) (m x 1 matrix of predicted values for our training set)
h(x)-y = ([X] * [θ] – [y]) (m x 1 matrix of Errors in our predictions)

whole objective of machine learning is to minimize Errors in predictions. Based on the above corollary, our Errors matrix is m x 1 vector matrix as follows:

To calculate new value of θj, we have to get a summation of all errors (m rows) multiplied by jth feature value of the training set X. That is, take all the values in E, individually multiply them with jth feature of the corresponding training example, and add them all together. This will help us in getting the new (and hopefully better) value of θj. Repeat this process for all j or the number of features. In matrix form, this can be written as:

This can be simplified as:

[E]’ x [X] will give us a row vector matrix, since E’ is 1 x m matrix and X is m x n matrix. But we are interested in getting a column matrix, hence we transpose the resultant matrix.

More succinctly, it can be written as:

Since (A * B)’ = (B’ * A’), and A” = A, we can also write the above as

This is the original expression we started out with:

theta = theta – (alpha/m) * (X’ * (X * theta – y))

April 15, 2017

The book of 0 and 1

by viggy — Categories: Uncategorized — Tags: , , Leave a comment

Imagine I had a nice fat and fancy notebook with great binding completely empty. I ask a young child who knows how to write 0 and 1 beautifully to fill that notebook completely, line by line, page by page with 0s and 1s. I give full liberty to the child to write it any sequence. At the end of the week, after 7 long days of writing the child returns and gives back the book very happy with the accomplishment. Now in a way of appreciation, I give the child a golden pen, which writes with golden ink and ask it to write a small sequence of 0 and 1 on the binding of the book.
Finally my book of 0 and 1 is ready. If at this moment, I would have come to you and tell you to buy the book from me for a small amount of money. Unless you are really feeling generous or pity on me, you would of course tell me that the book is worth nothing.

Now at this stage, I ask another random person, to choose any page of the book and any sequence of 0 and 1 and try to feed it into any of the machine he/she poses. What might happen. The machine understands the sequence and either return some gibberish or return something which we can understand. If the machine returns gibberish, I ask the person to change the machine and try again till it returns something more meaningful.

I do the same with many different people. Each choose their own random sequence from the book, their own machine to interpret it and then try to get something meaningful out of it what they can understand.

Now I have a book of some value as people are able to make some meaning out of it. Wonderful. I start a game, asking people to find the longest sequence in the book which makes sense. The game goes viral, there are now many machines which are able to make meaningful statements out of the sequence of the book. Very soon, we design machines specifically so that it returns meaningful statements just for the sequence of the book.
This book is the book of religion.

December 23, 2016

Its time we recognize Netizens as a separate species

by viggy — Categories: social — Tags: , , , , , , Leave a comment

Disclaimer: This is just a draft
For long, we have been told that Darwin’s theory of evolution with its main proposal of ‘Survival of the fittest’ does not apply with in a species. That when it comes to with in a species, it is best for the species to work together in a group towards a common survival plan. This has been accepted more or less amongst the academicians for quite some time now.
On the other hand, we now have a scenario amongst humans with the exponential growth of technology in last few decades that access to technology can become one of the prominent factor in distinguishing within the human species. It is no longer the physical transformation within a species which will decide the future of the individual animal within the species. Whether the species has developed an extra thumb or different way of breathing will not decide whether the animal will be able to survive and reproduce. What will decide the future of the individual animal is based on how much access to technology it has.
A farmer in a remote village has much lesser chance of survival. He/she may be able to avoid all the disease using natural medicine but will his/her family survive without artificial insemination for long? That family may survive a flood or a drought, but without proper knowledge and mechanisms, surviving prolonged famines or floods will be very difficult.
A Taxi driver will no longer survive he/she doesnt use technology. He/she needs to accept online payments, take online bookings and also keep himself/herself updated online.
With demonetization in India, the government has virtually left no room for any non technical people to do business or even survive without using technology. You either have to accept payments digitally or refuse to do business with the customer. Similarly you can either know how to book a bus by paying through cards or just have no access to that service since you dont have any cash.
Technology in a way has always been this way. You either knew how to use technical machines or just got removed from the factory floor. As machines increased, the labour force which did not know how to operate them had to be laid off. This is similar to how when nature changed, those who had adapted to the new climate could survive and other had to get extinct. Nature has always been very cold in choosing its best for the future, technology it seems is no different.

November 15, 2016

Leader of the rest 69%

by viggy — Categories: social — Tags: , , , Leave a comment

In 2014 elections, we saw BJP become the single largest party with 31% of the vote share and a total of 282 seats out of 543 seats. It was called the Modi wave which was flowing across the nation and helped BJP win in such handsome absolute majority. It is clear that more than Modi wave which definitely was a factor, a lack of any other credible leader to challenge Modi in the opposition was completely missing.

The results of US elections in which Trump with a very small margin has lot of lessons for the Indian opposition to learn. What was completely ignored by the mainstream media was the immense discontent amongst people with current environment of administration and desperate hope of some change which would better their lives. People had no complains as such against Obama but still didnt believe that Hillary would bring the change that they desperately were looking for. It is very doubtful that Trump even understands what changes he has promised but clearly his representation of change and against the established authority was enough for people to give him a chance.

Similarly, in India, there definitely was lot of despair with UPA government and people similarly were desperately looking for change. BJP, riding on the dreamy picture of ‘Gujarat Development’ by Modi in his three terms as CM, was able to sell the idea of change. Again the people did not know what this change was, how it would help them but merely representing a change gave them enough hope to vote for BJP.

The challenge for the opposition now either in India or US is to be able to present a real solution to the people rather than again create another dreamy picture slightly different from the people already bought during the previous election. In case of US, Bernie Sanders seems to have been atleast able to impress a good section of the opposition in his attempt to become the democratic presidential nominee. In India, this is a serious challenge. There does not seem to be any party which can currently present any credible solution and connect with people with its solution.

Rather the opposition in India seem to be completely focused on targeting on wrong policy decisions made by the current government. However,as we saw with Hillary campaign, people are ready to forget the finer details and forgive mistakes generously if they are convinced with the general intention of the government. So, Indians can completely forgive the government for mishandling the Pathanakot terrorist attack as misinformation spread by media. They can ignore the side effects of going to War with Pakistan on economy, on people if they are convinced that this is the only solution left as all other solutions tried ‘previously’ have ‘failed’. Similarly, they are convinced that ‘Industrialists’ need labour reforms to establish industry and generate jobs, even if it means exploiting the workers. They also seem ok with breaking all foreign policies develop over decades together if just some near time gains can be achieved. People are generous to the government as in their eyes the previous governments failed miserably and currently there is no other alternative that is being proposed by anyone credible.

The opposition is not able to use any of its imagination or ideology in countering any of the current decisions apart from attacking current policies in details which people do not seem to even consider. This seems to be a general failure of the world’s largest democracy where the opposition of 69% is not able to produce any credible solution or leader to look up to. Instead by ‘only’ attacking the government and Modi specifically, they are only cementing the views of the government amongst the people.

Unfortunately for the opposition, the task is only uphill as currently it seems the people in the democracies across the world only need quick medication rather than planned and slow changes in the system to put it in the right track. No medication can change the course of society, especially a democratic society in a jiffy and changes in society are only gradual while its destruction can be rapid as we saw during the two world wars.

November 13, 2016

USA with Trump vs India with Modi

by viggy — Categories: social — Tags: , , , Leave a comment

If you believe that Trump and Modi are on the two different sides on their stand on racism or minority rights, then probably reading further may not actually be of any interest to you. However, if you do believe that both Modi and Trump capitalized the racist and anti-minority sentiments, fueled it to strengthen their votes during election, then you would also agree that the future of the respective country is very grave. Not only for the minority but also for the majority. Politics of division doesnt stop at one point. It grows with each point, as it is fueled to take power from one set of minority, and completely remove the minority from any power share that democracy provides. So though it may start with majority race against the minority race, or majority religion against the minority religion, it would continue finding more reasons to further subdivide the society on aspects like language, caste, gender, sexual orientation, etc. ensuring that the power continuously gets concentrated with a smaller and smaller community which represents the majoritarian view.

If we agree with this, then we need to look at what would be future of India or US now that such a power is actually in place in both the countries. We do have a good preview of how the majority’s narrative is being implemented in India with continuous ban on various aspects in the name of religion, culture, tradition, etc. Even in US, it is expected to see such ban being implemented, ban on abortion, ban affecting the LGBTQ community, ban on various minority traditions, etc.

However, the rate of implementation of such enforcement of majority view on the minority would determine the extent to which minority community would be effected. In India, due to its diversity, the major challenge with even implementing any majoritarian view is that there isnt a single version of such a view. So while majority community in Northern Cow belt considers Cow a sacred animal, even the majority community in South India and North East India, dont have such a religious attachment to cow. Even the majority community differs so starkly in their culture and tradition that members of community in different regions may not even feel the same connection with each other. The diversity in language, diversity due to the caste system and diversity amongst regions is so different that imposing a single view is not possible. Sangh Parivar in India has been working tirelessly for decades together to reach out to different sections of the majority to spread a common view of the majority community. With such a large dedicated volunteer force on the ground, they still fail to connect to a large number of people with their narrative of the Indian past. The caste system’s rigidity again does not allow for bringing in different castes together against the minority religion.

Apart from this, Sangh Parivar’s goal of a single united medieval-age India, ‘Akhand Bharat’ is still far from any reality and they continue to strive to achieve such a goal. This ensures that Sangh Parivar cannot unleash a complete violent force on the minority as it would immediately alienate a large of its support base which look at it only a cultural organization spread basic tenants of the ‘peaceful’ hindu religion. Hence for Sangh Parivar, the path to their ‘Hindu rashtra’ is a very slow, divisive path continuously poisoning the people’s mind to accept hate against the minority community. They also understand that for such a path, they need to be in power for a long time and hence they would have to continue their rhetoric around of ‘development’ and improve lifestyle of the common people to have his/her support in the long run.

However, on the contrary, in the US, Trump’s support base barely has any organized force behind it. It is a group of people who are genuinely fed up of existing system which has been depriving them of basic life style. This along with the racist and anti-minority feeling developed over time formed a core support for Trump. Now that he is in power, such a support base would definitely feel more empowered. With no direction or guidance behind such a empowered force, there is nothing to stop them from being violent. Hence such a force is definitely going to be much more disastrous for the country. What is awaited in US seems to be a very unpredictable time-bomb which is set during the election campaign when hate was spewed across the nation against particular communities. What would trigger such bombs is what we need to await and see.

I had never thought I would ever say this, but thanks to Sangh Parivar in India, the disastrous force is more like a cancer spreading slowly until it corrodes the whole body and takes over it. But it still can be checked, depending how quickly it gets detected and then treated.

September 20, 2016

Blackfire in 15 minutes helped me reduce my site load by almost 50%

by viggy — Categories: Tech, Triphippie — Tags: , , , , , , Leave a comment

Having been working on Triphippie, an adventure travel marketplace for almost one year now, its pageload time was always one of our biggest issue. We have used Prestashop for Triphippie as it helped us to go live with a complete e-commerce site in less than a week. We did not concentrate on pageload time early on as we were more focussed on improving the product pages and overall features. Due to this negligence, the page load time was around 12-14s which is pathetic, especially for an e-commerce site. However in last 2 weeks, I was forced to work on improving its pageload time. First thing that we worked on was to migrate our images to Cloudfront. We did this successfully and reduced our page load time to around 8s-9s. This was still not good.

It was clear that our server was just taking too much of time to send the response, our first byte response was still around 6.5s. It was time to use a profiler and understand what was causing this. My initial guess was that this was an inherent issue of Prestashop as it depended heavily on data stored in database. To select a profiler, coming from a Java background, my clear intuition was that I needed something which will not force me to modify code unless I wanted some very specific things. I looked around and then came across Blackfire. The main thing I noticed in its documentation is that it can used without modifying the code at all. This suited me and I immediately signed in for the free premium plan for trail.

With the registration, it took just less than 10 mins to get the Agent and PHP Probe installed on the Amazon Linux EC2 instance. I used the Google Chrome Companion of Blackfire to run the profiler. In the first run itself, I noticed that one of the module of Prestashop which we had enabled on the homepage was executing a SQL statement which took 1.1s to execute. And there was another SQL statement which took 600ms to execute. Blackfire has very intuitive UI to analyze profile runs and this makes it very easy to pinpoint issues immediately. Apart from this, most of the other time consuming part were the Smarty Template compilation which was expected.

Pageload time from Pingdom

I just disabled the module which was causing the first SQL statement and to my surprise, my page load time decreases to 4.6s, it just reduced by almost 50% of the previous time. This was probably the most efficient 15 mins that I had ever spent on improving the site. Its really great that I can now just work on improving the site while being able to very easily get the profiler run output on my test machines and make improvement based on the results.