Skip to content

Instantly share code, notes, and snippets.

View justinvdm's full-sized avatar

Justin van der Merwe justinvdm

View GitHub Profile
const assert = require('assert');
const flow = fns => v0 => {
const n = fns.length;
let i = -1;
let v = v0;
while (++i < n) v = fns[i](v);
return v;
};
const assert = require('assert');
function Foo(val) {
this.val = val;
}
const acceptInstanceOf = (cls, acceptFn, rejectFn) => {
return v => v instanceof cls
? acceptFn(v)
: rejectFn(v);
const assert = require('assert');
const partialLodash = require('lodash.partial');
var protoSlice = Array.prototype.slice;
function partialApply(fn, v) {
return function() {
var args = protoSlice.call(arguments);
args.unshift(v);
return fn.apply(null, args);
@justinvdm
justinvdm / +flow-cont-monad.js
Last active January 2, 2018 07:10
Cont monad in javascript with flowtype
// @flow
type Cont<R, A> = (A => R) => R;
const ret = <R, A>(a: A): Cont<R, A> =>
k => k(a);
const bind = <R, A, B>(cont: Cont<R, A>, fn: A => Cont<R, B>): Cont<R, B> =>
k => cont(a => fn(a)(k));
// @flow
type Nothing = {|
type: 'nothing'
|};
type Just<A> = {|
type: 'just',
value: A
|};
// @flow
type ContFn<A, B> = <C>(A, B => C) => C;
const sqr = <R>(v: number, ret: number => R): R => ret(v * v);
const dbl = <R>(v: number, ret: number => R): R => ret(v * 2);
const pipe = <A, B, C>(fn1: ContFn<A, B>, fn2: ContFn<B, C>): ContFn<A, C> =>
<D>(v: A, ret: C => D): D => fn1(v, (res: B) => fn2(res, ret));
// @flow
type PipeObjMap<B,C> = <A>(A => B) => (A => C);
const pipeFn = <A,B,C>(fn1: A => B, fn2: B => C): (A => C) => (v: A) => fn2(fn1(v));
const pipeObj = <Fns: {},B,C>(fns: Fns, fn2: B => C): $ObjMap<Fns, PipeObjMap<B,C>> => {
const res = {};
for (const k in fns) {
// @flow
type Msg<Type, V> = {|
type: Type,
val: V
|};
type AcceptFn =
& (<A, B, OV>('val', Msg<'val', A> => B) =>
(Msg<'val', A> | Msg<'err', OV>) => (B | Msg<'err', OV>))
@justinvdm
justinvdm / mknote
Last active December 10, 2017 07:07
#!/bin/sh
genFilename() {
cat /dev/random | LC_CTYPE=C tr -dc "[:alpha:]" | head -c 8
}
slugify() {
echo "$@" | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z
}
diff --git a/src/config/base.js b/src/config/base.js
index df9f1e9..a82f926 100644
--- a/src/config/base.js
+++ b/src/config/base.js
@@ -1,5 +1,5 @@
export default {
- API_PATH: '/mentor',
+ API_PATH: '/mentor/v2',
API_BASE_URL: null,
SENTRY_URL: null,