Skip to content

Instantly share code, notes, and snippets.

@sfan5
sfan5 / build-waifu2x-cpp.sh
Last active June 18, 2023 14:30
Builds waifu2x-converter-cpp statically linked with a minimal OpenCV build
#!/bin/bash -e
OUTDIR=/tmp/waifu2x-cpp_install
OPENCV_VER=4.7.0
[ -d waifu2x-converter-cpp ] && (cd waifu2x-converter-cpp && git pull) || git clone https://github.com/DeadSix27/waifu2x-converter-cpp
[ -f opencv-$OPENCV_VER.tar.gz ] || wget https://github.com/opencv/opencv/archive/$OPENCV_VER.tar.gz -O opencv-$OPENCV_VER.tar.gz
[ -d opencv-$OPENCV_VER ] || tar -xaf opencv-$OPENCV_VER.tar.gz
cd opencv-$OPENCV_VER
@sfan5
sfan5 / nginx-hdrimg.patch
Last active October 31, 2016 14:34
Add randomly selected header icons to generated autoindexes in nginx
--- nginx-1.10.2/src/http/modules/ngx_http_autoindex_module.c.orig 2016-10-18 17:03:14.000000000 +0200
+++ nginx-1.10.2/src/http/modules/ngx_http_autoindex_module.c 2016-10-31 15:31:31.873696354 +0100
@@ -54,6 +54,10 @@
#define NGX_HTTP_AUTOINDEX_NAME_LEN 50
+#define NGX_HTTP_AUTOINDEX_HDRIMG_COUNT 4 // indexing starts at zero
+#define NGX_HTTP_AUTOINDEX_HDRIMG_SIZE "96px"
+#define NGX_HTTP_AUTOINDEX_HDRIMG_UPRE "/_/h"
+#define NGX_HTTP_AUTOINDEX_HDRIMG_UPOST ".png"
@sfan5
sfan5 / cjpeg-dssim.sh
Created August 30, 2015 13:12
Better version of technopagan/cjpeg-dssim
#!/usr/bin/env bash
###############################################################################
#
# Intro:
# Automatically find the ideal JPEG quality setting for a JPEG image by
# calculating the output images dissimilarity from the input JPEG. This
# frees us from having to rely on the unstandardized quality integer.
@sfan5
sfan5 / sonar.http_parse.py
Last active December 10, 2021 23:47
Converts result from https://opendata.rapid7.com/sonar.http/ into masscan-like format
#!/usr/bin/env python3
import base64
import sys
import os
try:
import simplejson as json
except ImportError:
import json
# Takes decompressed https://opendata.rapid7.com/sonar.http/ scan file on stdin
@sfan5
sfan5 / 000readme.md
Last active November 30, 2022 16:45
More and better configuration for youtube-dl (mpv)

DO NOT USE THIS. It is unmaintained and will not work with newer versions of mpv, youtube-dl, yt-dlp or at all.

@sfan5
sfan5 / 2gateway.sh
Created April 8, 2016 17:24
Support multiple gateways on one machine
#!/bin/bash -e
IFACE=wlp0s18f2u1
TBLN=10
# TBLN needs to be different for each interface
IPADDR=`ip addr show dev $IFACE | grep "inet " | awk '{print $2}' | cut -d '/' -f1`
IPSUBNET=`ip route show | grep "dev $IFACE" | grep "src $IPADDR" | awk '{print $1}'`
IPGATEWAY=`ip route | grep "default via" | grep "dev $IFACE" | awk '{print $3}'`
@sfan5
sfan5 / brnboot_brute.py
Last active May 2, 2016 15:25
Bruteforces brnboot command mode password (required either broken firmware (unbootable) or manual resets)
#!/usr/bin/env python2
import time
import serial
class PasswordGen(object):
def __init__(self):
self.charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
self.cur_pw = [0 for i in range(16)]
self.cur_i = 0
def restore(self, pw):
@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 / remove_br_wrapper.sh
Created September 8, 2016 15:33
Removes toolchain-wrapper added by recent versions of Buildroot
#!/bin/bash
if [ ! -f toolchain-wrapper ]; then
echo "Not a bin folder or wrapper already removed"
exit 1
fi
echo ":: Replacing symlinks to toolchain-wrapper"
for file in *; do
@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)