Skip to content

Instantly share code, notes, and snippets.

@tonyonodi
tonyonodi / prettify-generic.ts
Created February 14, 2023 15:26
Prettify generic
// from this tweet https://twitter.com/mattpocockuk/status/1622730173446557697
type Prettify<T> = {
[K in keyof T]: T[K]
} & {};
<?xml version="1.0" encoding="UTF-8"?>
<gesmes:Envelope xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01" xmlns="http://www.ecb.int/vocabulary/2002-08-01/eurofxref">
<gesmes:subject>Reference rates</gesmes:subject>
<gesmes:Sender>
<gesmes:name>European Central Bank</gesmes:name>
</gesmes:Sender>
<Cube>
<Cube time='2023-05-25'>
<Cube currency='USD' rate='1.0735'/>
import fs from "fs";
import express from "express";
import { WebSocketServer } from "ws";
import { NodeWSServerAdapter } from "@automerge/automerge-repo-network-websocket";
import { NodeFSStorageAdapter } from "@automerge/automerge-repo-storage-nodefs";
import os from "os";
import type { DocumentId, PeerId } from "@automerge/automerge-repo";
import {
isValidAutomergeUrl,
isValidDocumentId,
import fs from "fs";
import express from "express";
import { WebSocketServer } from "ws";
import { NodeWSServerAdapter } from "@automerge/automerge-repo-network-websocket";
import { NodeFSStorageAdapter } from "@automerge/automerge-repo-storage-nodefs";
import os from "os";
import type { DocumentId, Message, PeerId } from "@automerge/automerge-repo";
import {
isValidAutomergeUrl,
isValidDocumentId,
import { sql, type TransactionSQL } from "bun";
const [, , ...flags] = Bun.argv;
import { readdir } from "node:fs/promises";
const MIGRATIONS_DIR = "./migrations";
const makeMigration = (name: string) => {
const timestamp = new Date().toISOString().split(".")[0].replace(/\D/g, "");
const migrationName = `${timestamp}_${name}`;
const migrationPath = `${MIGRATIONS_DIR}/${migrationName}.ts`;
// Drop this into your console then call it with an input selector, a string, and a delay to have it automatically type for
// you. For demo videos and such.
async function fakeType(text, selectorString = '.cm-content', delay = 50) {
const element = document.querySelector(selectorString);
if (!element) {
console.error(`fakeType Error: Element with selector "${selectorString}" not found.`);
return Promise.reject(new Error(`Element with selector "${selectorString}" not found.`));
}