made with esnextbin
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 debug = require('debug')(__filename.replace(/^.*[/]([^.]+)\.js/, '$1')) // file-name | |
| const debug = require('debug')(__filename.replace(/^.*[/](.*)[/]([^.]+)\.js/, '$1:$2')) // folder:file-name |
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
| import {List} from 'immutable' | |
| export default fn => { | |
| const cache = {} | |
| const cacheKey = List() | |
| return function (...args) { | |
| const hashCode = cacheKey.push(this, ...args).hashCode() | |
| if (!(hashCode in cache)) { | |
| cache[hashCode] = fn.apply(this, args) | |
| } |
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 getUser = async $id => { | |
| const id = await Promise.resolve($id); | |
| return new Promise((resolve, reject) => { | |
| setTimeout(() => resolve({id}), 100); | |
| }); | |
| } | |
| const asyncId = new Promise((resolve, reject) => { | |
| setTimeout(() => resolve(5), 100); | |
| }); |
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
| document.addEventListener('focus', function (e) {console.clear(); console.log(e.target)}, true); |
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
| function* random(limit = 4) { | |
| let count = 0 | |
| while(count < limit) { | |
| yield Math.random(); | |
| count++; | |
| } | |
| } | |
| function* map(f, gen){ | |
| let next; |
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
| (function () { | |
| var textarea; | |
| function createTextArea() { | |
| if (textarea) { | |
| return textarea; | |
| } | |
| textarea = document.createElement('textarea'); | |
| textarea.style.position = 'absolute'; | |
| textarea.style.left = '-9999px'; | |
| textarea.style.top = (window.pageYOffset || document.documentElement.scrollTop) + 'px'; |
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
Show hidden characters
| { | |
| "stage": 0, | |
| "env": { | |
| "development": { | |
| "plugins": ["react-transform"], | |
| "extra": { | |
| "react-transform": { | |
| "transforms": [{ | |
| "transform": "react-transform-hmr", | |
| "imports": ["react"], |
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
| #! /usr/bin/env babel-node | |
| import dotenv from 'dotenv'; | |
| import program from 'commander'; | |
| import jwt from 'jsonwebtoken'; | |
| program | |
| .usage('[options]') | |
| .option('-u, --user <user id>', 'user id') | |
| .option('-E, --env [value]', 'environment, defaults to development', 'development') | |
| .parse(process.argv); |