Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / build-cubicsdr.sh
Created July 18, 2015 14:54
Builds CubicSDR (statically linked with liquid-dsp)
#!/bin/bash -e
CORES=4
OUTDIR=/tmp/cubicsdr_install
CUBICSDR_STABLE=1 # 1 for latest tagged version or 0 for git HEAD
[ -d CubicSDR ] && (cd CubicSDR && git pull) || git clone https://github.com/cjcliffe/CubicSDR
[ -d liquid-dsp ] && (cd liquid-dsp && git pull) || git clone https://github.com/jgaeddert/liquid-dsp
cd liquid-dsp
@sfan5
sfan5 / 0readme.txt
Last active August 29, 2015 14:24
Use CloudFlare ddos-protected sites from other programs (by going through nginx)
What you need:
* nginx
* dependencies to build CutyCapt (http://cutycapt.sourceforge.net/)
Steps:
* build CutyCapt with CutyCapt.patch applied and copy the executable somewhere
* install nginx and edit the config as outlined in nginx.conf
* change the paths to nginx, the nginx config and the patched cutycapt in renewcf.sh
* start nginx
* ensure that renewcf.sh runs every 55 minutes
@sfan5
sfan5 / parse.js
Last active March 20, 2016 16:14
Download all your fav'ed @catgirls_bot pictures and their original images (where possible)
// Go to https://twitter.com/favorites and scoll all the way until there are no more fav'd @catgirls_bot tweets
// maybe like this:
// window.temp=function(){window.scrollTo(0,document.body.scrollHeight);setTimeout(window.temp,750)};window.temp()
// window.temp=function(){}; // stop like this
var _q = document.getElementById('stream-items-id');
var _i;
var _o = [];
for(_i = 0; _i < _q.children.length; _i++) {
var _e = _q.children[_i];
if(_e.children[0].getAttribute('data-screen-name') == 'catgirls_bot') {
@sfan5
sfan5 / desmume-wav.patch
Created March 14, 2015 21:27
Sound recording directly from DeSmuME (w/o any UI, it just does it)
--- desmume-0.9.10/src/sndsdl.cpp.orig 2013-11-28 01:37:18.797021001 +0100
+++ desmume-0.9.10/src/sndsdl.cpp 2015-03-14 22:24:04.184578448 +0100
@@ -16,6 +16,7 @@
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>