Skip to content

Instantly share code, notes, and snippets.

View gist:e787d2b2348bb854cd67
#!/usr/bin/env python
# encoding: utf-8
import argparse
import os
import sys
from jinja2 import Template
parser = argparse.ArgumentParser(description='µ template')
View gist:8b88f834ae2493e5f57a
import socket
import struct
def ip_to_long(ip):
return struct.unpack('!L', socket.inet_aton(ip))[0]
def subnet_match(ip, subnet):
lsubnet = ip_to_long(subnet)
return lsubnet == (ip_to_long(ip) & lsubnet)
@athoune
athoune / Dockerfile
Last active Aug 29, 2015
Building wp-cli
View Dockerfile
FROM debian:wheezy
RUN apt-get -y update
RUN apt-get -y upgrade
RUN apt-get -y install ca-certificates wget fakeroot
WORKDIR /tmp
ADD https://raw.githubusercontent.com/wp-cli/wp-cli/master/utils/wp-cli-updatedeb.sh /tmp/
RUN /bin/bash wp-cli-updatedeb.sh
View gist:cab5efe261dc05c8186e
docker rm `docker ps -f status=exited -q`
View gist:0088f0ea3356d13c42ef
var casper = require("casper").create({
verbose: true,
logLeval: "debug",
timeout: 5000,
onTimeout: function() {
casper.echo("oups Timeout", arguments);
}
});
var args = casper.cli.args;
@athoune
athoune / gist:a39ae465c86d92e3e01b
Created Feb 24, 2015
Reading wp options from sql dump
View gist:a39ae465c86d92e3e01b
#!/usr/bin/env python
import sqlparse
from sqlparse.sql import Comment, Identifier, Parenthesis
from phpserialize import loads, phpobject
f = open('dump-no-contents.sql', 'r')
for line in sqlparse.split(f):
p = sqlparse.parse(line)[0]
if type(p.tokens[0]) == Comment:
@athoune
athoune / gist:0bdb2fcfad82a57cd22a
Created Mar 10, 2015
Reading auditd events while testing apparmor
View gist:0bdb2fcfad82a57cd22a
#!/usr/bin/env python
import socket
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.connect('/var/run/audispd_events')
def read(s):
@athoune
athoune / helloworld.py
Last active Aug 29, 2015
Chronology monkeypatching for nameko
View helloworld.py
import timeit
import json
import eventlet
from nameko.rpc import Rpc, RpcProxy
q = eventlet.Queue()
def read_events(q):
with open('timing.log', 'w') as l:
@athoune
athoune / header.py
Created Apr 30, 2015
Find plugins in a Wordpress folder
View header.py
#!/usr/bin/env python
import re
import glob
import os.path
GARBAGE = re.compile("^(\s|[*#])+")
def headers(lines, keys=["Plugin Name", "Plugin URI", "Version", "Author",
"License", "Author URI", "Description", "Network"]):
View gist:635b01795cb8e399fa9c
import requests
import json
s = requests.Session()
r = s.get('http://localhost:3000/login')
print r
r = s.post('http://localhost:3000/login',
data=json.dumps(dict(user="admin", email="", password="admin")),