Saturday, April 7, 2018

NodeJS

Basic Setup :

1. NPM
2. Node
3. MongoDB

NVM (Node Version Manager) : used for keeping multiple versions of NodeJS


NPM : Node Package Manager: a javascript package manager.

MongoDB: Document database which stores data in JSON format.
mLabs is cloud service for free sandbox  of MongoDB upto 500MB

MongoDB GUI:
Compass can be used.


To check the version of node:
node -v
mongo -v
npm -v


To Start the server for MongoDB:
mongod

Express

Express is a lightweight web application framework for Node.js, which provides us with a robust set of features for writing web apps. These features include such things as route handling, template engine integration and a middleware framework, which allows us to perform additional tasks on request and response objects.
 There is nothing you can do in Express that you couldn’t do in plain Node.js, but using Express means we don’t have to re-invent the wheel and reduces boilerplate. 

Nodemon:

nodemon is a convenience tool. It will watch the les in the directory it was started in, and if it detects any changes, it will automatically restart your Node application (meaning you don’t have to). In contrast to Express, nodemon is not something the app requires to function properly (it just aids us with development), so install it using:
npm install --save-dev nodemon



Pug is a  templating engine. Pug (formerly known as Jade)  




Angular JS - An introduction


AngularJS is a client-side MVC framework written in JavaScript. 

It runs in a web browser and greatly helps us (developers) to write modern, single-page, AJAX-style web applications.


It is a general purpose framework, but it shines when used to write CRUD (Create Read Update Delete) type web applications. 


AngularJS is a recent addition to the client-side MVC frameworks list. 

1. Dependency Injection
2. Strong focus on testability


It is Open source project by developed by Google INC. 

ng-app
ng-init
ng-model


The AngularJS team takes a very pragmatic approach to the whole family of MVC patterns, and declares that the framework is based on the MVW (model-view- whatever) 


Resources:
1. Source code : https://github.com/angular/angular.js
2. Community blog: https://blog.angularjs.org
3. Docs: https://docs.angularjs.org/tutorial
4. Code Samples: https://builtwith.angularjs.org
5. Youtube channel: https://www.youtube.com/user/angularjs

Everything you want to know about GIT

Git was created by Linus Torvalds the maker of Linux.

Bitkeeper was used by Linux system from 2002 - 2005 but Linus decided to write their own DVCS and hence the GIT was invented written in Pearl and C.

Installing Git on Windows: 
using msysgit http://msysgit.github.com

Installing on Mac
using Home Brew
   brew install git

if not using home brew, you can also download DMG package
http://git-scm.com/download/mac


To verify once git is installed, type the following command in Terminal to check the git version

git --version

Installing on Linux:
apt-get install git-core (Debian/Ubuntu)
yum install git-core (Fidora)


Git provides 3 different configuration stores:
1. System Level configuration

   git config --system
2. User level

git config --global

stored in user home directory with filename  ~/.gitconfig or c:\users\\.gitConfig

3. Repo level
   git config

stored in .git/config in each repo


Setting the Configuration

git config --global user.name
git config --global user.email
git config --global core.editor
git config --global help.autocorrect 1
git config --global color.ui auto
git config -global core.autocrlf true | false | input


git init


git status

git add

git add -u

git add -A

git commit -m 

git log

git diff

git diff Head~1















Communicating Microservices with gRPC

Interprocess communication is done by two styles;

1. REST (Representational State Transfer) : we send the resources back and forth and manipulate objects.
It is Resource focused.
Loosely coupled as get put delete methods allow to send information to the server.
Messages are text based.

2. RPC :
It is Action Focused.
Messages are birary based.

Background :
Google's internal protocol Stubby.

Thursday, January 26, 2017

Facts about Microsoft MVC

1. in Feb, 2007, Scott Guthrie from Microsoft written the basic prototype of  MVC framework during traveling in a plane.

2. Original prototype code name was "Scalene"

3. The first official release of ASP.NET MVC was on March 13, 2009

4. MVC 2 released after a year in March, 2010

5. MVC 3 shipped after 10 months from the release of MVC2. Things introduced were:
    1. Razor view engine
    2. Better javascript with Jquery/json
    3. Use of NuGet

6. MVC 4 contained: 1. ASP.NET web API, 2. Mobile project template, 3. Minification

7. MVC 5 was released along with Visual Studio 2013 in October 2013

8. Features of MVC 5:


1. One ASP.NET
2. New Web Project Experience 

3. ASP.NET Identity
4. Bootstrap templates 

5. Attribute Routing
6. ASP.NET scaffolding 

7. Authentication lters
8. Filter overrides 


9. In MVC 5, the project templates moved to run on the popular Bootstrap framework. Bootstrap was rst created by a developer and a designer at Twitter, who later split off to focus on Bootstrap com- pletely

10. a large variety of Bootstrap themes (both free and paid) are available from sites like http://wrapbootstrap.com and http://bootswatch.com

11. Scaffolding is the process of generating boilerplate code based on your model classes


12. Controllers within the MVC pattern are responsible for responding to user input, often mak- ing changes to the model in response to user input. In this way, controllers in the MVC pattern are concerned with the ow of the application, working with data coming in, and providing data going out to the relevant view.

13. Code name for Visual Studio Development Server is Cassini.

14. VS2012 or higher use IIS Express

15. To create a controller, we need to inherit it from System.Web.Mvc.Controller

16. HttpUtility.HtmlEncode sanitizes the user input to prevent from injecting the JS or HTML code.

17. Parameters to the controllers can be pass either using querystring or using path segments.

18. Model 

Sunday, July 24, 2016

Chain of responsibility pattern

Chain of Responsibility

If you have a scenario where you need to chain multiple handlers to handle an incoming request or command, you better use Chain Of Responsibility.

Workflow examples:
1. Lets say we have an organization where Team members when apply for leave, the request goes to the Team Leader. Team leader can approve all the leave request of less than 10 days. If the leave request is of more than 10 days then the request will be passed on to the Project Leader. Project leader is able to approve leaves of upto 20 days. If the leave is applied for more than 20 days then this requests will be passed to the HR. HR can approve upto 30 days of leave. If the leave is of more than 30 days then the leave application cannot be approved by the system and it needs a manual process for approval.

2. A typical example is your girlfriend requesting you something – If she is requesting/commanding you something like “Do you want to come with me for my best friend’s Bachelorette party?”, you will handle it directly. But if she is requesting/commanding you some thing like “Buy me a Porsche”, you say “Sorry Honey, I don’t have the money. Better you ask your dad for this, I’ll call him for you.” –i.e, you pass the request to the next handler, in this case your girl friend’s father. To sum up, in the above example, your girl friend is the client who is making the request, and you and your future father-in-law are handlers/approvers who handle/approve her requests. If you cannot handle it, you pass that responsibility to the next handler/approver in the chain.

Components:

1. Client : The class that request for something. In our case, its an employee, who will be requesting for a leave.
2. Request Handling Class : Could be an interface or an abstract class(preferably abstract class). Will discuss why to use abstract class. This class will be have the abstract method to handle the requests it receives, and a concrete method, to set the next request handler, in case the current handler cannot handle the request.
3. Concrete Request Handlers : These are the actual request handlers implementing the request handling class method, to manage the request which they receive, in their own ways. So let’s get started.




Sunday, May 29, 2016

POUCH DB

PouchDB is an open-source JavaScript database inspired by Apache CouchDB that is designed to run well within the browser.
PouchDB was created to help web developers build applications that work as well offline as they do online.
It enables applications to store data locally while offline, then synchronize it with CouchDB and compatible servers when the application is back online, keeping the user's data in sync no matter where they next login.



Reference: https://pouchdb.com/learn.html