Skip to content

Instantly share code, notes, and snippets.

View malinoff's full-sized avatar

Dmitry Malinovsky malinoff

View GitHub Profile
@malinoff
malinoff / Ответы
Created May 21, 2012 04:44
HiDevLab answers
#Типы данных, основные конструкции
Q: Как получить список всех атрибутов объекта
A: dir(obj)
Q: Как получить список всех публичных атрибутов объекта
A: [x for x in dir(obj) if x[0] != '_']
Q: Как получить список методов объекта
A: [x for x in dir(obj) if callable(getattr(obj,x)]
@malinoff
malinoff / gist:6129285
Created August 1, 2013 07:50
For salt IRC
#my-repo.sls
my-repo:
pkgrepo.managed:
- humanname: #...
- name: #...
- baseurl: #...
- gpgkey: #...
#my-cool-pkg.sls
include:
@malinoff
malinoff / gist:6265950
Created August 19, 2013 05:25
Conf file example
addrs {
{% for host, ip in salt['mine.get']('minion-*', 'network.ip_addrs') %}
{{ ip.0 }},
{% endfor %}
}
Setting up mysql user:
mysql_user.present:
- name: {{ 'db' + grains['id'] + 'user' }}
- host: localhost
- password: {{ grains['id'] + 'other_things' }}
@malinoff
malinoff / multiprocessing_mailbox.py
Created April 1, 2014 02:32
This gist describes how to run handler function in a separate process to be able to receive new publications
import time
import signal
import multiprocessing
from kombu.pidbox import Node, Mailbox
from kombu.clocks import LamportClock
from kombu.exceptions import InconsistencyError
from kombu import Connection, Exchange, Producer
def do_reply(reply, exchange, routing_key, ticket, channel, clock):
ansible-playbook -i inventory -c local play.yml
PLAY [api] *********************************************************************
TASK [setup] *******************************************************************
Thursday 07 July 2016 11:10:52 +0600 (0:00:00.050) 0:00:00.050 *********
ok: [localhost]
TASK [debug] *******************************************************************
Thursday 07 July 2016 11:10:53 +0600 (0:00:01.559) 0:00:01.609 *********
[defaults]
hash_behaviour=merge
roles_path=../common/roles:./roles
host_key_checking=False
pipelining=True
import asyncio
import pytest
@pytest.hookimpl(hookwrapper=True)
def pytest_fixture_setup(fixturedef, request):
outcome = yield
coro = outcome.result
if asyncio.iscoroutine(coro):
event_loop = request.getfixturevalue('event_loop')
result = event_loop.run_until_complete(coro)
import asyncio
from _pytest.compat import is_generator
async def foo():
await foo()
async def bar():
pass
print(is_generator(foo))