Skip to content

Instantly share code, notes, and snippets.

View Mufanc's full-sized avatar

Mufanc

  • Hangzhou, Zhejiang, China
View GitHub Profile
import math
import sys
import array
import fcntl
import termios
from base64 import b64encode
from PIL import Image
@Mufanc
Mufanc / pcstat.cpp
Created November 2, 2024 11:06
Get page cache statistics for files
#include <cstdio>
#include <cstdint>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
if (argc == 1) {
fprintf(stderr, "usage: pcstat <file>");
@Mufanc
Mufanc / qt-widget-in-gtk-window.cpp
Created August 11, 2024 04:48
在 GTK 窗口中嵌入 QT 控件
#include <QApplication>
#include <QWidget>
#include <QLabel>
#include <QVBoxLayout>
#include <QWindow>
#include <QTimer>
#include <QPushButton>
#ifdef signals
#define SIGNALS_BACKUP signals
@Mufanc
Mufanc / miui-ai-course.py
Created October 10, 2023 09:16
解析小爱导出的课程表
import json
from base64 import b64decode
from urllib.parse import unquote
import httpx
share_url = httpx.URL(input())
params = b64decode(httpx.QueryParams(share_url.params)['linkToken']).decode()
params = unquote(params).split('&')
#include <cstdio>
#include <cxxabi.h>
#include <dlfcn.h>
#include <unwind.h>
void backtrace() {
int count = 0;
_Unwind_Trace_Fn cb = [] (_Unwind_Context *context, void *args) -> _Unwind_Reason_Code {
int *count = static_cast<int *>(args);
#include <cstdlib>
#include <iostream>
#include <sys/inotify.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/unistd.h>
#define TMP_FILE "/tmp/fake.brightness"
#define HIJACK_FILE "/sys/class/backlight/intel_backlight/brightness"
TARGET="/usr/bin/typora"
if [ $(id -u) = 0 ]; then
rm /usr/bin/typora
cat <<-EOF > "$TARGET"
#!/usr/bin/sh
exec bwrap --unshare-all --share-net \
--ro-bind / / \
--dev-bind /dev /dev \
// fd-perm $(id -u nobody)
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fcntl.h>
#include <sys/unistd.h>
#include <sys/wait.h>
int main(int, char *argv[]) {
@Mufanc
Mufanc / new-bing-enhance.user.js
Created April 10, 2023 18:50
New Bing 增强脚本
// ==UserScript==
// @name New Bing
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author Mufanc
// @match https://www.bing.com/search?*showconv=1*
// @icon https://www.google.com/s2/favicons?sz=64&domain=bing.com
// @grant GM_addStyle
// @run-at document-start
@Mufanc
Mufanc / AC-automator.py
Created April 10, 2023 14:01
「机器学习」课程实训自动 AC 机
import inspect
from os import path
for info in inspect.stack():
if path.split(info.filename)[1] != 'main.py':
continue
print(''.join(info.frame.f_globals['hash_name']))
exit()