This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tornado.ioloop | |
import tornado.web | |
import tornado.httpserver | |
import tornado.httputil | |
import tempfile | |
class MainHandler(tornado.web.RequestHandler): | |
def put(self): | |
filename = self.request.body.name | |
# do stuff with the image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tornado.ioloop | |
import tornado.web | |
import tornado.httpserver | |
import tornado.httputil | |
import json | |
class MainHandler(tornado.web.RequestHandler): | |
def post(self): | |
# do something useful | |
name = self.get_argument('foo') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tornadorpc.xml import XMLRPCHandler | |
from tornadorpc import private, start_server | |
class Handler(XMLRPCHandler): | |
def add(self, x, y): | |
return x+y | |
def ping(self, obj): | |
return obj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from httplib import HTTP, HTTPConnection | |
from urlparse import urlparse | |
def get_page(url): | |
parsed = urlparse(url) | |
conn = HTTPConnection('%s' % parsed[1]) | |
conn.request("GET", parsed[2]) | |
response = conn.getresponse() | |
data = response.read() | |
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import jsonrpclib | |
>>> server = jsonrpclib.Server('http://localhost:8181') | |
>>> server.add(5, 6) | |
11 | |
>>> server._notify.add(5, 6) | |
>>> batch = jsonrpclib.MultiCall(server) | |
>>> batch.add(10, 17) | |
>>> batch.ping({'key':'value'}) | |
>>> batch._notify.add(50, 40) | |
>>> batch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tornado.httpserver | |
import tornado.ioloop | |
import tornado.web | |
def private(func): | |
# Decorator to make a method, well, private. | |
class PrivateMethod(object): | |
def __init__(self): | |
self.private = True | |
__call__ = func |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
AUTHOR: Josh Marshall | |
ACKNOWLEDGMENTS: Corey(?) http://www.ctrlv.ca/2010/04/163/ | |
REQUIREMENTS: Python 2.6+, x2x, openssh-server | |
This is just a simple script to start an x2x session over SSH | |
on a remote machine. It takes a few parameters (like what side of | |
the screen do you want to use to "cross over" to the other machine, | |
what SSH port / identify file to use, etc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user@localbox:~$ sudo apt-get install x2x | |
# On the remote machine... | |
user@remotebox:~$ sudo apt-get install x2x openssh-server | |
# Download the code from https://gist.github.com/1033384 | |
# and save it to ~/bin on the local machine | |
user@localbox:~$ python bin/mouseporter.py 192.168.1.10 | |
Session started... (type Ctrl-C to quit) | |
# ... and scroll to your right! :) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" This proves that there was no money under the table. """ | |
import random | |
import sys | |
from collections import Counter | |
def main(): | |
""" Pick one of the sys args """ | |
assert len(sys.argv) > 1 | |
names = sys.argv[1:] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from numpy import array | |
raw_data = """75 | |
95 64 | |
17 47 82 | |
18 35 87 10 | |
20 04 82 47 65 | |
19 01 23 75 03 34 | |
88 02 77 73 07 63 67 | |
99 65 04 28 06 16 70 92 |
OlderNewer