Skip to content

Instantly share code, notes, and snippets.

View maxnachlinger's full-sized avatar

Max Nachlinger maxnachlinger

View GitHub Profile
/* eslint-disable @typescript-eslint/no-var-requires, no-console, no-undef */
'use strict';
const Benchmark = require('benchmark');
const { createHash } = require('crypto');
const smallInput = '75448dcb-5131-4a45-8ced-01aff65183e8';
const largeInput = smallInput.repeat(75);
// eslint-disable-next-line new-cap
const baseTree = {
id: 'root',
children: [
{
id: 'child0',
children: [
{
id: 'child0-0',
children: [
{
#[derive(Clone, Debug, Default)]
pub struct WeightedInclusiveRange {
pub min: i32,
pub max: i32,
pub weight: i32,
}
impl WeightedInclusiveRange {
pub fn contains(&self, i: i32) -> bool {
i >= self.min && i <= self.max
use serde_json::Value;
fn redact_props_strings(keys_to_redact: &Vec<String>, value: &mut Value, clear: bool) {
match value {
Value::Object(map) => {
for (k, v) in map {
redact_props_strings(&keys_to_redact, v, keys_to_redact.contains(&k));
}
}
Value::Array(array) => {
const cluster = require('cluster');
const http = require('http');
const pEachSeries = require('p-each-series');
/*
# start polling via:
while
do
curl http://127.0.0.1:8080
sleep 0.5
@maxnachlinger
maxnachlinger / arrayToCols.js
Created May 17, 2015 15:08
1d array to 2d array of columns
/*
Given an array [0,1,2,3,4] and 3 columns, create:
[ [0,3], [1,4], [2] ] to power a screen that looks like: 0 | 1 | 2
3 | 4
*/
var a = [];
for(var i = 0; i < 5; i++) {
a[i] = i;
}