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 col(letters): | |
""" Convert column letters into zero-indexed number """ | |
letters = letters.lower() | |
num = 0 | |
for l in letters[:-1]: | |
num += (ord(l) - 96) * 26 | |
num += (ord(letters[-1]) - 96) | |
return num - 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
def haversine(lat1, lon1, lat2, lon2, miles=False): | |
phi1, phi2, dlat, dlon = map(radians, [lat1, lat2, lat2-lat1, lon2-lon1]) | |
radius = 6371 | |
if miles: | |
radius = 3956 | |
a = sin(dlat/2)**2 + cos(phi1) * cos(phi2) * sin(dlon/2)**2 | |
c = 2 * asin(sqrt(a)) | |
return radius * c |
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 itertools import combinations | |
class Generator(object): | |
def __init__(self, element): | |
self.elem = element | |
def __repr__(self): | |
return str(self.elem) + ' Generator' |
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 os | |
from Crypto.Cipher import _Blowfish | |
from struct import pack | |
def encrypt(infilepath, outfilepath, key): | |
""" Encrypt the specified file with the specified | |
key and output to the chosen output file.""" | |
size = os.path.getsize(infilepath) |