Skip to content

Instantly share code, notes, and snippets.

@meeuw
meeuw / vhost-local.site.conf
Created August 31, 2015 09:54
apache configuration for a local test site with hardcoded URLs
<VirtualHost *:80>
ServerName local.site
ProxyPass / http://local.site:81/ timeout=9999999
ProxyPassReverse / http://local.site:81/
RequestHeader unset Accept-Encoding
AddOutputFilterByType SUBSTITUTE text/html
Substitute s/www.site/local.site.nl/ni
Header edit Location ^http://www. http://local.
</VirtualHost>
import subprocess
import sys
import re
import json
def batch_execute(args):
print args[0]
return subprocess.check_output(
[
'mysql',
[branch]
autosetuprebase = always
[remote]
pushdefault = meeuw
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session, sessionmaker
from sqlalchemy import create_engine, MetaData, Column, Table
import sqlalchemy.dialects.mysql.base
import sqlalchemy.dialects.sqlite
dest_engine = create_engine('sqlite:////tmp/test.sqlite3', echo=True, encoding='utf8')
DestSession = sessionmaker(dest_engine)
<?php
function curl($opts)
{
$ch = curl_init();
foreach ($opts as $opt_key => $opt_value) {
if ($opt_key == CURLOPT_POSTFIELDS) {
$opt_value = http_build_query($opt_value);
curl_setopt($ch, CURLOPT_POST, 1);
}
curl_setopt($ch, $opt_key, $opt_value);
@meeuw
meeuw / pdfcolorprofile.sh
Created March 18, 2015 07:52
find and export color profile from pdf
pdf-parser.py -s ICCBased my.pdf
pdf-parser.py -o 21 -f -d 21.stream my.pdf
@meeuw
meeuw / group_sums.py
Created March 14, 2015 19:44
generate all combinations to a specified sum
def recurse(lst, c):
s = sum(lst)
if s > c:
return
if s == c:
print lst
return
for i in range(1, c+1):
if lst and lst[-1] < i: continue
recurse(lst+[i], c)
#!/usr/bin/env python
import radiotap as r, pcap
pc = pcap.pcap(name='/tmp/monitor.pcap')
while 1:
tstamp, pkt = pc.next()
off, radiotap = r.radiotap_parse(pkt)
off, pkt = r.ieee80211_parse(pkt, off)
if 'type' in pkt and pkt['type'] == 0 and 'subtype' in pkt and pkt['subtype'] == 4:
if pkt['data'][0] != '\x01':
print radiotap
#!/usr/bin/python
import json
table = 'table'
with open('output.csvdiff') as f:
diff = json.loads(f.read())
for added in diff["added"]:
print "INSERT INTO %s (%s) VALUES ('%s');" % (table, ", ".join(added.keys()), "', '".join(added.values()))
wget http://rdf.dmoz.org/rdf/content.rdf.u8.gz
zcat content.rdf.u8.gz |egrep -o 'r:resource="[^"]*'|cut -c13- > testurls
shuf testurls|head -n1000|xargs -n1 -P50 curl -m300 > /dev/null