Skip to content

Instantly share code, notes, and snippets.

View prologic's full-sized avatar
👋
Principal SRE, Founder of Yarn.social and Salty.im

James Mills prologic

👋
Principal SRE, Founder of Yarn.social and Salty.im
View GitHub Profile
@prologic
prologic / gist:ec2ed327030d445bfe92
Created June 21, 2015 22:04
created by github.com/tr3buchet/gister
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
@prologic
prologic / test_map.py
Created June 18, 2015 14:26
Naive implemtnation of Pool/map in circuits
#!/usr/bin/env python
"""Bridge Example
A Bridge example ...
"""
from __future__ import print_function
#!/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.
"""
@prologic
prologic / fib.py
Created June 15, 2015 12:46
created by github.com/tr3buchet/gister
#!/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/
@prologic
prologic / gist:874416e6f0a64d358d98
Created June 15, 2015 06:35
created by github.com/tr3buchet/gister
#!/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)
@prologic
prologic / hello.py
Created June 10, 2015 23:21
Sample event flow of a circuits.web Hello World
#!/usr/bin/env python
from circuits import Debugger
from circuits.web import Controller, Server
class Root(Controller):
def index(self, *args, **kwargs):
$ 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>
@prologic
prologic / server.py
Created June 4, 2015 13:31
circuits AddressBookMVC Demo with AngularJS
#!/usr/bin/env python
from os import environ, path
from json import dumps, loads
from circuits.web import Server, JSONController, Static
class AddressAPI(JSONController):
@prologic
prologic / server.py
Last active August 29, 2015 14:22
A simple RESTful-ish Comments API based on the ReactJS Tutorial(s)
from os import environ
from json import dumps, loads
from circuits.web import Server, Controller, Static
class Comments(Controller):
channel = "/comments.json"
#!/usr/bin/env python
from __future__ import print_function
from circuits import Component, Debugger, Event
class condition(Event):
"""condition Event"""