Skip to content

Instantly share code, notes, and snippets.

View cometkim's full-sized avatar
stealth mode

Hyeseong Kim cometkim

stealth mode
View GitHub Profile
@cometkim
cometkim / parametric.py
Created July 13, 2026 17:08
FastAPI parametric `Body()` model dependency injection
"""Parametric FastAPI dependencies: write a generic dependency once, specialize per model class.
A dependency that binds the request body wants a *different Pydantic model per router*
while sharing one implementation — but FastAPI fixes a ``Body()`` parameter's model at
function-definition time. Hand-rolling a closure factory per dependency needs memoization
(so specializations stay usable as ``dependency_overrides`` keys), default handling, and a
runtime ``__annotations__`` patch: ~20 lines of machinery each time.
``parametric`` packages that machinery as a decorator. Declare the dependency once as a
PEP 695 generic function whose single type parameter carries a class bound::
@cometkim
cometkim / SKILL.md
Last active April 24, 2026 01:02
Python FastAPI dependency-injection convention as a agent skill

name: dependency-injection description: FastAPI pattern for app-scoped dependency injection via ResourceProvider[T] classes. Each provider owns one resource's construction and teardown as a single @asynccontextmanager, declares dependencies on other providers via constructor arguments, and is exposed as a fastapi.Depends callable; providers are composed into the app with compose_providers(*providers), which accepts None entries so conditional wiring inlines at the call site as provider if cond else None. "Resource" is load-bearing - this is only for things that live for the lifetime of the app. Per-request values (authenticated user, request-id, per-request DB transaction) use plain async def + Depends; ResourceProvider is not a universal DI container. Trigger whenever you add, refactor, or wire any app-scoped resource in a FastAPI project; HTTP clients, DB pools, service clients, Kafka producers/consumers, schedulers, caches, feature-flag clients, or any singleton that previously

@cometkim
cometkim / comparison.md
Last active April 22, 2026 09:30
Token count change due to Claude's tokenizer update

Token counting: claude-opus-4-6 vs claude-opus-4-7

Generated: 2026-04-16 15:39:30 UTC

Both columns come from the real /v1/messages/count_tokens endpoint.

Summary by category

Category claude-opus-4-6 claude-opus-4-7 Ratio
@cometkim
cometkim / claude_legacy.tiktoken
Created March 27, 2026 10:49
Claude's legacy tokenizer vocab in tiktoken format.
This file has been truncated, but you can view the full file.
IQ== 5
Ig== 6
Iw== 7
JA== 8
JQ== 9
Jg== 10
Jw== 11
KA== 12
KQ== 13
@cometkim
cometkim / ANALYSIS_OPUS.md
Created March 10, 2026 08:12
AppsFlyer SDK compromised 2026-03-10

Analysis: Cryptocurrency Address Hijacker (Man-in-the-Browser Clipper)

This is a supply-chain cryptocurrency stealing payload — a "clipper" or "address swapper" that silently redirects crypto transactions to attacker-controlled wallets.

Core Architecture

The payload has four layers:

1. String Obfuscation Engine The bulk of the code is a multi-layered string decoding system (oFmFNH, iVp0dU7, byZJpo, fLOUxWf, etc.) using base91-like encoding with shuffled alphabets. Every meaningful string is encoded to evade static analysis.

@cometkim
cometkim / worker.js
Created June 24, 2025 16:47
Cloudflare Containers' bundle dumped
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
// node_modules/unenv/dist/runtime/_internal/utils.mjs
// @__NO_SIDE_EFFECTS__
function createNotImplementedError(name) {
return new Error(`[unenv] ${name} is not implemented yet!`);
}
__name(createNotImplementedError, "createNotImplementedError");
// @__NO_SIDE_EFFECTS__
@cometkim
cometkim / README.md
Last active May 6, 2025 00:17
Illustrate how early-returning syntax (let-else) in Rust eliminates nested pattern matching

Maybe you can flat using dot-free style function calls too.

However, it unnecessarly add runtime overhead, pollute the callstack, and even not intuitive as direct-style control flows are.

@cometkim
cometkim / v11-Evaluator.res.mjs
Created April 30, 2025 11:24
ReScript v11 to v12 compile output diff
// Generated by ReScript, PLEASE EDIT WITH CARE
import * as Objects from "./Objects.res.mjs";
import * as Caml_obj from "rescript/lib/es6/caml_obj.js";
import * as Caml_int32 from "rescript/lib/es6/caml_int32.js";
import * as Environment from "./Environment.res.mjs";
var cTRUE = {
TAG: "MBoolean",
_0: {
@cometkim
cometkim / opt-out-telemetry.md
Last active May 5, 2025 08:16
Curated list to opt-out telemetry collection from tools and frameworks
# Cargo binstall
# https://github.com/cargo-bins/cargo-binstall?tab=readme-ov-file#telemetry-collection
export BINSTALL_DISABLE_TELEMETRY=true

# Go Telemetry (not opt-in by default)
# https://go.dev/doc/telemetry
export GOTELEMETRY=off

# GatsbyJS
@cometkim
cometkim / varint.js
Created February 24, 2025 17:31
Variable Integer (LEB128) encoding with BigInt
export function encode(value) {
const long = BigInt(value);
const result = [];
let shift = 0n;
while (true) {
const number = Number(BigInt.asUintN(7, long >> shift));
if (number) {
result.push(number);
shift += 7n;