Skip to content

Instantly share code, notes, and snippets.

@markng
markng / gist:1838431
Created February 15, 2012 19:46
Create TM Projects automatically
import os
from django.conf import settings
from django.core.management.base import NoArgsCommand
from django.template.loader import render_to_string
from prey.models import State
class Command(NoArgsCommand):
"""command for creating templated tilemill projects"""
def handle_noargs(self, *args, **kwargs):
@markng
markng / gist:1148062
Created August 15, 2011 22:40
aside scroller.js
jQuery(document).ready(function() {
var triggers_in_viewport = [];
checkTriggers();
$(window).scroll(function(event) {
checkTriggers();
});
$('aside h3 a').click(function(event) {
showAside($(this).attr('href'));
});
@markng
markng / gist:1101904
Created July 23, 2011 21:28
Interactive translation tool.
#!/usr/bin/env python
import sys, tty, termios
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
try:
filename = sys.argv[1]
f = open(filename, 'r')
text = f.read()
@markng
markng / style.mss
Created April 29, 2011 06:51
Crashes the tilemill server
@sans:"Droid Sans Book","Liberation Sans Regular","Arial Regular","DejaVu Sans Book";
@sans_bold:"Droid Sans Bold","Liberation Sans Bold","Arial Bold","DejaVu Sans Bold";
Map {
}
#world {
polygon-fill: #363636;
line-color: #ccc;
line-width: 0.5;
@markng
markng / ocrpaio.py
Created March 17, 2010 22:11
nowhere near finished, parse ocr from arizona campaign contributions
import os
import sys
import curses.ascii
import pickle
import pprint
import re
from optparse import OptionParser
class Page(object):
"""a page of contributions"""
import time
from textwrap import TextWrapper
import re
import tweepy
import urllib, urllib2
swap_list = ["sausage", "house", "banana", "car", "computer"]
swap_list_re = '|'.join(swap_list)
swap_re = re.compile('(%s)' % swap_list_re, re.I)
$(document).ready(function() {
var slider = null;
var sliderUl = null;
$('div.sliding').each(function() {
sliderUl = $('ul', this);
var productWidth = sliderUl.innerWidth() - $(this).outerWidth();
slider = $('#slider').slider({
animate: false,
min: 0,
def json_callback(view_func):
"""if the GET parameter callback is set, wrap response in a function with that name"""
def _decorator(request, *args, **kwargs):
try:
# check for callback, if it's there, modify the return
callback = request.GET.__getitem__('callback')
response = view_func(request, *args, **kwargs)
response.content = callback + '(%s);' % response.content
return response
except KeyError, e: