Skip to content

Instantly share code, notes, and snippets.

@meeuw
meeuw / build_ntfs_ko.sh
Last active August 29, 2015 14:00
build the missing non-fuse ntfs kernel module, this is disabled because most distributions use ntfs-3g instead.
make -C /lib/modules/`uname -r`/build M=$PWD CONFIG_NTFS_FS=m CONFIG_NTFS_RW=y
@meeuw
meeuw / smtp.py
Last active August 29, 2015 14:01
script for a direct smtp test
import smtplib
import datetime
msg = {
'from': '[email protected]',
'to': '[email protected]',
'server': '127.0.0.1',
'body': '''Subject: test message
From: %(from)s
To: %(to)s
@meeuw
meeuw / doctrine2altertable.py
Created May 18, 2014 18:50
convert doctrine annotations to alter table / rename table sql
#!/usr/bin/python
import fileinput
import re
import json
with open('cols.json') as f: cols = json.load(f)
oldtablename = None
for line in fileinput.input():
if '@ORM\Table' in line:
m = re.match(r'.*Table\(name="([^"]*).*', line)
oldtablename = m.group(1)
@meeuw
meeuw / mysqldump2json.py
Created May 18, 2014 18:52
generate json dump from mysqldump
#!/usr/bin/python
import fileinput
import json
output = {}
for line in fileinput.input():
if line.startswith('CREATE TABLE'):
table = line.split('`')[1]
if line.startswith(' `'):
if not table in output: output[table] = {}
s = line[2:].split('`')
@meeuw
meeuw / socksl.sh
Created May 23, 2014 19:18
dynamic port forwards with openssh using the build-in socks proxy. for example: ssh remotehost -D 1080 & socksl.sh 1080 5901 127.0.0.1 5900 # acts like ssh -L 5901:127.0.0.1:5900 remotehost
socat TCP4-LISTEN:$2,reuseaddr,fork,bind=0.0.0.0 SOCKS:localhost:$3:$4,socksport=$1
@meeuw
meeuw / localsemodule.sh
Created May 26, 2014 19:02
generate selinux module's by using auseach and diffing output
#!/bin/bash
if [ -n "$2" ] ; then
ausearch -m avc -ts $2|audit2allow -m $1 > $1.tt.tmp
diff -ud $1.tt $1.tt.tmp
read
mv -f $1.tt.tmp $1.tt
fi
checkmodule -M -m $1.tt -o $1.mod
semodule_package -o $1.pp -m $1.mod
semodule -i $1.pp
<?php
$return = array(array(0,0,0),array(0,0,0),array(0,0,0));
switch ($argv[1]) {
case 1:
$return[1][1] = '1';
break;
case 5:
$return[0][2] = '1';
$return[2][0] = '1';
case 3:
@meeuw
meeuw / git-auto-merge.py
Last active November 16, 2015 20:10
Python script which reads commands from stdin to automatically merge (remote) branches, shows which branches are merged and shows which branches are available
#!/usr/bin/python2.7
import subprocess
import os
import json
import sys
import pygit2
FNULL = open(os.devnull, 'w')
#FNULL = sys.stdout
def status():
@meeuw
meeuw / csvdiff.py
Last active August 29, 2015 14:03
compare two (sorted) csv files and print differences
import sys
def mycmp(a, b):
if a.isdigit() and b.isdigit():
a = int(a)
b = int(b)
return cmp(a, b)
def cmpk(a, b, h):
for i in h:
<?php
/*
rm -f codecoverage.sqlite3
sqlite3 codecoverage.sqlite3 <<EOF
CREATE TABLE code_coverage(run integer, filename varchar(255), line integer);
CREATE TABLE run(dt datetime);
EOF
chown 1000:apache codecoverage.sqlite3
chmod 660 codecoverage.sqlite3
sqlite3 codecoverage.sqlite3 .dump