Skip to content

Instantly share code, notes, and snippets.

View charles-l's full-sized avatar
👾
making games

Charles charles-l

👾
making games
View GitHub Profile
# Python implementation of the wordwrap algorithm from
# http://blogs.perl.org/users/damian_conway/2019/08/greed-is-good-balance-is-better-beauty-is-best.html
import math
import re
def cost(lines, width):
# NOTE: not skipping the last line in the uniformity cost since
# if there's no way of splitting in greedy_wrap, the last line ends up
# with everything on it.
@charles-l
charles-l / sra.py
Last active March 31, 2023 15:10
writeup for the picoctf 2023 crypto challenge: SRA
'''
Script to solve SRA in picoCTF 2023
The challenge provides a broken version of RSA that gives the user the cipher text
and d (e^-1) for the private key. n is not given. Below is the original script
with some annotations I added.
from Crypto.Util.number import getPrime, inverse, bytes_to_long
from string import ascii_letters, digits
from random import choice
@charles-l
charles-l / tailscale.tf
Last active April 30, 2023 20:44
terraform notes: provision a server with tailscale automatically
terraform {
required_providers {
tailscale = {
source = "tailscale/tailscale"
version = "0.13.7"
}
}
}
provider "tailscale" {
  1. Install gdb
  2. Install GDB PEDA
  3. Install nasm
  4. Create a makefile:
    %: %.asm
      nasm -f elf64 $< && ld -s -o $@ [email protected]
    
    all: $(patsubst %.asm,%,$(wildcard *.asm))
@charles-l
charles-l / collision.py
Last active April 1, 2024 21:35
Simple collisions for action games (raylib python). Blog post: https://c.har.li/e/2024/03/28/implementing-robust-2D-collision-resolution.html
# `pip install raylib` to get pyray
import pyray as rl
from dataclasses import dataclass
import random
from typing import Optional
SIZE = 32
def copy_rect(rect):
@charles-l
charles-l / jumpapp.py
Last active May 4, 2024 16:51
python port of jumpapp
#!/usr/bin/env python3
# depends on having `wmctrl`, `xdotool`, and `zenity` installed.
import argparse
import re
import subprocess
import os
import traceback
@charles-l
charles-l / flake.nix
Created August 29, 2024 03:36
Flake for Rust + Bevy development on M3 Mac
{
description = "Bevy flake";
inputs =
{
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; # or whatever vers
};
outputs = { self, nixpkgs, ... }@inputs:
let
system = "aarch64-darwin"; # your version