Thursday, October 31, 2019

Matrix: inverse matrix, matrix multipication, linear algebra

Cost function (Mean squire error) : Gradient Decent


Cost Function:

It is a function that measures the performance of a Machine Learning model for given data. Cost Function quantifies the error between predicted values and expected values and presents it in the form of a single real number. Depending on the problem Cost Function can be formed in many different ways. The purpose of Cost Function is to be either:
  • Minimized - then returned value is usually called cost, loss or error. The goal is to find the values of model parameters for which Cost Function return as small number as possible.
  • Maximized - then the value it yields is named a reward. The goal is to find values of model parameters for which returned number is as large as possible.

Gradient descent  :

an algorithm called gradient descent for minimizing the cost function.
It turns out gradient descent is a more general algorithm, and
is used not only in linear regression.
It's actually used all over the place in machine learning.
And later in the class, we'll use gradient descent to minimize
other functions as well, not just the cost function J for the linear regression


Andreu NG coursera.com 1week (*****) to see the gradient descent.
--  Firstly try to understand the cost function and gradient for one variable/ one parameter/ one dimensional.


Ref: 
  1. https://towardsdatascience.com/coding-deep-learning-for-beginners-linear-regression-part-2-cost-function-49545303d29f
  2. https://medium.com/@lachlanmiller_52885/machine-learning-week-1-cost-function-gradient-descent-and-univariate-linear-regression-8f5fe69815fd (VVI) 
  3. https://towardsdatascience.com/machine-learning-fundamentals-via-linear-regression-41a5d11f5220
  4. https://www.mathsisfun.com/calculus/derivatives-introduction.html (VVI)
  5. https://www.mathsisfun.com/calculus/derivatives-partial.html (VVI)
  6. https://www.quora.com/What-is-the-purpose-of-derivatives-in-calculus (VVI)

Thursday, October 24, 2019

Tuesday, October 15, 2019

Webpack, angular cli, npm, yarn babel,


Angular CLI

Angular CLI is abbreviated for Angular command line interface.

Angular CLI creates the ideal Angular environment for your Angular app. It includes all the importing, packaging, BrowsLinks using Webpack all by itself. But there is no need for you to know what is a Webpack or how it works, because all of the webpack configuration is completely done by Angular CLI thus it takes all that burden off of the developer's shoulders.


Angular cli makes it easier to work in angular environment. As it contains whole bunch of commands to create core building blocks of angular and to even unit -testing them.
CLI is shipped with WebPack which bundles javascript and css files dynamically and add them to index. html like main.bundle.js , polyfill.bundle. js etc. .



webpack is powerful. It is incredibly configurable. However, this power and flexibility can make for a rather steep learning curve.

Learning about webpack is one of the major hurdles to getting up and running with modern JavaScript frameworks like React and Angular. The nice folks on the Angular team wanted to make it easier for people to start using Angular.

They did this by embedding webpack in the Angular CLI. Now, as an Angular developer you don’t need to know anything about webpack. The Angular CLI hides all that webpack complexity. However, that simplicity comes at the price of flexibility. By using the Angular CLI you lose the ability to configure and customize webpack.



webpack is a static module bundler for modern JavaScript applications

In webpack you configure the following:
  • Entry: the module where webpack should start
  • Output: where webpack emits the bundles it creates
  • Loaders: enable webpack to process more than just JavaScript files
  • Plugins: perform a wide range of tasks like minification, for example
You set all these up in the webpack configuration file which is typically named: webpack.config.js

So Where is the webpack.config.js?

“But wait Todd, I just searched my entire Angular project and there is no webpack.config.js. Are you sure Angular CLI still uses webpack?”
OK, you’re right, there is no webpack.config.js in our Angular project. And, some healthy skepticism is a good thing. But, let’s take a quick look and verify that Angular does in fact depend on webpack.
In our project we can find a local copy of the Angular CLI here: node_modules\@angular\cli
In that directory you should see the package.json file for Angular CLI. Open it and take a look at the dependencies and among others you will see webpack, webpack-dev-server, etc. For example:




Also, in node_modules you can see that these webpack based dependencies actually did get installed. For example: node_modules/webpack
So, we see that Angular CLI is, in fact, using webpack but it is only a black box to us. This is great if you aren’t a webpack expert. But, if you have taken the time to level-up your webpack skills, this might be unacceptable to you. Fear not, the Angular CLI has a solution for us.



NPM and Yarn

These two technologies solve the exact same problem. To be more concrete, Yarn is a superset of NPM that solves many problems that NPM has. So what are these for?
NPM stands for Node Package Manager. It is what its name describes. It is a package manager for Node based environments. It keeps track of all the packages and their versions and allows the developer to easily update or remove these dependencies.


Babel

As any language, Javascript also has versions named ECMAScript (short for ES). Currently, most browsers support ES5. ES5 used to be good even though it was painful to code in it. Remember, this not reading from inside callback functions? The new version of Javascript, ES6, also known as ES2015 (specs of the language were finalized in June 2015) makes Javascript great again. If you want to learn about ES6, check out the links at the end of this article. All the great features of ES6 come with one big problem — majority of browsers do not fully support them. That’s when Babel comes to play. Babel is a JS transpiler that converts new JS code into old ones. It is a very flexible tool in terms of transpiling. One can easily add presets such as es2015, es2016, es2017, so that Babel compiles them to ES5.


Webpack

Now that we know what Babel and ES6/7 are, we would like to use that. We would also like to use SASS for our styles, PostCSS for autoprefixing. Plus, we would like to minify and uglify both our CSS and Javascript code. Webpack solves all of these problems using one config file (named webpack.config.js) and one CLI command webpack.
Webpack is a modular build tool that has two sets of functionality — Loaders and Plugins. Loaders transform the source code of a module. For example, style-loader adds CSS to DOM using style tags. sass-loader compiles SASS files to CSS. babel-loader transpiles JS code given the presets. Plugins are the core of Webpack. They can do things that loaders can’t. For example, there is a plugin called UglifyJS that minifies and uglifies the output of webpack.


Ref:
  1. https://hackernoon.com/webpack-for-angular-developers-c8584a60e627
  2. https://www.quora.com/What-is-Angular-CLI
  3. https://medium.com/front-end-weekly/what-are-npm-yarn-babel-and-webpack-and-how-to-properly-use-them-d835a758f987

Angular performance


Angular performance

  1. Production Builds (AOT Compilation)
  2.  Lazy Loading Modules
  3. Enable Production Mode
  4.  OnPush Change Detection
  5. Preserve Whitespaces
  6.  Avoid Function Calls in Views
  7. Check your ngDoCheck
  8.  Async Pipe
  9. Unsubscribe the obserable subscribe
  10. Track By Function (https://dotnettutorials.net/lesson/angular-ngfor-trackby/) 
  11. console.log(): Using console.log() statements in your production code could be a bad idea
  12. 33. Avoid complex computations in the template:

REF:

  • https://angular-guru.com/blog/angular-performance-tips
  • https://medium.com/@spp020/44-quick-tips-to-fine-tune-angular-performance-9f5768f5d945

Understanding Change Detection Strategy onpush in Angular


Change Detection Strategy onpush in Angular

  1. https://alligator.io/angular/change-detection-strategy/
  2. https://stackblitz.com/edit/change-detection-strategy1
  3. https://blog.ninja-squad.com/2018/09/27/angular-performances-part-4/
  4. https://netbasal.com/a-comprehensive-guide-to-angular-onpush-change-detection-strategy-5bac493074a4 (VVI, ************, please study more)

Change Detection Strategy onpush follow some rules: You may need to take care this rules



Rule 1: @Inputs: Input properties value will be changed when its ref will be changed

Rule 2: A component have own internal state.  in the ts file , if value change due to api or set-timeout it will not show in html page directly. it only show when any event(click, change) occur from the html page.

Rule 3: We run change detection explicitly.  The first is detectChanges() which tells Angular to run change detection on the component and his children.

onstructor(private cdr: ChangeDetectorRef) {   
    setTimeout(() => {     
           this.count = 5;      this.cdr.detectChanges(); 
  }, 1000);
}

Rule 4: Angular Async Pipe. The async pipe subscribes to an observable or promise and returns the latest value it has emitted

see the example of above link

If a component depends only on its input properties, and they are observable, then this component can change if and only if one of its input properties emits an event.



Rule 5: onPush and View Queries.

 @Input() set content(value) {
    this._content = value;
    this.cdr.markForCheck();
  }



Rule 6:  === onPush++ (VVVVIIIIII)

Also, by creating a dedicated component we make our code more readable and reusable.


See the example of above medium doc link 


https://netbasal.com/a-comprehensive-guide-to-angular-onpush-change-detection-strategy-5bac493074a4










Sunday, October 13, 2019

multiple node version using nvm and cURL defination


nvm stands for Node Version Manager. As the name suggests, it helps you manage and switch between different Node versions with ease. It provides a command line interface where you can install different versions with a single command, set a default, switch between them and much more.

important command
-- nvm ls
-- nvm use 12.16.3 (bjit office)
-- nvm use 12.8.0 (bjit office)

Please run the nvm in vs code/ specific folder

REf:
  1. https://computingforgeeks.com/how-to-run-multiple-versions-of-node-js-on-linux/

cURL
cURL is a computer software project providing a library and command-line tool for transferring data using various protocols. It was first released in 1997. The name stands for "Client URL". The original author and lead developer is the Swedish developer Daniel Stenberg

Basic of react and interview question

Friday, October 11, 2019

Ngrx


NGRX:
Generally, it's a pattern for controlling the state of an application, and the flow of data throughout the appliction.


NgRx App State Management

Let’s look at the NgRx implementation — there are several components to understand.
  • Store: Store is what holds the app's state. 
  • Action: A unique event dispatched from components and services that describe how the state should be changed. For example, ‘Add Customer’ can be an action that will change the state (i.e. add a new customer to the list).
  • Reducer: All the state changes happen inside the reducer; it responds to the action and, based on that action, it will create a new immutable state and return it to the store.
  • Selector: Selector is a function used for obtaining a part of the state from the store.
  • Effect: A mechanism that listens for dispatched actions in an observable stream, processes the server response, and returns new actions either immediately or asynchronously to the reducer to change the state. Please note that we are not using effect in this example app.

Ref:
  1. https://blog.angularindepth.com/how-to-start-flying-with-angular-and-ngrx-b18e84d444aa
  2.  https://dzone.com/articles/angular-app-state-management-with-ngrx (VVI basic example)
  3. https://stackoverflow.com/questions/57563867/ngrx-pass-payload-through-dispatch-method-to-update-store 
  4. https://medium.com/@RupaniChirag/simple-angular-app-using-ngrx-8-store-and-effects-factory-methods-f3423b9f6d3b (effect very simpel and easy)

Thursday, October 3, 2019

Angular interview question

What’s the difference between agile, CI/CD, and DevOps?

Agile:
Agile is most popular software development process in software industry. Agile is a flexible software development methodology, involving a large number of various iterations.

Pros:

  1. Adaptive approach that responds to changes favorably
  2. Allows for direct communication to maintain transparency
  3. Improved quality by finding and fixing defects quickly and identifying expectation mismatches early.

Cons:

  1. Focuses on working with software and lacks documentation efficiency
  2. Chances of getting off-track as outcome are not clear


Continuous integration/continuous delivery (CI/CD)


Continuous integration (CI) is a software engineering practice where members of a team integrate their work with increasing frequency. In keeping with CI practice, teams strive to integrate at least daily and even hourly, approaching integration that occurs “continuous-ly.”


Continuous delivery (CD) is to packaging and deployment what CI is to build and test. Teams practicing CD can build, configure, and package software and orchestrate its deployment in such a way that it can be released to production in a software-defined manner (low cost, high automation) at any time.


Development : our account / north--vergenia
Stagging: client account / north--vergenia
Production: client-account / ireland


code commit : AWS CodeCommit is a version control service hosted by Amazon Web Services
code build
code deploye : CodeDeploy is a deployment service that automates application deployments to Amazon EC2 instances
code pipeline : AWS CodePipeline is a continuous delivery service you can use to model, visualize, and automate the steps required to release your software.

Continuous Integration and Continuous Delivery Model
-----------------------------------------------------------------------------------
Create a CodeCommit repository
Access the CodeCommit repository from developer machine
Design a code delivery model using CodeCommit, CodeDeploy, CodePipeline




Scrum

Scrum is the most popular agile development framework because it is relatively simple to implement.



In scrum, a small team is led by a scrum master whose main job is to clear away all obstacles to work getting done more efficiently. The team works in short cycles of 2 weeks called “sprints,” though the team members meet daily to discuss what’s been done and where there are any roadblocks that need clearing. This methodology allows for quick development and testing, especially within small teams.
Scrum is a framework for project management that emphasizes teamwork, accountability and iterative progress toward a well-defined goal. The three pillars of Scrum are transparency, inspection and adaptation

Scrum master: This team member serves as a facilitator. The Scrum master is responsible for ensuring that Scrum best practices are carried out and the project is able to move forward.

The Scrum process



Daily Scrum . The Daily Scrum is a short stand-up meeting that happens at the same place and time each day. At each meeting, the team reviews work that was completed the previous day and plans what work will be done in the next 24 hours. This is the time for team members to speak up about any problems that might prevent project completion.

Sprint Planning Meeting. A Sprint refers to the time frame in which work must be completed, and it's often 30 days. Everyone participates in setting the goals, and at the end, at least one increment -- a usable piece of software -- should be produced.
Sprint Review. This is the time to show off the increment.

REF:




Autoboxing and Unboxing

  Autoboxing  is the automatic conversion that the Java compiler makes between the primitive types and their corresponding object wrapper cl...