Skip to content

Instantly share code, notes, and snippets.

Avatar

sfan5

  • Germany
View GitHub Profile
@sfan5
sfan5 / imgbump.py
Created Feb 15, 2014
Adds a bumpmap-like effect to images (works best on low-res [~16x16] textures).
View imgbump.py
#!/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 Mar 12, 2014
Generates an image with an EAN-8 barcode
View gen_ean8.py
#!/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 Aug 29, 2015
does stuff using C++
View packetgen.cpp
#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 / run-as.c
Last active Aug 29, 2015
A simple Android run-as replacement when the preinstalled one won't work (I'm looking at you Android 4.2)
View run-as.c
#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 / mediacrush.py
Last active Aug 29, 2015
MediaCrush URL Info Module for phenny
View mediacrush.py
import re
import web
import json
mc_re = r'.*https?:\/\/(?:www\.|cdn\.)?mediacru\.sh\/([a-zA-Z0-9_-]{12})(?:\.webm|\.mp4|\.ogv|\.jpg|\.png|\.gif)?.*'
def durationconvert(inp):
secs = int(inp)
hrs = secs // 3600
secs -= 3600*hrs
@sfan5
sfan5 / bfi.rs
Last active Aug 29, 2015
Brainfuck Interpreter in Rust
View bfi.rs
use std::error::Error;
use std::fs::File;
use std::io::Read;
use std::io::Write;
use std::io;
use std::env;
fn write_u8<T: io::Write>(mut obj: &mut T, x: u8) {
let mut a: [u8; 1];
@sfan5
sfan5 / bf2c.py
Created Aug 31, 2014
Compiles Brainfuck to C || Warning: This not the best code I have written.
View bf2c.py
#!/usr/bin/env python2
import sys
def multstr(n,st):
o = ""
for i in range(0,n):
o += st
return o
def unpack_opts(s, t):
@sfan5
sfan5 / share-network.sh
Last active Aug 29, 2015
Allows you to easily share your internet connection with a machine connected via LAN (act as a router)
View share-network.sh
#!/bin/bash -e
if [ $# -ne 2 ]; then
echo "Usage: share-network.sh <internal interface> <external interface>"
exit 1
fi
sudo whoami >/dev/null # Make sudo cache the password
mkdir share-network$$
cd share-network$$
cat >dnsmasq.conf <<HEREDOC
@sfan5
sfan5 / record.sh
Created Sep 8, 2014
Records a window
View record.sh
#!/bin/bash -e
CRF=21
ABITRATE=256k
FILENAME=recording`date +%d-%m-%Y_%H.%M`.mp4
CMD=`xwininfo | awk '/Width/{printf"ffmpeg -f x11grab -s "$2"x"}/Height/{printf$2" -i '$DISPLAY'"}/Corners/{gsub(/\+/,",",$2);sub(/,/,"+",$2);print$2" -f alsa -i pulse -c:v libx264 -preset ultrafast -crf 0 -c:a copy"}'`
CMD="${CMD} -vf scale='iw+mod(iw,2):ih+mod(ih,2)' _tmp_record.nut"
# -vf scale='iw+mod(iw,2):ih+mod(ih,2)' makes sure the width and height are diviseable by 2 (needed for libx264)
echo "Press ^C to stop recording"
@sfan5
sfan5 / desmume-wav.patch
Created Mar 14, 2015
Sound recording directly from DeSmuME (w/o any UI, it just does it)
View desmume-wav.patch
--- 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>
You can’t perform that action at this time.