How To Run NPM Install From Behind A Proxy Server

Image Source Google Search In this quick tutorial, you’ll learn how to install NPM dependencies from behind a proxy server. While working on an Angular project recently, I had to clone the source code and install the required dependencies. To my surprise, nothing worked as expected. Things are somewhat different when run try to install Node packages from behind a proxy server. You need to set the https-proxy, proxy and registry to install the dependencies. [Read More]

How To Sort Array Of Objects In JavaScript

In this tutorial, you’ll learn how to sort array of objects in JavaScript. Depending on different scenarios you may be required to sort your JavaScript array objects by key or value or a date field. Let’s start by creating an array of objects. let arr = [ {'name' : 'Roy'}, {'name' : 'James'}, {'name' : 'Andrew'} ]; For sorting an array you can utilize the Array.prototype.sort method. Here is how you can use it: [Read More]

How To Stub A Function Using Sinon

While doing unit testing you’ll need to mock HTTP requests and stub certain methods of the application code. In this tutorial, you’ll learn how to stub a function using sinon. Creating A Simple JavaScript Module Let’s start by creating a folder called testLibrary. Navigate to the project directory and initialize the project. mkdir testLib cd testLib npm init Once you have project initialized you need to create a library module which provides a method to generate random strings. [Read More]

JavaScript : How To Get Last Character Of A String

In this quick tip, you’ll see how to get last character of a string using JavaScript. Most of the time, to work on strings you need to convert string to an array and then access string characters. To Get Last Character Of String The following code converts string to an array: let str = "CodeHandbook"; let arr = str.split(''); console.log(arr); Basically, the above code splits the string based on space and converts it into an array. [Read More]

JavaScript Ternary Operator

JavaScript ternary operator is short form of writing if and else statement in JavaScript. To understand how to use ternary operator in JavaScript, let’s have a look at some conditional JavaScript code example. let status = true; if(status){ console.log("Status is true."); } else { console.log("Status is false."); } Now let’s write the above code example using ternary operator in JavaScript. let status = false; status ? console.log("Status is true.") : console. [Read More]

Understanding Factories Design Pattern In Node.js

Design patterns are an important part of software development. Design pattern is a proven way of solving a certain problem. In this tutorial, you’ll try to understand factories design pattern in Node.js. Getting Started Let’s assume that you are trying to build a web application for employee management. There are different kinds of employees available in the company. For the time being assume three kind of employees working in the company [Read More]

Display Curly Braces in Jekyll

Display Curly Braces in Jekyll. Escape curly braces in jekyll.

To display curly braces or double curly braces in jekyll, you can use the raw tag.

Here is an example

{% raw %}{{emp.FirstName}}{% endraw %}

The above code display,

{{emp.FirstName}}

File Upload Security Best Practices

Image source: Pixabay Nowadays, any website requires constant new information to remain relevant and attract visitors. That means periodically uploading new content files. If a web administrator is going to upload manually every single file, there would not be a lot of new content around. Therefore, more websites upload their content using a process known as automatic file uploading. This tool uses code to upload new files to a site without human intervention, increasing the efficiency in keeping websites up to date. [Read More]

Looping Nested Object Keys With ngFor In Angular

In this tutorial, you’ll learn how to loop over nested object keys using ngFor in Angular. I’ll provide an example from one of projects where I used ngFor in Angular to loop over nested object keys and values. Before diving into the issue I will explain a bit about what are ngFor in Angular and how you can use them. So, let’s get started. Getting Started With Angular App Let’s start by creating an Angular web app using the Angular CLI tool. [Read More]

React Tutorial - How To Use react-table in React Web App

In this tutorial, you’ll learn how to use react-table in React web app. If you are just getting started with React, I will recommend reading Learning React From Scratch to get started with react web application development. Getting Started Let’s get started with creating a React web app using Create React App. Once you have npm 5.2+ installed in your system, create the react web app using the following command: [Read More]