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
from pymongo import MongoClient | |
from bson import SON | |
from time import mktime | |
from datetime import datetime, timedelta | |
from time import mktime | |
from pprint import pprint | |
from random import randrange, randint, choice | |
def seed_position_times(db): |
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
# put this file in home folder | |
date_format %d/%b/%Y | |
log_format %h %^[%d:%^] "%r" %s %b "%R" "%u" |
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
// 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 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 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 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 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
class PPrintMixin: | |
def __str__(self): | |
return '<{}: id={!r}>'.format(type(self).__name__, self.id) | |
def __repr__(self): | |
attrs = [] | |
for name in self._fields.keys(): | |
value = getattr(self, name) | |
if isinstance(value, (Document, EmbeddedDocument)): | |
attrs.append('\n {} = {!s},'.format(name, value)) |
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 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 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 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); |
OlderNewer