Skip to content

Instantly share code, notes, and snippets.

ABC...always be coding :)

Tre' wayneseymour

ABC...always be coding :)
View GitHub Profile
wayneseymour /
Created Mar 30, 2021
Use spencer's way to debug test failures in ci
# add his remote
git remote add spalger
# verbosely fetch his remote branch info
git fetch spalger -v
# bring down the branch he was working on, to your local
git branch --track pr/95667 spalger/pr/95667
# checkout that branch
git checkout pr/95667
wayneseymour / task-monad.js
Last active Mar 12, 2021
Task monad with some examples at the bottom
View task-monad.js
import { pipe } from './utils';
export const Task = (fork) => ({
map: (f) => Task((rej, res) => fork(rej, pipe(f, res))),
chain: (f) => Task((rej, res) => fork(rej, (x) => f(x).fork(rej, res))),
fold: (f, g) =>
Task((rej, res) =>
(x) => f(x).fork(rej, res),
View strategy.hs
data Parser = WebParser | DbParser
class ParseStrategy p where
parse :: p -> String -> String
instance ParseStrategy Parser where
parse WebParser s = "code for parsing web stuff goes here"
parse DbParser s = "code for parsing db stuff goes here"
fromDB = parse DbParser
View recurse-list.js
import { ToolingLog } from '@kbn/dev-utils';
import { SuperTest } from 'supertest';
// @ts-ignore
import * as Either from '../../../../src/dev/code_coverage/ingest_coverage/either';
const id = (x: any = null) => x;
const recurseEither = (max: number) => (x: number) =>
max > x ? Either.right(x) : Either.left(x);
wayneseymour / async_foreach.js
Created Feb 4, 2021
Asynchronous for reach using recursion.
View async_foreach.js
const id = x => x;
const asyncForEach = async (xs, i) => {
const res = await Promise.resolve(xs[i])
console.log(`\n### const res: \n\t${res}`);
i === xs.length ? id() : asyncForEach(xs, i)

Keybase proof

I hereby claim:

  • I am wayneseymour on github.
  • I am lambda_tre ( on keybase.
  • I have a public key ASDr8uWRf55DgF4MA2Qa4tOOS99Dw-9Fn-BaQEBF2utc2Ao

To claim this, I am signing this object:

View websocket-echo.js
// Start the connection to the WebSocket server at
ws = new WebSocket("ws://");
// Register event listeners for the open, close, and message events
ws.onopen = () => {
console.log("WebSocket ready!");
wayneseymour / filter-id.js
Created Sep 24, 2020
Filter over an identity fn, as a predicate.
View filter-id.js
id = x => x
results = [1,'',null].filter(id)
console.log(JSON.stringify(results, null, 2))
// => [ 1 ]
View simple.Task.js
// Finally wrapped your head around Promises? Time to toss out all that knowledge and learn the functional alternative!
// Here's a super simple implementation of a Task "type"
const __Task = fork => ({fork})
// Absurdly simple! All we're doing is using a function that returns some unknown value, by name, in an object.
// At this point "fork" is just a cute name though: what matters is how we use it.
// What makes Task a "Task" is that is that the "fork" value here... will be a higher-order function.
// Here's a usage example, already fully functional, already nearly as powerful as Promise!