virtualenv env; source env/bin/activate
easy_install butler
Save the attached .py files (router.py / worker.py / client.py)
- Start Router python router.py
>>> from sqlalchemy.schema import CreateTable | |
>>> print CreateTable(model.TrafficLog.__table__) |
#!/usr/bin/python | |
# OSX VPN monitor | |
# | |
# requires: | |
# - http://www.chungwasoft.com/shimo/ | |
# - http://growl.info/ | |
# - http://appscript.sourceforge.net/ | |
import sys | |
import socket |
import pdb | |
import time | |
import threading | |
class Event(object): | |
pass | |
class Observable(object): | |
def __init__(self): | |
self.callbacks = [] |
TestApp = SC.Application.create( | |
/** | |
Invoked when route change has been detected | |
*/ | |
routeDidChange: function(params) { | |
if (!params.target) return NO; | |
params = SC.clone(params); |
class exports.AddTaskTemplateView extends Backbone.View | |
events: | |
"change input": "fieldChanged" | |
"change select": "fieldChanged" | |
'click #btn-submit' : 'submitInput' | |
render: (context = {}) -> | |
$(@el).html require('./templates/user_create') context | |
this |
""" Example of how to get started with the `butler` library for RPC calls | |
Defines 3 example classes we want to expose for RPC use (ServiceA, ServiceB, ServiceC) | |
which all have a 'test' method. | |
Start a Router and register all the Service classes (`services_objects`) | |
python butler_service.py --service | |
Start only a Router process: |
$(document).bind('keydown', function(evt){ | |
var myStatechart = window.myStatechart, kid, | |
keyKey = {'38':'Up', '39': 'Right', '40':'Down', '37': 'Left', '13': 'Enter'}; | |
console.log('Which: ', evt.which); | |
kid = keyKey[evt.which]; | |
if (kid) myStatechart.sendEvent('key'+kid); | |
}); |
""" Tumblr API Example - Python CLI | |
""" | |
import oauth2 | |
import urlparse | |
import pytumblr | |
REQUEST_TOKEN_URL = 'http://www.tumblr.com/oauth/request_token' | |
AUTHORIZATION_URL = 'http://www.tumblr.com/oauth/authorize' | |
ACCESS_TOKEN_URL = 'http://www.tumblr.com/oauth/access_token' |
""" Python HTTP client implementations benchmark | |
# Bandwidth Throughput | |
INFO:__main__:TEST: pycurl | |
INFO:__main__:pycurl: Returned status in 17 ms | |
INFO:__main__:Completed read of 1527248057 bytes in 15410 ms at 756 Mbps | |
INFO:__main__:TEST: urllib2 | |
INFO:__main__:urllib2: Returned status in 18 ms |