Skip to content

Instantly share code, notes, and snippets.

@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:
from django.test import Client
from spec import Spec
from nose.tools 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):
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 = termstyle.green
pass_bg_color = termstyle.bg_default
fail_fg_color = termstyle.red
fail_bg_color = termstyle.bg_default
# All lists in this variable will be under surveillance for changes.