Skip to content

Instantly share code, notes, and snippets.

Avatar
🎙️
twitch.tv/gillchristian

Christian Gill gillchristian

🎙️
twitch.tv/gillchristian
View GitHub Profile
View logic-operators.js
const isCancelledDirectly =
cancellationReason === CANCELLATION_REASON.UNAWARE_OF_SUBSCRIPTION || CANCELLATION_REASON.MISS_DPG_TITLES;
// ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// a b c
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// d
// a === b => boolean (d)
//
// d || c => boolean | c
View keybase.md

Keybase proof

I hereby claim:

  • I am gillchristian on github.
  • I am gillchristian (https://keybase.io/gillchristian) on keybase.
  • I have a public key whose fingerprint is 965C AF06 AB76 AABA CABA CAC5 EA14 A615 39F6 7B49

To claim this, I am signing this object:

View validation.ts
/**
* We could use `Either<string, T>` as a validaiton result. But the problem is,
* we wouldn't be able to accumulate the errors. The `Validation` types enables
* that for us.
*
* ```ts
* type Validation<E, T> = Either<NonEmptyArray<E>, T>
* ```
*
* @example
View test.md
View fp-ts-workshop.ts
import * as Option from "fp-ts/Option";
import * as Either from "fp-ts/Either";
import * as ArrayFP from "fp-ts/Array";
import * as TaskEither from "fp-ts/TaskEither";
import { Ord, contramap } from "fp-ts/Ord";
import { Ord as ordString, Semigroup as semigroupString } from "fp-ts/string";
import { sequenceS } from "fp-ts/Apply";
import { flow, pipe } from "fp-ts/function";
// Functor
View flatten-object.js
const isPrimitive = (x) => {
const t = typeof x;
return (
t === 'string' ||
t === 'number' ||
t === 'boolean' ||
t === 'undefined' ||
t === null
);
View numeric-keyword-words.js
const fs = require("fs");
const letterToNumber = {
a: 2,
b: 2,
c: 2,
d: 3,
e: 3,
f: 3,
g: 4,
View factorial-complexity.js
let x = 0;
const f = (n) => {
if (n === 0) {
x += 1;
console.log("********");
return;
}
View merge-sort.js
const mergeSort = (arr) => {
if (arr.length < 2) return arr;
const mid = Math.floor(arr.length / 2);
const l = arr.slice(0, mid);
const r = arr.slice(mid);
return mergeSorted(mergeSort(l), mergeSort(r));
};