Monday, 2 May 2016

Moved - to Wordpress

Dear Blogger,

If someone come to visit me here, please let them know that I moved to a new place at WordPress.com. Please forward any letters/packages you may receive to my new home: https://thammegowda.wordpress.com/

Thanks and Good bye.

-
TG

Monday, 4 April 2016

Maven project with scala and Java sources

Some of the best tech I learned these days are scala, spark, spark-MLlib and graphx.
My work with spark forced me to learn scala even though I was very comfortable with Java8. I admit I had attempted to learn scala earlier but gave up with the prejudice that Java8 caught up with scala in terms of richness of language features. Actually now I figured out that Scala is 10x improvement over java (< 1.8). Java language with version 8 upgrade caught upto 4-5x and still missing bunch of rich features of scala language.

That is being said, i wanted to document how to setup a maven project which can build both the scala and java source code. (Do I need to say that we can call scala routines from java and viceversa?). This is very useful because we can just add the scala plugin to existing maven java projects and start to make use of scala without any extra effort.

mkdir my-project
cd my-project
mkdir -p src/main/java src/main/scala src/main/resources/ \
                src/test/java src/test/scala/ src/test/resource
emacs/edit pom.xml  # and copy paste the below content to

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    
    <groupId>com.example</groupId>
    <artifactId>test-project</artifactId>
    <version>1.0-SNAPSHOT</version>
    
    <packaging>jar</packaging>

    <name>Test Project</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <scala.version>2.11.8</scala.version>
        <exec.mainClass>JavaMain</exec.mainClass>
    </properties>

    <dependencies>
      <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-library</artifactId>
        <version>${scala.version}</version>
      </dependency>
      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
      </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>net.alchim31.maven</groupId>
                    <artifactId>scala-maven-plugin</artifactId>
                    <version>3.2.1</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                  <executions>
                    <execution>
                        <id>scala-compile-first</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>add-source</goal>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>scala-test-compile</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions> 
            </plugin>
        </plugins>
    </build>
</project>

Let's put a sample Scala code
emacs src/main/scala/ScalaMain.scala # paste the below conents

object ScalaMain{
     def hello(){
           println("Hello there from scala")
     }
}
Lets call scala code from java :
emacs src/main/java/JavaMain.java  # paste the below contents
public class JavaMain {
     public static void main(String[] args){
          System.out.println("Hello From Java");
     ScalaMain.hello();
     }
}
Lets Compile and run
mvn compile exec:java  # the class is already specified in pom.xml as exec.mainClass

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Test Project 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
.........
[INFO] 
[INFO] --- exec-maven-plugin:1.4.0:java (default-cli) @ test-project ---
Hello From Java
Hello there from scala
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.239s
[INFO] Finished at: Mon Apr 04 00:42:25 PDT 2016
[INFO] Final Memory: 14M/216M
[INFO] ------------------------------------------------------------------------


Summary : 
I just documented the pom.xml configuration for a maven project which can compile both scala and java sources.

Thursday, 21 January 2016

Multiplication table using matrix in spark

In this post, I am sharing a code snippet to demonstrate multiplication table in spark.

In addition, it also demonstrates the following:

  • How to create a custom Spark RDD
  • How to create an Iterator/Generator
  • How to work with matrices in spark

Assumption :

  • You are using JDK 8.
  • You added spark and spark-mllib libraries to the classpath. I assume you use something like Maven and add these dependencies.



import org.apache.spark.Partition;
import org.apache.spark.SparkConf;
import org.apache.spark.SparkContext;
import org.apache.spark.TaskContext;
import org.apache.spark.api.java.JavaPairRDD;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.mllib.linalg.distributed.CoordinateMatrix;
import org.apache.spark.mllib.linalg.distributed.MatrixEntry;
import org.apache.spark.rdd.RDD;
import scala.collection.AbstractIterator;
import scala.collection.Iterator;
import scala.collection.mutable.ArrayBuffer;
import scala.reflect.ClassManifestFactory$;

/**
 * This class illustrates multiplication table on spark!
 * @author  Thamme Gowda N
 *
 */
public class Main {

    /**
     * This RDD has numbers in it.
     * This RDD can be used for illustrating math operations on Spark
     */
    public static class SequenceRDD extends RDD<Long>{

        private long start;
        private long end;
        private Partition[] partitions;

        public SequenceRDD(SparkContext _sc, long start, long end) {
            super(_sc, new ArrayBuffer<> (),
                    ClassManifestFactory$.MODULE$.fromClass(Long.class));
            this.start = start;
            this.end = end;
            this.partitions = new Partition[]{
                    () -> 0 //just one part at index 0
            };
        }

        @Override
        public Iterator<Long> compute(Partition split, TaskContext ctx) {
            //we have only one part, so this is it
            return  new SequenceIterator(start, end);
        }

        @Override
        public Partition[] getPartitions() {
            return partitions;
        }
    }

    /**
     * This iterator yields numbers so we can build an RDD on it
     */
    private static class SequenceIterator
            extends AbstractIterator<Long>
            implements java.util.Iterator<Long> {

        private long nextStart;
        private long end;

        /**
         * Number generator for [start, end]
         * @param start the start
         * @param end the end, inclusive
         */
        public SequenceIterator(long start, long end) {
            this.nextStart = start;
            this.end = end;
            assert end >= start : "Invalid Args";
        }

        @Override
        public boolean hasNext(){
            return nextStart <= end;
        }

        @Override
        public Long next() {
            return nextStart++;
        }
    }

    public static void main(String[] args) {
        long n = 1_000;
        String outpath = "multiplication-matrix";

        long st = System.currentTimeMillis();
        SparkConf conf = new SparkConf()
                .setAppName("Large Matrix")
                .setMaster("local[2]");
        JavaSparkContext ctx = new JavaSparkContext(conf);
        JavaRDD<Long> rdd = new SequenceRDD(ctx.sc(), 0, n)
                .toJavaRDD()
                .cache();

        JavaPairRDD<Long, Long> pairs = rdd.cartesian(rdd);
        JavaRDD<MatrixEntry> entries = pairs.map(tup ->
                new MatrixEntry(tup._1(), tup._2(), tup._1() * tup._2()));
        CoordinateMatrix matrix = new CoordinateMatrix(entries.rdd());
        matrix.toIndexedRowMatrix()
                .rows()
                .saveAsTextFile(outpath);

        System.out.printf("n=%d\t outpath=%s\nTime taken : %dms\n", n,
                outpath, System.currentTimeMillis() - st);
        ctx.stop();
    }
}

Tuesday, 19 January 2016

Comparing cubic time complexity algorithm with a fourth-power complexity

   I thought of comparing n3 and n4 running times to feel what it means to have a slow algorithm.

Let us suppose we have an algorithm with cubic runtime complexity:

 int n = 2500;
 int[] arr = new int[n];
 System.out.println("Start");
 long st = System.currentTimeMillis();
 for (int i = 0; < n; i++) {
   for (int j = 0; j < n; j++) {
     for (int k = 0; k < n; k++) {
       arr[k]++;
    }
   } 
 }
 System.out.printf("%dms\nDone!", System.currentTimeMillis() - st);

For n = 2500, it completed in 1.827 seconds on a modern i5 CPU :
 Start  
 1827ms  
 Done!  

Now, an algorithm of power 4 time complexity,
 int n = 2500;
 int[] arr = new int[n];
 System.out.println("Start");
 long st = System.currentTimeMillis();
 for (int i = 0; i < n; i++) { 
   for (int j = 0; j < n; j++) {
     for (int k = 0; k < n; k++) {
       for (int l = 0; l < n; l++) {
         arr[l]++;
      }  
     }  
   }  
 }  
 System.out.printf("%dms\nDone!", System.currentTimeMillis() - st);

With just one additional loop, for the same n=2500, it took:

Well, it didn't complete... I waited 15 minutes, yet no answer!!
EDIT: It completed after 47 minutes!
 Start  
 2863936ms  
 Done! 


Why is this comparison important to me?
  This comparison became interesting to me because I have implemented a Tree Edit Distance algorithm which has a fourth-power time complexity of the input size (number of nodes in the trees). I used this algorithm on HTML DOM trees which have around 1000 to 2500 HTML elements.

Summary 
 Thus, an algorithm with power 4 is not an acceptable solution for tree edit distance for web pages with more than 1000 HTML elements.
I am seeking a better algorithm.



Digit grouping for very long numbers in Java

When we need to write a Billion on a sheet of paper we don't just write 1000000000, because it is hard to see if it is exactly a billion or  hundred million in the very first glance without counting the digits. Instead, grouping the digits is common practice so it can be written as 1,000,000,000. It is evident that grouping the digits improves the readability of numbers.

    However, all these days I never saw anywhere grouping the numeric literals in the software code.  Recently I was surprised to see that Java language supports digit groups by using the underscore ('_') characters as group separators. For example, the following is a perfectly valid way to store a decimal Billion in java.

int n = 1_000_000_000;

Saturday, 29 August 2015

Some day I will do it - not a procrastination

    'Someday I will do it' - might seem like words of a procrastinator. But let's not judge so quickly from a single sentence. Maybe today is not the best day, so 'someday in the future' will be better than 'never'.  I agree that saying 'someday I will do it' is indefinite and I haven't come across any system that accept 'someday' for an event. What is interesting is - when we wake up in the morning, how nice it is to know that the day we hoped in the past has arrived!
     I have said these phrases many times - 'Someday I will do it', 'someday I will have it'. Fortunate enough, that day has arrived to fulfill many of my wishes. I had to pack my stuff and run when I realized it. Out from my huge 'basket of wishes', I am going to pick few of them out because they are now real. I wished for going to a grad school, meet people, make friends, for the sake of knowledge and experience in life. I am excited to have my dreams coming true. We make wishes all the times, but rarely we find time to fulfill them. Some wishes have deadlines; if we can not fulfill them within the bounds, we have to let go of them. I know that failing to fulfill dreams is very disappointing. I am glad to say I did not fail here.
    It's been a while since I wrote any post here in my blog. Let me catch up! Three weeks prior to this day, I flew from Bangalore to Los Angeles, I also visited London on the way! I am now in USC campus near downtown LA.
A lengthy day with 20 hours of daylight
Memorable is my first international flight
From a colony in the east
To a colony in the west
Via the capital of the kingdom
History in hand is ridding-off the boredom
     If I draw a circle centered at Bangalore International Airport with the radius of 40miles, the area inside the circle covers everything including the place I born, schools and colleges I went to, offices I worked for, relatives and friends I have visited. I seriously wanted to travel to a different part of the world for the sake of experiencing the change in my mid-20s. The someday that I hoped in the past is here with me in the present.
     My classes started this week. Many exciting events are happening in and around the university campus.

I will be back with a new post.

Tuesday, 23 June 2015

How did I land in startup?


I like to dwell upon the time, but this time I am not writing about time from cosmos, instead I am going to share few incidents from my recent past and the lessons I learned. This occasion marks the completion of my three years of working in a startup environment. I strongly believe that my tomorrow will be the result of the choices I make today. With the same belief, I can say whatever I am today is the result of choices I made in the past. People say having a dairy and writing down about the thoughts and opinions will shape the personality for better as that is the time one speak with the self. This is the time to look back at the self to appreciate the good while also correct the wrong doings. I don't have my dairy to tear few passages to stick together and tell you the story, but I try to be honest and recollect the facts from self-memory.


How did I land in SimplyPhi?

I feel my entry to SimplyPhi as a serendipitous chain of events that somehow happened. Let's begin by traveling back in time and I am sure you will be equally surprised too. 

October 7, 2011: I was offered a job from a company named TC*. They are the first guys to come to our college campus for recruitment. I was in final year of my undergrad studies. People who head our college placement department sold them like hot cakes by stating the facts that
   1) they are one of the biggest companies of our country with so many branches around the globe.
   2) They are one of the best and safest place to work as they ensure that our job is safe irrespective of recession or anything like that.
   3) Most of our seniors work there! They have a great brand value.
I did not experience the real sense of a job interview. My name was among the college toppers' list so I received a direct entry. The HR round interviewer looking at my records said that my records show my brilliance and annotating to my name said that I am a 'Gowda' and he is a 'Gowda' too, hence my interview was complete. Well, this point in the timeline, I was happy that I have a job; My parents were happy that I will be joining a big company to earn big money and the job will be safe. Things were normal!

January 20, 2012: Somebody named Gautham sent me a tweet asking for an email-ID to begin a private conversation. I shared my email-ID and then we had exchanged few emails. I was not sure who he was in the beginning. In another mail, he articulated about what he was doing, and his ambitions with his emerging startup Jnaapti.

January 21, 2012: Gautham and I had a long talk on a phone, he talked about so many topics, mostly related to startups. One thing he said was TC*(Company which hired me in campus) was not the best company for my level of caliber(In my mind – He is true, indeed! Google should've come to our campus for recruitment). He said I shall be placed to a better company who utilize my enthusiasm, skills while also offer a better stage to learn.
I even mentioned to him that my dream company to work is Google. In a later email, he shared many links about startups, about startups in the news and the startups to which he is connected.
And one thing he made clear - “Remember that Google, Yahoo, Facebook etc started as startups one day.”  'Why not think of building one?' I was sold to that thought in the very next moment. Thank you, Gautham, what you did that day changed my thinkings and offered me enough confidence to go for it.

February 2, 2012: A screening call from Monis Khan, Director of SimplyPhi.
We had a talk and he invited me to their office for discussions. I asked for time.

April 28, 2012: Interview at SimplyPhi Software Solutions.
I literally took many days to get back to SimplyPhi after the screening call. The interview went fine as they made me implement few algorithms. I wrote C code. This was my second interview and I had received my second offer. I liked the place, the liberty in work culture and the idea of being fully responsible. Moreover, I wanted to become a very good programmer. No, I wanted to become extremely good at programming. These people promised me that they will make me write code every day and will guide me as they are programmers too. I hated the idea of being idle on bench or taking support calls on the first offer from TC* instead of constructing something, I was not even sure whether I will get a programming role if I join(as I get to know about this from seniors)

May 2012: The decision-making time.
While very few of my friends said it's good to not join TC* and join a startup, but many of friends said it's not wise. Even my dad was not so pleased to digest that I am not gonna join TC* offer which is in hand. He might have learned from his friends circle about TC*, its hugeness and ubiquitousness. But my decision was already made in my mind and all I needed to do was to convince them. At last my parents said - don't worry much about the job, if something goes wrong we can look after you, you can look after our farming, we have this for you. That was bold; thank you dad, you let me do what I wanted to do! Summary of this - When you are not worried about losing job or failures, you get the courage to do whatever you wish to do. For the next two years, I want to be a programmer, I want to learn to build Softwares, and SimplyPhi felt like a better deal for it.

June 14, 2012: Last day in college, I had the final demo of my project. My last days in college were not very enticing(in other words - sad, I just wanted to get out of that). I didn't want to go dormant, as the dormancy would only hurt my mood. I was seeking something fresh, exciting, challenging, yet fun to keep me busy. I was thinking of rushing to Bangalore

June 16, 2012: I joined SimplyPhi Software Solutions.
 I was supposed to join few days later, but I was very eager.
My new life began from this day. I was a villager and now I live in a metropolitan city known for IT. I was a guy from a tier-3 college, but now I am conversing with best minds from IITs. They encouraged me to fill up my shabby fundamentals, I re-read algorithms, computation theory, data structures and some pieces of mathematics which are essential to think like a real programmer. At times, I used to have 40+ tabs open in chrome most of them were from Wikipedia. As promised they made me write code and solve the variety of problems. Be it web servers, web crawler, android apps, distributed systems, databases, search engines or anything like that, I didn't say No (let me be honest: I had liberty to say no, rarely I said NO for the tasks I didn't like to do. No to a client with a decade old windows server with all the shitty outdated enterprise stuff. No to some web interface while my mind was drifting to NLP research). The best part of this service oriented startup is  I got a variety of problems to solve in less time, which I can summarize in my own words – learn in the money of clients in the exchange of my time. Later on I became part of a product based startup, Datoin. All these cannot be completely comprehended here.

What people say - why not join a startup? 

Joining a startup as a fresher was a pretty scary thing to do for me about few years ago. Because it seems lot of work. Because it seems complicated work. Because my college didn't teach me well and I didn't know if I will be able to handle it. Because it seems risky and company may be shut down as they have more chances of being bankruptcy or miserably failing. Because every educated uncle and aunty I meet will ask me where I work, and they will counter me when I say a company whose name is not well known. Because there are lesser people at work and less possible new friends. Because startups don't have much money to do extravagant offers. Because they won't have a cab service or free food. Becuase they don't have onsite trips. Because....

Stop! I can now separate the genuine claims from all the speculations.


What I say - why work in a startup?

I use this as an opportunity to answer few questions which I am being asked by many. I like answering in line, one-on-one.
Because the work seems much in quantity, quality, and complexity.
I would like to tell you a story which I heard somewhere a while back. Once there was an eighteen-year-old boy, he was assigned the task to drive to a railway station on a rainy dark night to pick up a distant relative. Does this assignment seem too much for the boy? If the visiting guest is an old man who keeps yelling at the boy – Yes it is too much indeed. Suppose if the visiting guest is a girl in sweet sixteen whom the boy has developed crush recently – the boy will do it out of pleasure. Though the time and effort required for the trip will be same irrespective of an old man or his crush, the boy will have a different feeling about it based on the person. That means nothing is too complicated when you enjoy. The first few years may be the foundation for the rest; it has to be hard to be strong. I loved programming, I love building Softwares, when things get complicated, I shall learn to deal with them and there is a fun/kick in solving the complex problems. If you love building stuff, startups need your time and you need to do so called 'field work' in startups. 


Because I am not from an elite college, my college didn't teach me, I am not sure if I am ready for it.
 Agreed that elite colleges alumni had gone through a better environment, but the past is past.  Don't ruin your today by complaining that your yesterday was not elite. We all keep looking for opportunities and we should act when we see one. If you think there is something you can do, sure there will be many things you can do. If you think you can learn on your own, then there is no one to stop you on the internet. You should seriously worry when you are physically or mentally challenged for learning and picking new stuff. When you see people with good caliber quitting their high paying jobs to do something on own to realize their ideas, why not go and join them and put a hand of support? You don't need to do this just for the sake of feeling good. While you sit and work along with them you can catch up with them and see how you match with them. If things go well, it's gonna be mutual benefit. You help the team to realize their dreams, they help you become what you want to be by offering enough support and opportunities.


Because it seems risky and you can be out of the job any time.
Let me tell you the harsh truth: The corporates hire you, they alter your hobbies, they make you like whatever is good and profiting for them, they make you get used to laziness while they keep you as redundant candidate for risk recovery and finally when they are in trouble or they find a better candidate in the queue, they will fire you, for God's sake- you will be in trouble, not the company which hired. On the other hand it doesn't matter whether the company is big or small, whether well established or starting up, it doesn't matter whether your seat is safe today or for next few more days; if you are not useful, you will be let off by the companies as well as most people you know. Being in twenties without many family commitments(like marriage, kids and all) but thinking that you're doomed on the next day you're removed from the job is immature. You should seriously worry when you don't have the skills that are useful for others to employ you. The only thing to save you from this mess is the child inside you who keep on learning to be a better self and the grown up in you who is ready to adopt to changes. If you are working in a startup that is trying to solve the problems that are worth solving, you are going to be useful for many others too. For instance, just after one year of my endeavor in my first startup, I started to receive messages in LinkedIn asking if I am available for Job switch. Some of them are from HRs of well-known product based MNCs. Few years back I'd have loved to join them straight after the college. Recently I was offered an offer of almost twice the salary I draw currently, but I had to turn them down. The final word on this anecdote is - Keep a green tree in your heart and perhaps a singing bird will come.

Because every educated uncle and aunt asks where I work. I need to have a brand name.
People love to associate with brand names and love to speak about big things, but very few of them associate with the quality work. This is real, and I have faced it. Occasionally when I meet some of my relatives, people say their boy/girl work in well-known company and was offered to travel to other part of the world. Often I feel irritated when they boast that their boy work for X company which sent to Y country for onsite work, now he is earning Z lakhs. One of the worst conversation I had that I cannot forget is when one distant relative gave his remark – “I heard you're quite good with studies why didnt you go for a Government Job?”. I want to live for the day when people really talk about the kind of work they do before taking about its consequences. I say myself - You are not your resume, you are your work, so a better you is when you do better work. Anyways, it doesn't matter what all the uncles and aunts you meet on road feel about you, what it really matters is feelings of your family.

Because less people around and less friends.
 I accept the fact that these are the choices I made. I might have made only few friends, but most of the people I happened to work along are dreamers and achievers. My lunch time discussions with my colleagues were always enjoyable, yet there were serious topics involved. Some of these conversations have impacted so much on me that they changed the way I now perceive the world. Who knows the current startup might have offered common lunch time and place for a next Bill Gates and a next Steve Jobs! they are not many. 

No pickup and drop, No free food.
I agree that they are good to have. But, seriously you wish to join a company because they have a nice pickup bus or they serve your favorite dish at lunch? Now I see what these big companies are making. They want you to get used to them so you can not quit even if you would like to quit. I chose to be independent and free.

Startups don't have too much money and no extravagant offers and perks
This is true as well as false, depends on the startup, your role and the remaining people in your team. When you join an early stage startup which has not yet gone for fund raising, then the odds will most likely to be compensated with the stake. All the well versed startup people talk about the stake instead of salary in this space, but that is for well-versed people. What I recommend for a person who is just out of the college and is trying to make his mark is: don't let the money decide what you do and what you don't do at this phase in your life. Let your first focus be on learning and exploring what you love. I can promise you, there is lesser politics at the place where there are few people involved than at the place where many people are involved. If you happened to meet right people who appreciate your hard work, you will be given appraisals like every other company. However this is not for sure, I have come across examples of my friends who happened to be underpaid and their hard work is overlooked. If you are surrounded by a bunch of greedy businessmen who keep all the stake with themselves and also feel the effort/risk you put is insignificant compared to their's, then you shall have a second thought. If you ever feel you're not at the right place to grow old, learn what you can, pack your stuff, and devise an exit. But if you're around handful of good men who appreciate your presence during the journey of conceiving an idea to MVP to scalable product/service, if everything goes fine you can be unprecedentedly rich few years later.  or if everything goes down you have to start again. That means the money part is quite uncertain. As a newbie out of college, set your expectations right, don't expect to be a millionaire or a billionaire(like Mark or Bill) in a night. Just focus on learning everything about starting-up, scaling-up so you can either land in your next high paying dream job when you plan to surrender your skills for money, or use these learning for starting up your own endeavour.


EDIT :
Looks like I added so much spirit about startup. Every Tom, Dick and Harry aren't encouraged. In spite of saying this, join startup only if you can foresee what is waiting for you.
  • More learning than what you did during your college. 
  • More pressure than what you had during the night before your exam; occasionally when things break, slip or don't work the way they suppose to work.
  • More complexity in the problems than you might face otherwise.
  • More responsibilities, multiple roles to take care of. You will be an admin, a developer, an architect, and a tester. Hence, you will be completely responsible for whatever you do.


 I have more exciting news which will be coming up soon in another post. If you have any question worth asking and getting a reply from me, go ahead and use comment box below!!


Tuesday, 2 June 2015

Answer to a younger friend - why things changed?

A younger friend of mine, asked me - brother, why are you not doing any hacking with phones these days like you were doing earlier? For a second, I was silent as my mind went past the time to dig an answer.

When I was in college, I enjoyed tinkering with machines. It started when I tried whole night to make my computer dual bootable instead of playing video games. My enthusiasm reached a new height when I figured out free Ubuntu CD to break into any computer with a CD drive; later I figured out to create bootable USB stick. I enjoyed computer repairs, when my school teachers, my techie as well as non-techie friends asked me to fix their machines. I still get some requests, sadly I can't say them - "No, I don't repair your computer". 
    Smartphones are the other fun part of the story. I started my journey with Nokia series-40 handset back in 2008. Those days phones had supported an SDCard of capacity upto 2 giga bytes size. I loved listening to the romantic songs of south Indian language movies. Okay, 2 GB was not sufficient to load my favorite MP3 files along with my favorite videos accompanied with thousands of images which we used to call as wallpapers. With the help of a multimedia converter, I figured out optimal size-to-quality ratio for audio clips and video clips by adjusting the bit-rates, which let me load nearly 900+ songs in 2 GB Card. ( Believe me, the batch conversion took whole night and the tiny music player responded like a dead beast after seeing those many songs). Then came Symbian OS handsets (N Series, E Series) which allowed me to reply a message on IM, browse web on a browser and listen to music at the same time - that's why I needed a multi task capable phone. That was not enough, there was a next step, where I could 'hack' (the very first meaning for this word I encountered in my life was close to jailbreak/root in today's ios/android terminology) the OS to provide full privileges. That enabled me to do some crazy things like install DOSBOX emulator on my Nokia E52, using which I was able to operate windows 95 and Turbo C++.
    I am sorry for your death, Symbian, I moved onto something I love even today - the Nokia N900. It had mobile debian linux OS called Maemo, and the best part was there was no need to hack/root as the OS offered it out of the box and it was legal. This is where I developed interest on Free and Open Source Softwares. Gone are those days, I had a mini laptop in my pocket! This story will become a new story if I start to give just a glimpse of what all I did on my N900, so lets move on to the next one. I joined the Android ride when it was at version 3.1. It was only a week after my purchase, my Galaxy Tab 10.1 was bricked while I was trying out something, but later I learned to root, flash, backup, recover the device without taking to repair shop. I don't remember me taking any device to service man for software repair even if device was within the warranty period. A few months later, I was virtually running ubuntu and fedora on my tablet as android was too kiddish for someone who lived with N900. Later I bought a Nexus device and an iPAD, which are way powerful, modern and capable than my previous gadgets (excluding N900, it will never be old for me ;-) ) but I don't remember having much fun with these compared to the previous gadgets. 
I think I found an answer for that question of my young friend, it is - 'I am busy with my work.' I have told this phrase to so many people at times, but this time it had a different connotation. This is the proof - we spend most of our time at work and it impacts our habits. On the other hand, I found my coolness in learning and solving harder problems at work so job is not the real culprit, it is change of interests.



Sunday, 19 April 2015

A Shakespearean conversation

A: do you use a spell checker?
B: Yes, I do.
A: why?
B:  Because I don't like to sound ridiculous. I care for my language.
A: Shakespeare didn't use one, but I believe he still cared for language..., look at him, he invented so many new words. Can you imagine what would have happened if he had used a stringent spell checker like yours?
B: That's not my business, please spare my neurons.
A: It is your business, you said you care for your language.
B: Oh! did I say that?
A: Yes, you did.
B: Alright, I don't have the liberty of Shakespeare to use whatever the word I feel like using. For instance, I can't use "cutted"  "putted", even tough I feel they're more appropriate and less confusing. You know, there are confusing rules.
A: Okay, I got it. World doesn't encourage creativity and abnormality.

Sunday, 11 January 2015

Time and Timeline

Tick...Tick...Tick...Tick... Its running. What is 'it' here? Any educated person who had seen clock says it is time. When somebody asks me 'What is time?' (I used to look at my wrist earlier, now) I look at my phone to answer it. It was alright till few theories and articles of physics spoiled my mind. One of which is 'The brief history of Time' by Professor Hawking. Questions such as : did I address the question of 'What is time?' properly by looking at my clock, Is that what that person was seeking from me? - never raised earlier. By looking at the clock I see its the clock running not the time. By looking at the count down at a traffic signal I see its the countdown running not the time. These are actually measures getting mapped to time. Then what exactly is time in my view? Read on..
Imagine a perfectly spherical ball on a perfectly flat ground staying at rest. Imagine a small supporting component which elevated the ball to few centimeters high in altitude. Suppose if a golf player hits the ball in parallel to ground, the ball start flying in parallel to ground with maximum velocity in the beginning but sooner it slows down. It slows down because there is gravity which pulls down the ball and opposition by air which resists to give way. As gravity pulls down the ball slowly tends to come down, when one face of ball touches the rough ground, it is felt pull back due to friction while the rest other parts are continuing the initial movement which gives a revolving motion to it. Let us suppose that we set up an ideal place to conduct this task again. Suppose there is a line one side of which there is gravity and other side of it has no mass and no gravity(a complete void). Imagine the same old player hitting the ball placed at the edge towards void side. The ball keeps moving in the direction of force and continues to move in its initial pace since no other external force acts on it. What if the direction it is advancing has no obstacles at all and no boundaries at all? It goes on and on and on as time goes on and on. Is it what the time like? If yes, then what precisely is the time here – the ball, its path, its current location or its direction? If only one of the aforementioned choices are true, what are the others?
Though I haven't found accurate answers for my previously mentioned questions, I am approximating few answers to pave my way to another curious yet interesting task. I presume that the 'Time' in our discussion is the ball in our previous experiment. It is moving. It is also running. It has no obstacles to hit and stop. It also has no other external force to alter its speed. Apparently if the ball is not messing with any other entity then it leaves no footprint or mark. Imagine an imaginary silencer at the back of the non revolving yet advancing ball which emits colored non diffusing smoke. Now we can see the path taken by ball. Let us call this path as 'TimeLine'. So the Time leaves our imaginary 'Timeline'. The path behind the ball is 'History' and the path it might take as it proceeds is 'Future'. I honestly do not know what is target is and who hit the ball. Leaving aside prediction of future path of ball but get hold of 'History', lets try to bring you and me into the path.
You, me, everybody has a lifeline which is the line segment in our imaginary timeline connecting the point where birth happened with the point where death would happen. Our enjoyments, studies, works, family life and everything else comes in between these two points in time. This tiny segment is duration of our lives!! Jesus Christ's life segment is nearly 2000 years earlier to us on the same timeline. Pythagoras, Euclid and other Greek nobles time lifespan is much farrer than that. The past timeline has witnessed glorious empires, merciless wars, amazing personalities and mind-blowing discoveries. I am after the problem of bringing all of these goodies and baddies and their actions virtually into a system as simulated entities. I am after the problem of making a computer to know complete history instead of saving narrated history as zeros and ones. Wish me best!!

Wednesday, 31 December 2014

Closure for 2014 year

 Here comes the end of 2014, so this is the time to say good bye to it. Another year is completely spent. The journey of 365 day units traversed along the dimension of time posed new challenges, offered new learning, met several new milestones. All these encircle around just three aspects - Family, Work and Dreams.
  This year at work I took over new responsibilities which confronted me with new challenges. From the beginning of the year I worked to make Datoin real. This gave me an opportunity to involve and witness end to end product development. Though I always loved programming and making stuff, this task was more than that. Everything went fine and now I am super excited to see what is going to happen to Datoin in 2015.
 In the family and dream side, many plans came into execution. We rejuvenated our house which was built at the time of my birth. I convinced my parents about my dream to continue further studies. And then worked restlessly towards making my dreams to come true. No, its not just continuation of studies, rather I was and I am very specific about my studies. I want to study Artificial Intelligence, moreover I need to join place which has best researchers.  So, I calculated what is in the middle of me and my dream grad school.  I found that I need 3 years time - one year to prepare & two years to pursue,  need to qualify few exams and need to apply for a loan to pay college fee. Near the end of the year, I managed to take temporary leave from work to prepare for exams.
   During my holidays, I spent days and nights to crack GRE. I loved mathematics so I didnt do any preparations for GRE maths. I realized that the path to my new dream demands superlative language usage capability irrespective of GRE's score. English as a language made me uncomfortable ever since I started to learn at age 11.  Though I have learned grammar in high school and few vocabulary words later on, it is only less than quarter of required. I had known only two ways of making myself prepared : read books, watch movies. Later I appeared for GRE and I secured score of 300/340. I was bit disappointed. I retook and this time I scored 315/340.  After my holidays, I joined my team at Datoin to continue my work on infrastructure. Meanwhile I applied to my dream schools for grad school admit.

 I  With this my 2014 nicely ended by leaving hopes for 2015 regarding Datoin and my Graduate Studies.



  

Tuesday, 9 September 2014

The four patterns : a philosophy

You took birth as an Homo Sapiens. You have limited lifetime as a living creature. In the past couple of decades, you've probably grown up: physically your growth has been stalled; mentally not yet!. May be you have earned some resources and/or inherited some. May be you acquired some knowledge by your own and learned from others. Now, standing somewhere in this jumbled society, looking for the path ahead. In a nutshell, all the tangles gets reduced to these 4 patterns:

  1. You convert energy into capital. May be you do business or a day job to serve the needs of others. You boost your capital. You use a portion of it to buy comforts. The rest, you transfer as inheritance or as charity.

 2. You use your energy to acquire more knowledge.You transfer your knowledge to others : may be via writing, teaching, etc.,.

3. You absorb all you receive, consume all you have and leave no trace. May be you are under privileged or got reasons to tell why this is so.

4. May be you will find the right balance of above. The extent of each of them depends on your abilities and luck.

And finally you will die, after which you are not a living body. May be your life will be interrupted if some one or something doesn't like your actions and possessions.  

Sunday, 31 August 2014

How did nature facilitate birth of intelligent species in finite amount of energy and time?

The question "How intelligent animals are came into existence in this planet?" was whirling in my mind. Such a question had arise when I was thinking what does it take to create a truly intelligent agent like human brain out of a finite amount of energy & time.
This is amazing - the answer I was seeking is finally here:
Vast amount of energy formed due to sudden burst(Big bang) resulted in formation of particles(such as quarks).  High temperature kicked these particles to move faster and faster, but expansion caused temperature to reduce and hence particles gradually slowed down. This resulted the formation of next order particles(such as electrons, protons, neutrons...). As the particles slowed down further due to dropping temperature, protons and neutrons accumulated into nuclei and hence atoms are formed. As the temperature further reduced and movement further slowed down, electrons gets attached to nuclei and relatively stable state is formed which resulted in formation of atoms. Till now atoms are of single atomic number (one proton, one electron) -  we call it as Hydrogen. These Hydrogen atoms with unit proton, neutron & electron then resulted in forming galaxies, stars, planets. Later on by addition/fusion of Hydrogen, higher elements with bulky atoms(more particles) formed. In that process an higher order atom with 6 protons and 6 electrons formed - we call it as Carbon.  And even an atom with 8 protons and 8 electrons also formed - we call it as Oxygen. After certain time when temperature dropped to a pleasant value,  in one of the revolving body (Earth),  these atoms of  Hydrogen, Carbon & Oxygen together created these wonders on this planet- Water(Hydrogen and Oxygen), organic matter(Carbon and Hydrogen) and combustion (Carbon & Oxygen).
 Now lets jump on to Darwin's theory - When water on this planet gets stagnated, Carbon and Hydrogen settled to form a cell of organic matter, it was later evolved to multi-cellular organisms such as algae, marine species including water plants, amphibians, land species, birds. Out of so many possible combinations, there also lies a combination which had natural intelligence, we call them humans.

Now the question is - these intelligent species are now trying to find out answer for the question - why is the universe the way it is?

A month ago, while I was surfing on an online store, there was a recommendation of book : 'Brief history of Time - Stephen Hawking'. I was aware of Professor Hawking, a famous physicist. Preface and short summary of it were interesting. I said myself - 'Its been long time you read physics, lets have a look'.

High school science text books introduced basic laws of science, which are then broadened during pre university studies. During undergrad freshman year had read physics again on few narrow topics such as quantum mechanics, optics,... (In fact, my all time high score in academics was achieved in physics - 99/100, during Bachelor degree!) But, somehow the topics read were so disconnected in mind. 'The brief history of Time' helped to link one with another to make real sense. Thank you author.

The Author starts with historical beliefs and theories about the world around us. Then takes readers into a journey alongside timeline in which he narrates how the beliefs gets revised as centuries rolled, from Greek Philosophers to Copernicus & Galileo to Newton to Einstein to Heisenberg & Bohr to contemporary physicists. Meanwhile, you will be given with thoughts and affirmations of improvement in accuracy of understanding of universe.

I enjoyed reading it end to end, completed today. I would greatly recommend it to anybody who is interested in physics. If you don't have time for going through works of several researchers & scientists of past two millenniums, Professor Hawking has summarized it for you in simple words! By the time you finish reading book, you will be more confident about basic concepts in science.

I was astonished, for the way Professor thinks. The way how he throws questions, and answers one by one. This book summarized many theories, out of which it developed deep interest in me to have a deeper look on Einstein's "General and Special theory of Relativity" and Darwin's "Evolution of species". Now, I know what to read next! 

Saturday, 16 August 2014

Effort is necessary to make favorable events happen but unfavorable can happen themselves

Wondering why conscious effort is necessary to make right events to occur but wrong events can happen by themselves! Right events, I mean here, are favorable events.

Recalling Murphy's law

1. Anything CAN go wrong, WILL go wrong. (full of pessimism)
2. what ever can happen will happen if we make trials enough.(a little room for optimism).

Inferring from second law of thermo dynamics: Disorder tends to increase over the time. From observations "wrong" events must be due to disorder.

Wednesday, 1 January 2014

Photo Tagging : One of the abused feature of Facebook.

One of the exciting feature of facebook is that it allows users to upload images and tag those images to people. This photo tagging has now become one of the abused feature. Mostly newly joined users  abuses it by tagging friends to every photo they want to show no matter whether their friends related to it or not!

Dear friends, If you want to share some content with a set of users, create a group and share it in group. Try not to be aggressive in that, its up to our interests and time to view your content. If you don't know, facebook team has invested lots of effort in recommending posts. If your content likely interests to me, it will automatically come up in my timeline and if it is really interesting to me I will click Like. Please don't abuse photo tagging to get more Likes.

Thursday, 14 November 2013

The next language I want to learn

     Well, these years I learnt a bunch of languages from C to Java to python to groovy to Javascript.....  If i want to learn another, I will go with the language of math. I took slightly long time to understand that the language of computers is language of math and not just 0's and 1's. After all, these machines only know Arithmetic and Logic. So, If I want to make these machines to think, I must start to think in mathematical way. I may be doing that already, but I am trying hard to connect at the moment. One fine day, everything I think, write, understand and speak(source of feelings are excluded) will be placed on top of foundation of arithmetic and logic. Then comes the fun part, sitting down in front of machine and do programming - an action of transferring ones mathematically well established thoughts to 'memory' of the computer!

Friday, 1 November 2013

Why is Kannada Language suffering? : All thoughts here are personal

    Today is November 1st, Every year on this day "Kannada Rajyothsava" is celebrated by Kannada speaking people. So many things happen on this day. Many schools, colleges and government offices of my state celebrates this day just like Independence day which is celebrated on August 15th every year. I can see many wishes by political parties on media.
You can see Saffron-White-Green flags on August 15th and Yellow-Red colors on November 1st. Many people who are Kannada language lovers publicly complain that our language is dying as number of people who speaks Kannada is diminishing as years pass on. These things happens every year and i am grown up in this environment. Yes I am Kannadiga( a person who speak Kannada) and I do love my language.

    I got a new crazy bunch of thoughts about my native language, which i thought of sharing with you all. How is Kannada Linguistics evolving? Well, i tried to find answer for this question, I googled it for a while and was disappointed by results.
As you know by facts - Bangalore is 'Silicon Valley of India' or 'IT capital of India'. Though you can see huge talent pool here in Bengaluru, the fact is - not much work is done in technical adaption of Kannada, in my humble opinion, the current adaption is no where sufficient. This 21st century is where exciting technologies are making impact on life. Kannada as a language is seriously lacking in technical field. My parents speaks Kannada, i had my formal primary school education in Kannada medium. In fact, if i know one language to good extent, that is Kannada(the odd thing is - i had to write this in English!).

I have been learning Natural language processing(NLP). Well, all the time now i am dealing with English text and its grammar. This is where Kannada lacks. Why does not some tools like 'Wordnet lexical data base', 'Stanford Core NLP' and 'Part of Speech tagger' exists for Kannada? From my knowledge it is completely possible because Kannada is a beautiful language with wonderful grammar influenced by Sanskrit(thanks to the works of Paanini).

If you are wondering "why on this planet earth I should really care for tools like above!" Well, applications are front end of technology, that's how people get access to technology. More the availability of tools, easy it is to develop applications and many developers jump to develop for it. I am yet to imagine when Apple's Siri like virtual assistant application can understand and act on my mothers words which are in Kannada!

To conclude, My crazy thoughts are these:
1) I wish some Kannada Universities over there who are encouraging language by giving doctorates to Kannada literature and music, should also consider development of software tools/libraries like this.
2) Its not that Government hiring a team of pure technical people, pay their wages and tell them to do it. Its about building a bigger ecosystem to adapt Kannada language. In my opinions, Kannadigas who managed to get technical education are the people who can make a difference here.
3) Once Sir M. Visvesvaraya, Diwan of Mysore kingdom, then said - "Get industrialized or else.....". Now in this era, it is, "Get used to technology or else you will suffer!"


UPDATE:
 I found that LTRC at IIT Hyderabad is doing some work in related field.

Saturday, 20 July 2013

Leisure cycling: 72km a day to start with

Wowwww! I did it! I did it! Yes, I pedaled my bicycle  60KM + 12KM today!
   It was early morning 5.30am, when i started my journey from Bangalore towards my native which is located at foot of Nandhi hills. It was a 60km ride, and took almost 3 hours and 24 minutes! Thanks to my boss, who advised me to carry few bottles of Getorade's, lots of water, these guys really saved me from dehydration.
Graph: Speed and Elevation
#cycling Stats

    Some beliefs wont change, after reaching home, i took my cycle to a temple to perform pooja to cycle just like we do to every new vehicle we buy. Actually, for me my btwin RockRider bicycle is no less than my Honda bike. This temple was 6Km away from home, my legs were already tired but still had another 12Km of ride.



  It was fun for me. I believe, when we are young, the more we work-out in a field, the more stronger we become in that. One should maintain a good health, no matter what field he works for.

Monday, 15 July 2013

Business versus engineering

Today I submitted my first document of plan. I got a nice feedback from my team about my plan. It was engineer's plan rather than business plan. I was given with example of hotel business plan and plan of hotel building. I don't forget this example. One thing that became clear to mind is: even the most awesomely built systems can fail because of not having good business plan. Yes, I am engineer, and I don't want to build systems which are not useful.

Saturday, 13 July 2013

I got a new bike: btwin RockRider 5.1

Yeah! I got a new bike,
     Its b'twin Rock Rider 5.1. I love my cycle. In childhood, I used to ride cycle to reach school. Now, its an MTB from btwin. No, i am not here to write review about cycle. I know its a good quality one.

    As my boss said once, - "The problem with software guys is that, they(should have been 'we') earn good amount of money, they eat good quality food, but they do less physical work". Its true, one should have a good health.

    Before coming to software industry, i used to get sufficient physical exercise by doing some sort of work(son of a farmer, before all!). My life has changed much in past one year, as Life of a software engineer.

    My Honda bike is pretty good but it does not give me sufficient exercise. I need some physical exercise. I need to write lots and lots of useful code for that i need to maintain good health. From today, I'll use my cycle to commute to office. Its healthy, eco-friendly, and has much more benefits.