Skip to content

Instantly share code, notes, and snippets.

View ktilcu's full-sized avatar

kyle tilman ktilcu

View GitHub Profile
@ktilcu
ktilcu / path.ts
Last active April 15, 2020 00:20
// doesn't work K1 evaluates to never. I assume it's because `obj` isn't immediately available
// export function path<S extends object, K1 extends keyof S, K2 extends keyof S[K1], K3 extends keyof S[K1][K2]>(
// p: [K1, K2, K3]
// ): (obj: S) => S[K1][K2][K3];
// doesn't work can't index that far
// export function path<S extends object>(p: [keyof S, keyof S[keyof S], keyof S[keyof S[keyof S]]): (obj: S) => S[keyof S][keyof S[keyof S]];
export function path<S extends object>(p: [keyof S, keyof S[keyof S]]): (obj: S) => S[keyof S][keyof S[keyof S]];
export function path<S extends object>(p: [keyof S]): (obj: S) => S[keyof S];
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="BFS"> </head>
<body>
<script>
</script>
<script id="jsbin-javascript">
// noprotect
'use strict';
@ktilcu
ktilcu / index.html
Created April 23, 2019 17:13
JS Bin CycleJS - Campaign Screenshots // source https://jsbin.com/hodusu
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="CycleJS - Campaign Screenshots">
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/4.0.6/rx.all.js"></script>
<script src="https://rawgit.com/cyclejs/cycle-core/v6.0.0-rc2/dist/cycle.js"></script>
<script src="https://rawgit.com/cyclejs/cycle-dom/v8.0.0-rc9/dist/cycle-dom.js"></script>
<script src="https://rawgit.com/cyclejs/cycle-http-driver/v7.0.0-rc2/dist/cycle-http-driver.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.0.0/jszip.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.22.1/ramda.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Iteration Samples - Ramda, Lodash, chaining, transducers">
<script src="https://cdn.jsdelivr.net/g/lodash@4(lodash.min.js+lodash.fp.min.js)"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.js"></script>
<script src="https://cdn.rawgit.com/zloirock/core-js/master/client/shim.min.js"></script>
<script src="https://wzrd.in/standalone/tape@latest"></script>
<script src="https://wzrd.in/standalone/tap-browser-color@latest"></script>
<script src="https://wzrd.in/standalone/tape-catch@latest"></script>
@ktilcu
ktilcu / index.html
Created April 23, 2019 17:07
Promise Retries // source https://jsbin.com/gorumid
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Promise Retries">
<script src="http://cdn.jsdelivr.net/bluebird/3.5.0/bluebird.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.22.1/ramda.min.js"></script>
</head>
<body>

Keybase proof

I hereby claim:

  • I am ktilcu on github.
  • I am tilman (https://keybase.io/tilman) on keybase.
  • I have a public key ASDxy9pamoukTrV6pZnqG_wuWE3ww09DO8i4pplu54HF4Qo

To claim this, I am signing this object:

@ktilcu
ktilcu / trapping_water.js
Last active March 28, 2019 13:49
Water Trapping - Dynamic Programming
// Given n non-negative integers representing an elevation map where the width
// of each bar is 1, compute how much water it is able to trap after raining.
const test = require('tape');
const trapped = bars => {
let index = 0;
let left_wall = 0;
let right_wall = 0;
const last = bars.length - 1;
let area = 0;
@ktilcu
ktilcu / connect-four.js
Last active March 26, 2019 13:49
Implement a connect 4 win detector
const board = [[t, f, t, f], [f, f, f, f], [f, f, f, f], [f, t, f, f]];
/*
0 1 2 3 4 5 6 7 8
0 O O O O O O O O B B = Winning col
1 X O O O A O O O B
2 O X O O O A O O B
3 O O X O O O A O B
4 O O O X O O O A O X and A = Winning DownRight Diagonals
5 O O O O O O O O A
@ktilcu
ktilcu / omg.js
Last active March 22, 2019 21:03
connect-four.js
"use strict";
const board = [
[t,f,t,f],
[f,f,f,f],
[f,f,f,f],
[f,t,f,f],
]
/*