Skip to content

Instantly share code, notes, and snippets.

@ZipFile
ZipFile / iqdb.py
Created April 4, 2021 15:50
IQDB-like image similarity calculation in Python
#!/usr/bin/env python
# Install deps:
# pip install scikit-image PyWavelets
# Run:
# python iqdb.py a.jpg b.jpg
# References:
# https://iqdb.org/code/
# https://github.com/ricardocabral/iskdaemon
# https://grail.cs.washington.edu/projects/query/
@HertzDevil
HertzDevil / dump.lua
Created August 19, 2016 03:29
MDRV2 MDT to MML unconverter
-- MDT filename is the only command line argument
local schar = function (f)
local z = string.byte(f:read(1))
return z >= 0x80 and z - 0x100 or z
end
local char = function (f)
return string.byte(f:read(1))
end
local sshort = function (f)
@adrian17
adrian17 / patcher.py
Created July 22, 2014 11:15
TH autobomb patcher
import shutil
import os
games = [
{"name": "th10", "offset": 0x25013, "data": [0xf6, 0x05, 0x5c, 0x4e, 0x47, 0x00, 0x02, 0x0f, 0x84, 0x52, 0x01, 0x00, 0x00]},
{"name": "th11", "offset": 0x30679, "data": [0xf6, 0x05, 0xc0, 0x93, 0x4c, 0x00, 0x02, 0x0f, 0x84, 0xd5, 0x02, 0x00, 0x00]},
{"name": "th12", "offset": 0x3619b, "data": [0xf6, 0x05, 0xd0, 0x49, 0x4d, 0x00, 0x02, 0x0f, 0x84, 0xe8, 0x01, 0x00, 0x00]},
{"name": "th125", "offset": 0x3ace8, "data": [0xf6, 0x05, 0x10, 0xb2, 0x4d, 0x00, 0x02, 0x0f, 0x84, 0xf9, 0x00, 0x00, 0x00]},
{"name": "th13", "offset": 0x42925, "data": [0xf6, 0x05, 0x14, 0x4c, 0x4e, 0x00, 0x02, 0x0f, 0x84, 0x2c, 0x01, 0x00, 0x00]},
{"name": "th14", "offset": 0x4d2c4, "data": [0xf6, 0x05, 0x9c, 0x8a, 0x4d, 0x00, 0x02, 0x0f, 0x84, 0x00, 0x01, 0x00, 0x00]}
@jzwinck
jzwinck / purge-directory.c
Created June 2, 2013 03:29
Inspired by http://linuxnote.net/jianingy/en/linux/a-fast-way-to-remove-huge-number-of-files.html this program removes all regular files within a directory, using multiple processes to work faster. Timings from my system are in a comment below; feel free to leave your own. Easily create lots of empty files with "seq 10000 | xargs touch".
#include <dirent.h>
#include <stdio.h>
#include <unistd.h>
/* filter for regular files only */
static int dirent_select(const struct dirent* ent)
{
return ent->d_type == DT_REG;
}