View react-fp.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
const something = {} | |
assert.strictEqual(shallowEqual({ a: O.none }, { a: O.none }), true) | |
assert.strictEqual(shallowEqual({ a: O.some(1)}, { a: O.some(1) }), true) | |
assert.strictEqual(shallowEqual({ a: O.some(something)}, { a: O.some(something) }), true) | |
assert.strictEqual(shallowEqual({ a: O.some(something)}, { a: O.none }), false) | |
assert.strictEqual(shallowEqual({ a: E.left(something)}, { a: E.left(something) }), true) | |
assert.strictEqual(shallowEqual({ a: E.right(something)}, { a: E.left(something) }), false) |
View basic.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type MyA = {} | |
type SomeF<A, B> = (a: A) => [A, B] | |
type MyF = SomeF<MyA, boolean> | |
declare const f1: MyF | |
declare const f2: MyF | |
declare const f3: MyF | |
function imperative() { |
View .eslintrc.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
"env": { | |
"browser": true | |
}, | |
"parser": "@typescript-eslint/parser", | |
"parserOptions": { | |
"project": "tsconfig.json", | |
"sourceType": "module" | |
}, | |
"plugins": [ |
View fetch.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as TE from "fp-ts/lib/TaskEither" | |
import { pipe } from "fp-ts/lib/pipeable" | |
import { Do } from "fp-ts-contrib/lib/Do" | |
type Error1 = { errors: object[]; type: "1" } | |
type Error2 = { errors: object[]; response: Response; type: "2" } | |
type Error3 = { errors: object[]; result: unknown; type: "3" } | |
type Errors = Error1 | Error2 | Error3 | |
export const post = (url: string, body: object) => |
View validation.sample.1.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Input = { | |
trainTripId: string | |
pax?: Pax | |
startDate?: Date | |
travelClass?: string | |
} | |
const validateStateProposition = ({ | |
pax, | |
startDate, |
View todos.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 3. Presentation/Root | |
const start = () => { | |
const getCompletedTodosRequestHandler = async (ctx) => { | |
const result = await getCompletedTodosResolved(ctx.params.id) | |
ctx.body = JSON.stringify(result) | |
} | |
const completeTodoRequestHandler = async (ctx) => { | |
await completeTodoResolved(ctx.params.id) | |
ctx.status = 204 |
View twoSum.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.annotation.tailrec | |
object ShittySolution { | |
// Given an array of integers, return indices of the two numbers such that they add up to a specific target. | |
// | |
// You may assume that each input would have exactly one solution, and you may not use the same element twice. | |
// https://leetcode.com/problems/two-sum/ | |
// NB: More efficient solution would iterate once over the array and keep a Map of values and indicies | |
def twoSum(nums: Array[Int], target: Int): Array[Int] = { |
View 1.useMatchFetch.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect } from "react"; | |
export const render = result => match => | |
result.pending ? match.pending() | |
: result.error ? match.error(result.error) | |
: result.data ? match.data(result.data) | |
: null // prettier-ignore | |
export const useMatchFetch = url => { | |
const [result, setResult] = useState({ pending: true, initial: true }); |
View controller-presenter-interactor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "controller" | |
(ctx, next) => { | |
let presenter = new Presenter(ctx) | |
let interactor = new Interactor(presenter) | |
interactor.handle(getRequestFrom(ctx)) | |
} | |
class Presenter { | |
constructor(ctx) { this.ctx = ctx } | |
present(response) { |
View docker-compose.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
command=`basename "$0"` | |
run-windows-command "$command" "$@" |
NewerOlder