Skip to content

Instantly share code, notes, and snippets.

View benlesh's full-sized avatar
🐶
☕ 🔥 🔥 this is fine

Ben Lesh benlesh

🐶
☕ 🔥 🔥 this is fine
View GitHub Profile
@bmeck
bmeck / gc.js
Last active May 10, 2021 20:19
#!/usr/bin/env node
// call using --inspect brk, GC using memory tab of devtools
// call globalThis.tick() to move the code along and see when things reap from
// manually calling GC
{
const registry = new FinalizationRegistry((_) => console.log(_, 'reaped'));
let EASY_TO_FIND = class EASY_TO_FIND2 {
big = new Uint8Array(1024 * 1024 * 10);
constructor(_) {
registry.register(this, _);
// Setup: RxJS shaped types
declare class Observable<T> { _t: T; }
declare interface ObservedValueOf<T> { _t: T; _brand: 'ObservedValueOf'; }
declare interface Scheduler { _brand: 'Scheduler'; }
declare type ObservableInput<T> = Observable<T> | Promise<T> | T[];
// A trick to force T to be inferred as a tuple type. TypeScript would prefer to infer
// an array, but arrays don't match {0: any}.
type Tuple<T> = (T & { 0: any }) | [];

bazel query cheatsheet

which packages depend on qtdb lib?

bazel query 'rdeps(..., //vistar/geo/qtdb:go_default_library)' --output package 

which packages does qtdb depend on?

@threepointone
threepointone / alternative.md
Last active July 31, 2022 17:46
list of things that don't do what they say they do

(also know as lies and/or alternative facts)

js

  • setImmediate - doesn't set anything immediately, waits for a tick before executing
  • setTimeout(fn, n) - never sets the timeout to exactly n
  • Math.random() - computers cannot generate random numbers
  • Promise - is a lie when rejected
  • Array.reduce - accumulates, does not reduce (via @sbmadhav)
@btroncone
btroncone / rxjs_operators_by_example.md
Last active June 15, 2024 07:17
RxJS 5 Operators By Example
@dherman
dherman / fgrep.md
Last active August 29, 2015 14:16
fgrep: a style/expressiveness test for stream libraries

How Would You Write fgrep?

This is a little style and expressiveness test for various stream libraries. It is certainly not a proof of anything, so much as an ability to showcase how some basic features of streams fit together with different libraries.

Problem statement: given a library of streams, implement an API analogous to fgrep, i.e., a literal string grepper.

Specifically, implement a function fgrep(test, filenames[, limit=10]), which takes a source string, a list of filenames, and an optional concurrency limit, and produces a stream of Match records { filename: string, lineNumber: number, line: string }, representing all lines of all files that contain the string test. For each matching record, filename is the name of the file where the match was found, lineNumber is the one-indexed line number where the match was found, and line is the contents of the line where the match was found.

The limit argument indicates the maximum number of concurrent filehandles that should b