Skip to content

Instantly share code, notes, and snippets.

View DanielFGray's full-sized avatar

Daniel Gray DanielFGray

View GitHub Profile
@DanielFGray
DanielFGray / effect-kysely.ts
Created November 6, 2026 15:04
effect-kysely
/**
* Kysely + Effect integration.
*
* Effect v4 removed the `@effect/sql-kysely` package, so this is a port of it.
* The technique is unchanged: Kysely runs with a dummy driver and its query
* builders are given the Effect protocol, so `db.selectFrom(...)` is itself an
* `Effect` that compiles the builder and runs the SQL through the active
* `SqlClient`. A `Proxy` supplies the per-query execution effect, which is why
* plugin tracking and `withTransaction` survive the builder chain.
*/
@DanielFGray
DanielFGray / test.ts
Created September 8, 2026 15:23
kysely-pg-points-and-paths
import { PGlite } from "@electric-sql/pglite";
import { Kysely, DummyDriver, PostgresAdapter, PostgresIntrospector, PostgresQueryCompiler, sql } from "kysely";
import { jsonArrayFrom } from "kysely/helpers/postgres";
interface Database {
event: { id: number; name: string; slug: string; description: string | null; startDate: Date | null; endDate: Date | null };
track: { id: number; eventId: number; name: string; slug: string; color: string | null; startingPoint: string; endPoint: string; path: string };
checkpoint: { id: number; trackId: number; name: string; abbreviation: string | null; point: string };
}
@DanielFGray
DanielFGray / scrape-my-messages
Created August 29, 2026 18:26
scrape-my-messages
#!/usr/bin/env bun
/**
* Walks Claude Code, opencode, codex, and copilot session storage and
* extracts every message the user actually typed (not tool output, not
* system-injected instructions/reminders).
*
* Incremental: a state file tracks how far each source has been read
* (byte offset + mtime for jsonl logs, last-seen timestamp for sqlite
* sources), so a rerun only fetches what's new since last time. Results
* accumulate in a cache file; the public output is always fully
@DanielFGray
DanielFGray / index.html
Created November 13, 2023 21:04
Map to values array, array spread vs array.from (http://jsbench.github.io/#0717707c579f990df95d04e8b276eae6) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Map to values array, array spread vs array.from </title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@DanielFGray
DanielFGray / index.html
Last active October 6, 2023 20:14
object lookup vs map lookup (http://jsbench.github.io/#12b6afb8665e3887c8e1c7dde244fd41) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>object lookup vs map lookup</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
begin;
-- user accounts
create extension if not exists citext;
create table users (
user_id int primary key generated always as identity,
username citext unique not null,
created_at timestamptz not null default now()
);
@DanielFGray
DanielFGray / rc.lua
Created April 22, 2023 01:55
current awesomewm config
-- {{{ libraries
local gears = require('gears')
local awful = require('awful')
awful.autofocus = require('awful.autofocus')
-- Widget and layout library
local wibox = require('wibox')
-- Theme handling library
local beautiful = require('beautiful')
-- Notification library
local naughty = require('naughty')
@DanielFGray
DanielFGray / init.lua
Last active June 28, 2025 17:02
current init.lua
-- Set <space> as the leader key
-- See `:help mapleader`
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
vim.g.mapleader = " "
vim.g.maplocalleader = " "
vim.g.loaded_netrwPlugin = 1
vim.opt.autoread = true
vim.opt.backspace = "indent,eol,start" -- backspace over everything
vim.opt.colorcolumn = { 80 } -- highlight 80th column
@DanielFGray
DanielFGray / .md
Created April 23, 2022 19:35
postgres with extensions
FROM postgres:14
RUN apt-get update && apt-get upgrade -y
ENV build_deps ca-certificates \
    git \
    build-essential \
    libpq-dev \
    postgresql-server-dev-14
RUN apt-get install -y --no-install-recommends $build_deps
@DanielFGray
DanielFGray / alarm.sh
Last active March 6, 2020 23:26
alarm
#!/usr/bin/env bash
declare loud=0
declare urgent
declare old_volume
declare old_volume
cleanup() {
set_volume "$old_volume"