Thursday, June 16

Github - Pushing your code to Github

Lets say you have a project you want to upload to github for versioning. You can take following steps to get started.

1) Login to your account in and create a new repository

2) Navigate to your project folder via the command prompt and run
    >> git init
    This will initialize a repository in your file system.

3) Now we need to add all the files into local repository, which will stage it for commit.
    >> git add .
    The "." or "dot" at the end of command is to add all the files in the directory.

4) Next, commit the files and add a message to the commit
    >> git commit -m "Initial Commit"
    Commits the tracked changes and prepares them to be pushed to a remote repository.

5) We are now ready to push the changes of local repository. However, we should first make a pull request so that our local repository is up to date. Usually this step should be taken before we add any files to the repository.
    >> git pull <your_repository_url>

6) If there are no conflicts or issues, you can now push your local repository changes to the remote repository.
   >> git push
   You will be asked for your username and password of github, after successful validation your code will be deployed to github.

Thursday, June 9

Introduction to TypeScript

What is Typescript?
It is superset of Javascript. EcmaScript 5, EcmaScript 6 are javascript specification, however they are not widely available across browsers. What Typescript allows us to do is transpile our ES6 code to ES5 so that it works on all browsers. It also allows us to leverage some ES7 future features.

Benefits of Strong Typing
- In Javascript you can create a varialbe and assign a number or string as per your usage. However in Strong Typing, you can strictly assign a variable of certain type and if the type changes, during compile time it throws an error. Thus Strong Typing catch errors at compile time vs. runtime.
- There is better tooling (refactoring, autocomplete, etc) and hence you can avoid several classes of errors. Example of autocomplete would be when you have a method with three arguments, it would specifically give you autocomplete for only three arguments and warn you if you pass a fourth argument.
- Strong typing allows you to explicitly intent i.e it allows you to write code for humans. For example
 var x: number = 3;
 var y: string = x; //Error
In Typscript you also have dynamic type (using any) i.e
var x: number = 3;
var y: any = x //Works!!! 

In Typescript, you can have Object Oriented Javascript.

Installing TypeScript
1) Install node
2) Install npm
3) npm install -g tsc

Thursday, May 26

Mobile Application Idea

Today, it was a geeknight here, even though I had registered for it, I felt an urge to NOT attend it. Somehow I feel that unless I know much about the subject it is a complete waste of time attending such sessions. I have been tinkering a lot around an idea of creating a Mobile application. Considering that it is quite easy to build an application these days, I still haven't found that eureka moment to actually sit and get started working on one application. The pain point being the initial setup. There are tremendous useful frameworks out there, but setting those up in windows is a tough task. I quit, before I start.

For a period of about 5-6 months, I ran this watsapp broadcast of sending out quotes daily. They were usually Motivational and Inspirational quotes. I had started with around 100+ people in my phone list and then after about 15 days I sent out a message to everyone, if they like the quotes and would want me to continue, they should reply. I got around 60ish replies.  I would send out quotes every single day, and it had become a very good habit until one day when I took a moment and realized that it could be that I am spamming people. "But they want me to send quotes" , I thought, or could it be that out of courtesy they ad replied. Anyways, what I learned from this experiment was
1) Understand your target audience
2) Have a two way communication
3) Even though you start from your family and friends, but don't trust on the outcome. They want you to feel happy, not your best critics.
4) Doing something everyday has greater benefits over doing occasionally. Even though I have stopped sending out quotes, few of them that I remember has helped me in my day to day life.
5) It was a manual task, first look for a good quote that you have not sent earlier, copy it, format it, and then send it out.

I feel that sending out daily quotes not only helped me, it also helped some others. It was not at all a waste of time.

However, Can I turn this into some application? Top of my head ideas that I would want to have in such application
1) User gets a notification every morning about a quote.
2) The application has entire screen covered with quote, also a picture if available.
3) User can comment on the quote, like, share etc.
4) User can browse through all the previous quotes.
5) The best approach appears to have a website and through this website API, the application be made. This way, I can have all the quotes lined up in the database. May be I will write some bot that will fetch the quotes and store in db.

I have to figure out the technology that I would want to use to build such application. Even though is a good idea, I would definitely want to learn a new technology out there.

Monday, May 16

Javascript - The DOM

DOM - Document Object Model

// Create a Simple Object
var object = {};

// It can have key value pairs
var object = {
   name : "Adam"

// An object can have another object
var object = {
   address : {
      street : "Florida"

// To access the values, use the dot notation
var name =

Dom Functions
//Create a paragraph tag
var paragraph = document.createElement("p");

// Add a text to the paragraph
paragraph.textContent = "The DOM is ready to be viewed";

//Add text to body

Event Listeners
//Create a Div element
var div = document.createElement("DIV");

// Set the height of the Element = "100vh";

//Append Element to DOM

// Add Event Listener to Element
div.addEventListener('mousemove', function(event){
    // Display client x and client y
   var x = event.clientX;
   var y = event.clientY;
   div.textContent = x + ', ' + y; = 'rgb(' + x + ', ' + y + ', ' + 100)';


Refactoring your Code
function fullScreen(element){
   //Create a element
   var newElement = document.createElement(element);

   // Set the height of the Element = "100vh";

   //Append Element to DOM

    return newElement;

function input(inputType, DOMElemenet, callback){
   // Add Event Listener to Element
    DOMElemenet.addEventListener(inputType, function(event){
        var x = event.clientX;
        var y = event.clientY;
        callback(DOMElement, x, y);

function output(element, x, y){
    element.textContent = x + ', ' + y; = 'rgb(' + x + ', ' + y + ', ' + 100)';

input('mousemove', fullScreen('DIV'), output);

// So which function's you can change arguments

input('click', fullScreen('DIV'), output);

Helper Functions

function time(){
   var date = new Date();
   var hours = date.getHours();
   var minutes = date.getMinutes();
   var seconds = date.getSeconds();
   var arr = [hours, minutes, seconds].map(function(num){
      return num < 10 ? '0' + num: String(num);

   hours = arr[0];
   minutes = arr[1];
   seconds = arr[2];

   return hours + minutes + seconds;

function output(time){
  var color = "#" + time;
  document.body.bgColor = color;
  document.body.textContent = color;

function startClick(callback, name){
  document.body.addEventListener('dblclick', function(event){

function stopClick(callback, name){
  document.body.addEventListener('click', function(event){

function init(){
   var tick = setInterval(function(){
   },  1000);

   stopClick(clearInterval, tick);


Tuesday, May 10

Blood Relations

Blood Relative and Relative in law => Two types of Relations.

All relations from Father's side is Paternal
All relations from Mother's side is Maternal

So Father's brother is your Paternal Uncle and similarly your Mother's brother is your Maternal Uncle

Cousin Brother or Cousin Sister is not correct. It is simply Cousin.

Nephew -> Male child of your Sibling (Brother or Sister)
Niece -> Female Child of your Sibling (Brother or Sister)

Tricks to solve blood relations Problems
1) Applying to your self
2) Summarizing the statements
3) Moving step by step

Q : I met a person, who was your bother's mother's brother. What would be the relation with you.
A : Maternal Uncle

Q: Your sister's Aunts husband daughter
A : Cousin

Q: Introducing Ramesh, sudha said, brother's father is the only son of my Grandfather
A : (Only Son of my Grandfather => Father)
     (Brother's Father => My Father)
     Therefore, Ramesh and Sudha are siblings i.e Ramesh is sudha's Brother

Q : John Introduced Mary as daughter of the only Son of My father's wife. How is Mary related to John?
A : My Father's wife => My Mother
      Therefore, Mary as daughter of the only Son of my Mother. So John is Only Son.
      Therefore Daughter of John is Mary.

Father-in-law -> Spouse's(Husband or Wife) Father
Mother-in-law -> Spouse's(Husband or Wife) Mother

Brother-in-law -> Spouse's(Husband or Wife) Brother or Your Sister's Husband is your Brother-in-Law
Sister-in-law -> Spouse's(Husband or wife) Sister or Your Brother's wife is your Sister-in-Law

Tricky Question
A is Father of B, then B is _______ of A
The answer could be Son or Daughter because we don't know the gender. So the best answer is Child. Thus,
A is Father of B, then B is Child of A.

Q : D is the brother of B. M is the Brother of B. K is Father of M, and T is wife of K. How is B related to T? And How is T is related to B?
A : B is son/daughter of T
      T is Mother of B.

Q: P/Q means P is father of Q
     P+Q means P is mother of Q
     P-Q means P is Brother of Q
     P*Q means P is Sister of Q

    Find A is E's ____________
    Ans : A is Grand Aunt of E
 Q : A is aunt of E?
  a) A-B+C/D*E
  b) A*B/C*D-E
  c) A/B*C+D-E
  d) A+B-C*D/E

 Ans is Option b)

Q : Rich is the only daughter of Arjun's father's wife's Mother-in-law's daughter's only brother. How is Arjun related to Richa.
A : Arjun is Brother of Richa