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 shelve | |
| import time | |
| from collections import defaultdict, deque | |
| from functools import lru_cache | |
| from pprint import pprint | |
| class FastaIndex(object): | |
| ''' |
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 random import random, choice | |
| from multiprocessing import Pool | |
| from time import sleep | |
| from pprint import pprint | |
| def call_api(who, other_subscribers): |
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 __future__ import print_function | |
| # that -- and it has to be at the top -- makes py2 use print like py3 | |
| import random | |
| from random import randint | |
| import time | |
| from collections import namedtuple | |
| Spell = namedtuple('Spell', ['name', 'damage_min', 'damage_max']) |
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 MinHeap(): | |
| def __init__(self, sourceCollection = None): | |
| self._heap = list() | |
| self._size = 0 | |
| for item in sourceCollection: | |
| self.add(item) | |
| def peek(self): | |
| if self.isEmpty(): |
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 json | |
| import logging | |
| from collections import namedtuple | |
| from pprint import pprint | |
| Record = namedtuple('CustomerRecord', ['first', 'last', 'id', 'phone', 'color']) | |
| logging.basicConfig() |
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 json | |
| import sys | |
| def main(argv): | |
| # show off some use of the context manager using `with` | |
| in_file = open("data.in", 'r') #opening our input file | |
| #in_file = open(argv[0], 'r') #input file on command line | |
| result_file = open("result", 'w') #Opening our output file |
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 | |
| from string import ascii_lowercase | |
| # a bit of a hacky solution to change the board names to be a bit better | |
| from boards import easy as easy_board | |
| from boards import hard as hard_board | |
| WORD_FILENAME = 'wordlist.txt' |
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 threading | |
| import time | |
| from collections import defaultdict | |
| class Effect(object): | |
| ''' | |
| class styled decorator because you need to have some way for the | |
| effects.starter to find the effects.stopper |
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 os | |
| import time | |
| from pprint import pprint | |
| BH = 40 | |
| BW = 40 | |
| ALIVE = 'X' | |
| DEAD = '.' |
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 cmd | |
| from pprint import pprint | |
| class Calculator(cmd.Cmd): | |
| def get_floats(self, line, number = None): | |
| ''' get number of floats from line | |
| if number is None, don't worry about the number returned | |
| if cannot float anything in the line it prints help and raises |