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
const findMin = array => | |
array.find( | |
(item, index) => item < array[index > 0 ? index - 1 : array.length - 1] | |
); | |
const findMinBinarySearch = (array, left = 0, right) => { | |
if (right === undefined) right = array.length - 1; | |
if (right - left === 0) return array[left]; | |
const midpoint = Math.floor(left + (right - left) / 2); |
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 fibonacciLike (input) { | |
const sequences = []; | |
input.forEach((number, i) => { | |
// Append to the all sequences where this is a legitimate continuation. | |
// We need to consider all of them because any values of a, b where a + b = c could form | |
// part of the solution depending on what comes afterwards. | |
sequences.forEach(sequence => { | |
const [a, b] = sequence; | |
if (a + b === number) sequence.unshift(number); | |
}); |
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
0 info it worked if it ends with ok | |
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'ci' ] | |
2 info using [email protected] | |
3 info using [email protected] | |
4 verbose npm-session e834e6c25bc148cd | |
5 info prepare initializing installer | |
6 verbose prepare starting workers | |
7 verbose prepare installation prefix: /code | |
8 verbose prepare using package-lock.json | |
9 warn prepare removing existing node_modules/ before installation |
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
services: | |
myservice: | |
volumes: npm-cache:/root/.npm | |
command: npm run install-start | |
volumes: | |
npm-cache: | |
external: false |
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
# First, create an ec2 instance and log in to it. | |
curl -sSL https://get.docker.com/ubuntu/ | sudo sh # (sets up docker on the box) | |
git pull <git repo> # get your repo | |
cd <git repo> && sudo docker build -t <image-tag> . #build your image | |
sudo docker run -d -p 80:80 --restart=always <image-tag> # start it |
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
/** | |
* @param {Object} job The data you want to save for the job. | |
* @param {int} processIn The job will not get service until this many ms have elapsed. | |
* @param {function} done Callback. | |
*/ | |
jobs.create(job, processIn, done); | |
// Form of callback for jobs.process(): | |
// done(err, newJob, processIn) | |
var callback = function(job, done) { |