Skip to content

Instantly share code, notes, and snippets.

Avatar

Benoît C dzen

View GitHub Profile
@dzen
dzen / decode.py
Last active Oct 26, 2019
Decode without network function
View decode.py
# 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)
View keybase.md

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:

View aio_http_fetch.py
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 Sep 21, 2014
Redis and induction sample
View main.py
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)
@dzen
dzen / factories.py
Created Jun 13, 2013
Use unittest.mock.Mock (python 3.3) with factoryboy
View factories.py
import factory
import string
import random
from unittest.mock import Mock
class ThingFactory(factory.Factory):
View reorder_film.py
#!/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)
You can’t perform that action at this time.