Skip to content

Instantly share code, notes, and snippets.

@sfan5
sfan5 / pngdiff.py
Created November 28, 2013 12:52
Makes each PNG only show the difference to the previous ones pasted on top of eachother
#!/usr/bin/env python
import sys
from PIL import Image
def rgb_rgba_cmp(a, b):
if a[0] != b[0]:
return False
if a[1] != b[1]:
return False
if a[2] != b[2]:
@sfan5
sfan5 / Makefile
Last active February 9, 2020 02:14
A small python wrapper for xbrz
#You may have to tweak some things here
CC = gcc
CXX = g++
FLAGS = -I/usr/include/python2.7
CFLAGS =
CXXFLAGS =
LDFLAGS =
#Do not change anything beyond this point
CXXFLAGS += -std=c++11
@sfan5
sfan5 / cpbitmap2image.py
Created January 6, 2014 10:13
Tools to work with .cpbitmap files
#!/usr/bin/env python2
from PIL import Image
import sys
import struct
def r8(f):
return ord(f.read(1))
if len(sys.argv) <= 2:
print("Usage: %s <input> <output>" % sys.argv[0])
@sfan5
sfan5 / ffbuild.sh
Last active March 11, 2022 03:40
Builds ffmpeg with many libraries; easily configurable; can build mpv too
#!/bin/bash
set -e
ffbuild_conf=~/.config/ffbuild.conf
nobuild=0
noextract=0
usage () {
echo "Usage: ffbuild.sh [options]"
@sfan5
sfan5 / imgbump.py
Created February 15, 2014 16:02
Adds a bumpmap-like effect to images (works best on low-res [~16x16] textures).
#!/usr/bin/env python
import sys
from PIL import Image
FCT = 8
def diff2(a, b):
return abs(a-b)
def avg3(a, b, c, d=0):
@sfan5
sfan5 / gen_ean8.py
Created March 12, 2014 20:47
Generates an image with an EAN-8 barcode
#!/usr/bin/env python
from PIL import Image
import sys
l_code = {
0: '0001101',
1: '0011001',
2: '0010011',
3: '0111101',
4: '0100011',
@sfan5
sfan5 / packetgen.cpp
Last active August 29, 2015 13:59
does stuff using C++
#include <iostream>
#include <fstream>
#include <sstream>
#include <map>
#include <list>
#include <utility>
#include <stdlib.h> // for exit()
#include <vector>
template <typename T, typename U> class create_map {
@sfan5
sfan5 / controlfilegen.html
Last active January 18, 2018 12:22
Various tools for managing Cydia repositories & packages
<!DOCTYPE HTML>
<html>
<head>
<title>Cydia package control file Generator</title>
<style type="text/css">
* {
font-family: sans-serif;
}
input {
border-radius: 6px;
@sfan5
sfan5 / run-as.c
Last active August 29, 2015 14:00
A simple Android run-as replacement when the preinstalled one won't work (I'm looking at you Android 4.2)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <errno.h>
#include <unistd.h>
#include <stdarg.h>
#include <stdbool.h>
// Link this with a libselinux.so from your Android device
@sfan5
sfan5 / itunes_conv.sh
Last active March 5, 2018 19:50
Converts a /var/mobile/Media/Purchases (from iPhone, iPad or iPod touch) directory to media files with artwork & tags
#!/bin/bash -e
### config ###
numbered=1
force_artwork="./-52743546503191174.jpeg"
##############
getxml () {
grep -F -A1 "<key>$1<" -- "$file" | sed -rn 's/.*<(string|integer)>(.+)<.*/\2/p'
}