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 collections | |
import random | |
def gen_ngrams(letters, n=2): | |
ngram = collections.deque([None] * n, n) | |
for letter in letters: | |
ngram.append(letter) | |
yield tuple(ngram) | |
ngram.append(None) |
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
""" | |
Generate a stream of characters that look like rain drops. | |
""" | |
import random | |
import time | |
class Bullet(object): | |
def __init__(self, pos=0, char='*', speed=1): | |
self.pos = pos |
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 | |
def main(): | |
while True: | |
a, b = random.randint(1, 10), random.randint(1, 10) | |
expr = "{} + {}".format(a, b) | |
print "What is {}?".format(expr) | |
try: | |
given_answer = int(raw_input('> ')) |
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
""" | |
http://www.kongregate.com/games/feerik/eredan-arena | |
""" | |
import itertools | |
die = ['R', 'R', 'B', 'Y', 'S', 'S'] | |
sides = set(die) | |
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 json | |
from flask import Flask, request, url_for, jsonify | |
app = Flask(__name__) | |
with open('photos.json') as fp: | |
PHOTOS = json.loads(fp.read()) | |
with open('albums.json') as fp: |
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
#/usr/bin/ruby | |
require "cgi" | |
require "base64" | |
require "openssl" | |
require "digest/sha1" | |
require "uri" | |
require "net/https" | |
require "rexml/document" | |
require "time" |
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 urllib import quote | |
_OP_LEVEL_2 = {'+', '#'} | |
_OP_LEVEL_3 = {'.', '/', ';', '?', '&'} | |
OPERATORS = _OP_LEVEL_2 | _OP_LEVEL_3 | |
_RESERVED = ':/?#[]@' + '!$&\'()*+,;=' | |
class Token(object): |
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
""" | |
REST client over requests. | |
""" | |
import logging | |
import requests | |
logging.basicConfig(level=logging.INFO) | |
logger = logging.getLogger(__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
# Manual constructor injection | |
class Charlie: | |
pass | |
class Beta: | |
def __init__(self, charlie): | |
self.charlie = charlie | |
class Alpha: |
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
* OK Gimap ready for requests from 67.164.75.146 cz17mb41670502pac | |
x login [email protected] PASSWORD | |
* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH | |
x OK [email protected] Ceasar Bautista authenticated (Success) | |
x select Gregory | |
* FLAGS (\Answered \Flagged \Draft \Deleted \Seen $Phishing $NotJunk NotJunk $NotPhishing $Junk) | |
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen $Phishing $NotJunk NotJunk $NotPhishing $Junk \*)] Flags permitted. | |
* OK [UIDVALIDITY 619011903] UIDs valid. | |
* 69 EXISTS | |
* 0 RECENT |
NewerOlder