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
/* 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 |
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
const baseTree = { | |
id: 'root', | |
children: [ | |
{ | |
id: 'child0', | |
children: [ | |
{ | |
id: 'child0-0', | |
children: [ | |
{ |
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
#[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 |
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
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) => { |
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
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 |
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
/* | |
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; | |
} |