Skip to content

Instantly share code, notes, and snippets.

View lucasvo's full-sized avatar

Lucas Vogelsang lucasvo

View GitHub Profile
@lucasvo
lucasvo / test_helpers.py
Created October 26, 2012 22:01
Flask Unit Test Helpers
import json as jsonlib
def response_success(response, code=200):
if 200 <= code < 300:
assert 200 <= response.status_code < 300
assert code == response.status_code
def response_error(response, code=400):
if 400 <= code < 500:
assert 400 <= response.status_code < 500
@lucasvo
lucasvo / queryset.coffee
Created August 24, 2012 07:09
Querysets in Backbone
define ['jquery', 'underscore', 'backbone'], ($, _, Backbone) ->
# The queryset iterator is a helper that builds iterator functions that allow simple string matching such as:
# sample_iterator = (model) ->
# return model.get(key) == value
class QuerysetIterator
constructor: (expressions) ->
@expressions = expressions
iterator: (model) ->
for key, value in @expressions
@lucasvo
lucasvo / .zshrc.sh
Created August 2, 2012 18:09
Automatically activate your python virtualenvironment
function auto_activate {
SEARCHPATH=`pwd`
function activate_env {
# ZSH outputs errors for the ls * command if you don't disable the nomatch output
unsetopt nomatch 2>/dev/null
ls $SEARCHPATH/*/bin/activate > /dev/null 2> /dev/null
if [ "$?" = '0' ]; then
deactivate > /dev/null 2> /dev/null
# This is an implementation using python-oembed with api.embed.ly
# python-oembed http://code.google.com/p/python-oembed/
import oembed
# Embed.ly Multi Provider API Endpoint
OEMBED_ENDPOINT = 'http://api.embed.ly/oembed/api/v1'
# URL Schemes Supported --- complete list maintained
# http://api.embed.ly/1/services/python