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
// HINT: Definitely use ts-result for this. | |
type Result<A, B> = { success: true, data: A } | { success: false, error: B }; | |
function Ok<A>(x: A): { success: true; data: A; } { | |
return { success: true, data: x }; | |
} | |
function Err<B>(e: B): { success: false; error: B; } { | |
return { success: false, error: e }; | |
} |
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
//////////////////////////////////////////////////////////////////////////////// | |
// Helpers | |
//////////////////////////////////////////////////////////////////////////////// | |
local string = { | |
typescript: 'string', | |
python: 'str', | |
psql: 'VARCHAR', | |
}; |
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
//////////////////////////////////////////////////////////////// | |
// Types | |
//////////////////////////////////////////////////////////////// | |
// # Instruction Set # Program # Registers # Memory # | |
// NOTE: Things would be way easier if we knew: | |
// - Which sector we're currently in: Program, Registers, Memory | |
// - Which direction we previously moved | |
// |
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
// Defines a function, compile, that can convert a textual | |
// representation of a state transition ruleset into a function | |
// that we can invoke to transition from one state to another. | |
// | |
// Also defines a simple function, decode, that converts a | |
// textual representation of a program into the "tape" that we | |
// feed our Turing Machine. | |
//////////////////////////////////////////////////////////////// | |
// Types |
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
// Turing Machine emulator implemented in TypeScript. | |
// For awhile I've known what a Turing Machine represented in computing, | |
// by regurgitating to someone that "it can compute anything". I could | |
// even explain how there was a tape, a read/writer, symbols, and on | |
// better days I would even name-drop "cellular automata", but if actually | |
// attempting to emulate (easy) and *program* (difficult) a Turing Machine | |
// was a totally new can of worms for me... a bit of a cold shower. | |
// | |
// NOTE: I cheated by incrementing the numbers (only god will judge me) | |
// |
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
// 5x5 image | |
const image = [ | |
[1, 2, 3, 4, 5], | |
[5, 4, 3, 2, 1], | |
[0, 2, 4, 6, 8], | |
[8, 6, 4, 2, 0], | |
[3, 4, 5, 2, 1], | |
]; | |
// seeded for horizontal edge-detection |
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
// NOT: given | |
// OR: given | |
// NOR: derived | |
// AND: derived | |
// NAND: derived | |
// XOR: derived | |
// XNOR: derived | |
function nor(x: boolean, y: boolean): boolean { | |
return !(x || y); |
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 collections import OrderedDict # this is awesome | |
class LRU(object): | |
def __init__(self, capacity: int): | |
self.capacity = capacity | |
self.xs = OrderedDict() | |
def __repr__(self): | |
return f"; ".join(f"{k}: {v[0]} ({v[1]})" for k, v in self.xs.items()) |
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
def job_shop(): | |
machines = [ | |
Machine(cmm_id="1"), | |
Machine(cmm_id="2"), | |
] | |
jobs = [ | |
Job(job_id="431", instances=3, duration_min=20), | |
Job(job_id="459", instances=1, duration_min=100), # ??? | |
Job(job_id="449", instances=10, duration_min=40), |
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 React from "react"; | |
import { useForm } from "react-hook-form"; | |
import { z } from "zod"; | |
import { zodResolver } from "@hookform/resolvers/zod"; | |
import DimensionID from "lib/quality/DimensionID"; | |
//////////////////////////////////////////////////////////////////////////////// | |
// Main | |
//////////////////////////////////////////////////////////////////////////////// |
NewerOlder