Skip to content

Instantly share code, notes, and snippets.

View waawal's full-sized avatar

Daniel Waardal waawal

View GitHub Profile
---
- hosts: all
user: vagrant
sudo: yes
tasks:
- name: update apt
apt: update_cache=yes cache_valid_time=86400
- name: install base packages
@waawal
waawal / plugin.py
Created October 30, 2012 12:14 — forked from davidyang/plugin.py
plugin.py
#!/usr/bin/env python
"""
Copyright 2011 William Dawson
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@waawal
waawal / gist:2250315
Created March 30, 2012 09:28 — forked from davidwtbuxton/gist:2219990
Memo-ize decorator that makes classes into singleton factories
# Based on
# http://wiki.python.org/moin/PythonDecoratorLibrary#Memoize
class memoized(object):
"""Decorator that caches a function's return value each time it is called.
If called later with the same arguments, the cached value is returned, and
not re-evaluated.
"""
def __init__(self, func):
@waawal
waawal / udpserver.py
Created January 29, 2012 03:54 — forked from pipoket/udpserver.py
UDP server implementation for gevent. Copied from http://code.google.com/p/gevent/issues/detail?id=50
# Copyright (c) 2009-2010 Denis Bilenko. See LICENSE for details.
"""UDP/SSL server"""
import sys
import errno
import traceback
from gevent import socket
from gevent import core
from gevent.baseserver import BaseServer
@waawal
waawal / redisdns.py
Created November 30, 2011 12:39
Python DNS server with Redis backend
#!/usr/bin/env python
# A naive dns server with a Redis backend
# Set keys in Redis you want to be authoritative for (set google.com. 127.0.0.1)
# Tip: Use Redis's ttl functions to have temporary names
# Currently only does A records, feel free to fix that
#
# Licensed under the PSF License
# Thanks to: http://code.activestate.com/recipes/491264-mini-fake-dns-server/
# Author: @Kaerast <alice@kaerast.info>
@waawal
waawal / txredns.py
Created October 6, 2011 12:29 — forked from fcoury/txredns.py
Python/Twisted/Redis backed DNS server.
# Python/Twisted/Redis backed DNS server - resolves from NAME to IP addrs
# fallback to google or any other DNS server to resolv domains not present on Redis
# to set a new domain on redis, just issue a SET domain.tld ip_addr
# run with twistd -ny txredns.tac
# gleicon 2011
from twisted.names import dns, server, client, cache
from twisted.application import service, internet
from twisted.internet import defer
from twisted.python import log
@waawal
waawal / gDNS.py
Created October 3, 2011 17:15 — forked from gleicon/gDNS.py
gevent/dnslib/redis based DNS server
# dns server using dnslib and gevent
# based on https://bitbucket.org/paulc/dnslib/src/80d85555aae4/src/server/gevent_server.py
# set the key as
# set IP:name ip_addr
# set TXT:name txtfield
# fallback on gevent's dns resolver
# gleicon 2011
import gevent