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 | |
from multiprocessing import Pool | |
NUM_PROCESSES = 4 | |
ALLOWED_EXTENSION = '.txt' | |
NEW_EXTENSION = '.reversed.txt' | |
OUTPUT_DIR = os.path.join(os.getcwd(), 'output') | |
def processFile(file): | |
# process a file, delegated over multiple processes |
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 calendar | |
from datetime import datetime | |
import types | |
import json | |
from functools import wraps | |
def convert_arg(type_name, value): | |
converter = None | |
if not isinstance(type_name, basestring): | |
converter = type_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
from mongoalchemy.fields import DocumentField, StringField | |
from mongoalchemy.session import Session | |
from mongoalchemy.query import BadQueryException, BadResultException | |
from mongoalchemy.query_expression import QueryField | |
from mongoalchemy.document import DocumentMeta | |
from pymongo.errors import DuplicateKeyError | |
from pytz import utc |
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
request = require 'request' | |
lastLunches = '' | |
module.exports = (callback) -> | |
request { | |
url: "http://www.urbanspoon.com/api/ispin?p=1&n=7003&r=#{lastLunches}&l=70&v=6f" | |
}, (err, msg, data) -> | |
fields = (data.split '\t') | |
restaurantID = fields[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 requests, json, string, os | |
chars = string.ascii_lowercase | |
random_crap = ''.join(chars[ord(x) % len(chars)] for x in os.urandom(16)) | |
# Auth | |
credentials = {'user': 'testapiuser', 'password': 'test1234'} | |
request_url = "https://www.openlearning.com/json/auth" | |
response = requests.post(request_url, data=credentials) | |
token = response.cookies["auth_token"].replace('"', '') |
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 tornado import web, ioloop, escape | |
import hmac, hashlib | |
SECRET = 'jGW7UPn8T1kpuNP1Op79YIL4Th4a5Cduebgta4riFE2zcAWAmhZToDmevmr4iLfO' | |
def constant_time_compare(val1, val2): | |
""" | |
Returns True if the two strings are equal, False otherwise. | |
The time taken is independent of the number of characters that match. |
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
.turquoise.background { | |
background-color: #1ABC9C; | |
} | |
.turquoise.text { | |
color: #1ABC9C; | |
} | |
.turquoise.border { | |
border-color: #1ABC9C; | |
} |
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
<canvas></canvas> | |
<script> | |
var L, M, Vect, v; | |
M = { | |
TAU: Math.PI * 2, | |
vary: function(amt) { | |
return 2 * amt * (Math.random() - 0.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
<!DOCTYPE html> | |
<head> | |
<script> | |
var start_indicator = 'START'; | |
var lineNum = 0; | |
var render = function(newData) { | |
var content = ''; | |
newData = newData.replace(/^\s+|\s+$/g, ''); | |
if (newData === '') return ''; | |
var lines = newData.split('\\n'); |
OlderNewer