# The Internet After You…

August 22, 2014

What will happen to all your data, your emails, your photos, blog posts, and pretty much everything that you have out there in “the cloud”, after you are gone? This thought came to me some time back when I was putting together data archival strategy for one of our in-house applications. As I navigated through the labyrinths of the database design to see how I could effectively and efficiently pack & archive “inactive records”, it struck to me, well how does a record become “inactive” at the first place? We, as software engineers, are dug so deep into the mechanics of our creations that many times we forget what we are creating is eventually meant to be used by people. Living breathing people, just like you and me. Every database record, profile information, session state, and what not, ultimately represents someone, a person, perhaps a father of two, a working mom, a high school student, a bus driver, a chief scientists, an astronaut, or a grandma. The bits & bytes of information that we technologists are eventually tasked to manage is really someone’s part of life that he or she shared with someone else, using the technology or solution that we, the software engineers, technologists, scientists, geeks, are whatever you may call, created.

With this light in my mind, I started exploring what others might have thought and written on this topic. To my surprise I found very little information. In fact most of the information wasn’t older than five years back. This made me realize how naive (in some sense) the Internet is. Most of the people on the Internet are still “first generation Internet users” (i.e. people who were perhaps born in mid to late 1970′s) and we all have just started to realize that those “inactive profiles and records” really are stories of someone who was living & breathing.

## What’s the community saying about it?

Most of the discussions and researches that I found related to this topic were in fact inclined towards another aspect, such as government regulations and laws governing personal information, etc. Such as who should own the data after someone’s death? Should it be covered as part of someone’s will? And what processes generally companies follow today in order to provide someone’s data to their successors, and so on. I found a lot of discussions and talks on this aspect that were mainly written by attorneys, government agencies, university professors. But nothing by the very own creators of such systems – the software engineers, the designers, the architects. And although it did catch me with a surprise, but not for more than a few moments. Because then I realized how we, most of the times at least, just treat these database records, profile information, etc. as nothing more than bits & bytes of information. We are caught up in increasing performance and throughput of our APIs, making sure our databases are optimally designed, our SQL queries are well written, and we have good logging and security checks in place, etc., etc. (which all by the way are definitely very important topics). What we forget is that all these bits & bytes of information eventually represent an emotion, and deserve to be treated more than just an “Integer”, or a “String”, or a “BigDecimal”. And as creators of such systems, it is our responsibility to not only design our systems in such a way so that they cover the entire life cycle of someone’s information, but also contribute and explain our viewpoint on this topic to government agencies, attorneys and the people who use our applications.

And so, for several days there after, I let this thought curate in the back roads and alleys of my subconscious thoughts. I started to imagine what could be done to make data archival and retrieval strategies better to take care of data of the dead.

## Why should there be a technological solution?

One could argue that why do we need technology to step up and solve this problem. In fact, from one angle this does look like a social problem that should perhaps is better dealt by forming appropriate laws and business processes. However, that’s just one part of the story. I think technology has a very important role to play here. Just archiving information which is not easily accessible will not only create a barrier in our knowledge to understand our societies and the human evolution, it will also make us short-sighted. As technology is becoming more accessible and is intruding into our lives, we are able to capture a much wider spectrum of our society. Instead of merely archiving this information, it should be put to use to perhaps learn from the mistakes of previous generations and help us make better decisions for today and tomorrow.

Another important reason why technology needs to step up in this area is because the sooner we think about possible solution, the easier it will be for us to deal with it in future. Let’s do a very rough calculation here. Today we probably don’t have enough “dead information” to worry about, but imagine a 100 years from now. There are roughly 7B people on the planet, and roughly three generations would have passed by the end of the century. Which means all the 7B people, their children, their grand children and their great grand children. Also the World population is statistically assumed to be 10B at that time. So we’ll have roughly 10B live people’s’ data and roughly speaking 7+8+9 = 24B dead people’s’ data. The data of the dead would be more than twice the data of the living. And this number will keep increasing.

## What are the possible technological solutions?

Beyond the standard data archival strategies, what I’m really trying to find is if current technology can be used in a more effective manner to distinguish between a dead and an alive person and hence automatically perform archival that is more suitable for analysis and decision-making. Today such concepts do not exist, but I believe technology does; If we use it with this inclination in mind. Here are some thoughts.

### The foaf:Person and foaf:Group classes in FOAF Vocabulary

One way to organize and structure human created data so that computers can easily read and “make sense” of it all is by using RDF. So, we can perhaps utilize the FOAF vocabulary to separate out living people from dead. However the current RDF foaf:Person vocabulary does not include an attribute that could tell if the person is dead or living. Perhaps one way could be to update the Person class. However considering that many applications on the web might not be aware of the person’s living or dead status, there should be an “Internet Group of the dead” represented by foaf:Group class. This group must be maintained by the census bureau and any person who’s found dead should be included to this group. This way as data on the Internet matures and is semantically indexed, and applications also mature to be able to automatically convert human information into computer understandable information (perhaps via RDF), the status of someone being alive or dead would be easily traceable. And based on that their rest of the information would be easily archive-able and sharable in some manner with their closest relatives or friends who ever they had chosen. In addition the same information could perhaps be used for analysis and decision-making for future generations.

A thing to note is that RDF itself is still evolving and the vocabulary is still under development. The approach that I have suggested has its own pros and cons and maintainability issues. However I do believe that if some serious thought is put into this aspect of the RDF vocabulary (i.e. dealing with data of the dead), I am sure we’ll have some elegant solution.

### Activity based indexing

This is a fairly new concept (considering how old databases are) and has gained lot of importance after around the Y2K era as the Internet literally exploded with lot of content. Activity based indexing plays a very important role in search engines, where-in you want to show results that are newer, are being actively updated, etc. However the same philosophy can perhaps be utilized to trace possible death or possible signs of social detachment. Perhaps this feature of indexing must be provided out of the box by databases. I haven’t done much research in this area, but this is something to explore. One thing to note though is that as technology would evolve and allow people to be omnipresent through various mediums, one would need to think about “activity” across multiple applications and channels. For instance if a person switches from Internet-based discussions to phone based discussions, the Internet applications should not assume that the person is dead or is socially detached.

### No Activity != Death (Omnipresence Detection)

Like I mentioned above, no activity in one channel doesn’t mean that the person is dead. Conversations on phone are still not interlinked with conversations on the Internet. Similarly media on Internet TV cannot be seamlessly integrated with media on Cable networks. And financial transactions captured via point of sale units use completely different set of platforms and protocols as compared to the transactions that happen over the Internet. People touch these systems and applications via different channels but there is very little effort to seamlessly integrate all of them. Considering the fact that COBOL applications still exist, I don’t foresee a single technology platform for omnipresence coming up in the near future. However perhaps some bridges could be developed to reduce the gap that exists today. That way applications from one channel could convey the living or dead status of someone to other channels.

I personally feel that the problem of omnipresence detection is not a “big problem”; it’s just that we haven’t given much thought to it yet. Considering advances in technology I definitely see people interacting with each other in a much more seamless fashion. This would either happen via Internet or technologies and channels that haven’t been invented yet. And when that happens, omnipresence detection will become an important challenge.

## Internet – the carrier of your legacy

For over five millennia, the human race has thought of legacy in more tangible terms than today. Internet has not only broadened the definition of legacy, it has also made it extremely easy to pass on and share legacy with others who are either living today or will be born tomorrow. The next step is to make it (the Internet) mature and capable enough to understand value of the legacy of the human race it holds. This is a task that we all share together.

# Writing a great “Hello World” example

June 27, 2014

I think one of the best inventions in the field of software tutorial writing is the classic “Hello World” example. Like perhaps most of the developers of my age, I started coding very young; just as a part-time hobby. Over these years as I literally saw the birth of various software languages, frameworks, and tool-kits, I noticed one thing remained pretty much the same; that is the way these new languages, frameworks, etc. are explained to anyone (especially developers) – using a simple “Hello World” example. Having coded in several languages and several different frameworks myself, there have been incidents where I was tasked to work with technical writers and the first thing we would do was write a “Hello World” example for whatever we were developing or sometimes had already developed. As I wrote these examples, I realized even though they looked so easy when I used to follow them as a kid, how hard it is to write a good, really good, “Hello World’ example. The challenge lies in following the “minimalist approach” without loosing any important aspect of whatever you are trying to explain. That’s when I truly started to appreciate the effort involved in writing a great “Hello World” example.

I am writing this post to appreciate all the effort of all the brilliant minds around the World who have developed great software products and contributed to writing “Hello World” examples. And to help all the explorers, the risk takers, the challengers, who already have developed or are developing great software products but are struggling to write equally great “Hello World” examples for their creations. I hope to learn from your feedback and improve this post in future.

## Why is it so important to write a “Hello World” example correctly?

“Hello World” example is like a “summary” of the actual product, in action. It gives the developer, or anyone for that matter, a quick glimpse into what the product is about and how it can be used without having to worry about going into too much of details. A correctly written “Hello World” example serves as a perfect starting point for anyone who’s trying to understand not only what the product can do, but also what it can’t. If not written correctly (and I’ll explain later what I mean by being “correct”), a “Hello World” example can give wrong impression about the actual product. For instance an over simplified version can make readers assume that the product is not as rich as they thought. On the other hand a complicated version can become a big barrier for anyone to just get the ball rolling. So, it’s very important to spend time to write a “Hello World” example correctly.

## What are the qualities of a good “Hello World” example?

A good “Hello World” example:

• Is easy to grasp relatively quickly and requires very little set up to get “off the ground”.
• Encourages the reader to play around and extend it to something more complicated (and perhaps “realistic”) without having to start from scratch or put too much effort.
• Inculcates best practices, such as using the correct way to “boot start” a system, etc.

## A look at some of the best “Hello World” examples

Personally I like all the “Hello World” examples of programming languages. I think they are very well written. For instance, take the classic “Hello World” example in C:

 #include <stdio.h>
#include <stdlib.h>

int main(void)
{
printf("Hello, world\n");
return EXIT_SUCCESS;
}

It’s easy and simple to grasp. It encourages the reader to play around with the sample a bit. For example, the first thing typically people would do is change the “World” with their name or parametrize it. And it shows some best practices such as code indentation, using the right set of headers, returning with the correct exit code, and so forth. In the same lines, here’s another good one from the language called “Go”.

 package main

import "fmt"

func main() {
fmt.Printf("Hello, World\n")
}


Notice, how both examples (and pretty much all the good “Hello World” examples you’d encounter) follow a “trend”. They all follow best practices. For example even though these are really simple, the author still defined a package and imported the right set of modules.

## Writing your own “Hello World” example

Now that you have looked at the good “Hello World” examples from a different perspective, it should be much easier to create one yourself. Let’s take an example. Let’s say you have developed a multipurpose screw driver, and you want to put together a “Hello World” equivalent for that. Without going into too much details of all the functions that the screw driver supports, you want to make the user understand how to use the screw driver. So you create a “quick start guide” of sorts. In order to keep it simple, you’d pick the most common use case – using a Flat or a Phillips screw. So you tell the user:

1. Push the Flat screw driver attachment.
2. Click the forward button.
3. Hold the screw driver from the grip and push & rotate clockwise.

The above example covers all the basics of a good “Hello World” example. It picks the most common and simple use case. It talks about the “basic setup” such as “clicking the forward button”. And it tells the user about the best way to hold the screw driver – from the grip. The user can then take one step further by replacing the Flat screw head with a Phillips screw head. He can further learn that by clicking the backward button and rotating the screw driver anti-clockwise to unscrew, and so on. Had the example been any more complicated or simple, you’d either confuse the user or put him at risk because of improper handling of the device.

Let’s take another example. Let’s say you created an API that takes a request composed of 15 parameters, all of which have some default value, and returns a String. You should first find out the most common use case of the API. If it’s a weather API, the most common use case might be getting current temperature of a zip code, but if it’s a translation API the most common use case could be to translate the word “Hello” from English to some other common language, say Spanish. Now that you have identified the most common use case, you show example usage of your API using those parameters. At this moment you don’t need to worry about exception scenarios, etc. However you do need to worry about making sure you have covered at least the most important best practices for your API. For example, if your API needs to login & authenticate and later logout in some sense, your “Hello World” sample should include that.

Once you have created your example, the last step is to run it by a couple of your target audience and get their feedback. After all, the best people to tell you if you have written a good “Hello World” example or not are the ones for whom you wrote it to start with! Find few people who fit your target audience and get their opinion. If you didn’t get it right the first time, you will get it right the second, or the third time :-).

If you have a “Hello World” example you’d like me to check out, please do share! I’d be happy to review it and provide my feedback.

# Batch jobs are just like traffic signals

May 16, 2014

Batch jobs play a very important role in any software solution. They may sound old and “so 70s” but fact of the matter is that they are still used more often than not in pretty much every software solution. Be it generation of daily transaction reports, sending marketing emails, or processing payrolls etc., batch jobs exist even in the most recently developed software solutions. And that’s not because architects designing these solutions are stupid or “old school” and so they end up using batch jobs again and again. It’s just that sometimes either there really are few benefits of using batch jobs, or sometimes you just can’t do without them! A good list of benefits of having batch jobs is available here: http://en.wikipedia.org/wiki/Batch_processing. Wikipedia rocks! Isn’t it? But hey, just like that, there are a lot of benefits of having traffic signals! So why do I see batch jobs as nothing more than traffic signals? Here’s why:

Both traffic signals and batch jobs execute at a given time interval and for a finite amount of time – When I’m waiting at a red light signal, I almost feel as if I’m some sort of “information packet” placed in a queue, waiting to be “processed” in some sense. The queue is processed by a “batch job”, aka the traffic signal, which becomes green for a finite amount of time.

Out of sync traffic signals and batch jobs lead to catastrophic results – What happens when a traffic signal goes out of sync? Accidents! I’m not sure about you, but if I were that “information packet” in a queue that’s being processed by a batch job that has gone out of sync, I would be dead scared! What happens when a batch job goes out of sync? Unwanted database updates, file rewrites, and flaky user experience to mention the least.

Both traffic signals and batch jobs are sort of workarounds to take care of nuances of the underlying technology – The reason we have batch jobs is so that somewhat identical operations can be grouped together and processed as part of a “batch”. This has significant performance benefits such as being able to run specific “heavy-duty” operations at the time when there are enough free CPU cycles available, or perhaps updating database records when no other application is actively making updates on the same table or records, etc. In the same manner a traffic signal is meant to “hold” traffic in one direction so that traffic in other direction can pass through without having to slow down. This way traffic can be made to flow safely and quickly through an intersection point.

********************************

OK; So we now know that batch jobs are like traffic signals. What I am still curious to know is why did we (and by “we” I mean “we as in the software engineers”) come up with the concept of batch jobs? I mean I know “why”, but the real question is that why didn’t we spend enough time to find a better alternative? Is it because subconsciously we were “tuned” to live with traffic signals and naturally picked and introduced the same concept to solving nuances of the underlying technology in software? Or there really was no other alternative? And if there was no alternative back then, does that mean there’s no alternative even today? Just five years back AJAX and the whole concept of real-time feeds in browser were very new concepts. Ten years back they weren’t even imaginable.

I definitely like the concept of grouping a set of transactions so that they can be processed in one shot, however I don’t like doing that at the expense of unwanted wait times for the end-user. So I believe the World needs a new batch processing mechanism that would dynamically change based on the needs of the system. To give full respect to traffic signals, I must admit that this idea of dynamically changing batch jobs isn’t mine and isn’t new. It’s already present in many traffic signals all across in the World. Have you noticed when you are driving on an empty road in the night-time how a traffic signal automatically turns green for you? More often than not that’s not a coincident. Many new traffic signals automatically detect oncoming traffic and based on the conditions on the intersection automatically turn green or red to ensure safe and free flow of traffic. We need something like that in the Software World. Sure there are concepts like “fair-share scheduling” and “workload management”, but the entire implementation of such concepts is mostly “very proprietary”. Personally I haven’t seen such concepts in “every day batch job implementations”. I believe the reason is lack of such concepts in the currently available ready to use open source batch processing libraries. I hope one day batch processing libraries and techniques will become smarter. If you know any such readily available open source library that does something like what I am talking about, I’d love to check it out! Or if you are thinking to code one, I am happy to help! Until then, I hope you enjoyed reading this philosophical comparison between batch jobs and traffic signals.

# Investments that will Zero up your taxes

April 14, 2014

Let’s assume your yearly base income is I, out of which you make some investment, which gives you a capital gain, G. Your tax T, in this case would be a function of I and G:

$T=f(I+G)&space;...................(1)$

For your investment to make up for all this tax, the capital gain G must be greater than or equal to the tax T.

$G&space;\geq&space;T$

$G&space;\geq&space;f(I+G)&space;...................(2)$

Considering a flat tax rate of x%, equation (2) becomes:

$G&space;\geq&space;x(I+G)$

$G&space;\geq&space;I&space;\frac{x}{1-x}&space;...................(3)$

Now, let’s see what kind of investments can actually produce that kind of gain. As you can see from equation (3), it really depends on your base income and the tax you’d end up paying. If you plot a graph of x v/s x/(1-x) as shown on the right, you can see as the tax increases, it would become harder to find an investment that would produce a gain enough to zero up the taxes. Even worst, it becomes exponentially difficult to achieve such a gain.

So how does it look for a person who makes a mere $65K a year and falls under 15% tax bracket? He/she would need to invest such that the gain is at least 65 x 0.15 / 0.85 =$15K. If this person invests in anything that produces a healthy 10% yearly gain, he/she should be investing 15/0.1 = $150K, which is roughly 2.3 times the base income. And how would it look for a person who makes$500K a year and falls under 33% tax bracket? He/she would need to invest such that the gain is 500 x 0.33 / 0.67 = $246.27K. If this person invests in anything that produces a similar 10% yearly gain, he/she should be investing 246.27/0.1 =$2.46M, which is roughly 4.9 times the base income!

This means the more your base income, harder it will be for you to find investments that produce gain enough to Zero up your taxes. The only way you’d be able to do that is to make risky investments in the hope they’d flourish.

Lesson: do your own math; Use your own brain and invest carefully. Because earning more wouldn’t necessarily give you more leverage as far as taxes are concerned :-).

Tags

# Java Geolocation API

March 22, 2014

This is my Java implementation of the Geolocation API specifications put together by W3C: https://bitbucket.org/gautamtandon/java-geolocation

My code is available under the MIT License, and I hope one day all geolocation service providers out there will use this code (or its variant) in order to provide a standardized way to perform IP to geolocation.

Please check it out and do not hesitate to get back to me if you have questions, doubts, suggestions, etc. You can simply reply to this post, or find my contact information in the MIT License file.

Tags

# Will there ever be a “Software Architectural Wonder” in the World?

October 1, 2013

The Architect’s Dream by Thomas Cole (1840)

Chuo-ku, Osaka, Japan

The field of Architecture has played a vital role throughout the history of mankind. It has helped build structures that have lasted for centuries; Some of them are so breathtaking that we call them “the wonders of our World”. It has played a key role in battles throughout the history, and it has even triggered revolutions. In some sense every architectural marvel acts as a tribute to its civilization. It’s a way for a civilization to pass on their message to its future civilizations that anything can be accomplished if you believe in yourself.

Being in touch with the “Software World” for over two decades it never struck me how differently we perceive the word “Architecture” when it comes to “Software”. Could an “Architectural Wonder” really exist in the World of “Software”? Would there ever be “that amazing piece of software” that people say two hundred years from now would look at and go spell bound, and really appreciate what our civilization had accomplished with “so little software knowledge” as compared to them? Would there ever be references made to “great architectural work done in software”, that perhaps would help future generations understand the cultural values of our current society?

Modern Software Programming

Today, software is everywhere, and yet it’s nowhere! From the very basic program burnt into the Flash ROM of a quartz watch to sophisticated software programs that coordinate flight plans, run trains and telephones across the globe, we have woven software everywhere into our lives. But it’s not visible at all. Perhaps it is the most “hidden” form of product ever developed by mankind. So how a “Software Architectural Wonder” would look like? How would we “see” it? And moreover, how would future generations look at it? Is a “software program” really capable of reflecting the true cultural values of a society just like other (non-software) works of art are? And if so, how?

Perhaps one could say that the Internet and the TCP/IP standard is the true testament of mankind’s software architectural capability because it is responsible for the “connected World” as we see it today. Or perhaps the UNIX operating system is the true epitome of mankind’s software architectural achievement because it is in a way the genesis of all modern operating systems – the very basic code that brings “life” into a piece of silicon, metal and plastic we call “computer”. If you think in these lines, then perhaps a “Software Architectural Wonder” would be more comparable to an outstanding work in “poetry” or “painting” rather than a “physical structure”. Question then will be – Are current software programming languages rich enough to produce such an outstanding work? In other words, do the basic building blocks of current programming languages allow us to produce a work of art, so “beautiful” and “meaningful”, that it would truly be respected by future civilizations as a “Software Architectural Wonder”? One could argue, yes we do have those building blocks already. Just like a painting masterpiece, such as a sketch art, can be created with only two contrasting colors – black and white, so can a “Software Architectural Wonder”. Only that in the case of software, the fundamental building blocks would be the binary Zero and One.

I believe the question whether or not there will be a “Software Architecture Wonder” in the World can be better answered by understanding the “philosophy of writing software”. Does our society write software to only solve certain problems? Or they are also written to express a thought? Is it “beautiful”? Is it “meaningful”? Is it worth “cherishing”? Perhaps only when software development would mature to a point where its use goes beyond the basic needs of solving problems, only then our society would be ready to create a true “Software Architectural Wonder”.

If you look at it from a different angle, it took mankind literally hundreds of years to reach to the point where spoken and written languages could be used for a purpose beyond basic communication. Perhaps in the same manner it shall take a few centuries before we can see a true “Software Architectural Wonder”. Until then let’s keep learning and perfecting our software development skills.

This is to all the amazing software engineers out there – Some day one of You will be acknowledged as the creator or a “Software Architectural Wonder”!

# jQuery plugin for showing informational popup

June 20, 2013

I recently created a jQuery plugin for showing informational popup right next to any HTML element. I have made it available on https://bitbucket.org/gautamtandon/jquery.attachinfo. It is free and open source (under MIT license). All the information related to this plugin is available on that link. So I’m not going to duplicate the same information here :-).

If you are using jQuery and need something like this, give it a try! And feel free to send me your feedback!

Here’s how it’ll look like:

Tags

# Mathematical proof of why most quarrels generally start because of one single stupid reason

June 13, 2013

Two days back I had a heated argument with my wife. The good part is, like every other time we quickly patched up things and life was back to normal. Later, we looked back and laughed as to how stupid we were just fighting on a “small thing” that didn’t even matter anymore!

Next day, when I was introspecting myself (like I usually do when I’m stuck in an hour long jam on I-880) and replaying the whole situation in my head, it struck upon me, how did that “one small thing” become such a “big thing” after all? Big enough to shake the entire relationship, even if it were for a moment? And why generally there’s always “that one thing” that unleashes the “beast” in us? When people have quarrels, why don’t they generally say “It all started because he or she did so, and so, and so.”; Or may be “It all started because he said this and this and that to me”? It’s generally always “just one stupid reason”. Why?

I’m sure many people would try to answer this from a psychological point of view. Some would perhaps throw a biological angle to it. And few would choose the path of Mathematics. I thought to go that direction and see if I can come up with some conclusion, mathematically, behind it all. This post is about my quest of understanding a part of the human psychology using Mathematics. Here’s my take:

Assumptions

1. A quarrel can only begin if there are at least two people involved. This is kind of “obvious”, but since we are under the shelter of Mathematics, let’s call it out loud.
2. A quarrel is always initiated by one person. While many quarrels may seem as if they started with both the people taking action at the same time, if you take a careful look at it, you’ll notice that it is always initiated by one person. After that it may continue back and forth.
3. Quarrel can be described as inverse of Understanding. In other words, when someone quarrels with someone, his/her “understanding” about the other person depletes. This again is one of those “obvious” things, but it’s important to call it out here.

Formulation

To make our equations easy to discuss, let’s assume there two individuals, $a$ and $b$. And let’s assume $a$ started the quarrel. With these assumptions, let’s define Quarrel as $Q$ and understanding of a person $a$ about a person $b$ as $U(a,&space;b)$. So our equation of quarrel between $a$ and $b$ becomes:

$Q&space;=&space;U^{-1}(a,&space;b)&space;\dots&space;(1)$

Now let’s dig deeper into the function $U(a,&space;b)$ because that seems to be the center theme here. $U(a,&space;b)$ signifies the “understanding” person $a$ has for person $b$. This can be further broken down into function of traits that that $b$ shows and how much weight $a$ gives to each of those traits. Hence each “weighted trait” $T_{i}$ can be represented as:

$T_{i}&space;=&space;w_{a_{i}}t(b_{i})&space;\dots&space;(2)$

Here $w_{a_{i}}$ is the weight person $a$ assigns to the $i^{th}$ trait $t(b_{i})$ of person $b$.

Since traits can be positive or negative we can safely assume that the best way to combine traits in order to form the understanding will be by performing a root mean square of all the $T_{i}'s$. This brings us to our third equation:

$U(a,&space;b)&space;=&space;\sqrt{\frac{\sum_{i=1}^{n}T_{i}^2}{n}}&space;\dots&space;(3)$

Combining $(2)$ and $(3)$ gives us:

$U(a,&space;b)&space;=&space;\sqrt{\frac{\sum_{i=1}^{n}w_{a_{i}}^2t^2(b_{i})}{n}}&space;\dots&space;(4)$

In case of a quarrel, understanding $U(a,&space;b)$ becomes Zero. Let’s represent that as $\mu\lim_{\mu\rightarrow&space;0}$.  Hence $(4)$ becomes:

$\sqrt{\frac{\sum_{i=1}^{n}w_{a_{i}}^2t^2(b_{i})}{n}}&space;=&space;\mu\lim_{\mu\rightarrow&space;0}&space;\dots&space;(5)$

Further simplification of this equation gives us:

$\sum_{i=1}^{n}w_{a_{i}}^2t^2(b_{i})&space;=&space;\mu\lim_{\mu\rightarrow&space;0}&space;\dots&space;(6)$

Since $w^2_{a_{i}}t^2(b_{i})$ will always be a positive number, the only way equation $(6)$ can resolve is if all the $w^2_{a_{i}}t^2(b_{i})$ values are significantly small. In all practical terms this is going to be harder to achieve as the value of $n$ increases. This is because the higher the number $n$ becomes, the more traits are being evaluated; And the more traits are evaluated, the harder it is going to be to sum them all up to Zero! Hence, the least possible value of $n$ will give us highest probability of quarrel. That means, for highest probability of quarrel,  $n&space;=&space;1$. In other words person $a$ only considers one trait of person $b$. Hence, we have:

$\dpi{150}&space;\large&space;n&space;=&space;1&space;\dots&space;(7)$

Assuming traits in general don’t vary drastically, however weights may change based on the “heat of the situation”, we can combine equations $(6)$ and $(7)$ and reach to this:

$\dpi{150}&space;\large&space;w_{a_1}&space;=&space;\mu&space;\lim&space;_{\mu&space;\rightarrow&space;0}&space;\dots&space;(8)$

In other words, equations $(7)$ and $(8)$ tell us that the possibility of a quarrel becomes extremely high when person $a$ “judges” person $b$ on only one trait that highlights during the argument and applies a very low weight on that trait. While doing so person $a$ completely disregards all other traits of person $b$ that otherwise would have created a healthy understanding $U(a,&space;b)$ between both of them, just enough to not lead to any quarrel.

Conclusion

When you are in a heated debate with someone, while you may get “tempted” to just pick that “one trait” that highlights at that moment, try to look at as many other traits as possible. This will help you “judge” the person in a much more “neutral” way and will possibly avoid quarrels at the first place! It’s common sense! It works! And Mathematics has just proved it!

Tags

# Are you a bot or a human – php utility

June 5, 2013

Are you looking for a quick and easy way to detect if a website call to your server came from a human or a bot? Here’s a simple PHP utility that I wrote for just that: https://bitbucket.org/gautamtandon/areyouabot-php

It’s extremely simple; does not require any extra software or changes in your code; and last but not the least, it’s free and open source!

Enjoy!

Tags

# Lego Mindstorms NXT Touchless Motion Sensing Faucet

June 1, 2013

This is my first Lego creation using the Mindstorms NXT set. After trying out the usual basic creations such as the ball sorter, car, etc. I wanted to build something that would be equally as much fun, simple, and at the same time useful in day to day activities. So I came up with this idea of converting our normal kitchen faucet into “touchless faucet”. And around two hours later here’s what I was able to do:

Lego Mindstorms NXT Touchless Faucet – closeup

Lego Mindstorms NXT Touchless Faucet – complete picture

I used one motor and a pair of gear assembly to handle the kind of power needed for turning the faucet.

Most of the assembly actually goes into securing the motor and gear system to the faucet as tightly as possible.

The ultrasonic sensor at the top senses if there’s anyone in front of the faucet.

As soon as someone approaches within 20 inches range, the sensor notifies the mindstorms brick, which turns on the faucet. Once the person moves farther than 20 inches, the faucet is turned off.

Here is the programming that went behind this.

I start by setting a logic variable called “isOpen” to “false”. This signifies that the faucet is currently closed.

Then, every 2 seconds, I check if there’s someone within 20 inches of proximity using the ultrasonic sensor. If there is someone within the range, and the “isOpen” logic variable is “false”, I run the motor to open the faucet and set the “isOpen” variable to “true”. Otherwise, I run the motor the other way round to close the faucet and set the “isOpen” variable to “false”. Simple!

Tags