Skip to content

Instantly share code, notes, and snippets.

View maxcountryman's full-sized avatar
🦀

Max Countryman maxcountryman

🦀
View GitHub Profile
@maxcountryman
maxcountryman / caesar.py
Created November 8, 2010 20:58
Extremely simple Caesar cipher
import argparse
parser = argparse.ArgumentParser(description='Shift a string n chars based on step.')
parser.add_argument('--shift', help='shift a string of text')
parser.add_argument('--deshift', help='deshift a string of text')
parser.add_argument('--steps', type=int)
args = parser.parse_args()
steps = args.steps
backend primary {
.host = "127.0.0.1";
.port = "8080";
}
acl purge {
"127.0.0.1";
}
sub vcl_recv {
@maxcountryman
maxcountryman / kaa.py
Created November 15, 2010 01:35
A very simple non-blocking IRC bot using gevent
import gevent
from gevent import socket, queue
from gevent.ssl import wrap_socket
import logging
logger = logging.getLogger('irc')
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
⨀_⨀
⨂_⨂
(/◔ ◡ ◔)/
°ﺑ°
(¬_¬)
(´・ω・`)
(ʘ_ʘ)
(ʘ‿ʘ)
(๏̯͡๏ )
(◕_◕)
@maxcountryman
maxcountryman / queue.py
Created November 20, 2010 22:57
Custom Queue, all credit goes to Pedro! (just posting here for archiving purposes, this is *not* my script)
#!/usr/bin/env python2
import sys
import pickle
class QueueError(Exception):
pass
class Queue:
def __init__(self, *args):
@maxcountryman
maxcountryman / brainfuck_converter.py
Created December 16, 2010 00:32
Converts a string to Brainfuck
def string_process(s):
cs = map(ord, '{0}'.format(s))
clist = ''.join(['>' + c for c in
['+' * n for n in
[(i-i%10)/10 for i in cs]]])
cell_zero = ''.join(['<' * n for n in [len(cs)]]) + '-'
@maxcountryman
maxcountryman / tabula.py
Created December 17, 2010 21:22
Simple tabula recta generator, using Python's random module.
import string, random
print ' '+' '.join(string.ascii_uppercase) + '\n'+' +'+''.join(['-' for x in range(52)])+'\n'+''.join([chr(x)+' | '+' '.join([chr(random.randrange(33,127)) for x in range(26)])+'\n' for x in xrange(65,91)])
@maxcountryman
maxcountryman / tabula_recta.py
Created December 18, 2010 01:42
Generates a string from a randomly generated tabula recta that is hopefully secure.
#! /usr/bin/env python
import sys
import json
import argparse
from string import uppercase, digits, letters, punctuation
from random import SystemRandom
FULL_MAP = letters + digits + punctuation
@maxcountryman
maxcountryman / weasel.py
Created January 5, 2011 22:01
A weasel program
import random, string, time
TEST = False
def timeit(func, *args):
'''Simple timeit wrapper for functions.'''
start = time.time()
func(*args)
elapsed = time.time() - start
@maxcountryman
maxcountryman / weasel_redux.py
Created January 6, 2011 22:14
Weasel program redux
import string, random
CHARS = string.uppercase + ' '
PROGENY = 100
RATE = 0.05
TARGET = 'METHINKS IT IS LIKE A WEASEL'
genotype = lambda s : [random.choice(s) for x in xrange(len(TARGET))]
phenotype = ''