Skip to content

Instantly share code, notes, and snippets.

Phoenix.set({
openAtLogin: true,
})
Key.on('return', ['option'], () => {
createTerminal()
})
Key.on('y', ['option'], () => {
Modal.build({
const UNSAFE_CHARS_REGEXP = /[<>\/\u2028\u2029]/g
const ESCAPED_CHARS = {
'<' : '\\u003C',
'>' : '\\u003E',
'/' : '\\u002F',
'\u2028': '\\u2028',
'\u2029': '\\u2029'
}
function escapeUnsafeChars(unsafeChar) {
return ESCAPED_CHARS[unsafeChar]
class Maybe<A> {
[Generic.repr]: Generic<MaybeRepr, A>
}
interface MaybeRepr extends Repr {
type: Maybe<this[1]>
}
type test1 = Of<MaybeRepr, string> // Maybe<string>
class Result<T, E> {
[Generic.repr]: Generic<ResultRepr, T, E>
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
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) {
return <U>(obj:
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) {
// Trying to simulate do-notation in TypeScript using async/await
// Trying to convert https://codewithstyle.info/advanced-functional-programming-typescript-monads-generators/
// to use async/await. Generators work but aren't type safe because of https://github.com/Microsoft/TypeScript/issues/2983
interface MyPromise<A> {
then<B>(fn: (a: A) => Option<B>): MyPromise<B>
}
export class Option<A> implements MyPromise<A> {
@frankpf
frankpf / os.org
Last active December 21, 2017 22:41

OS notes

Virtualization

Concurrency

Concurrency and threads

Threads

A single process can contain multiple threads, all of which are executing the

@frankpf
frankpf / macros.md
Last active December 21, 2017 22:40

Lisp macros

An example from Practical Common Lisp

Some fundamental notions

Lisp has a very simple syntax:

(<function> ...)

A function in Lisp has the following form: