Skip to content

Instantly share code, notes, and snippets.

import ctypes
import struct
import sys
from ctypes import wintypes
def cpuid(leaf: int, subleaf: int = 0) -> tuple[int, int, int, int]:
# Define VirtualAlloc and VirtualFree
kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
@chen3feng
chen3feng / struct_to_map.go
Created August 28, 2025 02:58
Struct to map in Go
import (
"reflect"
"strings"
"gopkg.in/yaml.v3"
)
// StructToMap converts a struct to a map[string]any recursively.
func StructToMap(s any, tagKey string) map[string]any {
out := make(map[string]any)
@chen3feng
chen3feng / fix_fullwidth_punct.py
Created April 25, 2026 17:18
Replace full-width (CJK) punctuation with ASCII in Markdown, skipping code blocks and inline code.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Replace full-width (CJK) punctuation with ASCII equivalents in Markdown.
Intended for English Markdown documents that accidentally contain stray
full-width punctuation copy-pasted from a Chinese source, without
disturbing code blocks or inline code spans.
Features
--------
@chen3feng
chen3feng / README.md
Last active May 13, 2026 00:58
Merge a Tencent Working merge request via REST API (Python, stdlib only, dry-run by default)

merge_mr.py

A tiny, dependency-free Python script to merge a Tencent Working (腾讯工蜂) merge request from the command line, since the web UI's "Merge" button has no first-class CLI counterpart.

Why