Skip to content

Instantly share code, notes, and snippets.

View AllanChain's full-sized avatar
💭
I may be slow to respond.

Allan Chain AllanChain

💭
I may be slow to respond.
View GitHub Profile
@AllanChain
AllanChain / hole.py
Last active June 18, 2022 03:30
网页版树洞渐变色
'''
网页版树洞从 Alice 到 Zombie Zach 的颜色渐变
https://pkuhelper.pku.edu.cn/hole/##1264962
参考了网页版树洞的颜色生成机制,值越接近则颜色越接近。
可以通过更改 i 的值(0 到 1)来改变从谁开始
'''
NAMES = [
'Alice',
@AllanChain
AllanChain / remove_parentheses.pyw
Created September 27, 2020 01:38
Removes parentheses in filename. Very useful for files downloaded from course.pku.edu.cn
from sys import argv
import os
import re
pattern = re.compile(r'^(.*?)(\(\d+\))+\.(.*?)$')
if __name__ == "__main__":
for file_to_rename in argv[1:]:
if os.path.isfile(file_to_rename):
match_result = re.match(pattern, file_to_rename)
@AllanChain
AllanChain / pdf-cloud-convert
Created March 16, 2022 02:11
Script to convert ppt(x) to pdf using cloudconvert
#!/bin/python3
from os import environ
from pathlib import Path
from subprocess import call
from sys import argv
API_KEY = """
""".replace(
"\n", ""
)
@AllanChain
AllanChain / zhihu-mobile.user.js
Last active November 8, 2021 23:21
知乎移动端修复
// ==UserScript==
// @name ZhiHu Mobile
// @version 1.0.2
// @description 知乎移动端修复
// @include https://www.zhihu.com/*
// @include https://zhuanlan.zhihu.com/*
// @grant GM_addStyle
// @run-at document-start
// ==/UserScript==
@AllanChain
AllanChain / wtContextMenu.reg
Last active October 4, 2021 01:46
Add "open wt" and "wt with profile" to context menu
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\Background\shell\openwtMore]
"ExtendedSubCommandsKey"="Directory\\ContextMenus\\wtMore"
"MUIVerb"="wt with Profile"
"Icon"="D:\\Syncthing\\Material\\Img\\wt.ico"
[HKEY_CLASSES_ROOT\Directory\ContextMenus\wtMore]
[HKEY_CLASSES_ROOT\Directory\ContextMenus\wtMore\shell]
@AllanChain
AllanChain / dynv6.py
Created September 22, 2021 15:37
Update a dynv6 ip
import socket
import urllib.request
def get_out_ipv6():
s = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
s.connect(("2620:0:ccc::2", 80))
ipv6 = s.getsockname()[0]
s.close()
print(ipv6)
return ipv6
@AllanChain
AllanChain / code_zipper.py
Created September 22, 2021 15:08
pkuphysu code zipper (legacy)
from pathlib import Path
from zipfile import ZipFile
PROJECT_ROOT = Path(__file__).parent.parent
SRC_ROOT = PROJECT_ROOT / "src"
DIST_ROOT = SRC_ROOT / "dist"
DIST_ZIP = DIST_ROOT / "output.zip"
FILE_INCLUDE = ["pkuphysu_wechat/**/*", "*.py", "bootstrap"]
FILE_NAME_EXCLUDE = [".secrets.local.toml"]
@AllanChain
AllanChain / mpltx.cls
Created September 10, 2021 13:50
A LaTeX Class for Modern Physics Lab - 北大近代物理实验报告 LaTeX 类 修改版本
%
% MpLtX --- a LaTeX Class for Modern Physics Lab
% Copyright (C) 2013 Modern Phys. Lab, School of Phys., Peking Univ.
%
% MpLtX is a template for experiment report of Modern Physics Lab in
% Peking University. This template depends on the "revtex4.2" package from
% APS Journals <http://publish.aps.org/revtex/revtex-faq>
%
% To use this template, you should open the package download from APS Journals'
% website as above and follow instructions from the README file in the package.
@AllanChain
AllanChain / BDWM_BLOCK.user.js
Last active June 24, 2021 02:54
未名 BBS 屏蔽用户脚本
// ==UserScript==
// @name BDWM Block Board Modified
// @version 2.0
// @description BDWM_BLOCK by motaguoke, modified by Allan Chain
// @icon https://bbs.pku.edu.cn/favicon.ico
// @include http://bbs.pku.edu.cn/*
// @include https://bbs.pku.edu.cn/*
// @include https://*.bdwm.net/*
// @include http://*.bdwm.net/*
// @homepageURL https://gist.github.com/AllanChain/50e2810d7abf54fe4fb09c175d5f00e7
@AllanChain
AllanChain / README.md
Created June 13, 2021 03:59
提取 人类生存发展与核科学 课件中的文字

这是简单地提取 人类生存发展与核科学 课件中文字的脚本。

适用于已经有笔记但担心考一些课件里边角的内容有觉得把课件全打下来太浪费的同学。