Skip to content

Instantly share code, notes, and snippets.

View dzen's full-sized avatar

Benoît C dzen

  • Polyconseil
  • Paris
View GitHub Profile
@dzen
dzen / decode.py
Last active October 26, 2019 09:31
Decode without network function
# The idea is simple: this code know how to decode some bytes, and how many bytes it requires.
# but this lib must not issue any network related code (read, write)
# to be used with any network framework
class Decoder:
buffer: typing.Optional[bytes]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

Keybase proof

I hereby claim:

  • I am dzen on github.
  • I am dzen (https://keybase.io/dzen) on keybase.
  • I have a public key ASCOZx3NI4TfZ4Cn3-xatY_CXkvM5h-EHNtLZB6mv3-p4Ao

To claim this, I am signing this object:

@dzen
dzen / factories.py
Created June 13, 2013 08:30
Use unittest.mock.Mock (python 3.3) with factoryboy
import factory
import string
import random
from unittest.mock import Mock
class ThingFactory(factory.Factory):
#!/usr/bin/env python
"""
arrange your films (with a name like "american_history_x.avi") on your filesystem:
BASEDIR/
./date/1998/american_history_x.avi (symlink)
./genre/drama/american_history_x.avi (symlink)
./genre/crime/american_history_x.avi (symlink)
./actor/edward furlong/american_history_x.avi (symlink)
import asyncio
import aiohttp.client
@asyncio.coroutine
def get_page(url):
return (yield from aiohttp.client.request('GET', url))
def main():
loop = asyncio.get_event_loop()
@dzen
dzen / main.py
Created September 21, 2014 11:34
Redis and induction sample
import asyncio
import asyncio_redis
from induction import Induction
app = Induction(__name__)
@app.route('/slow')
@asyncio.coroutine
def slow(request, response):
connection = yield from asyncio_redis.Connection.create(host='localhost', port=6379, auto_reconnect=False)