Skip to content

Instantly share code, notes, and snippets.

View weswigham's full-sized avatar
:shipit:
:shipit:

Wesley Wigham weswigham

:shipit:
:shipit:
View GitHub Profile
@weswigham
weswigham / catmullrom.js
Last active September 16, 2019 18:06
Javascript is functional
var catmullRom = function(p0, p1, p2, p3, distance) {
var points = [p0, p1, p2, p3],
t = function(dest) {
if (dest === 0) return 0;
return Math.pow(
Math.sqrt(
Math.pow(points[dest].x - points[dest-1].x,2) + Math.pow(points[dest].y - points[dest-1].y,2) + Math.pow(points[dest].z - points[dest-1].z,2)
), 0.5) + t(dest-1);
},
t0 = t(0),

Keybase proof

I hereby claim:

  • I am weswigham on github.
  • I am www (https://keybase.io/www) on keybase.
  • I have a public key whose fingerprint is 08AD 0E7B 235F E978 4AC5 DCCB D59F 87F6 0C54 00C9

To claim this, I am signing this object:

{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/gulp/bin/gulp.js",
"stopOnEntry": true,
"args": ["test"],
interface Obj<T> {
ref: T;
}
interface Func<T> {
(x: T): void;
}
type CtorOf<T> = T extends unknown ? (x: T) => T : never;
interface Big {
"0": { common?: string; "0"?: number, ref?: Obj<Big["0"]> | Func<Big["0"]>; }
@weswigham
weswigham / bigfactory2.ts
Last active May 22, 2019 18:44
Now with no union call resolution
interface Obj<T> {
ref: T;
}
interface Func<T> {
(x: T): void;
}
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
type CtorOf<T> = (arg: UnionToIntersection<T>) => T;
interface Big {
@weswigham
weswigham / bigfactory3.ts
Created May 22, 2019 18:57
This is roughly the minimum size required to make the TS compiler OOM - note it's not really that big.
interface Obj<T> {
ref: T;
}
interface Func<T> {
(x: T): void;
}
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
type CtorOf<T> = (arg: UnionToIntersection<T>) => T;
interface Big {
@weswigham
weswigham / apply-all-import-fixes.ts
Created June 6, 2019 00:26
Quick and dirty gist for using the compiler API to apply all available import fixes for a project
// Usage: node ./apply-all-import-fixes.js ./path/to/index.ts
import * as ts from "typescript/lib/tsserverlibrary";
import * as fs from "fs";
import * as path from "path";
class Logger implements ts.server.Logger { // tslint:disable-line no-unnecessary-qualifier
private fd = -1;
private seq = 0;
private inGroup = false;
private firstInGroup = true;