Skip to content

Instantly share code, notes, and snippets.

View 140am's full-sized avatar

Manuel Kreutz 140am

View GitHub Profile
@140am
140am / gist:563342
Last active August 12, 2016 22:38
print SQL CREATE from "sqlalchemy" DB tables
>>> from sqlalchemy.schema import CreateTable
>>> print CreateTable(model.TrafficLog.__table__)
@140am
140am / shimo_vpn.py
Created December 3, 2010 17:24
monitors an VPN connection and controls OSX Shimo.app in case of problems
#!/usr/bin/python
# OSX VPN monitor
#
# requires:
# - http://www.chungwasoft.com/shimo/
# - http://growl.info/
# - http://appscript.sourceforge.net/
import sys
import socket
@140am
140am / observer.py
Created June 18, 2011 08:35
python observer pattern example
import pdb
import time
import threading
class Event(object):
pass
class Observable(object):
def __init__(self):
self.callbacks = []
@140am
140am / core.js
Created November 30, 2011 23:16
SC 1.x routing / statechart example
TestApp = SC.Application.create(
/**
Invoked when route change has been detected
*/
routeDidChange: function(params) {
if (!params.target) return NO;
params = SC.clone(params);
@140am
140am / gist:2249117
Created March 30, 2012 07:55
backbone.js - dynamically set a model attributes based on From selection
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
@140am
140am / README.md
Created November 14, 2012 23:44
first butler framework example (v0.2)

Installation

virtualenv env; source env/bin/activate
easy_install butler

Use Examples

Save the attached .py files (router.py / worker.py / client.py)

  1. Start Router python router.py
@140am
140am / butler_service.py
Last active August 12, 2016 22:35
Example of using "butler" Python library to communicate between multiple processes (local or distributed)
""" 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:
@140am
140am / gist:7463028
Last active May 3, 2022 16:12
Exampel of arrow Key Navigation via Statechart events in JavaScript. from http://stativ.us
$(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);
});
@140am
140am / pytumblr_example.py
Created January 23, 2014 06:24
Example of using the Python Tumblr API v2 Client
""" 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