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
function fish_prompt | |
test $SSH_TTY; and printf (set_color red)(whoami)(set_color white)'@'(set_color yellow)(hostname)' ' | |
test $USER = 'root'; and echo (set_color red)"#" | |
# Main | |
echo -n (set_color cyan)(prompt_pwd)(set_color purple)(__fish_vcs_prompt) (set_color red)'β―'(set_color yellow)'β―'(set_color green)'β― ' | |
end |
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 ts from "typescript"; | |
// Haven't dealt with arrays and records | |
type AvscType = "string" | "int" | "null"; | |
type TsTypes = | |
| ts.SyntaxKind.StringKeyword | |
| ts.SyntaxKind.NumberKeyword | |
| ts.SyntaxKind.NullKeyword; | |
interface AvscField { |
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 t from "io-ts"; | |
import * as R from "fp-ts/lib/Record"; | |
type AvroStringSchema = "string"; | |
type AvroNullSchema = "null"; | |
type AvroFieldSchema = { name: string; type: AvroSchema }; | |
type AvroRecordSchema = { | |
type: "record"; | |
namespace: string; | |
name: string; |
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 Count<A, S extends 0[] = []> = A extends S["length"] | |
? S | |
: Count<A, [...S, 0]>; | |
type IncC<A> = [...Count<A>, 0]; | |
type DecC<A> = Count<A> extends [infer _H, ...(infer R)] ? R : []; | |
// Basic Arithmetic | |
type Inc<A> = IncC<A>["length"]; | |
type Dec<A> = DecC<A>["length"]; |
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
curl https://raw.githubusercontent.com/brunoklein99/deep-learning-notes/master/shakespeare.txt | say |
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
// From https://react-redux.js.org/api/hooks#using-memoizing-selectors | |
import { createSelector } from 'reselect' | |
// A Selector is just a fn from State to T | |
type Selector<T> = (state: State) => T; | |
const selectCompletedTodosCount = createSelector( // This utility does nothing you can't do easily without it | |
(state) => state.todos, | |
(_, completed) => completed, // Why would we do this? This is just a roundabout way of parameterizing a fn. |
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
// Monads for functional programming in TypeScript | |
// Here's a basic evaluator | |
type Term = | |
| { tag: 'Con', n: number } | |
| { tag: 'Div', arg1: Term, arg2: Term } | |
const con = (n: number): Term => ({ tag: 'Con', n }); | |
const div = (arg1: Term, arg2: Term): Term => ({ tag: 'Div', arg1, arg2 }); |
OlderNewer