Skip to content

Instantly share code, notes, and snippets.

@agurtovoy
agurtovoy / findDOMNode.ts
Created January 11, 2025 18:37
Using `react-reconciler` to reimplement `findDOMNode`
import { Component } from 'react'
//@ts-ignore
import { findCurrentHostFiber } from 'react-reconciler/reflection'
// https://github.com/facebook/react/blob/main/packages/shared/ReactInstanceMap.js#L18
export function getInstance(key: any) {
return key._reactInternals
}
// https://github.com/facebook/react/blob/main/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js#L167
@darkterminal
darkterminal / .env-example
Last active January 27, 2025 09:35
libSQL Daemon
# Database Path
SQLD_DB_PATH=data.sqld
# HTTP Listener Address
SQLD_HTTP_LISTEN_ADDR=127.0.0.1:8080
# Hrana Listener Address
SQLD_HRANA_LISTEN_ADDR=
# Admin HTTP API Address
@marcosrjjunior
marcosrjjunior / kysely + turso + migrations (sqlite)
Last active March 5, 2025 15:33
Kysely + Turso + Migrations
{
"scripts": {
// ...
"db:migrate:up": "bun run -r dotenv/config ./src/lib/db/migrate latest",
"db:migrate:down": "bun run -r dotenv/config ./src/lib/db/migrate down",
"db:migrate:create": "bun run -r dotenv/config ./src/lib/db/migrate create initial",
"db:generate:types": "bunx kysely-codegen --out-file=src/lib/db/schema/Database.ts",
},
"dependencies": {
"kysely": "^0.27.3",
@mathcodes
mathcodes / index.html
Created June 12, 2021 06:43
Three.js - Voxel Geometry - UI
<canvas id="c"></canvas>
<div id="ui">
<div class="tiles">
<input type="radio" name="voxel" id="voxel1" value="1"><label for="voxel1" style="background-position: -0% -0%"></label>
<input type="radio" name="voxel" id="voxel2" value="2"><label for="voxel2" style="background-position: -100% -0%"></label>
<input type="radio" name="voxel" id="voxel3" value="3"><label for="voxel3" style="background-position: -200% -0%"></label>
<input type="radio" name="voxel" id="voxel4" value="4"><label for="voxel4" style="background-position: -300% -0%"></label>
<input type="radio" name="voxel" id="voxel5" value="5"><label for="voxel5" style="background-position: -400% -0%"></label>
<input type="radio" name="voxel" id="voxel6" value="6"><label for="voxel6" style="background-position: -500% -0%"></label>
<input type="radio" name="voxel" id="voxel7" value="7"><label for="voxel7" style="background-position: -600% -0%"></label>
@reconbot
reconbot / batchFetchExchange.ts
Last active May 23, 2024 05:07
A batching exchange for URQL that lets you opt out of batch queries adapted form @jakubriedl's POC This version works on non persisted queries.
// Adapted from https://gist.github.com/jakubriedl/812c2a7b26927a2249a4719555d9a0ca
import DataLoader from 'dataloader'
import { Exchange, Operation } from 'urql'
import { pipe, map } from 'wonka'
interface BatchRequest {
url: RequestInfo | string
options?: RequestInit
}
@threepointone
threepointone / durable-objects-001-fundamentals.md
Last active January 29, 2025 13:22
Notes on Durable Objects. Part 1 - Migrations.

Note: Since writing this, I've been pointed to some exciting new research/tooling called Project Cambria https://www.inkandswitch.com/cambria.html I'll likely have to rewrite this article taking that into account. Leaving this up for posterity's sake.


(This series isn't meant to be a primer/tutorial, though we might do something regarding it in the future. For official documentation and starters, see https://developers.cloudflare.com/workers/learning/using-durable-objects.

Further - these are my personal views; I expect to be wrong about a lot of them. Indeed, I'm not paying much attention to presenting these well at the moment, simply writing down thoughts. As such, expect these writeups to change often, particularly as the platform takes shape. I'm also mostly a front end guy, so don't get mad if I get it very wrong. Give me feedback! Always happy to learn and make changes.)

Durable Objects are a fascinating new storage primitive from cloudflare for their workers platform. There's a lot of 'cool'

const HandlerRunner = require("serverless-offline/dist/lambda/handler-runner/index").default;
class OfflineInvalidate {
constructor(serverless, options) {
this.serverless = serverless;
this.hooks = {
"before:offline:start:init": (opts) => this.inject()
};
this.lastRunner = {};
}
@notakaos
notakaos / create_function_plv8_cuid.sql
Last active August 16, 2024 10:10
cuid for PostgreSQL with PL/v8
-- original code: https://github.com/ericelliott/cuid
-- Add the "plv8" extension
create extension if not exists "plv8";
-- Add the "pgcrypto" extension
create extension if not exists "pgcrypto";
\dx
-- Connect a database
@fnky
fnky / stripe-keys-and-ids.tsv
Last active June 26, 2025 15:05
Stripe keys and IDs
Prefix Description Notes
ac_ Platform Client ID Identifier for an auth code/client id.
acct_ Account ID Identifier for an Account object.
aliacc_ Alipay Account ID Identifier for an Alipay account.
ba_ Bank Account ID Identifier for a Bank Account object.
btok_ Bank Token ID Identifier for a Bank Token object.
card_ Card ID Identifier for a Card object.
cbtxn_ Customer Balance Transaction ID Identifier for a Customer Balance Transaction object.
ch_ Charge ID Identifier for a Charge object.
cn_ Credit Note ID Identifier for a Credit Note object.
# https://hakibenita.com/fast-load-data-python-postgresql
from typing import Iterator, Dict, Any, Optional
from urllib.parse import urlencode
import datetime
#------------------------ Profile
import time