Dear Vishi, this is my daily log for May 7, 2023.
I am still having jetlag I guess. I sleep at 3 am and wake at 8 am. It's been almost a week. There is hilarious quote about sleep
"Dear sleep, I’m sorry we broke up this morning. I want you back!" — Anonymous
I like to collect quotes and keep a personal collection.
I had applied for dropbox stamping on May 1, 2023. I am still waiting for my passport. More than a week has passed. I made a foolhardy plan to only give 2 week buffer before boarding my flight. Hope the passport comes on time.
There is a 30 day challenge hosted at leetcode.
Given an integer array arr and a mapping function fn, return a new array with a transformation applied to each element.
Input: arr = [1,2,3], fn = function plusone(n) { return n + 1; }
Output: [2,3,4]
          The solution is straightforward to use map
var map = function(arr, fn) {
   return arr.map(fn);
};
          Write a function createHelloWorld. It should return a new function that always returns "Hello World".
Input: args = []
Output: "Hello World"
          Solution:
var createHelloWorld = function() {
  return function(..args) {
    return "Hello World"
  }
}
          Given an integer n, return a counter function. This counter function initially returns n and then returns 1 more than the previous value every subsequent time it is called (n, n + 1, n + 2, etc).
const counter = createCounter(10)
counter() // 10
counter() // 11
counter() // 12
          Solution:
var createCounter = function(n) {
    return function() {
        return n++;
    };
};
          This is a simple example of using closures in javascript.
Closure are nested function which has access to the outer scope
After the outer function is returned, by keeping a reference to the inner function (the closures) we prevent the outer scope to be destroyed.
Sometimes you want to skip certain folders for scanning. Add following option to the config
-Dsonar.exclusions=**/site-packages/**
          I watched it today. It was in my bucket list. I liked the soundtrack and visual effects. I guess story could have been more captivating.
I am currenlty reading ng-book
Create a new project
$ ng new angular-hello-world
          In the file angular-hello-world/src/index.html
<body>
<app-root> </app-root>
</body>
          the app-root is where application is rendered. It's a component.
To run the application, go to localhost:4200
$ ng serve --port 4200
          $ ng generate component hello-world
          Component consist of two parts
a component decorator
a component definition class
Open the file angular-hello-world/src/app/hello-world/hello-world.component.ts
import {Component, OnInit} from '@angualar/core';
@Component({
    selector: 'app-hello-world',
    templateUrl: './hello-world.component.html',
    styleUrl: ['./hello-world.component.css']
})
export class HelloWorldComponent implements OnInit{
  constructor() {}
  ngOnInit(){}
}
          @Component is the decorators. In the angular-hello-world/src/app/app.component.html, we can use
<app-hello-world></app-hello-world>
          I am tracking my books here