Skip to content

Instantly share code, notes, and snippets.

View fffonion's full-sized avatar

Wangchong Zhou fffonion

View GitHub Profile
@fffonion
fffonion / patch_nginx_listeners.py
Last active January 14, 2024 23:05
Patch nginx configurations to add quic listeners and use new http2 directive.
#!/usr/bin/env python3
import os
import re
import sys
import argparse
def modify(path, args):
print("DO: ", path)
@fffonion
fffonion / replaceCert.ps1
Created December 19, 2023 14:20
Replace cert for Remote desktop and Windows Admin Center
function 测试UAC
{
[OutputType([bool])]
param()
process {
[Security.Principal.WindowsPrincipal]$用户 = [Security.Principal.WindowsIdentity]::GetCurrent();
return $用户.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator);
}
}
@fffonion
fffonion / github-widescreen.user.js
Last active September 25, 2023 08:43
github-widescreen.user.js
// ==UserScript==
// @name Github Widescreen Fix
// @namespace http://tampermonkey.net/
// @updateURL https://gist.github.com/fffonion/4f7bd4511ca1b6798ec422ae37fd5376/raw/github-widescreen.user.js
// @downloadURL https://gist.github.com/fffonion/4f7bd4511ca1b6798ec422ae37fd5376/raw/github-widescreen.user.js
// @version 0.2
// @description try to take over the world!
// @author You
// @match https://github.com/*/*/actions/runs/*/job/*
// @match https://github.com/*/*
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
extra-index-url = https://pypi.org/simple
https://download.pytorch.org/whl/cu113
@fffonion
fffonion / extract_subtitles.sh
Last active August 26, 2023 21:10
Extract subtitles track
#!/bin/bash
f="$1"
IFS=$'\r\n'
filename="${f%.*}"
bf=$(basename "$filename")
options=()
moptions=()
for s in $(ffprobe "$f" -show_entries stream=index,codec_type,codec_name:stream_tags=language,title -of compact 2>/dev/null|grep "codec_type=subtitle"); do
@fffonion
fffonion / luajit-ctyp-remember-self.patch
Created April 2, 2021 14:38
LuaJIT FFI avoid incoditionally function create patch
diff --git a/src/lib_ffi.c b/src/lib_ffi.c
index a29014e5..268c948c 100644
--- a/src/lib_ffi.c
+++ b/src/lib_ffi.c
@@ -494,6 +494,7 @@ LJLIB_CF(ffi_new) LJLIB_REC(.)
{
CTState *cts = ctype_cts(L);
CTypeID id = ffi_checkctype(L, cts, NULL);
+ printf("my type is %d\n", id);
CType *ct = ctype_raw(cts, id);
@fffonion
fffonion / main.cpp
Created June 30, 2020 09:20
Read Xiaomi Mijia temperature and humidity sensor 2 (LYWSD03MMC) from ESP32
#include <Arduino.h>
#include <BLEDevice.h>
BLEClient *pClient;
BLEScan *pBLEScan;
#define SCAN_TIME 10 // seconds
bool connected = false;
import re
import time
def rfc822(s):
_ = re.findall("[A-z][a-z]+,\s*([^\+G]+)(?:$|\s([\+\-]*)(\d+|GMT))", s)
if not s:
print("%s is not RFC822 Date" % s)
return 0
dt, sgn, tz = _[0]
if tz == "GMT":
@fffonion
fffonion / setup-dashbutton.py
Created September 28, 2019 22:32
Setting up dash button without Amazon App
import requests
import re
import sys
# Initial work from: https://mpetroff.net/2016/07/new-amazon-dash-button-teardown-jk29lp/
h = requests.Session()
BASE_URL = "http://192.168.0.1"
@fffonion
fffonion / changyan.py
Created June 13, 2019 02:52
畅言导出评论转换成导入评论格式
import json
import time
cmt = open('export.json').read()
cmt = json.loads(cmt)
print(len(cmt['comments']))
blk = set((
'=======',
'~~~~~~~~~~~~'