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 | |
import urllib | |
import httplib | |
import re | |
from tornado import httpclient | |
from tornado.web import asynchronous, RequestHandler | |
from tornado.auth import OAuth2Mixin | |
from tornado.gen import coroutine | |
from tornado.concurrent import return_future |
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 FloydWarshall(object): | |
def __init__(self, file_): | |
nodes = file_.read().splitlines() | |
file_.close() | |
self.get_graph(nodes) | |
self.len_ = len(self.nodes) | |
self.create_fw_matrix() | |
def get_graph(self, nodes): |
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 | |
from igraph import * | |
from priodict import priorityDictionary | |
def dijkstra(graph, source, target=None): | |
distances = {} | |
predec = {} | |
queue = priorityDictionary() | |
queue[source] = 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
# uglifyJS2 - https://github.com/mishoo/UglifyJS2 | |
# lessc - https://github.com/less/less.js | |
STYLES=$(pwd)/PATH/TO/MAIN/LESS/FILE | |
JS_ROOT=$(pwd)/PATH/TO/JAVASCRIPT/FOLDER | |
echo "Uglifying javacript..." | |
for i in $(find $JS_ROOT -name "*.js" -not -name "*.min.js") | |
do | |
o=${i/.js/.min.js} |
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 Calendar = function(element, context) { | |
var widget, utils, $calendar; | |
widget = this; | |
utils = { | |
mod: function(x, n) { | |
// Fix modulo. Javascript hates Maths. | |
// x: Number; n: Number. | |
return ((x % n) + n) % n; |
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 re | |
def underscorize(x): | |
""" | |
Camelcased and dashed text to underscored text. | |
Examples: | |
>>> underscorize('CamelCasedText') | |
'camel_cased_text' | |
>>> underscorize('camel-cased-text') | |
'camel_cased_text' |
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 HTMLParser import HTMLParser | |
import re | |
re_whitespace = re.compile(r'(\w+)') | |
class WordTruncatedHTMLParser(HTMLParser): | |
""" | |
Truncate an HTML text to a certain number of words. |
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/python | |
""" | |
Google translate client | |
usage: python translate.py [-h] [-v] [-ua User-Agent] source_lang target_lang text | |
positional arguments: | |
source_lang | |
target_lang |
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 data, ua, platform, browser, os; | |
data = { | |
page: window.location.pathname.replace(/\/$/, ''), | |
language: navigator.language.slice(0, 2).toUpperCase(), | |
screen_resolution: window.screen.width + 'x' + window.screen.height, | |
screen_dpi: window.devicePixelRatio, | |
is_touch_device: 'ontouchstart' in window || 'onmsgesturechange' in window | |
}; | |
ua = navigator.userAgent.toLowerCase(); |
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 json | |
from tornado.web import RequestHandler | |
from pygeoip import GeoIP | |
import dateutil.parser | |
from app.models import Visit | |
from app import settings |
OlderNewer