Skip to content

Instantly share code, notes, and snippets.

View scturtle's full-sized avatar
🐢

scturtle

🐢
View GitHub Profile
@scturtle
scturtle / build.sh
Last active May 13, 2026 01:41
build minimal emacs
# ubuntu/debian
# sudo apt install autoconf texinfo gnutls-bin -y
# homebrew
brew install texinfo tree-sitter
# build
#!/bin/bash
export CFLAGS="-O2 -DNDEBUG -g0 -fno-omit-frame-pointer"
./configure --prefix $HOME/.local \
#!/usr/bin/env fish
function check_var -a var msg
if test -z $var; echo $msg >&2; exit 1; end
end
function check_status -a msg
if test $status != 0; echo $msg >&2; exit 1; end
end
@scturtle
scturtle / hack.js
Created April 17, 2026 07:24
change background color of gnome shell main panel based on label of input method
(async () => {
const Main = await import('resource:///org/gnome/shell/ui/main.js');
const { default: GLib } = await import('gi://GLib');
const ind = Main.panel.statusArea.keyboard;
const mgr = ind?._inputSourceManager;
if (!mgr) return;
const update = () => {
const text = ind._indicatorLabels[mgr.currentSource?.index]?.get_text();
@scturtle
scturtle / kgp.c
Created April 1, 2026 03:44
kitty graphics protocol
/* gcc -O2 -march=native -o kgp kgp.c -lm */
#define _POSIX_C_SOURCE 200809L
#include <math.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
@scturtle
scturtle / qwen35.py
Last active March 6, 2026 10:12
qwen 3.5
# pip install torch huggingface_hub safetensors tokenizers transformers
import sys, re, time
from pathlib import Path
from collections import defaultdict
import torch
import torch.nn as nn
import torch.nn.functional as F
from tokenizers import Tokenizer
from safetensors import safe_open
@scturtle
scturtle / kkp.c
Created February 27, 2026 01:55
kitty keyboard protocol demo
#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
struct termios orig_termios;
void reset_terminal() {
@scturtle
scturtle / proxy.py
Last active February 6, 2026 03:46
use opera's built-in VPN as proxy
#!/usr/bin/env python3
import asyncio
from vpn import get_proxy
proxy = port = auth = None
pool = asyncio.Queue(5)
psize = 0
async def process_client(client_reader, client_writer, *, CHUNK=4096):
global psize
@scturtle
scturtle / mkf.py
Last active December 25, 2025 09:25
pal
from struct import pack, unpack_from
class MKFDecoder(object):
def __init__(self, path=None):
assert path or data
with open(path, "rb") as f:
self._content = memoryview(f.read())
self.count = unpack_from("<I", self._content, 0)[0] // 4
self.indexes = tuple(
#!/usr/bin/env python3
import re
from pathlib import Path
from typing import List
MARK = "// -----// IR Dump"
PAT = re.compile(r'IR Dump \w+ (?:.*::)?(\w+)')
def main(infile: Path, outdir: Path):
assert infile.exists(), f'{infile} not exists'
@scturtle
scturtle / qwen3.py
Last active September 1, 2025 18:58
qwen3
import os
from functools import lru_cache
import torch
from torch import nn
import torch.nn.functional as F
from transformers import Qwen3Config
from transformers import Qwen2TokenizerFast