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
var SocketioModel = Backbone.Model.extend({ | |
// | |
constructor: function (attributes, options) { | |
options || (options = {}); | |
if (options.socket) this.socket = options.socket; | |
if (options.controller) this.controller = options.controller; | |
if (options.model_id) this.id = options.model_id; | |
Backbone.Model.apply(this, arguments); | |
}, |
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 freeze(obj): | |
""" | |
""" | |
def _freeze(obj): | |
def do_list(): | |
for i in obj: | |
yield _freeze(i) | |
def do_dict(): | |
for k, v in obj.items(): |
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 geopy.geocoders import MapQuest, OpenMapQuest, Nominatim | |
omapquest_api_key = "APIKEYHERE" | |
gm = MapQuest(api_key=omapquest_api_key, timeout=60) | |
gom = OpenMapQuest(api_key=omapquest_api_key, timeout=60) | |
gn = Nominatim(timeout=60) | |
loc = "611 West Holt Blvd., ontario, ca, 91762" |
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 time | |
import forme.validators.sec | |
import formencode | |
v = forme.validators.sec.HmacValidator(b'12345') | |
val = v.from_python(b'abcdef') | |
v.to_python(val) | |
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 as IT | |
def area_of_polygon(x, y): | |
"""Calculates the signed area of an arbitrary polygon given its verticies | |
http://stackoverflow.com/a/4682656/190597 (Joe Kington) | |
http://softsurfer.com/Archive/algorithm_0101/algorithm_0101.htm#2D%20Polygons | |
""" | |
area = 0.0 | |
for i in range(-1, len(x) - 1): | |
area += x[i] * (y[i + 1] - y[i - 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
// TODO: Encaps this and fancyScroll in function. | |
var currentObj = null; | |
var fancyScrolling = false; | |
function fancyScroll(ev, down) { | |
var scrollToOffset = 60, | |
scrollDuration = 500; | |
// Do nothing if we're already animating. | |
if (!$('body').is(':animated')) { |
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
var formError = function (options) { | |
/* | |
options expected: | |
input_el - $selector for input field | |
error_el - $selector for error div | |
hide_error_duration - Duration in ms to hide the error. | |
hide_error_animation_duration - Jesus... | |
*/ | |
var options = _.extend({}, options); |
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 logging | |
log = logging.getLogger(__name__) | |
import codecs | |
from subprocess import Popen, PIPE | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.nonmultipart import MIMENonMultipart | |
from email.mime.text import MIMEText |
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 | |
import base64 | |
import flask | |
import urllib.parse | |
import requests | |
app = flask.Flask(__name__) | |
APP_ID = "ID" | |
APP_SECRET = "SECRET" |
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 DataFile: | |
"""Handle a data file using pickle. | |
""" | |
def __init__(self, filepath, init_data={}): | |
"""Initialize or load a pickled data file. | |
""" | |
self.__filepath = filepath | |
self.data = init_data |