Skip to content

Instantly share code, notes, and snippets.

View CCXXXI's full-sized avatar

CCXXXI

View GitHub Profile
import glob from "glob";
import {readFile, writeFile} from 'fs';
import {optimize, OptimizedSvg} from "svgo";
glob("**/*.html", (err, files) => {
if (err) throw err;
files.forEach(file => {
readFile(file, 'utf8', (err, content) => {
if (err) throw err;
"""See https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.2124-0-201901-I!!PDF-E.pdf."""
import numpy as np
import numpy.typing as npt
_bgr2lms_matrix = (
np.array(
[
[262, 462, 3688],
[2146, 2951, 309],
import json
from collections import defaultdict
# read data.json
data = json.load(open("data.json"))
d = defaultdict(dict)
for col in data:
col: dict
n = col["Column1"]
for k in col.keys():
import { createLogger, format, transports } from "winston";
const logger = createLogger({
level: "debug",
transports: [
new transports.Console({
format: format.combine(format.colorize(), format.simple()),
}),
new transports.File({
filename: "discord-embeds-reader-bot.log",
import re
def convert(s: str) -> str:
start = re.search(r"/\* (.*) \*/\s*", s).group(1).replace("( ", "(")
s = re.search(r"T0_init.*;", s, re.S).group(0)
s = re.sub(r"/\*.*\*/\s*", "", s)
s = s.replace("init", "S1").replace("&&", "&").replace("(", "").replace(")", "")
s = re.sub(r"\s*(if|fi;)", "", s)
s = re.sub(r"T\d+_S(\d+)", r"\1", s)
@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"),
@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 / 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 / untitled.ps1
Last active August 12, 2022 02:49
Several useful commands.
function fixnat {
net stop winnat
net start winnat
}
function proxy {
$Env:http_proxy="http://127.0.0.1:7890";$Env:https_proxy="http://127.0.0.1:7890"
}
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"