Skip to content

Instantly share code, notes, and snippets.

@asfaltboy
asfaltboy / callable_bug.py
Last active Mar 22, 2021
pyright: Callable not a callable bug
View callable_bug.py
from typing import Callable, NamedTuple, Tuple
# class RuleDefinition(NamedTuple):
# pattern: str
# path: str
# check: Callable
RuleDefinition = Tuple[str, str, Callable]
@asfaltboy
asfaltboy / my_app.py
Last active Nov 28, 2019
A reproduction of worker starvation on result backend failure (see https://github.com/celery/celery/issues/5642)
View my_app.py
import time
from celery import Celery
app = Celery(
'my_app',
broker='pyamqp://guest@localhost:5673//',
backend='redis://localhost',
)
app.conf.worker_prefetch_multiplier = 1
View output.log
$ python test.py
Starting running with handlers [<StreamHandler <stderr> (NOTSET)>, <StreamHandler <stdout> (NOTSET)>]
ERROR:root:Test log
Test log
ERROR:root:Test log
Test log
^CTraceback (most recent call last):
File "test.py", line 13, in <module>
time.sleep(1)
KeyboardInterrupt
@asfaltboy
asfaltboy / anaconda_jsonserver.v2.1.27.log
Last active Jul 6, 2018
st3 anaconda IDE issue logs
View anaconda_jsonserver.v2.1.27.log
2018-07-06 13:53:15,399: INFO : process 61387 does not exists stopping server...
2018-07-06 13:53:15,405: INFO : Closing the socket, server will be shutdown now...
2018-07-06 13:54:04,737: DEBUG : bind: address=('localhost', 56943)
2018-07-06 13:54:04,738: DEBUG : listen: backlog=5
2018-07-06 13:54:04,738: INFO : Anaconda Server started in 56943 for PID 95659 with cache dir /Users/pavel.savchenko/Library/Caches/Jedi/my_project and extra paths /Users/pavel.savchenko/dev/my_project
2018-07-06 13:54:04,744: INFO : Incomming connection from ('127.0.0.1', 56955)
2018-07-06 13:54:04,746: INFO : Incomming connection from ('127.0.0.1', 56956)
2018-07-06 13:54:04,789: INFO : client requests: lint
2018-07-06 13:54:24,896: INFO : client requests: goto
2018-07-06 13:54:28,078: INFO : client requests: goto
View keybase.md

Keybase proof

I hereby claim:

  • I am asfaltboy on github.
  • I am psav (https://keybase.io/psav) on keybase.
  • I have a public key ASDxF_wNcAkMRJscntEXV4qGrYrPatF1SjhAxlyFigkNtQo

To claim this, I am signing this object:

@asfaltboy
asfaltboy / output.log
Created Apr 5, 2018
django-braces pytest output coverage
View output.log
GLOB sdist-make: /Users/pavel.savchenko/github/django-braces/setup.py
py27-django15 inst-nodeps: /Users/pavel.savchenko/github/django-braces/.tox/dist/django-braces-1.12.0.zip
py27-django15 installed: coverage==4.1,Django==1.5.12,django-braces==1.12.0,factory-boy==2.8.1,Faker==0.8.12,funcsigs==1.0.2,ipaddress==1.0.19,mock==2.0.0,pbr==4.0.1,py==1.5.3,pytest==2.9.1,pytest-cov==2.5.1,pytest-django==2.9.1,python-dateutil==2.7.2,six==1.11.0,text-unidecode==1.2
py27-django15 runtests: PYTHONHASHSEED='3147501103'
py27-django15 runtests: commands[0] | py.test tests --cov=braces
============================= test session starts ==============================
platform darwin -- Python 2.7.14, pytest-2.9.1, py-1.5.3, pluggy-0.3.1
rootdir: /Users/pavel.savchenko/github/django-braces, inifile:
plugins: django-2.9.1, cov-2.5.1
collected 210 items
@asfaltboy
asfaltboy / responses-mixin.py
Last active Feb 22, 2019
A responses TestCase Mixin
View responses-mixin.py
"""
A unittest.TestCase mixin that allows using the
responses (https://pypi.python.org/pypi/responses/) package in tests.
Usage
-----
Install responses with `pip install responses`.
Add `ResponsesMixin` to your `TestCase` parent classes instead of using
@asfaltboy
asfaltboy / mousemap_wrapper.py
Last active Jan 28, 2019
A simply SublimeText plugin to run a command if matches a selector
View mousemap_wrapper.py
"""
A simply SublimeText plugin to run a command if matches a selector.
Usage example - my `Default (OSX).sublime-mousemap`:
[
// for Python we use Anaconda's goto command, for go we use go_guru,
// for others we use built-in goto command
{ "button": "button1", "modifiers": ["ctrl"], "command": "mousemap_wrap",
"press_command": "drag_select", "args": { "commands": [
{
@asfaltboy
asfaltboy / conftest.py
Last active Mar 30, 2022
A pytest fixture to test Django data migrations
View conftest.py
# based on https://gist.github.com/blueyed/4fb0a807104551f103e6
# and on https://gist.github.com/TauPan/aec52e398d7288cb5a62895916182a9f (gistspection!)
from django.core.management import call_command
from django.db import connection
from django.db.migrations.executor import MigrationExecutor
import pytest
@asfaltboy
asfaltboy / anagram_lookup.py
Created Nov 23, 2016
anagram phrase comparison
View anagram_lookup.py
from hashlib import md5
from collections import Counter
import itertools
import sys
import time
MATCH_MSG = '>>> We have a match!!! This phrase matches the mt5 hash'
def get_relevant_words(target):