Skip to content

Instantly share code, notes, and snippets.

View madsmtm's full-sized avatar

Mads Marquart madsmtm

  • Copenhagen, Denmark
  • 11:58 (UTC +01:00)
View GitHub Profile
@madsmtm
madsmtm / h11_sync_client.py
Last active December 9, 2018 23:41
`h11` example client as a class
# This file is adapted from h11's example client
# See https://github.com/python-hyper/h11/blob/master/examples/basic-client.py
import socket
import ssl
import h11
class Client:
def __init__(self, host):
self.conn = h11.Connection(our_role=h11.CLIENT)
@madsmtm
madsmtm / graphene-pytest.py
Created December 9, 2018 13:41
Graphene pytest fixtures
from pytest import fixture
from graphene.test import Client
@fixture(scope="session")
def _schema():
raise NotImplementedError(
"You must implement this fixture yourself."
"It should return an instance of `graphene.Schema`"
)
@madsmtm
madsmtm / eve-sqlalchemy-enums.py
Last active October 25, 2018 14:43
Minimal example of Eve-SQLAlchemy enumerators not working when using enumerated classes
import enum
from eve import Eve
from sqlalchemy import Column, Integer, Enum
from sqlalchemy.ext.declarative import declarative_base
from eve_sqlalchemy import SQL
from eve_sqlalchemy.config import DomainConfig, ResourceConfig
from eve_sqlalchemy.validation import ValidatorSQL
@madsmtm
madsmtm / Vagrantfile
Last active June 27, 2018 08:28
Conditional Vagrant Provisioner
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# When you type 'up' the first time, it's always updated
config.vm.provision 'update', type: 'shell', inline: "apt-get update;apt-get -yq upgrade"
# When you provision the machine, you're asked whether you want to update it
if ARGV.include?('up') or ARGV.include?('reload') or ARGV.include?('resume') and ARGV.include?('--provision') or ARGV.include?('provision')