Skip to content

Instantly share code, notes, and snippets.

@brecert
brecert / mini-parser.js
Last active January 25, 2023 22:40
mini-parser.js
const TOKENS =
/(?<name>[\w_-]+)|(?:"(?<string>.+?)")|(?<whitespace>\s+)|(?<symbol>.)/g;
type Token = {
name?: string;
string?: string;
whitespace?: string;
symbol?: string;
};
// deno-lint-ignore-file no-unused-vars prefer-const no-cond-assign no-empty
import {
assert,
assertEquals,
assertExists,
assertInstanceOf,
equal,
} from "https://deno.land/[email protected]/testing/asserts.ts";
type LiteralT =
@brecert
brecert / part1.ts
Created December 8, 2022 16:14
day 08
const file = Deno.readTextFileSync('days/06/input.txt')
const map = file.split('\n').map(line => line.split('').map(char => parseInt(char)))
const cols = map[0].length
const rows = map.length
const visible = new Set<string>()
// top to bottom
for (let x = 0; x < cols; x++) {
let prev = -1
// Utils
type Fn<T = void> = () => T
type None = typeof None
const None = Symbol()
const $batched: Set<Fn> = new Set()
// The behavior for batches will be different from wires
// unsure why but it feels right
@brecert
brecert / examples
Last active November 7, 2022 15:59
chat markup
# Basic Formatting
**bold**
*italic* (friendly)
//italic//
__underline__
~~strikethrough~~
https://flems.io/#0=N4IgtglgJlA2CmIBcBmATAOgBwHYA0IAzvAgMYAu8UyIGphhIBAZhAo0gNqgB2AhmERJaAC3JhYTEKQD2PSvJoB6JQCp1AIwBO8eOtUqAOjwB6AAgCS5PrAiljZs+YBCM2FAeOnl67dJmAdz5CMxsdPigATzNmGQBXHig8M0IAawgABwyIHgBzTy9Ck2MpYjJyCDkOEABWJAAGEABfPF4BIVoAK0YCWXl4RWFm1pB+QRo6Bik+hXIaMQkzYE8NPlJU3K14xKQzAGIUQ4BuT1j5AFpmATZI3bA5GUIMtfgTnkdZWBktXYCRCEob2Mai8q3Wm22UF2th48D4WnOmwiEAG5AAFABOepQeC5ZIHFAAFhqZhq9QApPiAGxUnBoUkUgCUeAKZhhcIRSKgKPkaOxuOphKpDMp+ypNWFZPJjKOZgMKzWGy2CShbJyHMRWmRqMx-Lx+xqEpF1NpIplCvBysS50IEAAXvBdjUMDVSCIzABGFDwAAebyaxmMGhkUSWnjA8NyOV29TejmeMByuRjcbMnj+APgNuepEdZgyOlTZ3INvteddIlTCHIlARTzWSZTxiapRI8AolR41RwSEJHuaAF0mkA
# Basic Formatting
**bold**
*italic* (friendly)
//italic//
__underline__
~~strikethrough~~
@brecert
brecert / routes.swift
Last active September 12, 2022 14:03
struct TweetRoute: Route {
@EnviromentObject var db: Database
@Path var user: User
@Path var tweet: Tweet
var pattern: Pattern {
.GET
"user"
User.ID
"status"
const COLLIDABLE = document.getElementsByClassName('collidable')
const Direction = {
None: 0,
Left: -1,
Right: 1
}
const State = {
Walking: 0,
{
"openapi": "3.0.0",
"info": {
"title": "Revolt API",
"description": "Open source user-first chat platform.",
"termsOfService": "https://revolt.chat/terms",
"contact": {
"name": "Revolt Support",
"url": "https://revolt.chat",
"email": "[email protected]"