Instantly share code, notes, and snippets.

View gist:8af43d5b84e5b7f323513a1d314b8a25
router.get("/all", USER, async function(req, res) {
// get summary
let all = await database.getContentSummary();
// filter out by query
all = simpleFilter(all, (item: any) => item.id, req.query.id);
all = simpleFilter(all, (item: any) => item.type, req.query.type);
// filter out privates and non-configurable
all = all.filter((item: any) => {
View simpleFIlter
const wildcard = require("wildcard");
/**
* Filter an array of object by wildcard filters.
*
* @param {any[]} items list of input objects to filter
* @param {any=>string} field function that will return a string to filter given an input object
* @param {string|string[]} filters wildcard filter or filters to test. Items will be returned if any of the filters match.
* @return {any[]} list of filtered items
*/
View gist:b24bd8f3de5f1854db32
# squash git commits
# https://wincent.com/wiki/Squashing_all_Git_commits_into_a_single_commit
git update-ref -d refs/heads/master
git commit -s -m shovel
#!/bin/bash
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
View gist:e28bd7507bd8c9033eb1
/**
* HDS File parser
*
* @todo add 64 bit value parsing.
*/
var loadHDS = function(binary, filename)
{
try
{
View gist:d2248dbb2c8411e03034
function Uint8ArrayListWriter(contentSize, filename)
{
var output, that = this, offset, errored;
function init(callback)
{
output = [];
offset = 0;
View gist:b3c26ddeb1f36c3f82ae
/**
* @class custom Writer; zipjs one breaks in chrome for large binary files
*/
function ArrayBufferWriter(contentSize, filename)
{
var output, that = this, offset, errored;
function init(callback)
{
output = new Uint8Array(contentSize);
View gist:4dd4e3ae2eb40954f0f6
/**
* @author Nahid Akbar
* @date 19/10/14
*/
"use strict";
var singleton = function(BaseClass, instanceParent, instanceVarName)
{
instanceParent = instanceParent !== undefined ? instanceParent : BaseClass;
instanceVarName = instanceVarName !== undefined ? instanceVarName : 'instance';
return function()
View encoding decoding cells into a single number inside fixed dimension discrete rectangular grid
var dx = 10;
var dy = 10;
var dz = 3;
var decode = function(v)
{
var z = v % dz;
var xy = (v - z) / dz;
var y = xy % dy;
var x = (xy - y) / dy;
View gist:a0de7a3e6b2b99d5bf5c
import os
import random
# INSERT INTO `dataset_album` (`pic_id`, `pic_cat_id`) VALUES
dataset_album = [
(1, 1),
(2, 1),
(3, 1),
(4, 1),
(5, 1),