Skip to content

Instantly share code, notes, and snippets.

Lars van de Kerkhof specialunderwear

Block or report user

Report or block specialunderwear

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
# Generated by Django 2.2 on 2019-04-22 12:38
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('through', '0001_initial'),
specialunderwear /
Last active Jul 12, 2019
Have a Meta inner class like in django, that will turn into a _meta attribute.
from django.utils.functional import cached_property
class MetaClass(object):
def __init__(self, attrs, endpointname):
self.endpointname = endpointname
def endpoint(self):
from contextlib import contextmanager
from unittest.mock import patch
def fake_autocreated(many_to_many_manager):
"Do not give a shit about any intermediate models, just update the relation"
with patch.object(many_to_many_manager.through._meta, "auto_created", True):
yield many_to_many_manager
from copy import deepcopy
from unittest import mock
from django.conf import settings
from import BaseCommand
from django.utils.translation import override
from django.template import base as template
from django.template import defaulttags
from oscar.core.loading import get_model
from django.db import models
class ThroughFooBars(models.Model):
foo = models.ForeignKey('ThroughFoo', models.DO_NOTHING)
bar = models.ForeignKey('ThroughBar', models.DO_NOTHING)
order = models.PositiveIntegerField()
class Meta:
managed = False
# Generated by Django 2.2 on 2019-04-22 11:25
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('through', '0001_initial'),
from django.db import models
class Bar(models.Model):
spam = models.EmailField()
class Foo(models.Model):
bars = models.ManyToManyField(Bar, through='ThroughFooBars')
specialunderwear /
Created May 11, 2017
Initialize a package directory structure with files.
#! /usr/bin/env python
import os
import argparse
def visit(arg, dirname, names):
name = os.path.join(arg, dirname, '')
if not os.path.exists(name):
open(name, 'a').close()
specialunderwear / ▼spyne■
Last active Dec 2, 2016
Spyne services with inheritance.
View ▼spyne■
import inspect
from functools import partial, update_wrapper
from spyne.decorator import rpc as original_rpc
from spyne.service import ServiceBase, ServiceBaseMeta
__all__ = ('rpc', 'DelegateBase', 'ExtensibleServiceBase')
class SpyneMethodWrapper(object):
View uwsgi.conf
master = true
workers = 1
reload-mercy = 30
vacuum = 1
socket = my.sock
auto-procname = true
enable-threads = true
lazy = 0
plugin = python
You can’t perform that action at this time.