This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WARNING:abot.bot:No message handler for <DubtrackUserUpdate <DubtrackEntity None#560b135c7ae1ea0300869b20 379/1680 0(S) ##0> skip#0 played#1680 queue#0 dubs#379> | |
WARNING:abot.bot:No message handler for <DubtrackDub#updub <DubtrackEntity txomon#560b135c7ae1ea0300869b20 379/1680 0(S) ##0> +1-0> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async def message_handler(message: DubtrackMessage): | |
print(f'Received {message.text}') | |
# await message.channel.say('Bot speaking here') | |
def run_bot(): | |
# Setup | |
bot = Bot() | |
dubtrack_backend = DubtrackBotBackend() | |
dubtrack_backend.configure() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from contextvars import ContextVar | |
import asyncio | |
import random | |
cv = ContextVar('cv') | |
async def waiting_func(name): | |
print(f'{name} Before sleep: {cv.get() == name}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import collections | |
async def ratelimit(*, max_request, in_interval): | |
slots = collections.deque() | |
while True: | |
slots.append(time() + in_interval) | |
yield | |
while len(slots) >= max_request: | |
left = slots[0] - time() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import absolute_import, division, print_function, unicode_literals | |
import string | |
from weakref import WeakKeyDictionary | |
class SafeDict(dict): | |
def __missing__(self, key): | |
return '{' + key + '}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Make sure only three files exist in /myfolder | |
declarative: | |
items: | |
- a | |
- b | |
- c | |
state: | |
command: find /myfolder/ | tail -n +2 | basename | |
extra_item: | |
file: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, traceback | |
def exception_hook(e, value, tb): | |
for line in traceback.TracebackException( | |
type(value), value, tb, capture_locals=True | |
).format(chain=True): | |
print(line, end="") | |
sys.excepthook = exception_hook |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Available context bindings: | |
* COLUMNS List<DataColumn> | |
* ROWS Iterable<DataRow> | |
* OUT { append() } | |
* FORMATTER { format(row, col); formatValue(Object, col); getTypeName(Object, col); isStringLiteral(Object, col); } | |
* TRANSPOSED Boolean | |
* plus ALL_COLUMNS, TABLE, DIALECT | |
* | |
* where: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ctypes | |
import enum | |
import logging | |
import os | |
import socket | |
import struct | |
import sys | |
try: | |
import tenacity.retry |
OlderNewer