Skip to content

Instantly share code, notes, and snippets.

View bczhc's full-sized avatar
🌴

Zhai Can bczhc

🌴
View GitHub Profile
@bczhc
bczhc / 0001-render-make-transformations-in-geometry-space.patch
Last active March 25, 2026 08:53
用于修复grim在hyprland下某些缩放值下截图模糊问题的patch
From 2d9d26b81bb1b3eec9c33b52bc9a2a8c7dd6fb8b Mon Sep 17 00:00:00 2001
From: Loukas Agorgianitis <loukas@agorgianitis.com>
Date: Mon, 13 Jan 2025 21:43:56 +0200
Subject: [PATCH] render: make transformations in geometry space
Previously, the rendering process made transformations in logical
geometry space. When using fractional scaling, this process scaled
the transformations to the logical geometry space and back using the
fractional scale, which led to floating point rounding errors. This,
produced non pixel perfect / slightly blurry images.
@bczhc
bczhc / a.rs
Created March 15, 2026 04:57
读PNG textual info,用于替代exiftool -Comment -s3。 #image #png
#![feature(file_buffered)]
use clap::Parser;
use serde::Serialize;
use std::fs::File;
use std::path::{Path, PathBuf};
#[derive(Parser)]
struct Args {
path: PathBuf,
@bczhc
bczhc / a.rs
Created March 14, 2026 04:23
拉取126邮箱的垃圾邮件和广告邮件
use imap::{Connection, Session};
use std::fs::{self, File};
use std::io::Write;
use std::net::TcpStream;
const JUNK_FOLDER_NAME: &str = "&V4NXPpCuTvY-";
const ADS_FOLDER_NAME: &str = "&Xn9USpCuTvY-";
const SAVE_DIR: &str = "pulled";
fn download_emails(session: &mut Session<Connection>, folder: &str) -> anyhow::Result<()> {
@bczhc
bczhc / a.md
Last active March 10, 2026 03:07
QQ获取共同群 #qq

使用onebot API。可以使用 https://github.com/LLOneBot/LuckyLilliaBot 方便导出。

qq-group-member-list输出为jsonl,每一行的类型定义为:

export interface Welcome {
    group_id:   number;
    group_data: GroupData;
    result:     Result;
}
@bczhc
bczhc / a.c
Created March 6, 2026 12:52
从除零错误中断中恢复
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <ucontext.h>
void handle_fpe(int sig, siginfo_t *info, void *ucontext) {
printf("Caught SIGFPE! Attempting to skip the broken instruction...\n");
// 强制转换为 ucontext_t 结构体指针
@bczhc
bczhc / a.md
Created March 6, 2026 12:52
内联x86汇编

Hello world

C

// demo.c
void _start() {
    // 1. 调用 write(1, "Hello\n", 6)
    const char *msg = "Hello\n";
    long syscall_nr = 1; // write 的系统调用号
@bczhc
bczhc / a.ipynb
Last active February 26, 2026 06:36
Palworld proton wayland模式下一些UI指针灵敏度不正确问题观察
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bczhc
bczhc / a.ipynb
Last active February 25, 2026 09:12
Palworld dxvk与vkd3d性能比较
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bczhc
bczhc / a.md
Last active February 24, 2026 11:20
Xwayland (Hyprland)和X11 (i3wm no compositor) 游戏性能双盲试验

先设置sudo ydotool免密执行。

首先使用另一个设备连接上电脑的ssh。在电脑的tty下运行./start-random-display,后面等待的十秒内,走离电脑屏幕。待十秒后随机桌面启动后,在ssh连接的终端中运行./manage-game start,自动启动Steam并进入游戏(一分钟多一点)。然后可以回到电脑旁。

完成之后,在ssh终端中使用./manage-game exit退出,再./close-display退出桌面,准备进行下一轮。

@bczhc
bczhc / ft8-send
Last active February 21, 2026 08:56
ft8模拟器 测试铅酸电池性能用
#!/usr/bin/env ruby
# --- 配置区 ---
SAMPLE_RATE = 44100
FREQUENCY = 800.0
DURATION = 15
# 你的 USB 设备关键字(用于 grep 匹配)
DEVICE_KEY = "usb-C-Media_Electronics_Inc._USB_Audio_Device-00"
# aplay 完整设备路径
DEVICE_PATH = "pulse:alsa_output.#{DEVICE_KEY}.analog-stereo"