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 net from 'node:net' | |
import { spawn } from 'bun' | |
const ready = Promise.withResolvers<number>() | |
const server = spawn({ | |
cmd: ['bun', 'server.ts'], | |
stdio: ['inherit', 'inherit', 'inherit'], | |
serialization: 'json', | |
ipc: port => ready.resolve(port), |
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 os | |
import sys | |
import json | |
from time import sleep | |
# if we open the fd before bun has written to it | |
# we'll get a "bad fd" error :\ | |
sleep(1) | |
fd = 3 |
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 fs from 'node:fs' | |
import { log } from './log.js' | |
const fds = fs.readdirSync('/dev/fd').join(' ') | |
console.log('child.fds', fds) | |
process.send('test IPC') | |
log('node', 3) |
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 path from 'node:path' | |
import Bun from 'bun' | |
import { z } from 'zod' | |
function soft(to: string, from: string) { | |
return new URL(import.meta.resolve(to, from)).pathname | |
} | |
function hard(to: string, from: string) { | |
return Bun.resolveSync(to, path.dirname(from)) |
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 invariant from 'tiny-invariant' | |
import type { PgColumn, PgSelect } from 'drizzle-orm/pg-core' | |
import type { SQL } from 'drizzle-orm' | |
import { desc, gt, lt, eq, and, or } from 'drizzle-orm' | |
// using `asc` or `desc` outside this function obscures the | |
// original column name, so they must be applied internally | |
type Order = 'desc' | 'asc' | |
type OrderColumn = PgColumn | [PgColumn, Order] | |
type Options = { |
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
const express = require('express') | |
const { text } = require('node:stream/consumers') | |
const { Writable } = require('node:stream') | |
const { Miniflare, Log } = require('miniflare') | |
const app = express() | |
const mf = new Miniflare({ | |
script: `addEventListener("fetch", (event) => { | |
event.respondWith(new Response("Hello Miniflare!")); |
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 os | |
import json | |
from typing import Any | |
SKIP_OPERATIONS = ["OPTIMIZE", "VACUUM START", "VACUUM END"] | |
def is_subset(a: dict[str, Any], b: dict[str, Any]): | |
sub = a.items() | |
full = b.items() |
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 { | |
SQLiteTableWithColumns, | |
SQLiteTextBuilderInitial, | |
SQLiteTextJsonBuilderInitial, | |
SQLiteIntegerBuilderInitial, | |
SQLiteColumnBuilderBase, | |
} from 'drizzle-orm/sqlite-core' | |
import type { BuildColumns, HasDefault, NotNull } from 'drizzle-orm' |
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 { get, patch, wrapImports } from './rewire' | |
const push = get('logSuggestionsAndReturn2') | |
const move = patch('_moveDataStatements', function (tableName, json) { | |
// set dataLoss=false to generate copy statements | |
return move.call(this, tableName, json, false) | |
}) | |
wrapImports('init_migrate', { |
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
from typing import Dict, List | |
from bytewax import operators as op | |
from bytewax.dataflow import Dataflow, Stream | |
from bytewax.connectors.kafka import operators as kop | |
from bytewax.connectors.kafka.serde import SchemaDeserializer | |
class KeyDeserializer(SchemaDeserializer[bytes, str]): | |
def de(self, data): | |
return data.decode() |
NewerOlder