Skip to content

Instantly share code, notes, and snippets.

View jtbandes's full-sized avatar
💜
Working on @foxglove!

Jacob Bandes-Storch jtbandes

💜
Working on @foxglove!
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<title>WebGL perf test</title>
</head>
<body>
<button id="create-button">Create canvas</button>
<button id="alloc-button" disabled>Allocate buffer</button>
<button id="remove-button" disabled>Remove canvas</button>
@jtbandes
jtbandes / tuple-types.ts
Created October 13, 2022 18:47
TypeScript tuple types using non-type generic parameters
type Ten<T extends any[]> = [...T, ...T, ...T, ...T, ...T, ...T, ...T, ...T, ...T, ...T]
type Tuple<T, N extends number> =
N extends 0 ? [] :
N extends 1 ? [T] :
N extends 2 ? [T,T] :
N extends 3 ? [T,T,T] :
N extends 4 ? [T,T,T,T] :
N extends 5 ? [T,T,T,T,T] :
N extends 6 ? [T,T,T,T,T,T] :
N extends 7 ? [T,T,T,T,T,T,T] :
import colorsys
import base64
import math
import json
import requests
from tqdm import tqdm
from time import time_ns
from pyquaternion import Quaternion
from mcap.mcap0.writer import Writer
FROM ubuntu:jammy
RUN apt-get update && apt-get install -y --no-install-recommends --no-install-suggests \
git \
python3 \
python3-pip \
cmake \
clang \
llvm-dev \
libclang-dev \
type MaybeAwait<P> = P extends Promise<infer T> ? T : P;
function maybeAsync<Args extends unknown[], TYield, TReturn>(
body: (...args: Args) => Generator<TYield, TReturn, MaybeAwait<TYield>>
): (...args: Args) => (TYield extends Promise<infer _P> ? Promise<TReturn> : TReturn);
function maybeAsync<Args extends unknown[], TYield, TReturn>(
body: (...args: Args) => Generator<TYield, TReturn, MaybeAwait<TYield>>
): (...args: Args) => (Promise<TReturn> | TReturn) {
return (...args: Args) => {
node_modules
out
package-lock.json
# Inspired by: https://www.futilitycloset.com/2017/04/17/a-poets-arsenal/
# Word lists from the Opinion Lexicon: https://www.cs.uic.edu/~liub/FBS/sentiment-analysis.html
from itertools import product, imap, ifilter, chain
import multiprocessing
def load_words(path):
with open(path) as f:
words = ifilter(lambda line: line.rstrip() and not line.startswith(";"), f)
return map(lambda word: word.rstrip(), words)
extension String {
func lazyComponents(separatedBy sep: Character) -> AnySequence<String> {
return AnySequence<String> { [cv = self.characters] () -> AnyIterator<String> in
var current = cv.startIndex
var finished = false
return AnyIterator<String> {
if finished {
return nil
}
#include <iostream>
using namespace std;
template<int N, char C, char... Cs> struct repeatImpl : repeatImpl<N-1, C, C, Cs...> {};
template<char C, char... Cs> struct repeatImpl<0, C, Cs...> {
static constexpr char cs[] = {Cs..., '\0'};
};
template<char C, char... Cs> constexpr char repeatImpl<0, C, Cs...>::cs[];
template<int N, char C> const char (& repeat())[N+1] {
return repeatImpl<N, C>::cs;