Skip to content

Instantly share code, notes, and snippets.

@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 / convert.sh
Last active March 11, 2022 03:59
Converting .xm/.mod files to .wav in batch using MilkyTracker
#!/bin/bash -e
# adjust as needed, leave encode_ext empty to keep the wav files
encode_ext="opus"
function encode_func() {
# $1: source file (wav)
# $2: destination file
opusenc --quiet --bitrate 64 "$1" "$2"
}
@sfan5
sfan5 / mapblock-parse.py
Last active March 11, 2022 03:59
parses serialized MapBlock
#!/usr/bin/env python3
import sys
import struct
import binascii
import zlib
import getopt
try:
import zstandard
except ModuleNotFoundError:
zstandard = None
@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 / 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 / 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 / mtforum-crawler.py
Last active March 9, 2022 00:55
Crawls the Minetest forum mod releases section
import urllib, urllib2, re
from xml.dom import minidom
# Made by sfan5 2013 v0.4.09.3
V = "0.4.09.3"
# this script runs through the 'Mod Releases' section and checks the topics for missing things
# Also displays Statistics
# Can also reply to topics when valid session cookies are provided
# Can also move faulty topics to another forum
## <Settings>
@sfan5
sfan5 / blacknode.py
Created November 2, 2016 22:10
Removes a single node from a whole Minetest world (SQLite3 backend only)
#!/usr/bin/env python3
import sys
import os.path
import struct
import zlib
import sqlite3
class BufferConsumer():
def __init__(self, buf):
assert(type(buf) == bytes)