This file contains hidden or 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
const arr1 = range(1, 3); | |
(async () => { | |
for await (let n of arr1) { | |
console.log(n); | |
} | |
})(); | |
// 1, 2, 3 |
This file contains hidden or 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
const express = require('express'); | |
const fs = require('fs'); | |
const app = express(); | |
app.get('/', async (req, res) => { | |
const stream = fs.createReadStream('file_name', { | |
highWaterMark: 5 | |
}); | |
for await (const chunk of stream) { |
This file contains hidden or 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 myQ = Q(); | |
myQ.push(1); | |
myQ.push(2); | |
myQ.push(3); | |
console.log(myQ.pop()); // 1 | |
console.log(myQ.pop()); // 2 | |
console.log(myQ.pop()); // 3 |
This file contains hidden or 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
Find the number of ways to express n as sum of some (at least two) consecutive positive integers. | |
Example | |
For n = 9, the output should be | |
isSumOfConsecutive2(n) = 2. | |
There are two ways to represent n = 9: 2 + 3 + 4 = 9 and 4 + 5 = 9. | |
For n = 8, the output should be |
This file contains hidden or 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
const express = require('express'); | |
const app = express(); | |
app.get('/', (req, res) => { | |
res.end(`Hello PID: ${process.pid}`); | |
}); | |
app.get('/check', (req, res) => { | |
console.log('Health Check Request'); | |
res.status(200).end(); |
This file contains hidden or 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
const express = require('express'); | |
const app = express(); | |
app.get('/', (req, res) => { | |
res.end(`Hello PID: ${process.pid}`); | |
}); | |
let status = 200; | |
setTimeout(() => { | |
status = 503; |
This file contains hidden or 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
global | |
log 127.0.0.1 local0 notice | |
user haproxy | |
group haproxy | |
defaults | |
log global | |
mode http | |
option httplog |
This file contains hidden or 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
const mySetFromArray = new Set([1, 2, 3]); |
This file contains hidden or 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
const mySetFromString = new Set('hello'); |
This file contains hidden or 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
console.time('Set test'); | |
const set = new Set(); | |
const count = 10; | |
for (let i = 0; i < count; i++) { | |
set.add(i); | |
} |