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 { | |
date as dateRaw, | |
int8 as int8Raw, | |
numeric as numericRaw, | |
} from '@ff00ff/mammoth'; | |
const int8 = () => int8Raw<BigInt>(); | |
const numeric = () => numericRaw<Big>(); | |
const date = () => dateRaw<DateString>(); |
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
"use strict"; | |
function sleep() { return new Promise(resolve => setTimeout(resolve, 1)); } | |
class Query { | |
constructor(f) { | |
this.f = f; | |
} | |
then(onFulfilled, onRejected) { | |
this.f() |
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
name="blah" | |
# Create the private key (EC P-256; not RSA). | |
openssl ecparam -name prime256v1 -genkey -noout -out "$name.key.pem" | |
# Create the CSR (to give to the CA) | |
openssl req -new -config csr.conf \ | |
-key "$name.key.pem" \ | |
-out "$name.csr" -outform PEM |
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 {defineTable, defineDb, text} from '@ff00ff/mammoth'; | |
const foo = defineTable({ | |
id: text(), | |
}); | |
const db = defineDb({foo}, async (query, parameters) => { | |
// To force an async gap. | |
await new Promise(setImmediate); |
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
// Node used to lose track of stack frames across async gaps. But due to improvements | |
// in V8, Node 14.x will now preserve stack frames for `async` functions. | |
// | |
// Unfortunately, this doesn't work for raw promises and most libraries on NPM either | |
// use raw promises or are transpiled down to raw promises. | |
// | |
// To counter this, you can use this wrapper whenever you're calling into a library | |
// that returns a raw promise: | |
// - OLD: const result = await someLibrary.query(...); | |
// - NEW: const result = await stackTraceFixer.wrap(someLibrary.query(...)); |
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
// Pretend this is the non-async library code we're calling in to. | |
function gap() { | |
return new Promise(resolve => setTimeout(resolve, 1)); | |
} | |
function f4() { | |
return new Promise((resolve, reject) => { | |
gap().then(() => reject(new Error('from f4'))); | |
}); | |
} |
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 multiprocessing | |
import argparse | |
import random | |
import time | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-p', '--parallelism', type=parse_int_range(1, 100), default=1, | |
help='the number of files to process in parallel (hint: the number of CPUs you want to use)') | |
parser.add_argument('paths', metavar='path', nargs='+', help='files to process') |
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
{ | |
"global": { | |
"check_for_updates_on_startup": true, | |
"show_in_menu_bar": true, | |
"show_profile_name_in_menu_bar": false | |
}, | |
"profiles": [ | |
{ | |
"complex_modifications": { | |
"parameters": { |
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
setopt histignoredups | |
setopt ignore_eof # Don't quit shell on Ctrl-D | |
# Tell Terminal.app whenever folder changes. | |
# This allows Terminal.app to open new tabs in the same folder as the current tab. | |
if [[ $TERM_PROGRAM == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]] { | |
function chpwd { | |
local SEARCH=' ' | |
local REPLACE='%20' |
NewerOlder