Skip to content

Instantly share code, notes, and snippets.

@tehmaze
tehmaze / vmdump.sh
Created July 31, 2011 16:37
tcpdump for VMWare Fusion
#!/bin/bash
if echo ${1} | grep -q '^vmnet[0-9]$'; then
ERRCOUNT='0'
PIDSNIFF='0'
PIDTDUMP='0'
CAPINTF="${1}"
CAPFILE="$(mktemp -t capture)"
@tehmaze
tehmaze / try_connect_ssh.sh
Created July 13, 2011 10:14
zsh/bash "command not found" handler that will use ssh if $1 resolves
#
# _______
# ____________ _______ _\__ /_________ ___ _____
# | _ _ \ _ | ____\ _ / | |/ _ \
# | / / / / | | | /___/ _ | | / /
# |___/___/ /___/____|________|___ | |_| |___|_____/
# \__/ |___|
#
#
# Put this in your ~/.zshrc or ~/.bashrc:
@tehmaze
tehmaze / check-key.sh
Created July 10, 2011 17:32
OpenVPN Yubikey authentication
#! /bin/bash
# _______
# ____________ _______ _\__ /_________ ___ _____
# | _ _ \ _ | ____\ _ / | |/ _ \
# | / / / / | | | /___/ _ | | / /
# |___/___/ /___/____|________|___ | |_| |___|_____/
# \__/ |___|
#
# (c) 2011 Wijnand Modderman-Lenstra <maze@pyth0n.org>
# MIT License
@tehmaze
tehmaze / ansi.py
Created May 26, 2011 15:17
ANSI Screen Rendition
#! /usr/bin/env python
'''
=======================
ANSI Screen Rendition
=======================
Library to help you use ANSI graphics on text terminals, featuring
cursor movement and color support.
@tehmaze
tehmaze / hexdump.py
Created February 13, 2011 16:23
Dump data streams
#! /usr/bin/env python
#
# _______
# ____________ _______ _\__ /_________ ___ _____
# | _ _ \ _ | ____\ _ / | |/ _ \
# | / / / / | | | /___/ _ | | / /
# |___/___/ /___/____|________|___ | |_| |___|_____/
# \__/ |___|
#
#
@tehmaze
tehmaze / jsonproxy.py
Created February 2, 2011 23:53
JSON serializer that can proxy non-standard Python types
import json
import datetime
try:
import iso8601
except ImportError:
iso8601 = None
class FancyJSONEncoder(json.JSONEncoder):
_registry = {}
@tehmaze
tehmaze / bitlair.py
Created January 29, 2011 16:01
bitlair.nl logo
#! /usr/bin/python
#
# compile logo:
#
# user@bitlair ~$ python bitlair.py > bitlair.svg
# user@bitlair ~$ convert bitlair.svg bitlair.png
# user@bitlair ~$ aplay tada.wav
#
LOGO = '''
@tehmaze
tehmaze / ternary.py
Created January 9, 2011 21:59
Python Ternary operator
class Ternary(object):
'''
Ternary-ish emulation, it looks like C-style ternary operator::
x = a ? b : c
In Python we would write::
>>> x = a and b or c
@tehmaze
tehmaze / singleton.py
Created January 9, 2011 21:57
Singleton Class decorator
def singleton(cls):
instances = {}
def instance():
if cls not in instances:
instances[cls] = cls()
return instances[cls]
return instance
@tehmaze
tehmaze / Ticker.Twitter.js
Created January 9, 2011 14:16
MooTools Twitter ticker based on the JSONP protocol
/*
* This requires https://gist.github.com/771026
*/
var Ticker = new Class({
Implements: [Options],
options: {
delay: 5000