This file contains hidden or 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 Fastify, { FastifyInstance, FastifyPluginAsync } from 'fastify' | |
import { Pool } from 'pg' | |
interface User { | |
id: string | |
email: string | |
} | |
interface UserStore { | |
findBySession(sessionId: string): Promise<User | null> |
This file contains hidden or 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
type Thing = { | |
id: string; | |
category: string; | |
name: string; | |
}; | |
const cache: Record<string, any> = {}; | |
function createGetSet< | |
F extends (...args: any[]) => Promise<any>, |
This file contains hidden or 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
#! /bin/bash | |
# This script builds or watches all dependencies of a project. | |
# | |
# Example: build all depdencies | |
# ./build-dependencies.sh my-app build | |
show_help_and_exit() { | |
echo "Incorrect or missing arguments" | |
echo "Usage: $0 <project> <build|watch>" |
This file contains hidden or 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 crypto from "crypto"; | |
const SALT_LENGTH = 8; | |
function encrypt(password: string, text: string) { | |
const iv = crypto.randomBytes(16); | |
const key = Buffer.concat([Buffer.from(password)], 16); | |
const cipher = crypto.createCipheriv("aes128", key, iv); | |
const salt = crypto.randomBytes(SALT_LENGTH); | |
const enc = Buffer.concat([cipher.update(salt), cipher.update(text), cipher.final()]); |
This file contains hidden or 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
// Run: | |
// bun run zsh_history_to_fish_history.ts > ~/.local/share/fish/fish_history | |
const zshData = await Bun.file(".zsh_history").text(); | |
const lines = zshData.split("\n"); | |
let cmdBuffer = ""; | |
let when = 0; | |
function flush() { | |
if (cmdBuffer.trim()) { |