Skip to content

Instantly share code, notes, and snippets.

View schlamar's full-sized avatar

Marc Schlaich schlamar

View GitHub Profile
@schlamar
schlamar / rc4.py
Created June 20, 2012 07:56
RC4 encryption
from hashlib import sha1
from itertools import islice, imap
from operator import xor, eq
DROP_N = 1536
# drop 1536 bytes is adviced in RFC 4345
# http://tools.ietf.org/html/rfc4345
@schlamar
schlamar / gist:2652543
Created May 10, 2012 11:34
Find the root document of a given LaTeX file
import glob
import os
import re
MAIN_PATTERN = re.compile(r'\\begin{document}')
def is_main(tex_file):
with open(tex_file) as fobj:
for line in fobj:
@schlamar
schlamar / ssdp.py
Created April 20, 2012 12:45
Simple Python SSDP discovery
import socket
import struct
import sys
from httplib import HTTPResponse
from BaseHTTPServer import BaseHTTPRequestHandler
from StringIO import StringIO
import gtk
import gobject
@schlamar
schlamar / processify.py
Last active June 11, 2024 12:46
processify
import os
import sys
import traceback
from functools import wraps
from multiprocessing import Process, Queue
def processify(func):
'''Decorator to run a function as a process.
Be sure that every argument and the return value