Skip to content

Instantly share code, notes, and snippets.

View buzzdecafe's full-sized avatar
💭
quaquaquaqua

buzzdecafe

💭
quaquaquaqua
View GitHub Profile
const NIL = Symbol('~~NIL~~');
const isNil = x => typeof x === 'symbol' && x.toString() === NIL.toString();
const pair = (a, b) => ({
fst: function* () { yield a; },
snd: function* () { yield b; },
[Symbol.iterator]: function* () { yield a; (b[Symbol.iterator] ? yield* b : yield b); }
});
@buzzdecafe
buzzdecafe / loop-recur.js
Created November 4, 2022 19:29
Scott's loop/recur impl
const Loop = (fn, ... init) => {
let r = fn (... init)
while (r instanceof Recur) r = fn (... r)
return r
}
const Recur = ( ...v) => Object .create (
Recur .prototype,
{[Symbol .iterator]: {value: _ => v .values ()}}
)
@buzzdecafe
buzzdecafe / recurly.sh
Last active December 15, 2022 15:26
cURL recurly API
# recurly does not document using cURL to access their API, they really want you to use their libraries.
# Sometimes i need to test something quick. I do not want to write a script importing your stupid library.
# So here's how you do it:
APIKEY=<get your API key from your recurly.com site>
curl -H "Accept: application/vnd.recurly.v2021-02-25+json" -u $APIKEY: https://v3.recurly.com/accounts