Skip to content

Instantly share code, notes, and snippets.

View lynn's full-sized avatar
🐞

Lynn lynn

🐞
View GitHub Profile
from copy import deepcopy
# puzzle = '''\
# ...12....
# .3.......
# 22.......
# .2.....4.
# .....3.3.
# .........
# ..24...2.

jailCTF 2025 writeup: pycryptojail

I enjoyed this crypto-based Python jail challenge at jailCTF 2025. I even found a partially unintended solution! Here's my writeup.

0. The challenge

#!/usr/local/bin/python3
from Crypto.Util.number import bytes_to_long, long_to_bytes, getPrime
import os
@lynn
lynn / ctrl-e.js
Created September 30, 2025 12:54
// ==UserScript==
// @name Ctrl+E to End
// @version 1.0.0
// @description Make Ctrl+E move the caret to the end of the line in input and textarea fields (Emacs-style)
// @match https://*.github.com/*
// @grant none
// @run-at document-start
// ==/UserScript==
(function () {
// https://wavepot.com/
const tau = 2*Math.PI;
const bpm = 132;
const bps = bpm / 60;
const spb = 1 / bps;
function pos(t) {
const beat = Math.floor(t / spb);
const frac = (t / spb) % 1.0;
import random
LONGEST_KEY = 2
STROKE = "KWR*RBG"
def keysmash(alphabet, size):
smash = ["a"] * random.randint(0, 1)
queue = list(alphabet)
for _ in range(size):
@lynn
lynn / uxn_animation.py
Created October 5, 2022 19:36
Makes an animated GIF explaining the uxn sprite format
from PIL import Image, ImageDraw
sprite_data = bytes.fromhex('''
00 00 3c 06 1c 06 3c 00 00 7f c3 f9 e3 f9 c3 ff
00 00 68 2c 78 2c 34 00 00 fe ff ff ff ff ff ff
00 01 19 07 0f 1f 07 0f ff ff e7 fb fd fe ff ff
00 80 f0 e0 c0 f0 f8 f8 ff ff ff ff ff ff 7f 7f
0f 0e 0c 00 80 ff ff 7f ff ff ff ff 7f 00 00 00
e8 e0 e0 60 01 ff ff fe 7f ff ff ff fe 00 00 00
''')
@lynn
lynn / cassini.lean
Created September 24, 2022 22:19
Proof of Cassini's identity in Lean 3
import data.nat.fib
import data.matrix.basic
import data.matrix.notation
import linear_algebra.matrix.determinant
theorem matrix.map_pow {m α β : Type*} [fintype m] [decidable_eq m] [semiring α]
{M : matrix m m α} {n : ℕ} [semiring β] {f : α →+* β} :
(M ^ n).map ⇑f = (M.map ⇑f) ^ n :=
begin
induction n,
# Discord bot for playing ABC notation music.
#
# ### Installation
# - Get the dependencies: abc2midi, timidity, ffmpeg, and lame.
# - `pip install discord.py`
# - `ACCORD_TOKEN=(your bot token) python3 accord.py`
#
# ### Usage
# In any channel where the bot is, say: $play (abc notation)
# The input may be multiple lines long, and may be in a ```code block```.
@lynn
lynn / PrettyParseError.hs
Last active October 20, 2020 09:29
Pretty ParseErrors for Text.Parsec
module PrettyParseError (
prettyParseError,
PrettyParseErrorOptions(PrettyParseErrorOptions),
prettyParseErrorDefaults
) where
import Data.List (intercalate, nub)
import Text.Parsec
import Text.Parsec.Error
import Text.Parsec.Pos
@lynn
lynn / frac.rs
Last active March 19, 2020 15:35
A bitwise-magic fractional part function
/// A "fractional part" function on f32s that does bitwise magic
/// on the representation of its argument.
pub fn frac(f: f32) -> f32 {
f32::from_bits(_frac(f.to_bits()))
}
/// A "fractional part" function that operates on a signed integer
/// representation of an IEEE single-precision floating point number.
fn _frac(i: u32) -> u32 {
// A floating point number consists of a sign bit,