This file contains 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 numpy as np | |
from PIL import Image | |
import collections | |
colors = [ | |
(238,203,173), | |
(49,79,79), | |
(100,149,237), | |
(127,255,0), | |
(255,255,0), |
This file contains 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 | |
from pprint import pprint | |
FN = 'tmpdata.txt' | |
def write_csv(fn, lines = 4): | |
'''writes a csv with a header, total and lines lines inbetween''' | |
with open(fn, mode='w') as fh: |
This file contains 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 re | |
from pprint import pprint | |
def option1(fn): | |
'''the screwy quoting break the csv module, so we just have to do it ourselves''' | |
data = [] | |
with open(fn, mode='r') as fh: | |
for r in fh: |
This file contains 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 pprint import pprint | |
def check_int(x): | |
'''probably want to work out how to deal with floats as well''' | |
'''but this is just proof of concept''' | |
try: | |
int(x) | |
return True, x |
This file contains 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.path | |
from hashlib import md5 | |
from pprint import pprint | |
# spacing is a bit wacked, should be 4 spaces per tab | |
def get_files(): | |
# let's make these generators | |
for f in os.listdir('.'): |
This file contains 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 time | |
import collections | |
import itertools | |
import numpy as np | |
from pprint import pprint | |
from PIL import Image | |
This file contains 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 time | |
import collections | |
import itertools | |
import numpy as np | |
from pprint import pprint | |
from PIL import Image | |
This file contains 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 sqlite3 | |
from collections import namedtuple | |
EMP = namedtuple('EMP', ['first_name','last_name','badge','hours']) | |
def yes_no(query): | |
''' | |
this is a simple func to as a y/n question and get back a valid y/n | |
response | |
This file contains 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
""" | |
Trollcheckbot 1.1a is a reddit bot written by (utter novice) /u/tingmakpuk. | |
In theory, this bot will be summoned by a user responding to an exising comment using | |
a trigger phrase. The bot will report on the user who posted the parent comment: | |
Version 1.0: Replies with target username and comment karma. | |
Version 1.1: Replies with target username and comment karma. Makes a judgement. | |
Version 1.1a: Fixed signature and related bug | |
WIP -- Version 2.0 will log the work and not duplicate the effort. |
This file contains 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 random import randrange | |
class Player(object): | |
def __init__(self, who = 'you'): | |
self.score = 0 | |
self.who = who | |
def choose(self): | |
'''let's not make choice an instance variable, since it varies on each |
OlderNewer