Skip to content

Instantly share code, notes, and snippets.

View PhotonQuantum's full-sized avatar

LightQuantum PhotonQuantum

View GitHub Profile
[@@@warnerror "-unused-value-declaration"]
open Bindlib
let ( <.> ) f g x = f (g x)
let ( <..> ) f g x y = f (g x y)
module Mu (M : sig
type 'fix t
end) =
[@@@warnerror "-unused-value-declaration"]
module type Functor = sig
type ('p, 'fix) t
val fmap : ('a -> 'b) -> ('p, 'a) t -> ('p, 'b) t
end
let ( <.> ) f g x = f (g x)
@PhotonQuantum
PhotonQuantum / genshin.sh
Created July 19, 2023 08:51
Genshin Start!
#!/usr/bin/env bash
set -e
declare -A replace_map
replace_map["cargo"]="genshin"
replace_map["Cargo"]="Genshin"
replace_map["rust"]="mihoyo"
replace_map["Rust"]="miHoYo"
replace_map["RUST"]="MIHOYO"
use std::net::TcpListener;
use std::sync::mpsc::{channel, Sender};
use std::thread;
use std::time::Duration;
use futures_util::{SinkExt, StreamExt};
use tungstenite::accept;
use tungstenite::Message;
fn block_client() {
use std::time::Duration;
use actix::{Actor, Arbiter, AsyncContext, Context, System};
struct MyActor;
impl Actor for MyActor {
type Context = Context<Self>;
fn started(&mut self, ctx: &mut Self::Context) {
ctx.run_later(Duration::from_secs(1), |_, _| {
#![feature(bool_to_option)]
use serde::Deserialize;
use std::path::PathBuf;
use regex::Regex;
use std::fs::{read_dir, File};
use opencc_rust::*;
#[derive(Debug, Deserialize)]
struct Poetry {
@PhotonQuantum
PhotonQuantum / elect_course_analysis.md
Last active July 11, 2023 16:11
正方教务(交大)选课协议分析

标记说明:

A 课程类型:主修、民族课、版块课(体育,英语)等,影响 rwlx xkly xkkz_id bklx_id kklxdm
B 个人及客观信息:学期号、专业号、选课学年等
C 特定课程及教学班信息
E 请求相关:分页参数

静态网页及相应查询参数准备

A1. 请求所有课程类型

from pysjtu import Session
from time import sleep
import re
from loguru import logger
course_map: dict
expect: str = "magicstring"
req_list: dict = {}
interval: float = 0.5
match_url = re.compile("curl '.*?'")
match_data = re.compile("--data-raw '.*?'")
import sys
from collections import OrderedDict
class DedupList(list):
def __init__(self, seq=()):
# print("init")
dic = {} if sys.version_info[1] > 5 else OrderedDict()
seq = list(dic.fromkeys(seq))
self._dedup_set = set(seq)
from PyPDF2 import PdfFileReader
import sys
from os import listdir, rename
from os.path import join
scan_dir = sys.argv[1]
files = [join(scan_dir, fn) for fn in listdir(scan_dir)]
for fn in listdir(scan_dir):
if fn[-4:] == ".pdf":
with open(join(scan_dir, fn), mode="rb") as f: