Skip to content

Instantly share code, notes, and snippets.

View agalatan's full-sized avatar

Alin Galatan agalatan

View GitHub Profile
@yelouafi
yelouafi / algebraic-effects-series-1.md
Last active September 15, 2024 16:59
Operational Introduction to Algebraic Effects and Continuations

Algebraic Effects in JavaScript part 1 - continuations and control transfer

This is the first post of a series about Algebraic Effects and Handlers.

There are 2 ways to approach this topic:

  • Denotational: explain Algebraic Effects in terms of their meaning in mathematics/Category theory
  • Operational: explain the mechanic of Algebraic Effects by showing how they operate under a chosen runtime environment

Both approaches are valuables and give different insights on the topic. However, not everyone (including me), has the prerequisites to grasp the concepts of Category theory and Abstract Algebra. On the other hand, the operational approach is accessible to a much wider audience of programmers even if it doesn't provide the full picture.

@miyaokamarina
miyaokamarina / conditions.js
Last active March 9, 2023 15:31
Type-level conditions in Flow https://is.gd/OPsJBd
// Licensed under CC BY 4.0.
type $If<X: boolean, Then, Else = empty> = $Call<
& ((true, Then, Else) => Then)
& ((false, Then, Else) => Else),
X,
Then,
Else,
>;
function * just (...values) {
yield * values;
};
function first (iterable) {
const iterator = iterable[Symbol.iterator]();
const { done, value } = iterator.next();
if (!done) return value;
};
@stefanocudini
stefanocudini / forever_daemon.sh
Last active September 21, 2019 01:11
Nodejs Forever Demonizer with a low privilege user
#!/bin/bash
#
# Copyright 2013 stefano.cudini@gmail.com
# http://labs.easyblog.it
#
# Nodejs Forever Demonizer with a low privilege user
# official code: https://gist.github.com/stefanocudini/6116527
# tested on Debian Squeeze
#
# inspired by: