Code & Craft

Where algorithms meet narratives

Join me, as I build worlds with words and code
  • Posted on

    Ah the comfort zone!

    Oh how warm the comfort zone is!

    That chess strategy I never waver from but keep loosing, That wrist-watch I am always wearing but never bother checking the time, That washbasin at work that I always use no matter how much it splashes, The coding routine that I have That idea that I will never convert to an app because I am too comfortable fixing defects! Those Rubik’s cube algorithms I will never stray from That computer language I will always use as a bench mark

    Oh how satisfying you are my dear comfort zone. Like that itch I will keep scratching

    and oh how bitter the medicine of change.

    Change, forced or otherwise, you are the only enemy,

    Oh you uncomfortable pain-in-the-ass bastard!!

  • Posted on

    Have you ever seen one of these irritating, half-assed, Tamil dubbed versions of English movies on the various Tamil channels?

    I recently saw The Hitchhiker's guide to the galaxy dubbed into Tamil. Not only was it totally silly, they changed the story all together.

    Every dialogue was changed to something that didn't even resemble what was originally said.

    For instance, there's a scene where Ford Prefect warns the patrons of a bar that the Earth will be destroyed in 10 seconds. The Barkeep (originally) responds by asking him whether they should cover their head with a paper bag or something. In the Tamil Dubbed version, this was changed to the Barkeep asking Ford to stop his insanity. The joke of this moment is entirely lost on Tamil audiences.

    To someone who hasn't read the book or seen the original movie, I am sure watching it in Tamil would have been bewildering. Needless to say, I switched channels within 10 minutes.

    You know what would be great, take an entire movie that has been dubbed in Tamil and transliterate it back in English.

    That would be hilarious!!!

    I will do it someday.

    Oh and here's a transliteration for this month.

    Quote: Mayirai katti malayai izhu - vanthal malai ponal mayir (மயிராய் கட்டி மலையை இழு - வந்தால் மலை போனால் மயிர்) Intended meaning: Pull a mountain by tying a hair to it. If you succeed you will get a mountain, if you lose you will lose a hair. There is no harm in trying. Transliteration: Hair tie mountain pull - coming mountain going hair.

    Cheers!

  • Posted on

    Time, for a long time, was considered a construct of the mind. Not really existing outside of our minds. Time being an illusion is a common theme in Buddhist thought. Some philosophers even postulated that time, along with motion, and change were all illusions. Hindus had a concept of wheel of time, considering time as cyclical and consisting of events that repeat.

    Modern physics tells us otherwise. We now know that time is a dimension. And based on the special theory of relativity we also know that it is strongly connected to space itself, thus the term space-time (or the space-time continuum). So connected are these two, one can infer that from the point of view of a single photon, (there is no such thing, but go with it) space has 0 size. When a photon crosses the universe, from its point of view it takes no time at all (zero). From our point of view of course, it will take an infinite amount of time. This is what is called time dilation and it is wonderfully explained using the twin paradox.

    Another way we know time exists for real is because of Entropy. Entropy is a law that measures a systems progress towards thermodynamic equilibrium. A red hot ball of nickel which is in a higher state of energy than its surroundings will always lose heat in a predictive manner so as to reach room temperature. A closed (or otherwise called isolated) system always evolves towards thermodynamic equilibrium. Once equilibrium is reached that system has reached a state of maximum entropy. Simply speaking, Entropy is a law of nature in which everything (high energy) slowly goes into disorder (equilibrium).

    Energy is key here. The more energy a system has the farther away from entropy it is. Want to keep a ball of nickel hot, keep it torched. The only way water will stay up in the tank and now flow down is having valves or taps; in other words, convert the kinetic energy of the water as potential energy.

    Macro effects aside (fruit decay, water leveling or a red hot nickel ball losing heat), Entropy can be measured on the sub-atomic state as well. Free neutrons (neutrons not bonded in an atom) will spontaneously undergo beta-decay. Beta decay is a process that allows the atom to obtain an optimal ration of protons to neutrons.

    That’s how we know that time has a direction. There is a definite forward and there is a definite backward. Like temperature, living beings can’t see it, but we have an intuitive sense of it. We know if a movie is being played backwards. And we definitely know something is wrong if a ball of nickel gains heat just sitting there.

    So anyways. This post was not supposed to be about the physics of entropy or time. The idea was how Entropy can be observed in societies.

    A group of humans always stick together and organize themselves automatically and always form a society and create rules for said society. Humans don’t need an external entity to organize, they organize themselves. And I hypothesize on such self-organized societies entropy plays a major role. Given enough time a society will always degenerate. Always. When a society reaches maximum entropy they split themselves into groups. These groups then form their own societies and rules. These new groups can then be said to be in minimum entropy. How else would you explain so many countries, so many religions?

    Of course this is until there is external force acting on it. A group that has reached maximum entropy can be put together again if there is a threat to it as a whole. Indeed history is littered with examples of former rival groups getting together to fight a common enemy.

    I also think that the more energy (in the form of food, electricity, gas etc.) a group has access to, the more time it will take for that group to degenerate. But in the end entropy will always catch up.

    So that’s that actually. I thought it was a good explanation of what we observe in the world. And any problems you observe in a country can be explained by entropy.

    One last thought. You know the meaning of life? Or rather what life is? You see the universe is in a constant state of change from a high state of energy (think the Big Bang) to equilibrium (Heat death of the universe). Life is simply in the way

  • Posted on

    Two things will always amaze me.

    One is the fact that I am here.

    No one has defined what consciousness (No I am not talking about the soul) is but the closest someone has come to explain it is that self-awareness (and therefore consciousness) is an evolutionary trait that gives a creature the ability to plan and execute rather than react to immediate environmental changes. Turns out that there is no seat of self-awareness in the brain. I have an area in the brain that is responsible for my heart rate, vision, hearing and so on for all senses, but consciousness does not have a center in the brain. It comes from an interaction of all these senses. Consciousness is self-arising. Like birds in a flock. No one designs their beautiful patterns; they just arise because of a few simple rules.

    But the fact that I am here, out of a million different possibilities, and all of the histories starting from a single celled organism to Genghis khan have been responsible for me being here boggles my mind. The fact that I waste it away is an entirely different topic.

    The second fact that amazes me is that all of this will end. It will cease to be. There’s a tiny part in my mind that hopes that all of science is wrong and there indeed is a beyond. But the fact that I don’t remember anything from before being here is solid evidence for me that there is no beyond as well. That should make me sad. But in some strange way, it doesn’t.

    As long as I am amidst family and friends who care for me, I have nothing to worry about.

  • Posted on

    Am I the last person in the world to discover this?

    One way to round off numbers in Javascript is to use the parseInt method. Like so.

    var someRandomNumber = 123.1872;
    var roundedOff = parseInt(someRandomNumber);
    

    Remember though that parseInt does not actually round, it truncates the decimal portions of the number.

    But that's not the point. I don't know how good parseInt is performance wise, but an easier way to round off (or truncate the decimal parts) numbers in Javascript is to right-shift a number by 0. Like so.

    var someRandomNumber = 123.1872;
    var roundedOff = someRandomNumber >> 0;
    

    Both these examples yield 123 as the result.

    So I did some performance tests to see which one performed better. Each method was run a 1,000, 10,000 and 100,000 times and the time was noted. The tests themselves were carried out 20 times.

    I did not see a great deal of difference when the tests were ran a 1,000 times. Each method ran for more or less a millisecond, however I have to say that over 20 times, the right-shift edged out.

    There was still no big difference when the tests were ran 10,000 times. Still, right-shift edged out.

    The big difference was when it was run 100,000 times. The right-shifting outperforms parseInt as a method to round off (or truncate) number.

    Here's the result of 20 runs. Each run was 100,000 conversions.

    # ParseInt Right-Shift
    1 9 5
    2 4 1
    3 5 1
    4 3 1
    5 2 1
    6 3 1
    7 3 1
    8 3 0
    9 4 1
    10 3 0
    11 3 1
    12 3 1
    13 3 1
    14 3 0
    15 3 1
    16 3 1
    17 3 1
    18 3 1
    19 3 0
    20 3 1
    Average 3.45 1

    Here's the code if you want to do this yourself.

    var testing = "ParseInt - Right-Shift\n";
    for(j=0; j<20; j++)
    {
      var startTime = new Date().getTime();
      for(i=0; i<100000; i++)
      {
        var myVar = Math.random() * 1970;
        var roundOff = parseInt(myVar);
      }
      var endTime = new Date().getTime();
      var timeTaken = endTime - startTime;
      testing += timeTaken + " - ";
    
      startTime = new Date().getTime();
      for(i=0; i<100000; i++)
      {
        var myVar = Math.random() * 1970;
        var roundOff = myVar >> 0;
      }
      endTime = new Date().getTime();
      timeTaken = endTime - startTime;
      testing += timeTaken + "\n";
    }
    alert(testing);
    
  • Posted on

    So in other news, Bill Gates has regained his title of the world’s richest man with a fortune that is valued at 72.7 billion US dollars. That's right he's back on top of the list. The last time he was on top was in 2007. You know how much is 72.7 billion dollars? Read on.

    The words million and billion are used so frequently (often together), we fail to recognize just how big a billion really is. Perhaps it is because these words sound so similar to each other.

    So how much is a billion really?

    In the short scale, numbers progress such that a new term greater than million is a 1,000 times the previous term. Thus,

    A million is thousand thousands; that is 1,000,000

    A billion is a thousand millions; that is 1,000,000,000 and so on and so forth

    Here’s an exercise that is guaranteed to blow your mind. Let’s calculate how much is a million seconds. For the sake of readability I am going to round-even all calculations.

    A minute has 60 seconds, so dividing 1,000,000 by 60 gives us 16667 minutes.

    An hour has 60 minutes, so dividing 16667 by 60 gives us 278 hours.

    A day has 24 hours, so dividing 278 by 24 gives us more or less 12 days.

    That’s how big a million seconds is. 12 days.

    And if you thought that was big, let’s do the same thing a billion seconds.

    A minute has 60 seconds, so dividing 1,000,000,000 by 60 gives us 16666667 minutes.

    An hour has 60 minutes, so dividing 16666667 by 60 gives us 277778 hours.

    A day has 24 hours, so dividing 277778 by 24 gives us 11574 days. That doesn't seem right..... right? Nope. The math checks out.

    A month has, on an average, 30.5 days, so dividing 11574 by 30.5 gives us 379 months.

    A year has 12 months, so dividing 379 months gives us 32 years.

    That’s how big a billion seconds, 32 years.

    Mind blown yet? And don't even get me started on the long scale.

  • Posted on

    This is harder than I thought! I thought it would be easier to keep this blog updated. I thought ideas would just float into my head. They didn't. At least not so far.

    So, here's the plan. Every time I don't get anything to say, I am going to transliterate a Tamil quote or proverb into English.

    Years ago we had a manager who had, shall we say, a little trouble with English grammar. It seemed that his internal monologue was Tamil and he was transliterating everything into English on the fly. The result was hilarious. That's the inspiration of posts like these. I will categorize these posts as #tamiltransliterations.

    Transliterating is not translating. Most translation tools found on the web do this. "To be or not to be" from English to German translates to "Zu sein oder zu nicht sein" and the same from German to English translates to "To be or be to not". Subtle, but hilarious.

    So here we go. I'll start with my favorite Tamil quote.

    Quote - "Ellu na ennai ya vandu nikkanam". (எள்ளு ந என்னைய வந்து நிகனம் ) Intended meaning - "Do more than what is expected of you." OR "...going the extra mile". Transliterate - "Sesame seeds means you should come and stand oil".

    Oh by the way. I had a blogspot years ago meant for just such a thing. I am borrowing stuff from there.

  • Posted on

    Today, Thursday, 11 July 2013, is a beautiful morning. It rained like heavily last night and that usually results in a cold and clear day. Perfect day to start blogging. Hopefully I will be able to keep up the blog despite my work. Wish me luck!!