Skip to content

Instantly share code, notes, and snippets.

@mdeous
mdeous / README.txt
Created July 22, 2012 18:46
IPtables Basic Configuration
The rules file should be copied to "/etc/iptables/iptables.rules".
The startup script should be copied to "/etc/init.d/iptables", and then the "update-rc.d iptables defaults"
command should be run to enable it on system startup.
@mdeous
mdeous / threaded_downloader.py
Created July 17, 2011 14:52
multithreaded file download
# -*- coding: utf-8 -*-
import os
from Queue import Queue
from threading import Thread
class FileDownloader(Thread):
"""Threaded file downloader."""
def __init__(self, infos_tuple):
@sbz
sbz / hexdump.py
Created July 13, 2011 13:04
hexdump implementation in Python
def hexdump(src, length=16):
FILTER = ''.join([(len(repr(chr(x))) == 3) and chr(x) or '.' for x in range(256)])
lines = []
for c in xrange(0, len(src), length):
chars = src[c:c+length]
hex = ' '.join(["%02x" % ord(x) for x in chars])
printable = ''.join(["%s" % ((ord(x) <= 127 and FILTER[ord(x)]) or '.') for x in chars])
lines.append("%04x %-*s %s\n" % (c, length*3, hex, printable))
return ''.join(lines)
@rwilcox
rwilcox / installing_python_packages_programatically.py
Created December 26, 2010 17:32
How to use PIP to install Python packages programmatically.py
#!/usr/bin/env python
"""
PIP can stand for PIP Installs packages Programmatically, too!
(and here's how)
Requires:
* Python 2.6 or higher (for print-as-a-function)
* PIP 0.8.2
"""