View config.js
function CSS_compute_middleware(css, next) {
if(this.foo === 'bar'){
css.padding = 0;
}
return next(css)
}
function CSS_async_compute_middleware(css, next) {
if(this.bar === 'foo'){
View elevators.py
"""
Elevator Exercise.
Edit the ElevatorController implementation, focusing on
the ElevatorController.call(Passenger) method.
Run the elevator script try to increase your score.
python elevators.py
> score: 51
View README.md

Celery Bug

When running a celery task, in a SQLAlchemy event, in a unit-test the connection get destroyed somehow.

I attached the requirement to reproduce the bug:

git clone https://gist.github.com/5762792fc1d628843697.git
cd 5762792fc1d628843697
virtualenv venv
. venv/bin/activate
View detector.md

Detecting Similar News

The following gist is an extract of the article Detecting Similar News. It exploit data retrieve by a crawler and detect similar article across different domains

Usage

Start by running the crawler to retrieve the data. Crawler takes about 50 minutes to retrieve all the data the first time.

$ python run.py
retrieving url... [techcrunch.com] /
View crawler.md

Simple Website Crawler

The following gist is an extract of the article Building a simple crawler. It allows crawling from a URL and for a given number of bounce.

Basic Usage

from crawler import Crawler
crawler = Crawler()
crawler.crawl('http://techcrunch.com/')
# displays the urls
View Flask-SQLAlchemy Caching.md

Flask-SQLAlchemy Caching

The following gist is an extract of the article Flask-SQLAlchemy Caching. It allows automated simple cache query and invalidation of cache relations through event among other features.

Usage

retrieve one object

# pulling one User object
user = User.query.get(1)
View LICENSE.txt
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
View palindrome.py
#!/usr/bin/python
from __future__ import with_statement
# To run:
#
# python -m timeit -n5 -s 'from palindrome import run, get_words, palindrome_X; words = get_words()' 'run(words, palindrome_X)'
def palindrome_1(x):
# 998ms / loop (Best of 3)
return x == ''.join(reversed(x))
View equal.js
// test that every value of A exists in B and are equal
// true equality: eq(a,b,1)
// true: eq({b:[1,2]}, {a:1, b:[1,2]})
// false: eq({a:1, b:[1,2]},{b:[1,2]})
// false: eq({b:[1,2]}, {a:1, b:[1,2,3]})
// false: eq({b:[1,2,3]}, {a:1, b:[1,2]})
function eq(a, b, bidirectional){
if (typeof(a) != typeof(b)) return false;
if (typeof(a) in {string: 1, number: 1}) return a == b;
if (a.length != b.length) return false;