Skip to content

Instantly share code, notes, and snippets.

View notwa's full-sized avatar
🚲
bikeshedding

Connor notwa

🚲
bikeshedding
View GitHub Profile
@notwa
notwa / gist:985b3a986c9489d22f9bfd938c5b5b0c
Last active July 25, 2017 00:29
MM default save file copies
(J 1.0)
here's all the calls to 801008C0 when creating a save file,
which in turn calls memcpy at 80092260:
to: 801EF484; from: 801C1510; size: 00000028
to: 801EF4AC; from: 801C1538; size: 00000022
to: 801EF4D0; from: 801C155C; size: 00000088
to: 801F07EE; from: 801C15E4; size: 00000002 # checksum
to: 80506D30; from: 801EF460; size: 00003F50 # copy to buffer to write to SRAM
same thing but with save context offsets and decompressed rom addresses:
@notwa
notwa / PDF.ipynb
Created August 5, 2017 18:20
messing around with random variables
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@notwa
notwa / idup.py
Last active August 10, 2017 10:28
duplicate/similar image finder
#!/usr/bin/env python3
# find duplicate images given a hamming distance threshold.
# employs dhash to do the heavy lifting.
# doesn't recurse into "./_duplicate/" so you can dump things there if you wish.
# dependencies: pillow, dhash
import sys, os, os.path, pickle
from PIL import Image
import dhash
@notwa
notwa / desmos.md
Last active January 5, 2021 18:02
stuff i've plotted in desmos

stuff i've plotted in desmos

in some order idk

the two nonlinearities involved in (a scalar version of) converting RGB to CIELAB.

f(x) converts RGB to linear sRGB. g(x) is used in converting linear sRGB to XYZ. the black line is the combination of the two, not quite linear.

@notwa
notwa / sckey.c
Created August 21, 2017 11:22
Starcraft CD-Key Validator
int validate(const char *key) {
int magic = 3;
int count = 0;
for (char c; (c = *key); key++) {
if (c < '0' || c > '9') continue;
int v = c - '0';
if (++count == 13) {
// final character.
return magic % 10 == v;
} else {
@notwa
notwa / clock.h
Last active March 3, 2018 23:49
portable snippets clock.h without pulling in windows.h — https://github.com/nemequ/portable-snippets
/* Clocks (v1)
* Portable Snippets - https://github.com/nemequ/portable-snippets
* Created by Evan Nemerson <[email protected]>
*
* To the extent possible under law, the authors have waived all
* copyright and related or neighboring rights to this code. For
* details, see the Creative Commons Zero 1.0 Universal license at
* https://creativecommons.org/publicdomain/zero/1.0/
*
* Modified by Connor Olding, 2017
@notwa
notwa / dwarf.lua
Last active April 21, 2018 02:15
dwarf fortress (VGA) font in love2d format
-- This is free and unencumbered software released into the public domain.
-- For more information, please refer to <http://unlicense.org/>
local charset = ("\
\x00☺☻♥♦♣♠•◘○◙♂♀♪♫☼\
►◄↕‼¶§▬↨↑↓→←∟↔▲▼\
!\"#$%&'()*+,-./\
0123456789:;<=>?\
@ABCDEFGHIJKLMNO\
PQRSTUVWXYZ[\\]^_\
@notwa
notwa / huffman.py
Last active October 21, 2020 18:46 — forked from mreid/huffman.py
Example implementation of Huffman coding in Python
# Example Huffman coding implementation
# Distributions are represented as dictionaries of { 'symbol': probability }
# Codes are dictionaries too: { 'symbol': 'codeword' }
def huffman(p):
'''Return a Huffman code for an ensemble with distribution p.'''
# Base case of only two symbols, assign 0 or 1 arbitrarily
if len(p) == 2:
return dict(zip(p.keys(), ['0', '1']))
import autograd.numpy as np
import autograd.numpy.random as npr
from autograd.misc.flatten import flatten
from autograd.misc.optimizers import unflatten_optimizer
import itertools, types
def iterize(iterable):
if type(iterable) in (tuple, list):
iterator = iter(iterable)
elif np.isscalar(iterable):
@notwa
notwa / _example.sh
Last active March 21, 2018 10:23
recompress.py: deconstruct and reconstruct Ocarina of Time ROMs
#!/usr/bin/env bash
set -e
# set this as needed!
rom="Legend of Zelda, The - Ocarina of Time (U) (V1.0) [!].z64"
output="reconstructed.z64"
gcc_flags="-std=gnu11 -Wall -O3 -s"