Skip to content

Instantly share code, notes, and snippets.

View w568w's full-sized avatar

w568w w568w

View GitHub Profile
@w568w
w568w / hack_command.py
Created November 7, 2025 05:53
Modify the command line of a running process shown in `top`, `ps`, etc.
import os
import sys
import ctypes
from typing import Tuple, List
def get_argv_address(pid: int) -> Tuple[int, int, bytes]:
"""
Get the memory address of the argv area of a given process.
@w568w
w568w / main.md
Created October 22, 2025 07:04
pacman 签名问题

1. 描述

今天开始,突然无法正常通过 ALHP 源更新,提示 signature from "ALHP Buildbot <[email protected]>" is invalid

$ LANG=C sudo pacman -Syu
error: core-x86-64-v4: signature from "ALHP Buildbot <[email protected]>" is invalid
error: extra-x86-64-v4: signature from "ALHP Buildbot <[email protected]>" is invalid
error: core-x86-64-v3: signature from "ALHP Buildbot <[email protected]>" is invalid
error: extra-x86-64-v2: signature from "ALHP Buildbot <[email protected]>" is invalid
@w568w
w568w / 01-zig-patch.md
Created June 24, 2025 08:00
Patch Zig standard library to support old Linux devices

Patch Zig Stdlib

Zig is great. But its aggressive minimum Linux kernel support policy—only supporting versions newer than the current Debian LTS kernel, 5.10—makes it unusable on older systems like Kindles, Termux on Android, and old servers.

This guide introduces a simple, minimally invasive patch for the standard library to maximize compatibility with these older devices.

What not supported?

The specific syscall that's breaking compatibility with old kernels is statx, which was introduced in Zig 0.14 (replacing POSIX's fstat).

It appears to be [called in only two places in the standard library](https://github.com/search?q=repo%3Aziglang%2Fzig+language%3AZig+linux.statx%28++NOT+path

@w568w
w568w / image-add-mime-types.ini
Last active June 13, 2025 03:57
Add MIME types when copying images from ill-behaviored clients
[Command]
Automatic=true
Command="
copyq:
function hasHtmlDataAndNoImageData(formats) {
let hasHtml = false;
let hasImage = false;
for (const format of formats) {
if (format === mimeHtml) {
hasHtml = true;
@w568w
w568w / log.md
Last active December 6, 2025 11:24
MECHREVO Wujie 14XA (Ryzen 7 8845HS) Reverse-engineering

MECHREVO Wujie 14XA (Ryzen 7 8845HS) Reverse-engineering

This log documents ACPI calls and driver calls found through reverse engineering the MECHREVO Wujie 14XA laptop (marketed as 机械革命无界 14X 暴风雪版, or Mechrevo Boundless 14X Blizzard Edition).

I am playing with:

  • BIOS version: N.1.14MRO17
  • AP (control center) version: 5.56.51.17

"How did you capture these calls?"

@w568w
w568w / network-manager-auto-reconnect.md
Last active March 29, 2024 12:49
Network Manager Auto Reconnect

Network Manager Auto Reconnect

Motivition

I have an Orange Pi that connects to the network via WiFi, and since my network is not very stable, the wireless router side often forcefully disconnects all devices, requiring manual reconnection. This is an annoying thing when I'm out: first, I have to figure out how to SSH to my Pi!

The network manager I use is NetworkManager, which is very modern and user-friendly. Unfortunately, until today its developers were not interested in adding an option to automatically reconnect to hotspots.

In this issue, some developers have suggested using the dispatcher to accomplish this. Well... I wrote a simple script to do this. It will try to restart the NetworkManager service 3 times when the network is disconnected (down event received).

Usage

@w568w
w568w / CommonDrawer.kt
Created August 18, 2017 11:29
Draw a hexagon on a Pixmap(by libGdx).
/**
* Created by w568w on 2017-7-29.
*/
class CommonDrawer : SixPloDrawer {
var w: Int = 0
var height: Int = 0
override fun draw(pixmap: Pixmap?, color: Color?) {
this.w = pixmap!!.width
height = (w / 4 * Math.sqrt(3.0)).toInt()