Skip to content

Instantly share code, notes, and snippets.

View zachwill's full-sized avatar

Zach Williams zachwill

View GitHub Profile
#!/usr/bin/env python
"""
Use Tor through Python. Note, Tor must be running for the script to
work properly.
"""
import urllib2
$(document).ready(function() {
var location = window.location.href;
if (location.exec(window.location.href)) {
initialize();
} else {
$('.goMap').click(function(e) {
initialize();
});
}
});
$(document).ready(function() {
var location = /#wifi/i;
if (location.exec(window.location.href)) {
initialize();
} else {
$('.goMap').click(function(e) {
initialize();
});
}
});
#!/bin/bash
# For working with Python's pip and virtualenv modules.
activate() {
if [ "$1" != "" ]; then
source "$1/bin/activate"
elif [ -d "env" ]; then
source "env/bin/activate"
else
my_list = [{'a': 1}, {'a': 2}, {'a': 3}]
print sum(d['a'] for d in my_list)
class GaryBernhardt(object):
def __getitem__(self, value):
return "ohai"
gb = GaryBernhardt()
print gb['foo']
@zachwill
zachwill / utils.py
Created November 18, 2011 22:32
Flask JSONP decorator
"""
Taken from: https://gist.github.com/1094140
"""
from functools import wraps
from flask import request, current_app
def jsonp(func):
"""Wraps JSONified output for JSONP requests."""
@zachwill
zachwill / popcorn.coffee
Created November 23, 2011 22:12
Popcorn + CoffeeScript
# For working with the Popcorn/Vimeo interaction.
# Here's the JS Fiddle: http://jsfiddle.net/zachwill/eKHKc/
Popcorn.vimeo('#vimeo', 'http://vimeo.com/123456')
.footnote(
start: 1, end: 5
text: "Hey, it's working!"
target: "foo"
)
@zachwill
zachwill / zfill.coffee
Created December 2, 2011 04:04
CoffeeScript zfill
String::zfill ||= (padding) ->
string = this
while string.length < padding
string = '0' + string
string
"""
Test if a request is XHR.
"""
import argparse
from flask import Flask, request, jsonify, make_response
app = Flask(__name__)