$ lsof -i :$PORT -- set desired port, e.g. 3000
$ kill $PID -- set discovered PID, e.g. 2227
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
let R = require("ramda") | |
let {Observable, Subject} = require("rx") | |
let scanFn = function (state, updateFn) { | |
if (typeof updateFn != "function" || updateFn.length != 1) { | |
throw Error("updateFn must be a function with arity 1, got " + updateFn) | |
} else { | |
return updateFn(state) | |
} | |
} |
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
let assert = require("assert"); | |
function curryN(N, fn) { | |
let self = undefined; | |
let collectFn = Object.defineProperties(function (...args) { | |
if (this) { | |
self = this; | |
} | |
if (args.length >= N) { | |
return fn.apply(self, 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
import Fs from "fs"; | |
import Parse5 from "parse5"; | |
import MemWatch from "memwatch-next"; | |
import humanFormat from "human-format"; | |
process.on("unhandledRejection", function (reason, p) { | |
throw reason; | |
}); | |
let timeScale = new humanFormat.Scale({ |
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 Fs from "fs"; | |
import {Parser} from "htmlparser2"; | |
import MemWatch from "memwatch-next"; | |
import humanFormat from "human-format"; | |
process.on("unhandledRejection", function (reason, p) { | |
throw reason; | |
}); | |
let timeScale = new humanFormat.Scale({ |
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
/* | |
This wrapper | |
1. Reduces boilerplate. Lwip functions like .resize() are very low-level. See the code to get what I mean. | |
2. Adds sharpen to downsampling. | |
3. Has promise-based API | |
4. Operates on file buffers instead of image buffers to make operations immutable. | |
Use Lwip directly if you experience bottleneck and need to batch operations for performance. | |
Use this wrapper (it's forks) in other cases. | |
*/ |
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 Path from "path"; | |
const splitPathRe = | |
/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/; | |
function assertPath(path) { | |
if (typeof path !== 'string') { | |
throw new TypeError('Path must be a string. Received ' + | |
util.inspect(path)); | |
} |
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 npm_package_is_installed { | |
if [ $(npm list --depth 0 --parseable true "${2}" | grep "${1}$") ]; then | |
echo "1" | |
else | |
echo "0" | |
fi | |
} | |
# npm_package_is_installed gulp | |
# npm_package_is_installed gulp -g |
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
// resolution is [width, height] structure | |
// Evaluate resolution by width (height doesn't matter, just keep it proportional) | |
function evalResolutionByWidth(requiredWidth, actualResolution) { | |
var actualWidth = actualResolution[0]; | |
var actualHeight = actualResolution[1]; | |
if (actualWidth > requiredWidth) { | |
var scale = actualWidth / requiredWidth; | |
return [requiredWidth, Math.round(actualHeight / scale)]; | |
} else { |
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
# put this file in home folder | |
date_format %d/%b/%Y | |
log_format %h %^[%d:%^] "%r" %s %b "%R" "%u" |