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
random_string = "".join(random.choice(string.hexdigits + string.digits) for r in [i for i in range(16)]) |
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 Image | |
import urllib | |
import StringIO | |
from math import log, exp, tan, atan, pi, ceil | |
EARTH_RADIUS = 6378137 | |
EQUATOR_CIRCUMFERENCE = 2 * pi * EARTH_RADIUS | |
INITIAL_RESOLUTION = EQUATOR_CIRCUMFERENCE / 256.0 | |
ORIGIN_SHIFT = EQUATOR_CIRCUMFERENCE / 2.0 |
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 random | |
import string | |
print("".join([random.choice(string.ascii_letters + string.digits + string.punctuation) for i in range(64)])) |
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 twitter | |
TWITTER_CONSUMER_KEY = 'XXX' | |
TWITTER_CONSUMER_SECRET = 'XXX' | |
TWITTER_ACCESS_TOKEN_KEY = 'XXX' | |
TWITTER_ACCESS_TOKEN_SECRET = 'XXX' |
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
class AttrDict(dict): | |
""" | |
Convert a dict to an object. | |
""" | |
def __init__(self, new_dict): | |
self.__dict__.update(new_dict) | |
for key, val in new_dict.items(): | |
if isinstance(val, dict): | |
self.__dict__[key] = AttrDict(val) |
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
# add homebrew executables to bash | |
export PATH=/usr/local/bin:$PATH | |
# bash prettify | |
export CLICOLOR=1 | |
export LSCOLORS=GxFxCxDxBxegedabagaced | |
# git bash completion via brew | |
if [ -f `brew --prefix`/etc/bash_completion ]; then | |
. `brew --prefix`/etc/bash_completion |
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 | |
import sys | |
def fix_case(name): | |
splitname = name.split() | |
return " ".join([n.lower().capitalize() for n in splitname]) | |
def extract(file_path): |
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
MAX_DIR_SIZE = 100_000 | |
REQUIRED_SPACE = 0 | |
def calculate_deletable(file_system): | |
total = 0 | |
for v in file_system.values(): | |
if isinstance(v, int): | |
total += v if v <= MAX_DIR_SIZE else 0 | |
if isinstance(v, dict): |
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 functools import reduce | |
from itertools import chain | |
def determine_visibility(input): | |
matrix = [[int(x) for x in b] for b in input] | |
def look_up(current_position): | |
x, y = current_position | |
return [matrix[i][x] for i in reversed(range(y))] |
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 logging | |
import multiprocessing | |
import sys | |
import time | |
logger = logging.getLogger(__name__) | |
multiprocessing.set_start_method('fork') | |
OlderNewer