Skip to content

Instantly share code, notes, and snippets.

View tlareg's full-sized avatar
😃

tlareg

😃
View GitHub Profile
@tlareg
tlareg / streams.ts
Created December 23, 2022 22:38
streams
type Stream<T> =
| {
value: T;
getNext: () => Stream<T>;
}
| undefined;
type CreateStreamArgs<T> = {
value: T;
next: (x: T) => T;
@tlareg
tlareg / cloudSettings
Last active January 25, 2019 14:06
Visual Studio Code Settings Sync Gist, vscode
{"lastUpload":"2018-10-11T12:22:00.116Z","extensionVersion":"v3.1.2"}
@tlareg
tlareg / loop_y_combinator.js
Last active February 19, 2018 14:45
loop js lambda calculus y combinator
const loop = (cb, counter, maxCounter) =>
((x, i, max) => x(x, i, max))
(
(x, i, max) => (
cb(i),
(i++ < max) && x(x, i, max)
),
counter,
maxCounter
)
@tlareg
tlareg / dynamic-load-script.js
Created August 2, 2017 17:09
load js script dynamically
function loadJS(src) {
let scriptEl = document.createElement('script')
scriptEl.type = 'application/javascript'
scriptEl.src = src
const scriptLoadedPromise = new Promise((resolve, reject) => {
scriptEl.onload = () => resolve()
})
document.body.appendChild(scriptEl)
return scriptLoadedPromise
}
@tlareg
tlareg / child-window-2.html
Created January 23, 2017 23:26
parent-child-window-communication
<!doctype html>
<html>
<head>
</head>
<body>
<div>
<h1>CHILD WINDOW 2</h1>
</div>
<div>
<button class="back-btn">back</button>
@tlareg
tlareg / js-snippets.json
Last active December 6, 2016 10:34
VSC js snippets
{
"console log": {
"prefix": "cl",
"body": [
"console.log($1)"
],
"description": ""
},
"lambda": {
@tlareg
tlareg / functor-monad-applicative.js
Last active March 3, 2024 09:43
functor monad applicative
// http://hackage.haskell.org/package/base-4.9.1.0/docs/src/GHC.Base.html
// (f, g, h) => x => h(f(g(x)))
const compose =
(...fns) =>
initial =>
fns.reduceRight(
(result, fn) => fn(result),
initial
)
<body class="t-light">
<article class="c-modal c-modal--wide js-modal is-open">
<div class="c-modal__content">
<div class="s-cms-content">
...
</div>
@tlareg
tlareg / npm_scripts
Last active November 17, 2017 14:27
npm_scripts
# create package.json
npm init
# can define scripts in package.json
# pre and post runs before and after script
"scripts": {
"pretest": "echo 'running pretest'",
"test": "echo 'no test specified'",
"posttest": "echo 'running posttest'",
"start": "echo 'running start script'",