Skip to content

Instantly share code, notes, and snippets.

View dixyes's full-sized avatar
🧧
<-- this is a 红包

Yun Dou dixyes

🧧
<-- this is a 红包
View GitHub Profile
@dixyes
dixyes / Readme.md
Last active April 20, 2024 13:24
ASUS ROG Zephyrus G14 2022 GA402RJ pci passthrough

ASUS ROG Zephyrus G14 2022 GA402RJ pci passthrough

This is a record for my own passthrough setup, I can finally use a single laptop for windows gaming and linux programming at the same time.

The device

My G14 is GA402RJ(6800HS + 6700s) with MT7922 WiFi/BT card.

At this time, BIOS version is 309.

@dixyes
dixyes / fuckexposure.c
Created February 29, 2024 12:42
fuck uvc auto exposure
// aarch64-linux-gnu-gcc fuckexposure.c -nostdinc -nostdlib -nostartfiles -e _start -g -o fuckexposure -Wall -static -ffreestanding -fno-stack-protector
#define NULL ((void *)0)
#define O_RDONLY 0
#define O_WRONLY 1
#define O_RDWR 2
#define AT_FDCWD -100
@dixyes
dixyes / fuckcache.py
Created February 18, 2024 02:48
Fuck buildx cache
#!/usr/bin/env python3
'''
Usage: ./fuckcache.py \
--mount=type=secret,id=npmrc,target=/root/.npmrc \
--mount=type=cache,target=/root/.npm \
--mount=type=cache,id=somecache,target=/var/cache/somecache
like docker RUN instruction
it will product dockerfile and build it
@dixyes
dixyes / conv.py
Last active November 7, 2023 13:35
GA402R anime matrix with python
from PIL import Image, ImageDraw, ImageOps, ImageStat
"""
convert picture to matrix data uint8 array
this script is too slow...
maybe we should rewrite it in np things
@dixyes
dixyes / hello.php
Created February 23, 2023 14:06
How to write hello world in PHP
<?php
// x86_64 sysv abi only
// simple hello
$code = "" .
"\x48\xc7\xc0\x01\x00\x00\x00" . // mov $0x1 (SYS_write for x86_64), %rax
"\x48\xc7\xc7\x01\x00\x00\x00" . // mov $0x1 (stdout), %rdi
"\x48\x8d\x35\x0b\x00\x00\x00" . // lea 0xb(%rip), %rsi PIE!
"\x48\xc7\xc2\x0d\x00\x00\x00" . // mov $0xd (sizeof("hello world!\n") - 1), %rdx
// SPDX-License-Identifier: GPL-2.0-or-later
/dts-v1/;
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include "armada-372x.dtsi"
/ {
model = "Not Aliyun SAG-100wm";
compatible = "notaliyun,sag100wm",
@dixyes
dixyes / extinst.lua
Last active June 27, 2022 19:29
use luajit, ncurses(w) to create a command line ui
#!/home/dixyes/awsl/pl/luajit
--[[
gist: https://gist.github.com/dixyes/cd945d8a195889de32cb524254d90d33
First to say : ffi niubi!
This file is ncursesw command line ui written in lua, using luajit and some C things.
Note: pits here:
1. variables created by ffi.new("sometype") may be gced at anytime (maybe use ffi.typeof() to create type can resolve this.);
workaround: use ffi.C.malloc instead
2. struct index may be not reliable: for example a structure struct sStruct{u32 lFirst; u64 llSecond;}; when use instSStruct[0].llSecond, it will use area from llSecond's half to out of bound 4 bytes as llSecond.
@dixyes
dixyes / play.php
Last active May 6, 2022 02:40
php FFI registry utilities
<?php
/**
* Win32 api utitlities class
* needs to be initialized with W32api::init()
*/
final class W32api
{
private const BASIC_CDEFS = <<<'CDEF'
typedef uint16_t WORD, *PWORD, *LPWORD;
#!/bin/sh
mirror_host='mirrors.ustc.edu.cn'
sed -i 's|^#baseurl=|baseurl=|g' /etc/yum.repos.d/fedora*
sed -i 's|^metalink=|#metalink=|g' /etc/yum.repos.d/fedora*
sed -i 's|^download.example/pub/fedora/linux|'"${mirror_host}"'/fedora|g' /etc/yum.repos.d/fedora*
/*
this is undocumented, to be confirmed
read id_aa64isar0_el1 from registry HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\x\CP 4030
*/
uint64_t getaa64isar0() {
const WCHAR cpus_key[] = L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\";
HKEY cpus_handle;
if (ERROR_SUCCESS != RegOpenKeyExW(HKEY_LOCAL_MACHINE, cpus_key, 0, KEY_ENUMERATE_SUB_KEYS, &cpus_handle)) {
printf("failed open reg\n");
return 0;