Sunday, April 26, 2020

AWS Lambda (serverless service)


AWS Lambda (server-less service)

https://github.com/serverless/serverless/issues/2372 (********** serverless folder structure)









Getting Started with Amazon Web Services | A Complete Beginner Roadmap

Thursday, April 16, 2020

Angular library create command



Go to the lib folder of nodejs then run these 4 command 


ng new ngx-charts --create-application=false

cd ngx-charts

ng generate library ngx-charts

ng generate application ngx-charts-test

Monday, April 13, 2020

angular project publish to github page



command need to follow
npm install -g angular-cli-ghpages
🌹 ng build --prod --base-href https://[username].github.io/[repo]/
🌹 ngh --dir=dist/[project-name]

You need to change <base href="/"> to <base href="./">

ng build ngx-datagrid-test --prod --base-href https://tusharghoshbd.github.io/ngx-datagrid


ngh --dir=dist/ngx-datagrid-test

some important commands use for angular


ng build [project_name] // for library ex "ng build ngx-datatable"

ng build [project_name] --prod //here project name option and only build js file in dist folder

ng serve [project_name] --prod // here project name option and run server in production mode



Can't load angular generated webpage (ng build --prod)


The problem is you're trying to run the application without a server serving the js bundles generated by Angular. Angular will load the js asynchronously.
An option run live-server on the compiled directory
// Install live-server if you haven't
npm install -g live-server

// Run live-server on you dist
cd <project-compile-dist-path>
live-server

// Note: if you don't want to install live-server globally you
// can use npx
npx live-server <path-to-directory>
https://stackoverflow.com/questions/58878123/cant-load-angular-generated-webpage-ng-build-prod





Wednesday, April 8, 2020

Runge-Kutta, SIR - susceptible (S), infected (I), and resistant (R)


Ref:

  1. https://www.geeksforgeeks.org/runge-kutta-4th-order-method-solve-differential-equation/

The formula basically computes next value yn+1 using current yn plus weighted average of four increments.
  • k1 is the increment based on the slope at the beginning of the interval, using y
  • k2 is the increment based on the slope at the midpoint of the interval, using y + hk1/2.
  • k3 is again the increment based on the slope at the midpoint, using using y + hk2/2.
  • k4 is the increment based on the slope at the end of the interval, using y + hk3.



SIR model 

REF: 

  1. Susceptible (S). The individual hasn't contracted the disease, but she can be infected due to transmisison from infected people
  2. Infected (I). This person has contracted the disease
  3. Recovered/Deceased (R). The disease may lead to one of two destinies: either the person survives, hence developing inmunity to the disease, or the person is deceased.
There are many versions of this model, considering birth and death (SIRD with demography), with intermediate states, etc. However, since we are in the early stages of the COVID-19 expansion and our interest is focused in the short term, we will consider that people develops immunity (in the long term, immunity may be lost and the COVID-19 may come back within a certain seasonality like the common flu) and there is no transition from recovered to the remaining two states. With this, the differential equations that govern the system are:
dSdt=βSIN

dIdt=βSINγI

dRdt=γI

Where Î² is the contagion rate of the pathogen and Î³ is the recovery rate.

Thursday, April 2, 2020

ExportAs feature in angular, Angular selector


Ref:

for better uderstanding 

exportAs is used for directives, see: http://plnkr.co/edit/IlLtBY7Ic9yKiRIpjukf?p=preview
@Directive({
  selector: "div",
  exportAs: "myDiv"
})
class MyDiv {

  constructor(private element: ElementRef, private renderer: Renderer) {
  }

  toUpper() {
    return this.renderer.setElementStyle(this.element.nativeElement, "text-transform", "uppercase");
  }

  toLower() {
    return this.renderer.setElementStyle(this.element.nativeElement, "text-transform", "lowercase");
  }

  reset() {
    return this.renderer.setElementStyle(this.element.nativeElement, "text-transform", "");
  }
}

Angular selector

Selector property of @Component decorator support, element selector, attribute selector and class selector:
1. Element selector:
@Component({
 selector: 'app-servers'
})
Usage: <app-servers></app-servers>
2. Attribute selector:
@Component({
 selector: '[app-servers]'
})
Usage: <div app-servers></div>
3. Class selector:
@Component({
 selector: '.app-servers'
})
Usage: <div class="app-servers"></div>
Note: Angular 2 does not support id and pseudo selectors





Autoboxing and Unboxing

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