This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
NewerOlder