Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
ABC...always be coding :)

Tre' wayneseymour

💭
ABC...always be coding :)
View GitHub Profile
@wayneseymour
wayneseymour / get_his_branch_on_your_local.sh
Created Mar 30, 2021
Use spencer's way to debug test failures in ci
View get_his_branch_on_your_local.sh
# add his remote
git remote add spalger git@github.com:spalger/kibana.git
# 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
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) => ({
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) =>
fork(
(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
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++
i === xs.length ? id() : asyncForEach(xs, i)
}
View keybase.md

Keybase proof

I hereby claim:

  • I am wayneseymour on github.
  • I am lambda_tre (https://keybase.io/lambda_tre) on keybase.
  • I have a public key ASDr8uWRf55DgF4MA2Qa4tOOS99Dw-9Fn-BaQEBF2utc2Ao

To claim this, I am signing this object:

View list-applicative.md
View websocket-echo.js
// Start the connection to the WebSocket server at echo.websocket.org
ws = new WebSocket("ws://echo.websocket.org/");
// Register event listeners for the open, close, and message events
ws.onopen = () => {
console.log("WebSocket ready!");
console.log('yo')
@wayneseymour
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!