This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isSubset(arr, subArr) { | |
return subArr.every(function(value) { | |
return arr.includes(value) | |
}) | |
} | |
console.log(isSubset(['A', 'D', 'E'], ['A', 'A', 'D', 'E'])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void runMultiThread() { | |
// Creates and makes ready a pool of 5 threads to wait for tasks | |
ExecutorService executorService = Executors.newFixedThreadPool(5); | |
// Define task for each Runnable which will be submitted to executorService for assingment to threads | |
Runnable task1 = () -> { | |
System.out.println("Inside task1 on thread: " + Thread.currentThread().getName()); | |
try { | |
TimeUnit.SECONDS.sleep(10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | |
echo "POST RECEIVE hook triggered" \ | |
echo "POST-RECEIVE: git checkout ..." | |
git --work-tree=/var/repos/project --git-dir=/var/repos/project/project.git checkout -f | |
cd /var/repos/project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
apps : [{ | |
name : "my-app", | |
script : "./path/to/app/entry/point.js", // path needs to be relative from ecosystem.config.js | |
watch : true, // any changes to app folder will get pm2 to restart app | |
env : { | |
"NODE_ENV": "development", // define env variables here | |
} | |
}] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app.js file | |
const express = require('express'); | |
const bodyParser = require('body-parser'); | |
const morgan = require('morgan'); | |
const app = module.exports = express(); | |
// someModule.js | |
const app = require('../path/to/app.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:8-alpine | |
# prepare project directory within container | |
RUN mkdir -p /opt/nats-streaming-console/ | |
# Specifies the current working directory. RUN or cd commands will use this directory as reference point | |
WORKDIR /opt/nats-streaming-console/ | |
# Copy source code into container | |
COPY <insert/source/code/path> /opt/nats-streaming-console/ | |
# install dependencies, build application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
nats-mon: | |
container_name: nats-mon | |
image: nats-mon:latest | |
ports: | |
- 8282:8282 | |
environment: | |
- STAN_URL=nats://db01.d2sphere.com:4222 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let promises = [query1(), query2(), query3(), query4(), query5()] | |
Promises.all(promises) | |
.then(function(result)) { | |
// result here will be an array of results in the same order as promises arr | |
res.status(200).json(result); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let directorsArr = [ | |
['Thomas', 220000], | |
['Michael', 200000] | |
] | |
let managersArr = [ | |
['Robert', 100000], | |
['Sandra', 105000] | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function updateSalaryPerEmployee(type, employee, grossSalaryChange) { | |
let updatedEmployee = employee.slice() | |
switch(type) { | |
case 'director': | |
updatedEmployee[1] = employee[1] + (grossSalaryChange * 0.55); | |
break; | |
case 'manager': | |
updatedEmployee[1] = employee[1] + (grossSalaryChange * 0.65); | |
break; |
OlderNewer