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 / lambda_calculus.py
Created November 16, 2025 11:04
A demonstration that you can use Python to write lambda calculus.
class Curried:
def __init__(self, fn):
self.fn = fn
self.args = ()
self.kwargs = {}
def __call__(self, *args, **kwargs):
args = self.args + args
kwargs = {**self.kwargs, **kwargs}
if len(args) + len(kwargs) >= self.fn.__code__.co_argcount:
@EtaoinWu
EtaoinWu / fft.ua
Created September 9, 2025 08:15
FFT implementation in Uiua
# Experimental!
FFTObfs ← (
⊏⍜⋯≡⇌⇡⊸⧻∧(♭≡⌟(⊂⊃+(ט-)°⊟↯2_∞)⊃(↯⊟∞˙+|ₑ×πi÷⟜⇡))⇌⍜°ₑ₂⇡⧻.
)
# reverse bit order
# num[2^k] -> num[2^k]
RevOrder ← ⊏⍜⋯≡⇌⇡⊸⧻
@EtaoinWu
EtaoinWu / arp_monitor.lua
Created October 28, 2024 15:51
continuously check if i'm at home with wifi tcpdump
#!/usr/bin/env lua
-- This script runs on my router
local socket = require("socket.http")
local url = require("socket.url")
local ltn12 = require("ltn12")
local json = require("dkjson")
-- Run the tcpdump command with stdbuf
@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: