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 sys | |
def generate_sequence(size, N=3): | |
if size == 1: | |
return[[1]] | |
else: | |
accumulator = generate_sequence(size-1, N) | |
# First, increment the value of the array by 1 | |
next = list(accumulator[-1]) |
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 csv | |
file_names = [] # THE CSV FILES TO BE PROCESSED | |
def key_from_filename(filename): | |
table_name, _ext = filename.rsplit('.', 1) | |
_prefix, key = table_name.split("_", 1) | |
return key | |
def read_files(files=file_names): |
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 string | |
INVERSION = string.maketrans('0123456789abcdef', 'fedcba9876543210') | |
__all__ = ['COLOR_LOOKUP', 'COLOR_REVERSE', 'invert'] | |
# See http://www.w3.org/TR/css3-color/#svg-color for the W3C list | |
COLOR_LOOKUP = { | |
"aliceblue": "f0f8ff", | |
"antiquewhite": "faebd7", | |
"aqua": "00ffff", |
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
def encode(ip_address): | |
return reduce((lambda ip, part: (ip << 8) | int(part)), ip_address.split('.'), 0) | |
def decode(addr): | |
return '.'.join(map(lambda (bits, ip): str((ip >> bits) & 255), [(i*8, addr) for i in range(4)])[::-1]) | |
def test(): | |
TEST_IPS = ["0.0.0.0", "0.1.2.3", "1.1.1.1", "10.11.12.13", "127.0.0.1", "172.16.255.1", "192.168.1.1", "255.255.255.255"] | |
for test_subject in TEST_IPS: | |
print "Testing %s ..." % test_subject, |