ngb-accordion or ngb-panel do not appear

First and most importantly Check if the third party import is correct and the import is in the right module

Either import NgbModule or NgbAccordionModule

import { NgbAccordionModule } from '@ng-bootstrap/ng-bootstrap';

...
import: [
     NgbAccordionModule
]
...

Basic code for the ngb-accordion:

<ngb-accordion activeIds="test-panel">
  <ngb-panel title="Accordion Panel 1" id="test-panel">
    <ng-template ngbPanelContent>
      This is accordion panel content
    </ng-template>
  </ngb-panel>
</ngb-accordion>

Refer here for examples: https://ng-bootstrap.github.io/#/components/accordion/examples

Redis – quick primer

Redis is an open source, in-memory, data structure store used as database, cache and message broker.

Installation

wget http://download.redis.io/releases/redis-6.0.3.tar.gz (wget this version or the latest)

tar xzf redis-6.0.3.tar.gz (-x extract the files from the archive, -z uncompress, -f use a file – file you are processing)

cd redis-6.0.3

make (make command has a lot of built-in knowledge, it can’t know how to build your application all by itself. You must provide a file that tells make how your application is constructed.This file is called the makefile.)

Common Use cases

  • Cache
  • Analytics
  • Leaderboards
  • Queues
  • Cookie Storage
  • Expiring data
  • Distributing locks
  • High I/O workloads
  • Messaging
  • Pub/Sub

JavaScript – The very basic

Truthy and Falsy

In JavaScript, there are six basic falsy values:

  • undefined
  • null
  • “” (empty string)
  • NaN (not a number)
  • 0 (zero number)
  • false (boolean)

Any other values in javascript is considered truthy.

triple equals (===) AND double equals (==)

Triple equals tests for strict equality. This means both the type and the value both have to be the same.

Double equals tests for loose equality. Double equals also performs type coercion.

Primitive values and objects

There are six primitive values in JavaScript:

  • Boolean
  • Null
  • Undefined
  • Number
  • String
  • Symbol

All other values in JavaScript are objects (objects, functions, arrays, Sets, Maps etc).

Set default Java version (mac)

First search what is your current java version:

echo $JAVA_HOME

If java is already installed, the results will be a location like this:

/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home

In case, it is not you need to download the latest JDK (NOT JRE) (or the version required) and install that version (https://www.oracle.com/au/java/technologies/javase-downloads.html)

Now, change directory to JAVA_HOME one (a few levels up though)

cd /Library/Java/JavaVirtualMachines

You will be able to view all the JDKs installed here.

ls -al

Now to set, say the version 13.0.2, use the command

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home

For a permanent change of JAVA_HOME, add/update your .bash_profile or .zshrc

/usr/libexec/java_home is the simplest maintainable way of setting JAVA_HOME on macOS.

export JAVA_HOME=`/usr/libexec/java_home -v 13`

Use the below command to find out all the versions of JAVA that are installed on this mac

/usr/libexec/java_home -V

Using AWS Parameter store to store password and fetching it

Store passwords in Parameter store (refer https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html)

Code for accessing parameter store from a nodeJs application:

// create system manager object with proxy setup

const SSM = new AWS.SSM({ httpOptions: {proxy: `http://${process.env.PROXY_HOST}:${process.env.PROXY_PORT}`}});

let getSSMData = async () => {

try {

let dbPassword;

let response = await SSM.getParameters({

Names: [‘some_parameter_key’], WithDecryption: true }).promise();

dbPassword = response[“Parameters”][0][“Value”];

} catch (error) {

// handle error

}

customising create-react-app

For most of the projects, one should be alright to use the react skeleton app as created by create-react-app. However, if you want more customisation, here are some options:

  • Use npm run eject to the config to get full control over the build deploy and the entire lifecycle of the react app
  • Use sass instead of css
    • npm install node-sass
    • update the app.css and other files to app.scss

NPM Install global packages without sudo

Thanks to John Papa: https://johnpapa.net/how-to-use-npm-global-without-sudo-on-osx/

  1. Pre-requisites: npm should be installed

2. make a directory:

mkdir ~/.npm-global

3. tell npm where to find/install global packages

npm config set prefix ~/.npm-global

Extra step so that it’s available in the environment variable:

Update bash profile (in *nx or mac) – update or create ~/.bash_profile:

NPM_PACKAGES=~/.npm_global/bin

PATH=”$NPM_PACKAGES:${PATH}”

export PATH

CORS issues and resolutions

Issue 1:

Response to preflight request doesn’t pass access control check: The value of the ‘Access-Control-Allow-Origin’ header in the response must not be the wildcard ‘*’ when the request’s credentials mode is ‘include’. Origin ‘http://localhost:4200&#8217; is therefore not allowed access.

Solution 1:

You should not have

“Access-Control-Allow-Origin”: “*”,
Instead have specific ‘Access-Control-Allow-Origin’.
“Access-Control-Allow-Origin”: “http://localhost:4200&#8221;,
Issue 2:
Response to preflight request doesn’t pass access control check: The value of the ‘Access-Control-Allow-Credentials’ header in the response is ” which must be ‘true’ when the request’s credentials mode is ‘include’. Origin ‘http://localhost:4200&#8217; is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
Solution 2:
Apart from adding the specific Allow origin instead of *, you will be required to add the Allow-Credentials.
“Access-Control-Allow-Origin”: “http://localhost:4200&#8221;,
“Access-Control-Allow-Credentials”: “true”,  // this extra needs to be added

Issue 3: 

No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:4200&#8217; is therefore not allowed access.

Solution 3: TBC