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 { encode } from '@toon-format/toon' | |
| import { sql } from 'drizzle-orm' | |
| import { db } from './src/db/db' // replace | |
| import { env } from './src/env' // replace | |
| /** | |
| * Run a SQL query against the current database from .env | |
| */ | |
| async function runQuery() { | |
| // Get the SQL query from the command line arguments |
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
| sudo tee /etc/sysctl.d/99-inotify.conf >/dev/null <<'EOF' | |
| fs.inotify.max_user_watches = 1048576 | |
| fs.inotify.max_user_instances = 2048 | |
| fs.inotify.max_queued_events = 32768 | |
| EOF | |
| sudo sysctl --system |
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
| pnpm dlx shadcn@latest add accordion alert-dialog alert aspect-ratio avatar badge breadcrumb button calendar card carousel checkbox collapsible command context-menu dialog drawer dropdown-menu form hover-card input-otp input label menubar navigation-menu pagination popover progress radio-group resizable scroll-area select separator sheet skeleton slider sonner switch table tabs textarea tooltip |
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 { getTableName, sql } from 'drizzle-orm' | |
| import * as schema from '../src/schema' | |
| import { db } from '../src/db' | |
| const allTableNames = Object.values(schema).map((table) => getTableName(table)) | |
| for (const table of allTableNames) { | |
| console.log(`Dropping table ${table}`) | |
| await db.run(sql.raw(`DROP TABLE ${table}`)) | |
| } |
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 { Column, sql } from 'drizzle-orm' | |
| import { SQLiteTable, SQLiteUpdateSetSource } from 'drizzle-orm/sqlite-core' | |
| export function conflictUpdateSet<TTable extends SQLiteTable>( | |
| table: TTable, | |
| columns: (keyof TTable['_']['columns'] & keyof TTable)[] | |
| ): SQLiteUpdateSetSource<TTable> { | |
| return Object.assign( | |
| {}, | |
| ...columns.map((k) => ({ |
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 puppeteer from 'puppeteer' | |
| const requestTimings = [] as { | |
| url: string | |
| startTime: number | |
| }[] | |
| async function run() { | |
| const browser = await puppeteer.launch({ | |
| headless: false |
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
| limit $3 undefined +0ms | |
| knex:bindings [ 'c609097c-9d6d-470f-b3f6-200f52e19fe4', 74277, 1 ] undefined +0ms | |
| knex:query select "id" from "favorites" where "aws_user_id" = $1 and "post_id" = $2 limit $3 undefined +3ms | |
| knex:bindings [ 'c609097c-9d6d-470f-b3f6-200f52e19fe4', 74400, 1 ] undefined +2ms | |
| knex:query select "id" from "favorites" where "aws_user_id" = $1 and "post_id" = $2 limit $3 undefined +1ms | |
| knex:bindings [ 'c609097c-9d6d-470f-b3f6-200f52e19fe4', 84433, 1 ] undefined +1ms | |
| knex:query select "id" from "favorites" where "aws_user_id" = $1 and "post_id" = $2 limit $3 undefined +0ms | |
| knex:bindings [ 'c609097c-9d6d-470f-b3f6-200f52e19fe4', 88374, 1 ] undefined +1ms | |
| knex:query select "id" from "favorites" where "aws_user_id" = $1 and "post_id" = $2 limit $3 undefined +1ms | |
| knex:bindings [ 'c609097c-9d6d-470f-b3f6-200f52e19fe4', 89165, 1 ] undefined +0ms |
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
| benchmark time (avg) (min … max) p75 p99 p995 | |
| ------------------------------------------------- ----------------------------- | |
| • select * from customer | |
| ------------------------------------------------- ----------------------------- | |
| b3 253.87 µs/iter (243.63 µs … 2.77 ms) 248.21 µs 402.05 µs 520.94 µs | |
| b3:p 242.2 µs/iter (235.88 µs … 1.18 ms) 239.09 µs 341.76 µs 379.37 µs | |
| drizzle 207.76 µs/iter (193.1 µs … 1.01 ms) 203.32 µs 378.86 µs 686.33 µs | |
| drizzle:p 172.78 µs/iter (167.05 µs … 1 ms) 170.92 µs 204.4 µs 356.89 µs | |
| knex 303.22 µs/iter (282.06 µs … 1.34 ms) 301 µs 478.92 µs 915.14 µs | |
| kysely 270.4 µs/iter (257.37 µs … 1.21 ms) 265.37 µs 426.33 µs 773.33 µs |
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 'dotenv/config' | |
| import { prismaClient } from '../src/lib/prismaClient' | |
| const setSequenceToMaxInTable = async (props: { | |
| table_name: string | |
| sequence_name: string | |
| column_name: string | |
| }) => { | |
| const setval = ` | |
| SELECT setval('"${props.sequence_name}"', COALESCE((SELECT MAX(${props.column_name})+1 FROM ${props.table_name}), 1), false); |
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 { z } from 'zod' | |
| /** | |
| * generates default object for a given zod schema, you can supply an object to override the defaults | |
| */ | |
| export const zodSchemaDefaults = <Schema extends z.ZodFirstPartySchemaTypes>( | |
| schema: Schema, | |
| override?: Partial<z.TypeOf<Schema>> | |
| ): z.TypeOf<Schema> => { | |
| if (override !== undefined && typeof override !== 'object') { |
NewerOlder