Skip to content

Instantly share code, notes, and snippets.

View weaver's full-sized avatar

Ben Weaver weaver

View GitHub Profile
import sys, socket, select, errno
from tornado import ioloop, iostream
### Main Program
def main(kind=None):
if not kind or kind not in ('Original', 'Modified'):
usage()
#!/usr/bin/env python
"""ply-path -- analysis of an path expression using PLY
Example: ply-path.py 'child::para[position()>1]'
"""
import sys
from ply import lex
@weaver
weaver / starttls.py
Created February 3, 2010 07:40
Example of STARTTLS with Tornado
"""starttls -- an example of wrapping a non-blocking socket with TLS.
Example:
> openssl req -new -x509 -days 365 -nodes -out /tmp/cert.crt -keyout /tmp/cert.key
> python /path/to/this-file.py
starting client: 7
starting server: 8
client said: 'hello'.
server said: "YOU SAID: 'hello'".
## An example of using lxml as a namespace-aware, event-based push
## parser.
import urllib2
from contextlib import closing
from lxml import etree
class Target(object):
def start(self, tag, attr):