Skip to content

Instantly share code, notes, and snippets.

View ninyawee's full-sized avatar
🏠
Working from home

Ben Nutchanon Ninyawee ninyawee

🏠
Working from home
View GitHub Profile
@ninyawee
ninyawee / build-merge.py
Created November 10, 2026 02:59
JetBrains Mono Thai: merge Noto Sans Thai Looped into JetBrains Mono so Thai fits terminal cells (Herdr, any single-font terminal)
"""Add Noto Sans Thai Looped's Thai glyphs to JetBrains Mono (Nerd Font) as "JetBrains Mono Thai".
1. Subset Noto Sans Thai Looped to Thai, keeping its shaping (ccmp, locl, mark, mkmk).
2. Fit every spacing glyph into one 600-unit cell: centre it, and narrow (horizontally only)
the ones that are wider than the cell, such as ญ ฌ ณ. Marks keep zero advance.
Base and ligature anchors move with their glyph, so vowels and tone marks still land on it.
3. Merge into JetBrains Mono and rename the family.
Usage (run once per style: Regular, Bold, Italic, Bold Italic):
@ninyawee
ninyawee / mise.toml
Created December 14, 2025 09:14
zig is low level in python. trust in human. the dangling pointer.
[tools]
zig = "latest"
@ninyawee
ninyawee / clickhouse-user-agent-behavior.md
Created July 31, 2025 06:23
ClickHouse.com User-Agent Based Content Serving Explanation

ClickHouse.com User-Agent Based Content Serving

The ClickHouse website (https://clickhouse.com/) serves different content based on the User-Agent header in the HTTP request.

How it Works

For Command-Line Tools (Default curl/wget)

When accessed with command-line tools like curl or wget, the server returns a shell installation script:

@ninyawee
ninyawee / ipv6_finder.py
Created April 6, 2025 07:44
ipv6 tailscale
#!/usr/bin/env -S uv run --script
# /// script
# dependencies = [
# "ipaddress",
# ]
# ///
"""
IPv6 Finder - A utility to find IPv6 addresses for Tailscale 4via6 subnet routers.
@ninyawee
ninyawee / db dump.sh
Created March 27, 2025 14:18
db dump
pg_dump -h dev_host -U dev_user -d dev_db -- no-owner -- no-privileges -f db_dev.sql
psql -h 127.0.0.1 -U local_user local_db -f db_dev.sql
@ninyawee
ninyawee / edit_with_cursor.ps1
Last active March 9, 2025 04:58
open cursor in windows
$cursorPath = "c:\Users\lifep\AppData\Local\Programs\cursor\resources\app\bin\cursor"
$arguments = "--wait", "--reuse-window"
if ($args.Count -gt 0) {
$arguments += $args
}
Start-Process -FilePath $cursorPath -ArgumentList $arguments -WindowStyle Hidden -Wait
@ninyawee
ninyawee / console.ipynb
Created February 6, 2025 16:23
jupyter sql init
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ninyawee
ninyawee / clone schema.sql
Last active February 6, 2025 15:45
pg clone schema
CREATE OR REPLACE FUNCTION clone_schema(source_schema text, dest_schema text)
RETURNS void AS $$
DECLARE
object text;
buffer text;
default_ text;
column_ text;
BEGIN
EXECUTE 'CREATE SCHEMA ' || dest_schema;
@ninyawee
ninyawee / ai_db_context
Last active December 6, 2024 09:05
Generate the DB schema for the AI Contexts
#!/usr/bin/env bash
# mise description="Generate the DB schema for the AI Contexts"
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
mkdir -p ./AIContexts/
docker run --rm -v "$PWD/AIContexts:/data" postgres:15 \
pg_dump $POSTGRES_URL -s -O -x -n public -t public.* -f /data/db_schema.sql
#!/usr/bin/env bash
# mise description="Generate the DB schema for the AI Contexts"
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
mkdir -p ./AIContexts/
docker run --rm -v "$PWD/AIContexts:/data" postgres:15 \
pg_dump $POSTGRES_URL -s -O -x -n public -t public.* -f /data/db_schema.sql