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 / 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 / hole.py
Last active June 18, 2022 03:30
网页版树洞渐变色
'''
网页版树洞从 Alice 到 Zombie Zach 的颜色渐变
https://pkuhelper.pku.edu.cn/hole/##1264962
参考了网页版树洞的颜色生成机制,值越接近则颜色越接近。
可以通过更改 i 的值(0 到 1)来改变从谁开始
'''
NAMES = [
'Alice',
@dschaehi
dschaehi / index.css
Last active September 17, 2022 09:06
Jupyterlab Solarized Dark Theme
/*-----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
/*
The following CSS variables define the main, public API for styling JupyterLab.
These variables should be used by all plugins wherever possible. In other
words, plugins should not define custom colors, sizes, etc unless absolutely
necessary. This enables users to change the visual theme of JupyterLab
@diastremskii
diastremskii / create-new-file.ahk
Last active October 24, 2022 06:25
AutoHotKey: Create a new file with Alt+N keyboard shortcut in Windows Explorer
; This is part of my AutoHotKey [1] script. When you are in Windows Explorer it
; allows you to press Alt+N and type a filename, and that file is created
; in the current directory and opened in the appropriate editor (usually
; [gVim](http://www.vim.org/) in my case, but it will use whatever program is
; associated with the file in Windows Explorer).
; This is much easier than the alternative that I have been using until now:
; Right click > New > Text file, delete default filename and extension (which
; isn't highlighted in Windows 7), type the filename, press enter twice.
; (Particularly for creating dot files like ".htaccess".)
@vankesteren
vankesteren / Adamopt.jl
Last active February 25, 2023 05:35
Julia implementation of Adam optimizer
module Adamopt
# This is a module implementing vanilla Adam (https://arxiv.org/abs/1412.6980).
export Adam, step!
# Struct containing all necessary info
mutable struct Adam
theta::AbstractArray{Float64} # Parameter array
loss::Function # Loss function
grad::Function # Gradient function
@alexdevero
alexdevero / markdown.reg
Last active January 3, 2024 08:48
Add markdown as an item to “New” context menu in Windows 10 (https://superuser.com/questions/638755/add-item-to-new-context-menu-in-windows-8#640486).
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\.md]
@="markdown"
[HKEY_CLASSES_ROOT\.md\ShellNew]
"NullFile"=""
[HKEY_CLASSES_ROOT\markdown]
@="Blank Markdown file"
@tgroshon
tgroshon / index.ts
Last active January 26, 2024 13:41
Tailwind CSS GIMP Color Palette
// Execute with "bun run index.ts > tailwind.gpl"
//
import colors from 'tailwindcss/colors'
type RGB = {r: number, g: number, b: number};
function isObj(data: any): data is object {
return data !== null && typeof data === 'object' && !Array.isArray(data)
}
@ManiaciaChao
ManiaciaChao / article-style.css
Last active February 11, 2024 18:42 — forked from bangedorrunt/article-style.css
GoldenDict Arc Dark Theme
/* mkdir ~/.goldendict/styles/arc-dark/
then put this stylesheet there */
body {
margin-top: 1px;
margin-right: 3px;
margin-left: 2px;
margin-bottom: 3px;
background: #4b5162;
color: white;
font-family: Noto Serif CJK SC, Noto Serif, Bookerly, Segoe UI,
@AllanChain
AllanChain / PKUAutoClick.user.js
Last active February 24, 2024 08:47
PKU Auto Click
// ==UserScript==
// @name PKU Auto Click
// @namespace https://gist.github.com/AllanChain/c0782061f9e9836e2807a81acfe3b254
// @version 3.5
// @description 自动点击 PKU IAAA,教学网和邮箱的登录键,首次使用需手动点击一次以使插件记录密码。
// @icon https://www.pku.edu.cn/favicon.ico
// @author Allan Chain
// @copyright 2020 - 2024, Allan Chain
// @homepageURL https://gist.github.com/AllanChain/c0782061f9e9836e2807a81acfe3b254
// @supportURL https://gist.github.com/AllanChain/c0782061f9e9836e2807a81acfe3b254
@lilydjwg
lilydjwg / gh-check
Last active March 18, 2024 04:43
gh-check: speed test to known GitHub IPs
#!/usr/bin/python3
import asyncio
import time
import socket
import argparse
import aiohttp
class MyConnector(aiohttp.TCPConnector):