Skip to content

Instantly share code, notes, and snippets.

View jethrolarson's full-sized avatar
:shipit:

Jethro Larson jethrolarson

:shipit:
  • Tableau
  • Seattle
View GitHub Profile
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
/* Source: https://github.com/Microsoft/TypeScript/pull/21316#issuecomment-364982638 */
type DiscriminateUnion<Union, TagKey extends keyof Union, TagValue extends Union[TagKey]> =
Union extends Record<TagKey, TagValue> ? Union : never
type MatchingFunc<A extends { kind: string }, K extends A['kind'], U> = (a: Omit<DiscriminateUnion<A, 'kind', K>, 'kind'>) => U
function match<A extends { kind: string }>(discriminant: A) {
@gabejohnson
gabejohnson / fl-interfaces.js
Last active June 13, 2017 12:48
[WIP] Fantasy Land Interfaces
import { class, interface, implements } from 'sweet-interfaces';
const constant = x => _ => x;
const identity = x => x;
const flip = f => (a, b) -> f(b, c);
interface Setoid {
// eq :: Setoid a => a ~> a -> Boolean
eq(b) { return this === b; }
}
@jethrolarson
jethrolarson / reactiveLibraries.md
Last active March 26, 2022 01:14
Reactive Stream Library Comparison

Flyd

https://github.com/paldepind/flyd
License: MIT
Size: 22.4 KB (3.4 KB gzip)
Functions: 16
Project Life: Good
Stars: 1129
Code Quality: Good Functional/Procedural
Comments: JSDoc
Quality Automation: Extensive unit tests, CI

@DavidWells
DavidWells / aligning-images.md
Last active November 14, 2024 03:45
Guide to aligning images in github readme.md files. https://davidwells.io/snippets/how-to-align-images-in-markdown

Aligning images

This is a guide for aligning images.

See the full Advanced Markdown doc for more tips and tricks

left alignment

@natefaubion
natefaubion / thread-result.js
Last active January 5, 2017 23:58
Sweet.js threading macro
arg |> foo[0].bar(42)
|> baz("hello", "there")
|> quux.foo().bar()
|> new Foo()
// Expands to:
// new Foo(quux.foo().bar(baz('hello', 'there', foo[0].bar(42, arg))));
arg |> foo() |> bar
// SyntaxError: [|>] Expected function call
// 31: arg |> foo() |> bar
@int3
int3 / gist:4027626
Created November 6, 2012 21:17
Chained comparisons using sweet.js
macro $if {
case ($x ...) => { if (relCar($x ...)) }
}
macro $while {
case ($x ...) => { while (relCar($x ...)) }
}
// naive form:
/*
@jethrolarson
jethrolarson / _grid.scss
Last active September 27, 2015 07:37
Super simple compass grid system for modern browsers (IE8+)
/*
F'n Sweet Grid system
Reduced fluid version of http://960.gs with fixed-width gutters
No support for < IE8
Basic usage:
In some stylesheet:
@include grid();
In your html:
<div class="container">
<div class="grid_4">4</div>
@jocafa
jocafa / gist:967083
Created May 11, 2011 19:06
A Cakefile
sys = require 'sys'
fs = require 'fs'
util = require 'util'
childProc = require 'child_process'
coffee = require 'coffee-script'
stylus = require 'stylus'
uglify = require 'uglify-js'
_ = require 'underscore'
_.mixin(require('underscore.string'))