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 / Dockerfile
Last active August 29, 2015 14:12
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
ADD /tmp/
RUN /bin/bash
athoune / gist:cab5efe261dc05c8186e
Created February 19, 2015 23:21
rm exited dockers
View gist:cab5efe261dc05c8186e
docker rm `docker ps -f status=exited -q`
athoune / gist:0088f0ea3356d13c42ef
Created February 21, 2015 21:05
Casper web screenshot
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 / gist:a39ae465c86d92e3e01b
Created February 24, 2015 09:45
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 / gist:0bdb2fcfad82a57cd22a
Created March 10, 2015 21:32
Reading auditd events while testing apparmor
View gist:0bdb2fcfad82a57cd22a
#!/usr/bin/env python
import socket
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
def read(s):
athoune /
Last active August 29, 2015 14:19
Chronology monkeypatching for nameko
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 /
Created April 30, 2015 15:16
Find plugins in a Wordpress folder
#!/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"]):
athoune / gist:635b01795cb8e399fa9c
Created May 18, 2015 10:09
Bootstraping Grafana 2
View gist:635b01795cb8e399fa9c
import requests
import json
s = requests.Session()
r = s.get('http://localhost:3000/login')
print r
r ='http://localhost:3000/login',
data=json.dumps(dict(user="admin", email="", password="admin")),