Daily Learning

Daily Learning – Medium


In every package.json, there are two types of dependencies.

Normal dependencies are part of your production application. Let’s say you‘re using @material-ui/core for your form fields. The package will be used during development, but of course also by every end-user.

In order to add a package under dependencies, while installing, use — save.

For example,

npm install <package-name> — save

→ In contrast, devDependencies are only used during development and testing.

You won’t find these packages in your bundled code. Thus, they also won’t slow down your production application.

Typically, devDependencies are tools like testing frameworks, module bundlers, and transpilers. 🔨

In order to add a package to this list, while installing, use — save-dev.

For example,

npm install <package-name> — save-dev

There can be other scripts as well, such as prepush, postbuild, lint, deploy, etc. Each has their own set of commands.

For example, when using gh-pages, you can write

deploy”: “gh-pages -d build”

Here the command specifies which branch and directory to deploy.

git commands

source: https://medium.com/geekculture/5-git-commands-when-working-with-remote-repositories-95486063b17c

git remote add

While the clone command is used to get an existing repository from a server, if you want to set up a remote server for a repository you have on your local machine, you will use the remote add command.

The first step you need to do is create a repository on a server. On GitHub, do this going to your Repositories tab in your profile, and click the “New” button.

Click “New” button on the Repositories tab to create new repository.

On your local machine, if you don’t have a repository setup, you can initialized a new repository with the following commands in Git Bash.

$ mkdir foo-bar
$ cd foo-bar
$ git init
$ touch .gitkeep
$ git add .
$ git commit -m "initial commit"

Now, in the repository, you can run the “git remote add <name> <url>”. The name is the name reference for the server, which is typically “origin”. The URL value can be grabbed off the GitHub page where you set up the empty repository. After you add the remote server, you can move you local repository to the server. When you push, you will be asked to authenticate, and after that, you will see a message like the one below.

Running commands to up remote server.

git pull

The last command is the pull command. The pull command is used to take any changes that have occurred on the remote repository, and move them into you local repository. When you run “git fetch”, the reference of the changes on the remote come down to you local repository. When you run “git pull”, you actually put the changes into your repository.

It is usually a good practice to follow to run “fetch” before you run “pull”, so you can see what is actually coming into your branch — you can check the remote repositories logs if you want to, but usually seeing if there are any commits should be enough to know what you are putting in your local repository.

As mentioned above, there can be a point when you fetch the latest code for a branch on the remote, and you discover that you local branch the the remote have diverged. In cases like this, you can pull the changes from the remote into you local branch, but in order to do so, you need to create a merge commit. If there are merge conflicts, you will need to resolve them before you are able to pull — merge conflicts happen when the same file has changes on the same line and git doesn’t know what changes should be used.

If there are no merge conflicts, your terminal will open Vim in order to create a merge message. You will see a prompt to enter a commit message.

Merge branch 'foo-bar' of https://github.com/cameronDz/bar-foo-project into foo-bar
# Please enter a commit message to explain why this merge is
# necessary, especially if it merges an updated upstream into a
# topic branch.
# Lines starting with '#' will be ignored, and an empty message
# aborts the commit.

If you have not used Vim before, it can be a bit confusing — in order to keep the default message, you can hit the ESC key, and then enter “:wq” when you see the cursor at the bottom of the terminal. This will save and quit Vim, saving the commit message and completing the merge.

TypeScript — Interfaces

Interfaces defines the syntax for classes to follow. Classes that are derived from an interface must follow the structure provided by their interface.

The TypeScript compiler does not convert interface to JavaScript. It uses interface for type checking. This is also known as “duck typing” or “structural subtyping”.

TypeScript — Modules

The TypeScript code we write is in the global scope by default. If we have multiple files in a project, the variables, functions, etc. written in one file are accessible in all the other files.

TypeScript provides modules and namespaces in order to prevent the default global scope of the code and also to organize and maintain a large code base.

Modules are a way to create a local scope in the file. So, all variables, classes, functions, etc. that are declared in a module are not accessible outside the module. A module can be created using the keyword export and a module can be used in another module using the keyword import.

User authentication using passport.js in Node.js

Here we will learn how to implement user authentication using passport-local strategy. In last post, we learned User Authentication using JWT. There, we used JSON Web Token. These both are different way and robust way. What we are going to use here:

  • Node.js
  • Express Framework
  • Mongodb
  • JWT

What is Passport.js? Passport is authentication middleware for Node.js. Extremely flexible and modular, Passport can be unobtrusively dropped in to any Express-based web application. A comprehensive set of strategies support authentication using a username and password, Facebook, Twitter, and more. Copyright © Passport.js.

read more @ https://pandeysoni.medium.com/user-authentication-using-passport-js-in-node-js-c5b85a636724

How to use body-parser in Express to handle different POST requests

@ https://medium.com/@gohitvaranasi/how-to-use-body-parser-in-express-to-handle-different-post-requests-c58c29d45b46

When we talk about source control or version control , we commonly hear GitHub or Bitbucket. Under the hood, both the websites use GIT.


Azure functions using java


The FunctionName annotation is used to specify to the Azure Functions tooling what name is to be applied to the associated function when the function is deployed onto Azure. This becomes the endpoint (in the case of an HttpTrigger function, for example, but more generally it is what is shown to users in the Azure Portal, so a succinct and understandable function name is useful.

An example of how the FunctionName annotation is shown in the code snippet below. Note that it is applied to the function that will be called by Azure, based on the specified trigger (in the code below it is a HttpTrigger).

Place this on a parameter whose value would come from a blob, and causing the method to run when a blob is uploaded. The parameter type can be one of the following:

  • Any native Java types such as int, String, byte[]
  • Nullable values using Optional
  • Any POJO type

The following example shows a Java function that logs the filename and size when a blob is added or updated in the “samples-workitems” container:


public void blobMonitor(
@BlobTrigger(name = "file",
dataType = "binary",
path = "samples-workitems/{name}",
connection = "AzureWebJobsStorage") byte[] content,
@BindingName("name") String filename,
final ExecutionContext context
) {
context.getLogger().info("Name: " + filename + ", Size: " + content.length + " bytes");


public interface BlobTrigger implements Annotation



Java Classes/Objects

Remember from the Java Syntax chapter that a class should always start with an uppercase first letter, and that the name of the java file should match the class name.

Remember that the name of the java file should match the class name.

If you don’t want the ability to override existing values, declare the attribute as final:

final int x = 10;

Static vs. Non-Static

You will often see Java programs that have either static or public attributes and methods.

In the example above, we created a static method, which means that it can be accessed without creating an object of the class, unlike public, which can only be accessed by objects:

public class Main {
// Static method
static void myStaticMethod() {
System.out.println("Static methods can be called without creating objects");

// Public method
public void myPublicMethod() {
System.out.println("Public methods must be called by creating objects");

// Main method
public static void main(String[] args) {
myStaticMethod(); // Call the static method
// myPublicMethod(); This would compile an error

Main myObj = new Main(); // Create an object of Main
myObj.myPublicMethod(); // Call the public method on the object

Note that the constructor name must match the class name, and it cannot have a return type (like void).

Also note that the constructor is called when the object is created.

All classes have constructors by default: if you do not create a class constructor yourself, Java creates one for you. However, then you are not able to set initial values for object attributes.

An abstract method belongs to an abstract class, and it does not have a body. The body is provided by the subclass:

You learned from the previous chapter that private variables can only be accessed within the same class (an outside class has no access to it). However, it is possible to access them if we provide public get and set methods.

A package in Java is used to group related classes.

To use a class or a package from the library, you need to use the import keyword:


import package.name.<Class_name>;   // Import a single class
import package.name.*; // Import the whole package

Java ArrayList

The ArrayList class is a resizable array, which can be found in the java.util package.

The difference between a built-in array and an ArrayList in Java, is that the size of an array cannot be modified (if you want to add or remove elements to/from an array, you have to create a new one). While elements can be added and removed from an ArrayList whenever you want. The syntax is also slightly different:



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Anil Kumar

Anil Kumar

Experience with Front-end Technologies and MERN / MEAN Stack. Working on all Major UI Frameworks like React, Angular.