Skip to content

Instantly share code, notes, and snippets.

View Drvanon's full-sized avatar
😀
Ready to get working

Robin Alexander Dorstijn Drvanon

😀
Ready to get working
  • Groningen
View GitHub Profile
@Drvanon
Drvanon / main.py
Created May 1, 2012 18:22
module questions
import module
e = 10
def main():
while Trye
h = module.do_shitty_things(e)
print h
import twisted
import pygame
import amp
# the game
# sell items
# here comes the amp protocol
# buy items
Traceback (most recent call last):
Failure: twisted.internet.error.ConnectionRefusedError: Connection was refused by other side: 111: Connection refused.
Done with math: [(True, 94), (False, <twisted.python.failure.Failure <class 'twisted.internet.error.ConnectionRefusedError'>>)]
@Drvanon
Drvanon / main.py
Created May 2, 2012 13:05
**kargs
class FingerFactory(protocol.ServerFactory):
def __init__(self, **kwargs):
self.users = kwargs
users = {'moshez':'happy and well', 'Rob':'Programming','Danny':'being happy'}
factory = FingerFactory(users)
from twisted.internet import reactor, defer
from twisted.internet.protocol import ClientCreator
from twisted.protocols import amp
from ampserver import Sum, Divide
def doMath():
try:
a = raw_input('What number for a ? \n >')
b = raw_input('What number for b? \n >')
" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2008 Dec 17
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/twisted/python/log.py", line 84, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
File "/usr/lib/python2.7/dist-packages/twisted/python/log.py", line 69, in callWithContext
return context.call({ILogContext: newCtx}, func, *args, **kw)
File "/usr/lib/python2.7/dist-packages/twisted/python/context.py", line 118, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/usr/lib/python2.7/dist-packages/twisted/python/context.py", line 81, in callWithContext
return func(*args,**kw)
--- <exception caught here> ---
from twisted.application import internet, service
from twisted.internet.protocol import ServerFactory, Protocol
from twisted.python import log
# Normally we would import these classes from another module.
class PoetryProtocol(Protocol):
def connectionMade(self):
poem = self.factory.service.poem
from twisted.internet import reactor
from twisted.internet.protocol import Protocol, ClientFactory
from twisted.protocols import amp
class ChangeCurrency(amp.Command):
arguments = [('newPrice', amp.Integer())]
class MarketProtocol(amp.AMP):
def __init__(self, price):
self.price = price
class NewProtocol(Protocol):
def __init__(self, x):
self.x = x
class NewFactory(Factory):
protocol = Newprotocol # i would think ( x ) but then it becomes an instance