Skip to content

Instantly share code, notes, and snippets.

View CCXXXI's full-sized avatar

CCXXXI

View GitHub Profile
@CCXXXI
CCXXXI / css_color.py
Last active August 4, 2021 03:15
Change colors in a css file.
import re
import sys
from colorsys import hls_to_rgb, rgb_to_hls
from itertools import chain
def hex2rgb(x):
x = x.lstrip("#")
if len(x) == 3:
x = "".join(chain(*zip(x, x)))
@CCXXXI
CCXXXI / python_oj_tips.md
Created September 24, 2021 04:48
做题时踩过的一些坑。

RecursionError

from sys import setrecursionlimit
setrecursionlimit(10**8)

IO加速

@CCXXXI
CCXXXI / sort.md
Last active September 24, 2021 06:02

排序

对呀对呀!……排序有十二样写法,你知道么?

前置模板

冒泡排序

这种算法能如此知名,可能是历史遗留问题

@CCXXXI
CCXXXI / base.cpp
Last active September 24, 2021 06:06
一些常用的或不常用的代码模板。
#pragma region base
#include "bits/stdc++.h"
using namespace std;
using i64 = int64_t;
using u64 = uint64_t;
using i32 = int32_t;
using u32 = uint32_t;
@CCXXXI
CCXXXI / markdown_check_reference_links.py
Last active September 27, 2021 06:53
Check if reference links in markdown files is valid.
final _cjkQuote = RegExp(
'([\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])(["])');
final _quoteCJK = RegExp(
'(["])([\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])');
final _fixQuote = RegExp("([\"']+)(s*)(.+?)(s*)([\"']+)");
final _fixSingleQuote = RegExp(
"([\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])( )(')([A-Za-z])");
final _hashANSCJKhash = RegExp(
'([\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])(#)([A-Za-z0-9\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff]+)(#)([\u2e80-\u2eff\u2f00-\u2fdf\u3040-\u309f\u30a0-\u30ff\u3100-\u312f\u3200-\u32ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff])');
final _cjkHash = RegExp(
var delimiter = "<br>"
var weekCycle = [];
weekCycle[1] = "";// "%u8FDE";
weekCycle[2] = "%u5355";
weekCycle[3] = "%u53CC";
var result = new String("");
var weeksPerYear = 53;
// 输出教学活动信息
function activityInfo() {
return "teacherId:" + this.teacherId + "\n"
@CCXXXI
CCXXXI / danganronpa_auto_monomono_machine.py
Last active April 30, 2022 12:00
Press "1" to start. Press "0" to stop.
import keyboard
import pydirectinput as pyautogui
pyautogui.PAUSE = 0
def f():
while not keyboard.is_pressed("0"):
pyautogui.press("up")
@CCXXXI
CCXXXI / automata.py
Last active May 4, 2022 07:11
To check my automata homework.
import re
from itertools import product
from random import sample
import pytest
from automata.fa.dfa import DFA
dfa = DFA(
states=set("pqrs"),
input_symbols=set("01"),
@CCXXXI
CCXXXI / monus_tm.py
Created June 5, 2022 15:27
A turing machine to calc monus.
from itertools import product
import pytest
from automata.tm.configuration import TMConfiguration
from automata.tm.dtm import DTM
from automata.tm.tape import TMTape
tm = DTM(
states={f"q{i}" for i in range(7)},
input_symbols=set("01"),