Skip to content

Instantly share code, notes, and snippets.

View sfan5's full-sized avatar

sfan5

  • Germany
  • 22:02 (UTC +02:00)
View GitHub Profile
@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 / 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 / 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 / mkapng.py
Last active May 28, 2016 21:13
Creates an APNG from PNGs (all PNGs need to have the same IHDR checksum for this to work)
#!/usr/bin/env python
import sys
import struct
import binascii
def mkchunk(tp, data):
return struct.pack("!L", len(data)) + tp + data + struct.pack("!L", binascii.crc32(tp + data) & 0xffffffff)
def getchunk(f, tp):
f.seek(0)
@sfan5
sfan5 / binclock.py
Last active December 27, 2015 22:21
Binary Clock using PyGame; Shows month, day, hour, minute and second
import pygame, time
from pygame.locals import *
OFFCOLOR = (25,25,25)
ONCOLOR = (42,65,89)
BGCOLOR = (36,36,36)
FIELDSIZE = 25
def rect(s, c, r): # We need to use this because it isn't drawn for some unknown reason when using pygame.draw.rect
for xx in range(r[0], r[2]):
@sfan5
sfan5 / README
Last active March 9, 2022 00:56
Minetest Forum statistics
Missing Things:
* jquery.min.js ( http://jquery.com/download/ )
* highstock.js ( http://www.highcharts.com/download )
* A cronjob for executing getvals.py
* A webserver with PHP [with SQLite3]
@sfan5
sfan5 / collectstatic.sh
Last active July 10, 2022 20:20
Collects media files from mods/games and puts them in a media directory, also creates an index.mth file in the MTHS format
#!/bin/bash
###### Options ######
MINETESTDIR=/home/username/minetest
GAMENAME=minetest_game
WORLDDIR=none
MEDIADIR=./media
LEGACY_SYMLINKS=0
# When settings this up be aware that the Minetest client
@sfan5
sfan5 / checkpae.sh
Last active December 20, 2015 10:59 — forked from arsdragonfly/checkpae.sh
Resolves the PlayerArgsEnd missing problem(prints the filenames that have it missing)
#!/bin/bash
# Put this into (worldname)/players folder and execute it
find . -type f -not -name "*.sh" | xargs grep -iL PlayerArgsEnd
@sfan5
sfan5 / xteapipe.c
Last active December 19, 2015 17:59
De/Encrypts from stdin to stdout using XTEA in OFB mode
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
void xtea_encrypt(unsigned int num_rounds, uint32_t v[2], uint32_t const key[4]) {
unsigned int i;
uint32_t v0=v[0], v1=v[1], sum=0, delta=0x9E3779B9;
for (i=0; i < num_rounds; i++) {
v0 += (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + key[sum & 3]);
@sfan5
sfan5 / readpng.py
Created June 7, 2013 22:05
Reads a .png file and outputs its sections
#!/usr/bin/env python2
import sys, binascii, struct
def islower(c):
return (c.upper() != c)
def countin(s, c):
i = 0
for b in s:
if b == c:
i += 1
return i