Using Nodemon

When developing a webapp with nodejs. It can be a pain having to restart the webserver after every change.

Nodemon is a package that monitors your code files for changes, and as soon as they change, it stops and restarts the webserver and takes the load of manually restarting off of your shoulders.

To use it, first you need to install nodemon as a development dependency.

Use the following command.

> npm install -D nodemon
Continue reading Using Nodemon

Adding Custom Fonts in CSS

If you want to add a font in your website that does not come with the browser or the users normally dont have installed.

You can do it like this.

First get the font that you want to apply. For this example I am using DaFont

Click the Download button on the font that you would like to use and it will download a zip file. Extract that file into your project folder. It will be a .ttf, .otf or .woff file.

Continue reading Adding Custom Fonts in CSS

Javascript Constructors

To work in an object oriented way in javascript, you can create a function and define properties using the ‘this’ keyword.

Let’s take an example of a ‘Car’ class which has 3 propertiesmake‘, ‘model‘ and ‘year‘. It will look like this.

/// create a constructor function.
function Car(make, model, year) {
  this.make = make;
  this.model = model;
  this.year = year;
}

Now to create instances of this class or create objects of this class, you can use the new Keyword.

const car1 = new Car('Toyota', 'Corolla', 1980);

Now we can use the ‘.’ syntax on the object get values of properties.

console.log(car1.make); // 'Toyota'
console.log(car1.model); // 'Corolla'
console.log(car1.year); // 1980
Continue reading Javascript Constructors