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
# Add these lines to your dockerfile, before `npm install` | |
# Copy the bitbucket private key to your docker image | |
COPY ./bitbucket_ssh_key /opt/my-app | |
# Copy the ssh script to your docker image | |
COPY ./ssh-bitbucket.sh /opt/my-app | |
# Tell git to use your `ssh-bitbucket.sh` script | |
ENV GIT_SSH="/opt/map-project-tile-server/ssh-bitbucket.sh" |
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
// Track the equation as a string | |
let equation = ''; | |
// 🤯 🤯 🤯 🤯 🤯 🤯 🤯 | |
// This regular expression defines a set of "rules" for | |
// how our equation string should look | |
// It also tells us how to break apart the different sections of the | |
// string into "groups" | |
// These are super powerful, though not always so easy to use 😉 | |
let equationRegEx = /^([0-9]+(\.[0-9]+)?)?([\+\-\/\*])?([0-9]+(\.[0-9]+)?)?$/ |
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 intent({DOM}) { | |
return { | |
addTodo: DOM.get('input', 'change'). | |
map(evt => evt.target.value). | |
filter(val => val.trim().length), | |
removeTodo: DOM.get('button', 'click'). | |
// Map the remove button click to the item text | |
map(evt => evt.target.previousElementSibling.innerText.trim()) | |
}; | |
} |
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
import * as fs from 'fs'; | |
import * as assert from 'assert'; | |
import * as _ from 'lodash'; | |
function assertFileExists(filePath:string, msg?:string) { | |
try { | |
fs.statSync(filePath); | |
} | |
catch (err) { | |
if (_.includes(['ENOENT', 'ENOTDIR'], err.code)) { |
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
import * as assert from 'assert'; | |
function assertMatches(actual:string, regex:RegExp, msg?:string) { | |
if (regex.test(actual)) { | |
assert(false, `${msg}: expected "${actual}" to match regex "${regex.toString()}"`) | |
} | |
} | |
export default assertMatches; |
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 fs = require('fs'); | |
const assert = require('assert'); | |
const _ = require('lodash'); | |
function fileExists(filePath, msg) { | |
try { | |
fs.statSync(filePath); | |
} | |
catch (err) { | |
if (_.includes(['ENOENT', 'ENOTDIR'], err.code)) { |
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 co = require('co'); | |
const _tmp = require('tmp'); | |
_tmp.setGracefulCleanup(); | |
// Promise wrappers around tmp | |
const tmp = { | |
/** @return {Promise<{path, cleanup}>} */ | |
file: () => co(function* () { | |
return yield cb => _tmp.file({ unsafeCleanup: true }, (err, path, fd, cleanup) => cb(err, { | |
path, |
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
import * as assert from 'assert'; | |
function assertPartial(actualObj:any, expectedPartial: any, msg?:string) { | |
const actualPartial:any = Object.keys(expectedPartial) | |
.reduce((part, key) => ({ | |
...part, | |
[key]: actualPartial[key] | |
}), {}); | |
assert.deepStrictEqual(actualPartial, expectedPartial, msg); |
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 S3 = require('aws-sdk').S3; | |
const dotenv = require('dotenv'); | |
const Url = require('url'); | |
const p = require('util').promisify; | |
const fs = require('fs'); | |
/** | |
* @param {string} envUri | |
* @returns {Promise<Object>} | |
*/ |
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
/** | |
* Run a series of async functions in sequence, | |
* so that each fn waits to run until the last one has completed. | |
* | |
* @param {function():Promise<T>} fns | |
* @returns {Promise<T[]> | |
*/ | |
function sequence(fns) { | |
return fns | |
.reduce((_prevResults, fn) => ( |
NewerOlder