Skip to content

Instantly share code, notes, and snippets.

@decentral1se
decentral1se / groupby.yml
Created September 14, 2018 12:37
groupby.yml
---
- hosts: localhost
connection: local
tasks:
- name: Ensure mandatory variables specified
assert:
that: env is defined
- name: Show execution path
debug:
@decentral1se
decentral1se / fosdem-2019.md
Last active September 19, 2018 14:30
fosdem-2019.md

Python has acquired new super powers since version 3.5 and the arrival of PEP 484. Type hints are a new programming language feature which python projects can progressively adopt to improve their confidence in their code base doing what it is supposed to be doing.

Django, the massively used Python web framework, has yet to receive comprehensive core integration for type hinting. While much effort is being put into upgrading many open source community projects (such as Zulip, one of the biggest success stories), Django has yet to receive this effort and focus. We want to make a big push this FOSDEM 2019 to see if we can take the big leap into bringing type hints to Django core!

Following the lead of the Zulip developers (see https://blog.zulip.org/2016/10/13/static-types-in-python-oh-mypy/ for more) format used at PyCon 2016, we intend to open up a collaborative space for making fly-by contributions to adding type hints to the Django code base.

Volunteers can come with their laptop, install the project so

@decentral1se
decentral1se / requirements.yml
Created March 5, 2019 11:42
requirements.yml
---
- src: https://github.com/openstack-infra/zuul-jobs.git
version: master
path: foobar
scm: git
@decentral1se
decentral1se / gist:ae3dd734f552f8065e95cdbca4c68b19
Created September 16, 2019 16:26
molecule-goss failure logs
devel develop-inst-noop: /home/decentral1se/hacking/pycontribs/molecule-goss
devel installed: ansible==2.10.0.dev0,ansible-lint==4.1.0,anyconfig==0.9.10,apipkg==1.5,appdirs==1.4.3,arrow==0.15.2,asn1crypto==0.24.0,aspy.yaml==1.3.0,atomicwrites==1.3.0,attrs==19.1.0,bcrypt==3.1.7,binaryornot==0.4.4,Cerberus==1.3.1,certifi==2019.9.11,cffi==1.12.3,cfgv==2.0.1,chardet==3.0.4,Click==7.0,click-completion==0.5.1,colorama==0.4.1,cookiecutter==1.6.0,coverage==4.5.4,cryptography==2.7,decorator==4.4.0,docker==4.0.2,dogpile.cache==0.7.1,entrypoints==0.3,execnet==1.7.1,fasteners==0.15,flake8==3.7.8,future==0.17.1,git-url-parse==1.2.2,identify==1.4.7,idna==2.8,importlib-metadata==0.23,iso8601==0.1.12,Jinja2==2.10.1,jinja2-time==0.2.0,jmespath==0.9.4,jsonpatch==1.24,jsonpointer==2.0,keystoneauth1==3.17.1,MarkupSafe==1.1.1,mccabe==0.6.1,mock==3.0.5,molecule==3.0a1,-e git+https://github.com/pycontribs/molecule-goss@a951b2dd2cd8144b26d73df762aa3c3bdd09155b#egg=molecule_goss,monotonic==1.5,more-itertools==7.2.0,munch==2.3.2,netif
@decentral1se
decentral1se / testproto.py
Created January 1, 2020 22:39
testproto.py
import attr
import trio
import trio.abc
import trio.testing
@attr.s(auto_attribs=True)
class Proto:
stream: trio.abc.Stream
@decentral1se
decentral1se / nproto.py
Last active January 3, 2020 17:11
nproto.py
import trio
import trio.testing
class Protocol:
def __init__(self, stream):
self.stream = stream
async def aclose(self):
await self.stream.aclose()
@decentral1se
decentral1se / withmem.txt
Last active January 17, 2020 12:04
example memory channel context usage
# 1 (ain't working, weird usage anyway)
>>> async def main():
... incoming = open_memory_channel(15)
... async with incoming:
... await incoming[0].send(b'aaaa')
...
>>> run(main)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/decentral1se/work/datpy/hypercore-protocol/.venv/lib/python3.8/site-packages/trio/_core/_run.py", line 1804, in run
@decentral1se
decentral1se / muxdemux.py
Last active May 17, 2020 18:41
Mux/demux example with trio (first steps...)
"""Mux/demux protocol toy example with Trio.
Naively done and just about working! Probably buggy. There is not much by way
of error handling however it does showcase an approach for multiplexing a
streamed connection with multiple channels. All messages that are sent over the
stream are tagged with a channel ID. Each Protocol and Channel instance have
their own incoming and outgoing queue.
I'm trying to work towards having a robust mux/demux implementation and need
some help. Any comments on this would be greatly appreciated. Hopefully this
@decentral1se
decentral1se / test_trio_exc.py
Last active February 4, 2020 14:51
trio_exc.py
import pytest
import trio
from trio.testing import memory_stream_pair
from muxdemux import open_protocol
@pytest.fixture()
def stream():
return memory_stream_pair()
@decentral1se
decentral1se / pelican.py
Created March 19, 2020 17:43
pelican.py
"""Pelican plugin for interacting with Homebase."""
from collections import defaultdict
from datetime import datetime as dt
from operator import attrgetter
from pelican import signals
from pelican.contents import Article, Author, Category
from pelican.generators import ArticlesGenerator, Generator
from pelican.readers import BaseReader