Skip to content

Instantly share code, notes, and snippets.

View andy0130tw's full-sized avatar
๐ŸŒ
why no ๐Ÿ†

Andy Pan andy0130tw

๐ŸŒ
why no ๐Ÿ†
View GitHub Profile
@andy0130tw
andy0130tw / agda-stdout-decoder.ts
Last active July 22, 2026 17:43
Message delimiter for Agda's interaction mode
import chp from 'child_process'
import { Readable } from 'stream'
import { inspect } from 'util'
enum DecoderState {
Initial,
// Agda used to (until 2.7.0.1) emit error when the data dir is not found before the very first prompt;
// this has now (v2.8.0) become a runtime error message to stderr;
// in v2.9.0 nightly (2026/7/22) the stacktrace is printed to stdout???
StartupMessage,
type U8Arr = Uint8Array<ArrayBuffer>
class MaybeUnzipGzipTransformer implements Transformer<U8Arr, U8Arr> {
nbytes = 0
isGzip: boolean | null = null
static expectedHeader = new Uint8Array([0x1f, 0x8b, 0x08])
sink: WritableStreamDefaultWriter<U8Arr> | undefined
transform(chunk: U8Arr, controller: TransformStreamDefaultController<U8Arr>) {
if (this.isGzip == null) {
[data-testid=ai-panels] {
display: none;
}
#menu-section-button-ai {
display: none;
}
@andy0130tw
andy0130tw / freetype-test.zig
Last active June 28, 2026 12:08
My first Zig project!
const std = @import("std");
const freetypeWrapper = @import("freetype.zig");
const freetype = freetypeWrapper.freetype;
const ftUnwrap = freetypeWrapper.ftUnwrap;
const shstw = @embedFile("shstw-hinted.ttf");
var ftlib: freetype.FT_Library = null;
var face: freetype.FT_Face = null;
๏ผ ๅคชBDF่จˆ็”ป ๏ผ
Programmed by NAGAO, Sadakazu
-- ็›ฎ ๆฌก ----------------------------------------------------------------------
1. ๆฆ‚่ฆ ... 16(่กŒ็›ฎ)
2. ไป•็ต„ ... 25
3. ไฝฟ็”จๆณ• ... 64
@andy0130tw
andy0130tw / myft.py
Created June 10, 2026 15:17
FreeType rendering some chars
import freetype
from PIL import Image
import math
def byte2bin(n):
assert 0 <= n < 256
return bin(n)[2:].rjust(8, '0')
ttf_path = 'Cubic_11.ttf'
pixel_size = 12
@andy0130tw
andy0130tw / kagi-mute-slop-results.css
Last active June 23, 2026 13:03
A minimal CSS snippet to make AI slop results appear faded
.theme_dark .search-result:has(.ai-stain-icon),
.theme_dark .search-result:has(.ai-stain-icon) + .sr-group {
--app-text: #403E3C80;
--search-result-url-link: #878580;
--result-item-title-border: #87858080;
--search-result-title: #87858080;
--search-result-content-text: #87858080;
}
.theme_dark .search-result .ai-stain-icon > svg {
@andy0130tw
andy0130tw / idbaafs.ts
Created January 20, 2026 21:26
IndexedDB as a filesystem
import { Buffer } from 'buffer'
;(globalThis as any).Buffer = Buffer
import git from 'isomorphic-git'
import http from 'isomorphic-git/http/web'
function idbRequestToPromise<T>(req: IDBRequest<T>) {
return new Promise<T>((resolve, reject) => {
req.onsuccess = evt => resolve((evt.target as IDBRequest<T>).result)
req.onerror = evt => reject((evt.target as IDBRequest<T>).error)
@andy0130tw
andy0130tw / cm6.userstyle.css
Created January 5, 2026 11:08
Night mode for CodeMirror 6 docs
html, body {
color-scheme: dark;
background: #100F0F;
color: #CECDC3;
}
nav#toc a.current-section {
color: white;
}
@andy0130tw
andy0130tw / codemirror-auto-color-scheme.ts
Last active September 18, 2025 17:09
CodeMirror theme switcher based on the current color scheme of the containing window
const SELECTOR_PREFERS_DARK_COLOR_SCHEME = '(prefers-color-scheme: dark)'
export function autoColorScheme(options: {
dark?: Extension, light?: Extension, defaultDark?: boolean} = {}): Extension {
const {
dark: darkExt = [],
light: lightExt = [],
defaultDark = false,
} = options