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 timer = (ms) => new Promise(resolve => setTimeout(resolve, ms)); | |
let producer = async function*() { | |
let counter = 0; | |
while (true) { | |
let delay = Math.random() * 1000; | |
await timer(delay); | |
yield counter++; | |
} | |
}; |
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 intRegex = /^(0|[1-9]\d*)$/; | |
let isIndex = prop => | |
typeof prop === 'string' | |
&& intRegex.test(prop); | |
let concat = (left, right) => { | |
let w = left.length; | |
let h = right.length; |
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 getCost(cell) { | |
return cell.match(/\$[\d.,]+\d/)[0] | |
} | |
function getCondition(cell) { | |
return cell.match(/((like )?new|used|mint|good|great|excellent)/i)[0] | |
} | |
function getEmail(cell) { | |
return (cell.match(/[^\s@]+@[^\s@]+/i) || ['N/A'])[0] |
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 SlackBot = require('slackbots'); | |
const BOT_NAME = 'Slacks or Shorts'; | |
const BOT_TOKEN = '<YOUR-TOKEN-HERE>'; | |
const BOT_HANDLE = 'slacks-or-shorts'; | |
let bot = new SlackBot({ | |
token: BOT_TOKEN, | |
name: BOT_NAME | |
}); |
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/bash | |
DEV_HOST="localhost:2368" | |
PROD_HOST="blog.yellowscale.com" | |
BUILD_DEST=${1:-./build} | |
DEV_URL="http://${DEV_HOST}" | |
PROD_URL="https://${PROD_HOST}" | |
# Hop into build directory | |
pushd $BUILD_DEST > /dev/null |
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
/* Metaproxy | |
* The proxy that doesn't do anything | |
**/ | |
let target = { a: 1, b: 2, c: 3 } | |
let handler = new Proxy({}, { | |
get: (...args) => Reflect[args[1]](...args) | |
}) |
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 processImage from 'process-image'; | |
var file = /* File() object from drag-n-drop or file input */ | |
var imageProcessOpts = { | |
maxWidth: 1200, | |
maxHeight: 1200, | |
quality: 0.6 | |
}; |
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
Show hidden characters
{ | |
"presets": [ | |
"es2015", | |
"es2016", | |
"es2017" | |
], | |
"plugins": [] | |
} |
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
var graph = [ | |
'AB6', | |
'AC3', | |
'BD6', | |
'CD5', | |
'CE9', | |
'DF8', | |
'DE3', | |
'EG8', | |
'FG2' |
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
// Create a Promise that resolves after ms time | |
var timer = function(ms) { | |
return new Promise(resolve => { | |
setTimeout(resolve, ms); | |
}); | |
}; | |
// Repeatedly generate a number starting | |
// from 0 after a random amount of time | |
var source = async function*() { |
NewerOlder