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
# SCREW YOU CONDITIONALS | |
def fizzbuzz(n): | |
fizzes = [1, 0, 0] | |
buzzes = [2, 0, 0, 0, 0] | |
words = [None, "Fizz", "Buzz", "FizzBuzz"] | |
for i in range(1, n): | |
words[0] = i | |
print(words[fizzes[i%3] + buzzes[i%5]]) |
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
# Hypothetical win condition for a hangman game called 'words with fiends' | |
if guess == answer: | |
print("You guessed the right answer! May all your children be blessed from here until eternity.") | |
else: | |
print("Words fail me, as they have clearly failed you. Begone from my sight.") |
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
analysis_mode = get_mode_from_input() | |
if analysis_mode == 1: | |
# Do Pearson correlation | |
data = load_data() | |
elif analysis_mode == 2: | |
# Do Spearman rank | |
data = load_data() | |
elif analysis_mode == 3: | |
# Do a literature correlation lookup |
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 tweepy | |
import sys | |
while True: | |
line = raw_input("> ") | |
tokens = line.split() | |
if not tokens: | |
continue | |
command = tokens[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
from flask import Flask, request, session, g, redirect, url_for, \ | |
abort, render_template, flash | |
import tweepy | |
SECRET_KEY = 'development key' | |
DEBUG = True | |
app = Flask(__name__) | |
app.config.from_object(__name__) |
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 sys | |
import random | |
import puppies | |
class CentralCorridor(object): | |
def play(self): | |
print "Hey guys this is the central corridor. Neat, huh?" | |
your_input = raw_input("> ") | |
if your_input == "death": |
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 MultipartPostHandler(urllib2.BaseHandler): | |
handler_order = urllib2.HTTPHandler.handler_order - 10 # needs to run first | |
def http_request(self, request): | |
data = request.get_data() | |
if data is not None and type(data) != str: | |
v_files = [] | |
v_vars = [] | |
try: |
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
def format(filename, class_type): | |
"""Creates list of names from file ordered by name length""" | |
f = open(filename) | |
file_list = f.read().split() | |
f.close() | |
person_list = [] | |
for person in file_list: | |
person_list.append(class_type) | |
person_list.sort(key = lambda p: p.length) |
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 Person(object): | |
@classmethod | |
def format(cls, filename): | |
f = open(filename) | |
file_list = f.read().split() | |
f.close() | |
person_list = [] | |
for person in file_list: | |
person_list.append(cls(person)) | |
person_list.sort(key = lambda p: p.length) |
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
def match(m, p): | |
"""Matches each player with their optimal mentor pair""" | |
pairs = [] | |
total_score = 0 | |
while m: | |
mentor = m.pop() | |
player = p.pop() | |
score = mentor.score(player) | |
total_score += score | |
pair = Pair(player, mentor, score) |
OlderNewer