Skip to content

Instantly share code, notes, and snippets.

View nitsanavni's full-sized avatar
🤔
Learning

Nitsan Avni nitsanavni

🤔
Learning
  • Málaga, Spain
  • 04:22 (UTC +02:00)
View GitHub Profile
@miguelmota
miguelmota / faketime_install.sh
Created June 22, 2018 23:12
macOS faketime brew install
brew install libfaketime --build-from-source
# usage
faketime -f "@2020-01-01 00:00:00" node app.js
@pelotom
pelotom / existential.ts
Last active May 18, 2022 10:08
Encoding of existential types in TypeScript
type StackOps<S, A> = {
init(): S
push(s: S, x: A): void
pop(s: S): A
size(s: S): number
}
type Stack<A> = <R>(go: <S>(ops: StackOps<S, A>) => R) => R
const arrayStack = <A>(): Stack<A> =>
const λ = ({raw}, ...subs) => {
const expr = raw
.reduce((prev, next, n) => prev + `(___subs[${n - 1}])` + next)
.replace(/#(\d+)/g, (_, n) => `(___args[${n}])`)
const evaluate = new Function('___subs', '___args', `return (${expr});`)
return (...args) => evaluate(subs, args)
}
@jordan-brough
jordan-brough / git-recent
Last active June 27, 2024 21:22
Git: Display a list of recently checked out branches/tags/commits
#!/usr/bin/env bash
# Source: https://gist.github.com/jordan-brough/48e2803c0ffa6dc2e0bd
# See also: https://stackoverflow.com/a/25095062/58876
# Download this script as "git-recent" (no extension), chmod it to be executable and put it in your
# path somewhere (e.g. /usr/bin). You can then use it via `git recent` from inside any git repo.
# Examples: