Tags

NodeJS Get HostName from request ExpressJS

Sometimes we need hostname to do various log activities. We can get the hostname from the request property in ExpressJS NodeJS. We have two options to get the hostname: hostname property of request header method of request Request HostName Property Below code is shown to get hostname from request object. app.get('/',(req, res) => { hostName = req.hostname; //dotnetpattern.com...

Continue Reading

NodeJS UUID Validate

To validate UUID (GUID) in NodeJS, we can use below options: UUID NPM Package We can write our own custom regular expressions to validate. 1. UUID NPM Package To use UUID package, we can use below command to include in our project. To validate UUID in NodeJS, we can use validate method of UUID package. Below is the sample code. const uuid = require('uuid'); const uniqueId = "3112b3db...

Continue Reading

Go Variables

Variables in Go refer to the names associated with values like numbers, or strings. When we declare a go variable, we specify the type and optionally the default value. If we don't specify the default value, go automatically assigns the default value to a go variable. Go is a statically-type language that means when we declare a variable, we also specify a data type. From the data type, Go com...

Continue Reading

chmod 755 - Change Access Permissions

chmod 755 linux command is used for changing permissions for the files and directories. Only the file's owner or superuser can change the file access permissions. chmod 755 command does following work: It gives read, write and execute (RWX) file permissions to file owner, It gives read and execute (R_X) file permissions to file's group owner and other system users. It removes write p...

Continue Reading

Python Script to Optimise Images and upload to FTP server

Below is the python script to optimize PNG images files using OPTIPNG library and upload compressed images in FTP folder. If you don't have OPTIPNG library, download from this url: http://optipng.sourceforge.net/ import ftplib import os username = 'username1' pwd = 'pwd1' localdirpath = "/home/username/Documents/screenshots/" files = os.listdir(localdirpath) ftp = ftplib.FTP...

Continue Reading

ASP.NET Core Introduction

ASP.NET Core is a open source framework to develop web applications on Windows, Linux, and Mac operating systems. It provides framwork to build cloud-enabled web applications and web API services. It is a lighweight framework that provides high-performance. In Techempower Benchmark, asp.net core comes in 36 position. It comes before NodeJS framework which comes in 172 position. https://...

Continue Reading

ASP.NET Core MVC Linux Hello World Program

In this tutorial, we will create a simple hello world web mvc application in .NET Core. .NET Core Installation on Linux To install .NET on linux, we need to first add Microsoft package signing key to your trusted keys and add the package repository. We have different commands for different linux distributions. Run below commands in terminal window according to your distribution. ...

Continue Reading

NodeJS MySQL Tutorial

One of the main advantages of using the NodeJS framework is the easy integration with the Database libraries. MySQL is one of the most popular database. NPM MySQL library provides easy integration with NodeJS application. In this tutorial, we'll learn following operations from NodeJS application: Installing MySQL NPM module Connect to MySQL database Execute select quer...

Continue Reading

TypeScript Abstract Class

A TypeScript Abstract class is a class which may have some unimplemented methods. These methods are called abstract methods. We can't create an instance of an abstract class. But other classes can derived from abstract class and reuse the functionality of base class. TypeScript Interface vs Abstract Class Interface Abstract Class All members are abstract. ...

Continue Reading

TypeScript Interfaces

In this tutorial, we will learn about TypeScript Interfaces. An interface defines what members (properties, functions) an object must have. For example, we define that a interface ICar has two properties 'make', and 'name' then all objects which implements this interface must have these two properties. In TypeScript interface, we can define only properties and functions signatures. We do not p...

Continue Reading