Skip to content

Instantly share code, notes, and snippets.

View Dockerfile
FROM node:14.15 as build-deps
WORKDIR /usr/src/app
COPY package.json yarn.lock ./
RUN yarn
COPY . ./
RUN yarn build
FROM nginx:1.12-alpine
COPY --from=build-deps /usr/src/app/build /usr/share/nginx/html
EXPOSE 80
View single-spa.angular.ts
import { enableProdMode, NgZone } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { Router } from '@angular/router';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
import singleSpaAngular from 'single-spa-angular';
import { singleSpaPropsSubject } from './single-spa/single-spa-props';
if (environment.production) {
View single-spa.react.js
import React from 'react'
import ReactDOM from 'react-dom'
import singleSpaReact from 'single-spa-react'
import { property } from 'lodash'
import setPublicPath from './set-public-path.js'
const reactLifecycles = singleSpaReact({
React,
ReactDOM,
loadRootComponent: () => import(/* webpackChunkName: "react-app" */'./App.js').then(property('default')),
View single-spa.root-app.html
<!DOCTYPE html>
<html>
<head>
<title>Root application</title>
<meta name="importmap-type" content="systemjs-importmap">
<script type="systemjs-importmap">
{
"imports": {
"angular-app": "http://localhost:4201/main.js",
"react-app": "http://localhost:4202/main.js",
View selection-sort.js
function selectionSort(array) {
for (var i = 0; i < array.length; i++) {
let min = i; // storing the index of minimum element
for (var j = i + 1; j < array.length; j++) {
if (array[min] > array[j]) {
min = j; // updating the index of minimum element
}
View bubble-sort.js
const bubbleSort = (inputArr) => {
let length = inputArr.length;
for (let i = 0; i < length; i++) {
for (let j = 0; j < length; j++) {
if (inputArr[j] > inputArr[j + 1]) {
let tmp = inputArr[j];
inputArr[j] = inputArr[j + 1];
inputArr[j + 1] = tmp;
}
}
View observable.js
// create observable
const exampleObservable$ = new Observable((observer) => {
// observable execution
observer.next('example value 1');
observer.next('example value 2');
observer.next('example value 3’);
observer.complete();
})
View iterator.js
var Iterator = function(items) {
this.index = 0;
this.items = items;
}
Iterator.prototype = {
first: () => {
this.reset();
return this.next();
},
View observer.js
function Click() {
this.handlers = []; // observers
}
Click.prototype = {
subscribe: (fn) => {
this.handlers.push(fn);
},
unsubscribe: (fn) => {
this.handlers = this.handlers.filter(...);
View reactive.js
let a = 1;
let b = 2;
let c = a + b;
console.log('c = ', c);
//Output: c = 3
a = 2;
console.log('c = ', c);
//Output: c = 4