Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View EtaoinWu's full-sized avatar
🀄
School

Yue Wu EtaoinWu

🀄
School
View GitHub Profile
@EtaoinWu
EtaoinWu / jaxtyped_eqx_module.py
Created November 9, 2023 09:29
dirty equinox/jaxtyping/beartype hack for typechecking eqx.Module methods
import inspect
from abc import abstractmethod as abstractmethod
import beartype._decor._decornontype
import equinox as eqx
import jax as jax
from beartype import BeartypeConf, beartype as typechecker
from beartype.door import die_if_unbearable, is_bearable
from beartype.typing import * # pyright: ignore[reportWildcardImportFromLibrary]
from equinox import Module as EqxModule
@EtaoinWu
EtaoinWu / remove_old_files.py
Created August 23, 2023 06:41
Recursively remove files older than 1mo and remove empty directories. Useful for QQ group photos cleanup. Co-written by ChatGPT.
import os
import time
import pathlib
from tqdm import tqdm
def is_file_old(file_path, month_in_seconds = 30*24*60*60):
"""Returns if the file is not a directory and is at least one month old."""
if os.path.isdir(file_path):
return False
file_time = os.path.getmtime(file_path)
/* esm.sh - esbuild bundle(ffjavascript@0.2.57) deno production */
import __Process$ from "https://deno.land/std@0.177.0/node/process.ts";import { Buffer as __Buffer$ } from "https://deno.land/std@0.177.0/node/buffer.ts";var Ae=Object.defineProperty;var Fe=(i,t)=>{for(var e in t)Ae(i,e,{get:t[e],enumerable:!0})};var U={};Fe(U,{abs:()=>Ie,add:()=>yt,band:()=>Ct,bitLength:()=>V,bits:()=>Yt,bor:()=>Ue,bxor:()=>ke,div:()=>it,e:()=>M,eq:()=>P,exp:()=>Me,fromArray:()=>_e,fromRprBE:()=>ne,fromRprLE:()=>Y,fromString:()=>Mt,geq:()=>se,gt:()=>ft,isNegative:()=>Wt,isOdd:()=>bt,isZero:()=>It,land:()=>Ze,leq:()=>Ge,lnot:()=>Pe,lor:()=>Ne,lt:()=>ze,mod:()=>T,mul:()=>ee,naf:()=>Vt,neg:()=>te,neq:()=>Ce,one:()=>tt,pow:()=>ht,shiftLeft:()=>wt,shiftRight:()=>st,shl:()=>ve,shr:()=>Oe,square:()=>Re,sub:()=>X,toArray:()=>qe,toLEBuff:()=>H,toNumber:()=>we,toRprBE:()=>ie,toRprLE:()=>nt,toString:()=>lt,zero:()=>re});var Se=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];function Mt(i,t){if(!t||t==10)return BigInt(i);if(t==16)return i.slice(0,2)=
@EtaoinWu
EtaoinWu / merge_rescale_pdf.py
Created December 21, 2022 15:35
Merge PDFs into one and rescale them all to A4 width (21cm or 595px)
from PIL import Image
from PyPDF2 import PdfWriter, PdfReader
import tempfile
PREPEND_FILE = "打分框.pdf"
def scale_pdf_to_a4(input):
reader = input
if not isinstance(input, PdfReader):
@EtaoinWu
EtaoinWu / README.md
Created May 6, 2022 13:45
CSL Style for Chinese University Politics Homework

CSL Style for Chinese Uni-Politics Homework

This CSL file is made according to Peking University's style guide for politics term paper.

Released under CC BY-SA 3.0.

Keybase proof

I hereby claim:

  • I am etaoinwu on github.
  • I am etaoinwu (https://keybase.io/etaoinwu) on keybase.
  • I have a public key ASCYKRJA3Mdn4OisIAFDWbHdnz9aW8Qw8BWXmQu7Jgjmjgo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am etaoinwu on github.
  • I am etaoinwu (https://keybase.io/etaoinwu) on keybase.
  • I have a public key ASCAFzUjUlSyrJeSu4fUmhi4hgwdj1AOmzE9UwpfOjL7CQo

To claim this, I am signing this object:

@EtaoinWu
EtaoinWu / chatting history.txt
Created March 14, 2018 23:48
the chat about WC2018 Task1
Remark: All the time is UTC+8.
Etaoin Wu, [13.03.18 08:24]
subtask 1: a path, so the answer is the sum of all edge weights
Etaoin Wu, [13.03.18 08:25]
subtask 2: one same tree repeating 3 times, equal to 3 * the distance, calculating the distance is O(n)
Etaoin Wu, [13.03.18 08:26]
subtack 3: a tree and a path, dis(a,b)=dep(a)+dep(b)-2 dep(LCA(a,b))+abs(L(a)-L(b))