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
@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)
}
@solarkraft
solarkraft / syncthing-automerge.py
Created December 30, 2022 18:00
Monitors a Syncthing-synced directory and tries to merge conflicting files (based on https://www.rafa.ee/articles/resolve-syncthing-conflicts-using-three-way-merge/). Probably adaptable for other directory types, but only tested with Logseq (works for me™️).
import os
import time
import re
import subprocess
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
def get_relative_path(path):
return os.path.relpath(path)
@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',
@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
@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
@pastleo
pastleo / howdy-face-recognition-arch-kde.md
Last active April 12, 2024 06:34
Setup face recognition authentication on ArchLinux and KDE Plasma using howdy

Setup face recognition authentication on ArchLinux and KDE Plasma using howdy

This is surprisingly easy...basically following Arch Wiki:

https://wiki.archlinux.org/index.php/Howdy

After some investigation, here is step by step and preferences

Install howdy

@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,
@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):
@John-Paul-R
John-Paul-R / FabricModList.md
Last active April 7, 2024 00:48
A list of (almost all) mods for Fabric

Fabric Mod List

This page contains a list of the current Minecraft Fabric mods. (As of 2021-08-19 08:05:23 Timezone: UTC+0000 (GMT))

To search for mods by name, category, or download count, visit the website, fibermc.com!

Note: You can view a mod's source files by following the "Source" link on its CurseForge page, assuming that the mod's creator has made such files public.

There are currently 2954 mods in this list.