Skip to content

Instantly share code, notes, and snippets.

View AllanChain's full-sized avatar

Allan Chain AllanChain

View GitHub Profile
@AllanChain
AllanChain / termux-init.sh
Created February 22, 2021 07:49
Termux Quick Setup
termux-setup-storage
apt install clang python python-dev fftw libzmq libzmq-dev freetype freetype-dev libpng libpng-dev pkg-config curl vim-python zsh
sh -c "$(curl -fsSL https://github.com/Cabbagec/termux-ohmyzsh/raw/master/install.sh)"
@AllanChain
AllanChain / xb.py
Created February 22, 2021 09:25
Termux auto start and open browser
from os import popen
from sys import argv
import subprocess
from re import findall
app_nickname = {'j': 'jupyter notebook --no-browser',
'd': 'grip',
'k': 'mkdocs serve'}
mode := 1
#c::
mode:=!mode ;not! toggle
return
#If mode ; All hotkeys below this line will only work if mode is TRUE
j::1
k::2
l::3
@AllanChain
AllanChain / README.md
Created June 13, 2021 03:59
提取 人类生存发展与核科学 课件中的文字

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

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

@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 / netease_music_dl.py
Created June 29, 2021 03:37
网易云音乐歌单下载,保留 ID3 属性
from bs4 import BeautifulSoup
from pathlib import Path
from dataclasses import dataclass
import urllib.request
import re
from unicodedata import normalize
from mutagen.mp3 import EasyMP3
DOWNLOAD_TEMPLATE = "http://music.163.com/song/media/outer/url?id=%s.mp3"
@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 / 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 / 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 / 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