Skip to content

Instantly share code, notes, and snippets.

View ilonachan's full-sized avatar
🎩
This cryptic binary file format reminds me of a puzzle...

ilona ilonachan

🎩
This cryptic binary file format reminds me of a puzzle...
View GitHub Profile
@ilonachan
ilonachan / nom-pratt-parser.rs
Last active July 14, 2024 17:37
I followed the tutorial at https://matklad.github.io/2020/04/13/simple-but-powerful-pratt-parsing.html as closely as possible,while using nom at every step and creating the result to be a nom-compatible parser.
use std::{borrow::BorrowMut, cell::RefCell, rc::Rc};
use nom::{combinator::map_res, error::FromExternalError, IResult, Parser};
pub trait BinaryDefFn<'a, I, O, E, Op>: FnMut(I, Op, O, O) -> IResult<I, O, E> + 'a {}
impl<'a, T, I, O, E, Op> BinaryDefFn<'a, I, O, E, Op> for T where
T: FnMut(I, Op, O, O) -> IResult<I, O, E> + 'a
{
}
pub struct BinaryDef<'a, I, O, E, Op>(
@ilonachan
ilonachan / merge.py
Created February 12, 2023 21:39
Merge PDF files
#! /usr/bin/python3
import subprocess
import os
import re
# adapt this to fit whatever pattern you need
pattern = re.compile(r"^skript-[^\.]*.pdf$")
infiles = sorted([name for name in os.listdir(".") if os.path.isfile(name) and pattern.fullmatch(name)])