HashMark is a small utility which takes a file (or sdtin) as input, and writes the contents of the input to a file named with a hash digest of the file.
#npm-run-all A CLI tool to run multiple npm-scripts in parallel or sequential.
| function promiseOnce () { | |
| let promise = null | |
| return function (createPromise) { | |
| if (promise) { | |
| return promise | |
| } | |
| promise = createPromise() |
| .u-ratio | |
| --ratioX 1 | |
| --ratioY 1 | |
| position relative | |
| &:before | |
| display block | |
| padding-top calc(var(--ratioY) / var(--ratioX) * 100%) | |
| content '' |
| const log = (...message) => | |
| console.log.apply(console, [ '[PREFIX]', ...message ]) | |
| log('foo', 'bar', 'bat', 1, 2, 3) | |
| // [PREFIX] foo bar bat 1 2 3 |
| <?php | |
| function l ($name) { | |
| return function ($line) use ($name) { | |
| file_put_contents($name, $line . PHP_EOL, FILE_APPEND); | |
| }; | |
| } |
| <?php | |
| function b () { | |
| $start = microtime(true); | |
| return function () use ($start) { | |
| $end = microtime(true); | |
| return $end - $start; | |
| }; | |
| } |
| 'use strict'; | |
| const timeoutPromise = ms => promise => new Promise((resolve, reject) => { | |
| const timeout = setTimeout(() => { | |
| reject(new PromiseTimeout()); | |
| }, ms); | |
| promise.then( | |
| res => { | |
| clearTimeout(timeout); | |
| resolve(res); |
| const delay = delayPromise(1000) | |
| delay(() => fetch('/')) | |
| .then(console.log) |
| /* | |
| * !!! IMPORTANT !!! | |
| * This has been modified to accept "onRemove" and "onAppend" callbacks. | |
| * See comments 1, 2, and 3. | |
| */ | |
| /*! appendAround markup pattern. [c]2012, @scottjehl, Filament Group, Inc. MIT/GPL | |
| how-to: | |
| 1. Insert potential element containers throughout the DOM | |
| 2. give each container a data-set attribute with a value that matches all other containers' values | |
| 3. Place your appendAround content in one of the potential containers |
| function routeWebsocket(server, controllers = []) { | |
| server.on('connection', client => { | |
| client.on('message', ({ event, data }) => { | |
| const controller = controllers[event]; | |
| if(controller) { | |
| controller(data); | |
| } | |
| }); | |
| }); | |
| } |
HashMark is a small utility which takes a file (or sdtin) as input, and writes the contents of the input to a file named with a hash digest of the file.
#npm-run-all A CLI tool to run multiple npm-scripts in parallel or sequential.