Skip to content

Instantly share code, notes, and snippets.

Sovetnikov

Block or report user

Report or block Sovetnikov

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
@Sovetnikov
Sovetnikov / dramatiq_eager_broker.py
Created Jun 27, 2019
Dramatiq eager broker for unittest
View dramatiq_eager_broker.py
from dramatiq import Worker
from dramatiq.brokers.stub import StubBroker
from dramatiq.worker import _WorkerThread, _ConsumerThread
class EagerBroker(StubBroker):
def __init__(self, *args, **kwargs):
super(EagerBroker, self).__init__(*args, **kwargs)
self.worker = Worker(self, worker_timeout=100)
View proxy.py
import random
import re
import socket
import ssl
from urllib.parse import urlparse
from urllib.request import urlopen
import socks
from shared.enum import StrEnum
@Sovetnikov
Sovetnikov / socks.py
Created Jan 14, 2018
SocksiPy рабочий для Python 3.4
View socks.py
"""SocksiPy - Python SOCKS module.
Version 1.00
Copyright 2006 Dan-Haim. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
View run_celery_from_django_test.py
import os
import subprocess
import unittest
from datetime import timedelta
from random import SystemRandom
from celery import Celery
from kombu import Exchange
from kombu import Queue
@Sovetnikov
Sovetnikov / run_celery_cam.py
Created Feb 13, 2017
How to run celery cam to save memory by not loading all modules of your app
View run_celery_cam.py
import os
import time
from copy import copy
from celery.events.snapshot import evcam
from qiwichain import settings as novtest_settings
from qiwichain.celery import app
DATABASES = copy(novtest_settings.DATABASES)
@Sovetnikov
Sovetnikov / fsm_log_inline.py
Last active Jul 30, 2019
django-fsm-log admin model inline for Django 1.7.7
View fsm_log_inline.py
from django.contrib.admin import TabularInline
from django.contrib.admin.utils import flatten_fieldsets
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.forms import BaseInlineFormSet, BaseModelFormSet
from django_fsm_log.models import StateLog
# Making possible to show django inline model admin without actual foreign key to parent model
# Works by making new model that has required FK (just to pass startup checks) and overriding actual queryset generated in FormSet
# For Django 1.7.7
View django_extreme_fast_tests.py
import logging
import os
ABSOLUTE_PATH = lambda x: os.path.abspath(os.path.join(os.path.abspath(os.path.dirname(__file__)), x))
# For Django 1.7.7 sqlite and spatialite
# Uses monkeypatch
#
# Runs tests as:
# 1. Create initial db and apply all migrations if it does not exists
You can’t perform that action at this time.