How to configure multi term in Emacs to allow login shell

Mar 31, 2017

To configure multi term in Emacs to allow login shell

(setq multi-term-program-switches "--login")
  • Reference

http://stackoverflow.com/questions/19750218/emacs-multi-term-as-a-login-shell

Categories : Emacs

Responsive vs Adaptive Design

Mar 29, 2017

  • Responsive Design - Responsive websites respond to the browser size at any given point. No matter the browser width, the site adjusts its layout.

  • Adaptive Design - Adaptive websites adapt to the browser size at specific points.

  • Reference - https://css-tricks.com/the-difference-between-responsive-and-adaptive-design/

Categories : CSS   Design

Difference between CSS reset and normalize

Mar 26, 2017

Normalize.css

  • Preserves useful defaults rather than “unstyling” everything.
  • Corrects some common bugs that are out of scope for reset.css.
  • Doesn’t clutter your dev tools.
  • Is more modular.
  • Has better documentation.
  • Reference http://stackoverflow.com/questions/6887336/what-is-the-difference-between-normalize-css-and-reset-css http://nicolasgallagher.com/about-normalize-css/
Categories : CSS

Different ways of creating Objects in JavaScript

Mar 25, 2017

Explained below are some of the different ways of creating Objects in JavaScript.

  • Objects created with syntax constructs (Object Literal Notation)
var o = {a: 1};
  • With Function (New Objects with Constructor function)

A constructor is a function that contains instructions about the properties of an object when that object is created and assigned. Advantage over object literal is you can create many instances of objects that have the same properties.

function Car() {
    this.make = 'Honda';
    this.model = 'Civic';
}

var c = new Car();
  • With Object.create

ECMAScript 5 introduced a new method Object.create.

var a = {a: 1};

var b = Object.create(a);

console.log(b.a); // 1 (inherited)
  • With Class

JavaScript classes were introduced in ECAMScript 2015 (ES6)

Class Car {
    constructor(make, model) {
        this.make = make;
        this.model = model;
    }
}

var c = new Car();

Reference

Categories : JavaScript

What is prototype and prototype chain in JavaScript

Mar 24, 2017

Each JavaScript object has a private property which holds a link to another object called its prototype. That prototype object has a prototype of its own, and so on until a object is reached with null as its prototype. null has no prototype and acts as the final link in this prototype chain.

Multiple inheritance with prototypes is referred to as a prototype chain.

function Car() {
    this.make = "Honda";
    this.model = "Civic";
}

let c = new Car();
Car.prototype.fuel = "Gas";

console.log(c.make); // "Honda"
console.log(c.model); // "Civic"
console.log(c.fuel); // "Gas"

To check whether an object has a property defined on itself and not somewhere on its prototype chain, it is necessary to use the hasOwnProperty method which all objects inherit from Object.prototype.

c.hasOwnProperty("make"); //true
c.hasOwnProperty("fuel"); //false

References:

Categories : JavaScript