This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from Crypto.Cipher import AES | |
from Crypto.Cipher import DES3 | |
def add_padding(message): | |
pad_len = 16 - (len(message) % 16) | |
message += (' ' * pad_len) | |
return message |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from lxml import objectify | |
tree = objectify.parse(tcx_file') | |
root = tree.getroot() | |
root.xpath('//ns:HeartRateBpm', namespaces={'ns': 'http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2'} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import argparse | |
import subprocess | |
import shlex | |
import sys | |
def compress_file(filename, level): | |
try: | |
cmd = shlex.split("gzip %s -c %s" % (level, filename)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
def divider(): | |
print '-'*40 | |
def width_str(width): | |
return "x%d" % (width) | |
gens = [1,2,3] | |
link_widths = [1,2,4,8,16,24,32] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fileinput | |
for line in fileinput.input(): | |
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
######################################################################### | |
# Script to clean up whitespace in source files. | |
# - Removes trailing whitespace at the end of lines | |
# - Converts tabs to spaces (4 spaces = 1 tab) | |
# | |
# Copyright 2013 Stephen Doyle | |
######################################################################### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = [1,2,2,3,4,4,5,6,5,7] | |
no_dups = list(set(data)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python -d | |
import argparse | |
from subprocess import call | |
def copyfile(src, dst): | |
call(["cp", src, dst]) | |
parser = argparse.ArgumentParser(description='Copy files from a list to a destination directory') | |
parser.add_argument('filelist', help="File containing list of filenames to copy") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Crypto.Cipher import AES | |
key='\x63\x5b\x76\xd1\x71\x5c\xdf\x2a\x69\x99\xc9\x0f\x3b\x23\x13\x02' | |
iv='\x4c\x84\x2e\x40\x8b\xb0\x73\x01\xe4\x64\x92\x94\xfa\x5b\x73\x0b' | |
obj = AES.new(key, AES.MODE_CBC, iv) | |
obj.decrypt(message) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From: http://www.noulakaz.net/weblog/2007/03/18/a-regular-expression-to-check-for-prime-numbers/ | |
def is_prime(n) | |
("1" * n) !~ /^1?$|^(11+?)\1+$/ | |
end |