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 datetime | |
import sys | |
import time | |
from subprocess import check_output | |
try: | |
filename = sys.argv[1] | |
except IndexError as e: | |
print "Must specify a filename." | |
sys.exit(1) |
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
class AdminFieldPopulator(admin.ModelAdmin): | |
""" | |
Wrapper around ModelAdmin that exposes all of a Model's fields in admin ui | |
""" | |
def __init__(self, model, admin_site): | |
super(AdminFieldPopulator, self).__init__(model, admin_site) | |
self.list_display = [field.name for field in model._meta.fields] |
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 rest_framework.routers import DefaultRouter | |
class RouterCombiner(DefaultRouter): | |
""" | |
Extends `DefaultRouter` class to add a method for extending url routes | |
from another router. | |
Allows for app-specific url definitions to stay inside their own apps. | |
""" |
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 itertools | |
import sys | |
def spinner(granularity): | |
"""Wraps a function in an ASCII spinner display loop. granularity | |
represents the number of times the function should be called | |
before moving the spinner.""" | |
spinner_chars = itertools.cycle("\|/-") | |
def make_spinner(f): | |
calls = {'x': 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
__author__ = 'scott' | |
with open('massachusetts_municipalities.txt', 'r') as inf, open('interleaved_list2.txt', 'w') as out: | |
A,B,C =[],[],{} | |
A += [item.strip() for item in inf] | |
for item in A: | |
if not item[0] in C: C[item[0]] = [] | |
C[item[0]].append(item) | |
B += [C[key] for key in sorted(C)] | |
while B: | |
if [] in B: B.remove([]) |
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 pifacedigitalio as pfio | |
import time,sys, threading, pickle | |
pifacedigital = pfio.PiFaceDigital() | |
pfio.init() | |
#Solenoid LOW | |
pfio.digital_write(5, 1) | |
time.sleep(.1) |
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 pifacedigitalio as pfio | |
import time,sys, threading, pickle | |
pifacedigital = pfio.PiFaceDigital() | |
pfio.init() | |
#Blink LED to let user know they can enter knock codes | |
def blink_LED(PIN): | |
while 1: | |
p = PIN |
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 pifacedigitalio as pfio | |
import time,sys, threading | |
pifacedigital = pfio.PiFaceDigital() | |
pfio.init() | |
#Blink LED to let user know they can enter knock codes | |
def blink_LED(PIN): | |
while 1: | |
p = PIN |
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
# Scott Ouellette | |
# Brainfuck interpreter w/ optimizations | |
import sys as s | |
import time,re | |
def parser(code): | |
open_brack = [] # contains indexes of open brackets that are found | |
loop = {} # dictionary mapping idx of open brackets to closed ones |
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 nltk,re,os | |
from nltk.corpus import wordnet as wn | |
#Lossy text compression using a thesaurus | |
print "File size originally: " , float(os.path.getsize('Sample.txt')) / 1048576, "MB" | |
with open('Sample.txt','r') as f, open('Output.txt', 'w+') as O: | |
for line in f: | |
for word in line.split(): | |
punctuation = [] | |
l = [] |
NewerOlder