Skip to content

Instantly share code, notes, and snippets.

View gist:3d4b9057f266e599bd49
from django.test import Client
from spec import Spec
from import *
from spec.plugin import SkipTest
from wall.models import Wall, Card, Row, Column
from wall.factories import WallFactory, CardFactory, RowFactory, ColumnFactory
import json
class CardWallApplication(Spec):
def setup(self):
View gist:233222b96e1ae1ca9971
from sniffer.api import * # import the really small API
import os, termstyle, subprocess
# you can customize the pass/fail colors like this
pass_fg_color =
pass_bg_color = termstyle.bg_default
fail_fg_color =
fail_bg_color = termstyle.bg_default
# All lists in this variable will be under surveillance for changes.
markng / gist:4026171
Created Nov 6, 2012
wordpress db router
View gist:4026171
class WordpressRouter(object):
""" Database router - for the moment, everything to default except the wordpress app, which has its own setting """
def db_for_read(self, model, **hints):
if model._meta.app_label == 'wordpress':
return 'wordpress'
return None
def db_for_write(self, model, **hints):
if model._meta.app_label == 'wordpress':
markng /
Created Apr 17, 2012 — forked from anonymous/azsosxmlparse
election results
import requests
import lxml
from lxml import etree
from decimal import *
from jinja2 import Template
import codecs
r = requests.get('')
xml_source = r.text
root = etree.fromstring(xml_source)
markng /
Created Feb 25, 2012
Web Scraping NICAR Python class
import requests
import csv
from pyquery import PyQuery as pq
f = open('strike_all_bills.csv', 'w')
wr = csv.DictWriter(f, ['billno'])
req = requests.get('')
html = pq(req.text)
rows = html('tr.TableHeaderBackground').siblings()
markng / gist:1849167
Created Feb 17, 2012
duct tape to render and upload all tilemill projects automatically
View gist:1849167
for file in `ls`:; do rm /Users/mng/Documents/MapBox/export/$file.mbtiles; tilemill export $file /Users/mng/Documents/MapBox/export/$file.mbtiles --format=mbtiles --files=/Users/mng/Documents/MapBox; tilemill export $file /Users/mng/Documents/MapBox/export/$file.mbtiles --format=upload --files=/Users/mng/Documents/MapBox; done
markng / gist:1838431
Created Feb 15, 2012
Create TM Projects automatically
View gist:1838431
import os
from django.conf import settings
from 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 / gist:1148062
Created Aug 15, 2011
aside scroller.js
View gist:1148062
jQuery(document).ready(function() {
var triggers_in_viewport = [];
$(window).scroll(function(event) {
$('aside h3 a').click(function(event) {
markng / gist:1101904
Created Jul 23, 2011
Interactive translation tool.
View gist:1101904
#!/usr/bin/env python
import sys, tty, termios
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
filename = sys.argv[1]
f = open(filename, 'r')
text =
markng / style.mss
Created Apr 29, 2011
Crashes the tilemill server
View style.mss
@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;
You can’t perform that action at this time.