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
#SingleInstance Force | |
; Debugging | |
; https://www.autohotkey.com/scite4ahk/pages/debugger.htm | |
; Map Capslock to control (macOS is Capslock as Command, so most keybindings feel similar) | |
CapsLock::RControl | |
; Left Ctrl Tab -> Left Alt Tab | |
<^Tab::>!Tab |
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
/** Memory-volatile multi-key cache with a root weak key */ | |
export class WeakCache { | |
private wm = new WeakMap<object, Map<string | number, unknown>>(); | |
/** It's very important to not call this with the same keys and expect a different result. */ | |
getOrPut<R>(weakKey: object, keys: CacheKeys, fn: () => R): R { | |
let found = this.wm.get(weakKey); | |
const innerKey = typeof keys === "object" ? JSON.stringify(keys) : keys; | |
if (!found) { | |
const computed = fn(); | |
found = new Map([[innerKey, computed]]); |
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
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |
type $IntentionalAny = any; | |
/** | |
* This special type can help generate pattern matchers for you! | |
* Just use it as so: | |
* // enum-ts | |
* type Result<Ok, Err> = Enum<{ | |
* Ok: Ok, | |
* Err: Err, |
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 { createTRPCProxyClient, httpLink } from "@trpc/client"; | |
import { AnyRouter, initTRPC, MaybePromise, Router } from "@trpc/server"; | |
import { fetchRequestHandler } from "@trpc/server/adapters/fetch"; | |
import type { ParserWithInputOutput, ParserWithoutInput } from "@trpc/server/dist/core/parser"; | |
import type { AnyRouterDef } from "@trpc/server/dist/core/router"; | |
import type { ResponseMetaFn } from "@trpc/server/dist/http/internals/types"; | |
import { getParseFn } from "./getParseFn"; | |
export type TrpcDurableObjectRouter<Router extends AnyRouter> = { | |
router: Router, |
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
# -*- coding: utf-8 -*- | |
# | |
# Slack file downloader from export archive | |
# | |
# Requirements: | |
# Python 2 (or Python3 if you can use six) | |
# | |
# How to use: | |
# 1. Log in as admin, export your chat logs, and download archive. | |
# 2. Unarchive archive to directory (ex. TeamName export Apr 24 2016) |
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
// Place your key bindings in this file to override the defaultsauto[] | |
[ | |
{ | |
"key": "ctrl+right", | |
"command": "-cursorWordEndRight", | |
"when": "textInputFocus" | |
}, | |
{ | |
"key": "ctrl+shift+right", | |
"command": "-cursorWordEndRightSelect", |
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
#!/usr/bin/env bash | |
set -euxo pipefail | |
database_url="${1}" | |
dump_path="${2:-schema}" | |
schemas=("app_public" "app_hidden" "app_private" "public") | |
find "$dump_path" -name '*.sql' -delete |
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
JSON.stringify( | |
mappedSchema, | |
(_key, val) => { | |
if (val != null && typeof val === "object") { | |
return Object.fromEntries( | |
Object.keys(val) | |
.sort() | |
.map((key) => [key, val[key]]), | |
); | |
} else { |
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 z from "zod"; | |
export const zo = z.object.bind(z); | |
export const zu = z.union.bind(z); | |
export interface Znum< | |
T extends Record<string, any>, | |
TT = { | |
[P in keyof T]: Record<P, T[P]>; | |
}[keyof T] |
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
export class OpenPromise<T> implements PromiseLike<T> { | |
private inner: Promise<T> | |
private resolved?: [T] | |
public resolve = (item: T) => { | |
this.resolved = [item] | |
} | |
private rejected?: [any] | |
public reject = (error: any) => { | |
this.rejected = [error] | |
} |