Skip to content

Instantly share code, notes, and snippets.

Avatar

M.J. theelous3

  • Dublin, Ireland
View GitHub Profile
View min_emit.py
import aiohttp
import asyncio
from opentelemetry.instrumentation.aiohttp_client import AioHttpClientInstrumentor
from opentelemetry import trace
from opentelemetry.exporter import jaeger
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor
View main.py
# On our aiohttp.Application.on_startup we append `on_startup` which includes:
def on_startup(config: Mapping):
init_tracer()
AioHttpClientInstrumentor().instrument()
session = ClientSession(
headers={telnyx_http_constants.TELNYX_CLIENT_HEADER: "billing"}
)
View request_with_timeout.py
@defer.inlineCallbacks
def _request_with_timeout(func, request, context, timeout, *args, **kwargs):
try:
request.addTimeout(timeout, reactor)
response = yield request
except defer.TimeoutError as e:
error_str = "Timeout calling {} with args: {} kwargs: {}".format(
context, args or None, kwargs or None
View app.py
from asyncio import sleep
from random import random
from unittest.mock import Mock
from aiohttp import web
from handlers import some_endpoint
from app_contexts import request_context, RequestContext
View app.py
from asyncio import sleep
from unittest.mock import Mock
from aiohttp import web
from random import random
from handlers import some_endpoint
from app_contexts import request_context
View words.json
{
"five_w":[
"flyer",
"gored",
"dandy",
"idiot",
"suing",
"hales",
"yowed",
"hands",
View words_gen.py
import json
from random import sample
_ALL_WORDS = []
with open("words.json", 'r') as word_file:
word_dict = json.load(word_file)
for key, word_list in word_dict.items():
_ALL_WORDS.extend(word_list)
View base60.py
>>> from collections import deque
>>>
>>> def ldp(n, current=60):
... # largest_divisible_power
... s = 1
... while n > current:
... current = current ** s
... s += 1
... return s - 2
...
View app.component.html
<app-top-bar></app-top-bar>
<div class="container">
<router-outlet></router-outlet>
</div>