Skip to content

Instantly share code, notes, and snippets.

@brandon-rhodes
brandon-rhodes / gist:3438936
Created August 23, 2012 17:19
Geographically correct alternative to Radarmatic.com's sweepArc() function
/* NOTE: this function requires the Google Maps "geometry" library which
Radarmatic does not currently load. It would need to load Maps with:
http://maps.google.com/maps/api/js?libraries=geometry&sensor=false */
function sweepArc(context, center_x, center_y, radius, width,
start_angle, end_angle) {
/* Special case: if we are being asked to draw the big gray circle
around the current radar site, then draw a big gray circle. */
#!/usr/bin/env python
import re
import sys
# 00:00:00 < user> optional_prefix: TEXT TO KEEP
content = re.compile('^[0-9]{2}(:[0-9]{2})+ <[^>]+> ([^\s]+:\s)?(.*)$')
for line in sys.stdin:
result = content.search(line)
try:
@kelleyk
kelleyk / tornado_basic_auth.py
Created July 9, 2011 15:51
A simple decorator that makes a RequestHandler prompt for basic auth username and password
# A decorator that lets you require HTTP basic authentication from visitors.
# Kevin Kelley <kelleyk@kelleyk.net> 2011
# Use however makes you happy, but if it breaks, you get to keep both pieces.
# Post with explanation, commentary, etc.:
# http://kelleyk.com/post/7362319243/easy-basic-http-authentication-with-tornado
# Usage example:
#@require_basic_auth
#class MainHandler(tornado.web.RequestHandler):
@FSX
FSX / async_psycopg2.py
Created March 8, 2011 22:11
A module for asynchronous PostgreSQL queries in Tornado.
#!/usr/bin/env python
__author__ = 'Frank Smit <frank@61924.nl>'
__version__ = '0.1.0'
import functools
import psycopg2
from tornado.ioloop import IOLoop, PeriodicCallback