Skip to content

Instantly share code, notes, and snippets.

@hansoksendahl
hansoksendahl / ski.ts
Last active October 20, 2022 18:09
SKI Combinators Typescript
type S = <A, B, C>(abc: (a: A) => (b: B) => C) => (ab: (a: A) => B) => (a: A) => C
type K = <A>(a: A) => <B>(b: B) => A
/** λx.λy.λz.xz(yz) */
const s: S = a => b => c => a(c)(b(c))
/** λx.λy.x */
const k: K = a => b => a
/** λx.x */
const i = s(k)(k)
@hansoksendahl
hansoksendahl / provider.tsx
Last active April 8, 2020 23:13
URQL BoilerPlate
import { useMemo, ReactNode } from 'react';
import { createClient, Client, Provider, ClientOptions } from 'urql';
type AnyFunction<T = any> = (..._: any[]) => T;
interface SharedProps {
children?: ReactNode;
}
type URQLURLProps = SharedProps & ClientOptions;
/* eslint no-dupe-class-members: 0, lines-between-class-members: 0, class-methods-use-this: 0, require-jsdoc: 0 */
/**
* A signal accessor is a type safe getter and setter which corresponds to an interface.
* It can safely get and set nested properties up to an arbitrary depth of eight properties.
*
* @author Hans Oksendahl
*/
class SignalAccessor<T extends object> {
/**
@hansoksendahl
hansoksendahl / no_job_sad_times.js
Created March 25, 2020 23:40
Wall Street Bets Unemployment Estimate
const data = {
"CA": {
"comment": '1 million',
"source": "https://twitter.com/lilyjamali/status/1242902096745132032?s=21",
"value": 1e6
},
"NY": {
"comment": "NY ~ 1.7 million",
"source": "https://www.nbcnewyork.com/news/local/1-7m-calls-in-a-week-ny-labor-dept-swamped-with-newly-unemployed/2340481/",
"value": 1.7e6
Copyright 2019 Hans Oksendahl
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OT