This file contains hidden or 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 itertools import chain, ifilter, imap # noqa | |
def flatten(*seq): | |
return chain(*(chain.from_iterable(x) for x in seq)) | |
def within(x, y): | |
def f(i): | |
return x <= i <= y |
This file contains hidden or 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 | |
"""Bridge Example | |
A Bridge example ... | |
""" | |
from __future__ import print_function |
This file contains hidden or 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 | |
"""Simple UNIX Echo Server | |
This example shows how you can create a simple UNIX Server (an Echo Service) | |
utilizing the builtin Socket Components that the circuits library ships with. | |
""" | |
This file contains hidden or 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/python | |
"""A Fibonacci Web App and API | |
Inspired by SO Question:http://stackoverflow.com/questions/30844887 | |
Usage:: | |
$ curl -q -o - http://localhost:8000/ |
This file contains hidden or 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 | |
import socket | |
ip, port = "0.0.0.0", 10000 | |
SocketFd = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
SocketFd.bind((ip, port)) | |
SocketFd.listen(5) |
This file contains hidden or 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 | |
from circuits import Debugger | |
from circuits.web import Controller, Server | |
class Root(Controller): | |
def index(self, *args, **kwargs): |
This file contains hidden or 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
$ python3.4 -i foo.py | |
>>> a = PieceType.queen | |
>>> b = PieceType.queen | |
>>> a == b | |
True | |
>>> a is b | |
True | |
>>> x = PieceType(2) | |
>>> x | |
<PieceType.queen: 2> |
This file contains hidden or 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 | |
from os import environ, path | |
from json import dumps, loads | |
from circuits.web import Server, JSONController, Static | |
class AddressAPI(JSONController): |
This file contains hidden or 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 os import environ | |
from json import dumps, loads | |
from circuits.web import Server, Controller, Static | |
class Comments(Controller): | |
channel = "/comments.json" |
This file contains hidden or 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 | |
from __future__ import print_function | |
from circuits import Component, Debugger, Event | |
class condition(Event): | |
"""condition Event""" |