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 = {
   name:"Adam",
   address : {
      street : "Florida"
   }
}

// To access the values, use the dot notation
var name = object.name
alert(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
document.body.appendChild(paragraph);


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

// Set the height of the Element
div.style.height = "100vh";

//Append Element to DOM
document.body.appendChild(div);

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

});


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

   // Set the height of the Element
   newElement.style.height = "100vh";

   //Append Element to DOM
   document.body.appendChild(newElement);

    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;
    element.style.backgroundColor = 'rgb(' + x + ', ' + y + ', ' + 100)';
}

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

// So which function's you can change arguments

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





Helper Functions
SetInterval

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){
    callback(name);
  });
}

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


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

   stopClick(clearInterval, tick);
   startClick(init);
}

init();

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

    A*B/C-D+E
    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
   

Thursday, April 28

Syllogism

Rule 1 : All + All = All

Problem I
Statement 1 : All boys are intelligent
Statement 2 : All intelligent are girls

Therefor the conclusion derived will be
All boys are girls
From statement 1 : Some intelligent are boys
From statement 2 : Some girls are intelligent

Problem II
Statement 1: All books are pens
Statement 2 : All pens are pencils

I : All books are pencils
II : All pencils are books

From Rule 1 we can derive that All books are pencils
Hence, only conclusion I is true.

Rule 2 : All + No => No
When predicate of 1st statement is equal to Subject of 2nd statement

Problem 1
Statement 1 : All tigers are horses
Subject is "Tiger" and Predicate is "Horse"

Statement 2 : No horse is dog
Subject is "Horse" and Predicate is "Dog"

Since Predicate of 1st statement is same as subject of 2nd Statement, we can apply the rule.

I : No Tiger is Dog
II : Some tigers are dog

Therefore, as per Rule 2, the conclusion would be
No Tiger is Dog

Hence, only conclusion I is correct. Conclusion II cannot be correct.

 Problem II
Statement 1: All students are scouts.
Statement 2 : No Scout is Lady.

I : No Student is lady
II :  Some scouts are students

Therefore the conclusion after applying Rule 2 is
No Student is lady

From statement 1 : All Students are scouts, we can conclude that Some scouts are Students.

Therefore, we can conclude that both the given conclusions are true.

Rule 3 : All + Some => No Conclusion

Problem I
Statement 1 : All pens are pencils
Statement 2 : Some pencils are papers

I : Some papers are pens
II : Some pens are not papers

From Rule 3 : We can concur that there is No Conclusion. Note that for Rule to be used, Predicate of Statement 1 should be same as Subject of Statement 2.


Problem II
Statement 1 : All bats are balls
Statement 2 : Some balls are nets

I : Some bats are nets
II : All nets are bats

Applying Rule 3, There is No Conclusion

Rule 4 : Some + All => Some
In this scenario, there will be 2 conclusions.

Problem I
Statement 1 : Some parrots are Doves
Statement 2 : All Doves are Peacocks

I : All peacocks are doves
II : Some peacocks are parrots

Applying Rule 4, we get two statements
Some Parrots are Peacocks
Some Peacocks are Parrots

From 2nd statement "All Doves are Peacocks" we can derive that "Some Peacocks are Doves"

There the 2nd conclusion alone is true.

Problem II
Statement 1 : Some books are pens
Statement 2 : All pens are papers

I : Some books are papers
II : Some papers are books

Applying Rule 4 i.e Some + All => Some, we get
Some books are papers
Some Papers are books

Therefore both the Conclusion are true.

Rule 5 : Some + No => Some Not 

Problem I
Statement 1 : Some Books are Toys
Statement 2 : No Toy is Red

I : Some books are red
II : Some books are not red

From Rule 5 : Some books are not red.
From statement 1 : Some Toys are Books
From Statement 2 : No Red is Toy.


Problem II
Statement 1 : Some trains are trees
Statement 2 : No Tree is a Picture

I : Some trains are picture
II : No train is a picture

From Rule 5 : Some Train is not Picture
From Statement 1 : Some trees are Trains
From Statement 2 : No Picture is Tree

From above derivation, we can say that no conclusion is true.

Rule 6 : Some + Some => No Conclusion

Problem I
Statement 1 : Some stones are cups
Statement 2 : Some cups are black

I : Some blacks are not cups
II : Some cups are Stones

As per Rule 6 -> There is no Conclusion

Problem II
Statement 1 : Some dogs are rats
Statement 2 : Some rats are horses

I : Some horses are dogs
II : No horse is a rat

As per Rule 6 -> No Conclusion.


Rule 7 : No + No => No Conclusion

Rule 8 : No + All/Some => Some Not Reversed

Problem I
Statement 1 : No File is an Elephant
Statement 2 : All elephants are Caps

I : Some Caps are elephants
II : Some Caps are not Files

As per Rule 8 :
Some Caps are not Files
From Statement 2 we can derive -> Some caps are elephants

Therefore, both the conclusion are correct

Problem II
Statement 1 : No Goat is Door
Statement 2 : All doors are chairs

I : Some chairs are doors
II : Some chairs are goats
III : Some chairs are not goats
IV : Some doors are goats

As per Rule 8:
Some chairs are not Goats

From Statement 2
Some Chairs are Doors
Also -> Some Doors are Chairs (From above derivation)

From statement 1
No Door is Goat

Therefore I and III are true



Problem with 3 statements

Statement 1 : Some newspapers are radios
Statement 2 : Some radios are Television
Statement 3 : No television is magazine

I : No newspaper is magazine
II : No Radio is magazine
III: Some radios are not magazines
IV : Some newspapers are televisions


Statement 1 : Some newspapers are radios
We can derive -> Some Radios are Newspapers

Statement 2 : Some radios are Television
We can derivie -> Some Television are Radios

Statement 3 : No television is magazine
We can derive -> No Magazine is Television

From Statement 1 and Statement 2, we cannot derive any conclusion
From statement 2 and statement 3 : We can get -> Some Radios are not magazine

Therefore only III is true.

Problem with 3 statements

Statement 1 : All fowls are kites
Statement 2: No kite is insect
Statement 3 : No fowl is kite

I : No Fowl is insect
II: No Insect is Fowl
III : Some Kites are Fowls
IV : No Kite is Fowl

Statement 1 : All fowls are kites
=> Some kites are Fowls
     => Some Fowls are Kites

Statement 2: No kite is insect
=> No Insect is Kite

Statement 3 : No fowl is kite
=> No Kite is Fowl

From Statement 1 and Statement 2
No Fowls are Insects
=> No Insects are Fowls

Therefore from all the derived statements, we can get the result that all the conclusions are True.


Friday, February 19

Notes : Brings Up Strong Reasons to Use React.js



- Search wise, in Google trends, React is most widely searched

- Angular is going a major re-write and looks more similar to React. So Angular 2.0 will have lots of API's broken for Angular 1.0, does it mean it is back to square one for Angular 1.0 users?

- Pick up a framework when you know you are building a Web application. Don't use it for making static websites.

- jQuery is still valid, so for web developers can it can be used very productively.

- Unlike Google, facebook is using React on their critical projects.