Skip to content

Instantly share code, notes, and snippets.

View cometkim's full-sized avatar
🛌
sleeping

Hyeseong Kim cometkim

🛌
sleeping
View GitHub Profile
@cometkim
cometkim / redacted.ts
Created August 12, 2026 07:50
Redacted value class should be a primitive for all codebase
const registry = new WeakMap<Redacted<any>, any>();
/**
* Redacted<T> is a basic primitive for handling credentials.
* This prevents to leak your secrets to any output by implicit behaviors like `toString()`.
*
* @example
*
* ```ts
* const password = Redacted.make('secret');
@cometkim
cometkim / enum.ts
Created August 12, 2026 07:46
Enum primitive for Zod codebases
import * as z from 'zod';
type ReservedFields = 'Schema' | 'KeyAsInputSchema' | 'meta' | '$Key' | '$Type';
type EnumDefinition<K extends string, V extends string | number> = {
readonly [key in K]: {
value: V;
description?: string;
};
} & {
@cometkim
cometkim / opencode.jsonc
Created August 10, 2026 07:38
Use Slack's official MCP in OpenCode
{
"mcp": {
"slack": {
"type": "remote",
"url": "https://mcp.slack.com/mcp",
"oauth": {
// Slack's officially support MCP for Claude Code, but there is nothing specific.
// Just use their pre-registred client ID and redirect URL and OpenCode will automatically handle its port.
"clientId": "1601185624273.8899143856786",
"redirectUri": "http://localhost:3118/callback"
@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
Kg== 14
@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.