Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Zeta611's full-sized avatar
🎯
Focusing

Jay Lee Zeta611

🎯
Focusing
View GitHub Profile
@Zeta611
Zeta611 / .latexmkrc
Created April 21, 2024 18:14
[.latexmkrc] latexmk recipe for LuaLaTeX + shell-escape
$pdf_mode = 4;
set_tex_cmds('%O --shell-escape %S');
@Zeta611
Zeta611 / mkdoc.sh
Created March 21, 2024 14:44
[mkdoc.sh] Make a LaTeX document #automation
#!/bin/bash
name="$1"
if [ -z "$name" ]; then
echo "Usage: $0 <name>"
exit 1
fi
mkdir "$name"
@Zeta611
Zeta611 / decrypt_pdfs.sh
Created April 20, 2023 14:09
[Decrypt PDFs] #automation
#!/bin/bash
# Check if qpdf is installed
if ! command -v qpdf >/dev/null; then
echo "qpdf not found. Please install qpdf and try again."
exit 1
fi
# Check if enough arguments are supplied
if [ "$#" -lt 3 ]; then
@Zeta611
Zeta611 / merge_pdfs.sh
Created April 20, 2023 13:53
[Merge PDFs] #automation
#!/bin/bash
# Check if qpdf is installed
if ! command -v qpdf >/dev/null; then
echo "qpdf not found. Please install qpdf and try again."
exit 1
fi
# Check if enough arguments are supplied
if [ "$#" -lt 3 ]; then
@Zeta611
Zeta611 / isbn.py
Last active February 15, 2023 04:46
[Real World Web Scraping] I used this script to find and parse missing ISBNs to help a librarian. Fixed 700+ books, took 3 hours to write. #automation #demo
from bs4 import BeautifulSoup
import re
import requests
import webbrowser
registrationNumbers = [
"HHA000010715",
"HHA000010711",
"HHA000001827",
@Zeta611
Zeta611 / z_combinator.ml
Created August 9, 2022 12:55
[Fixed-point combinator in OCaml] Fixed-point combinator (Z combinator) in OCaml. Y combinator is not available, as OCaml is a strict language. #demo
type 'a fix = Fix of ('a fix -> 'a)
let fix f =
(fun (Fix x as fix) -> f (fun z -> x fix z))
(Fix (fun (Fix x as fix) -> f (fun z -> x fix z)))
let factorial = fix @@ fun f n -> if n <= 0 then 1 else n * f (n - 1)
@Zeta611
Zeta611 / Zcombinator.swift
Created August 9, 2022 12:53
[Fixed-point combinator in Swift] Fixed-point combinator (Z combinator) in Swift. Y combinator is not available, as Swift is a strict language. #demo
struct Fix<T> {
let x: (Fix<T>) -> T
}
func fix<T, U>(f: @escaping (@escaping (T) -> U) -> ((T) -> U)) -> (T) -> U {
{ _fix in
f { (_fix.x(_fix))($0) }
}(
Fix { _fix in
f { (_fix.x(_fix))($0) }
@Zeta611
Zeta611 / adt.py
Last active March 1, 2022 02:44
[ADT in Python] Algebraic data type (sum type) in Python #demo
from dataclasses import dataclass
@dataclass(frozen=True)
class Var:
name: str
@dataclass(frozen=True)
class Int:
@Zeta611
Zeta611 / downloader.py
Last active February 24, 2022 07:54
[Async downloader] Async file downloader #automation
import aiohttp
import asyncio
async def download(session, url, file):
async with session.get(url) as res:
with open(file, "wb") as f:
f.write(await res.read())
@Zeta611
Zeta611 / FileIO.swift
Created August 16, 2021 14:51 — forked from JCSooHwanCho/FileIO.swift
ps할 때 입력을 한꺼번에 받기 위한 유틸리티 클래스. fread의 swift 버전.
import Foundation
final class FileIO {
private let buffer:[UInt8]
private var index: Int = 0
init(fileHandle: FileHandle = FileHandle.standardInput) {
buffer = Array(try! fileHandle.readToEnd()!)+[UInt8(0)] // 인덱스 범위 넘어가는 것 방지