Skip to content

Instantly share code, notes, and snippets.

View euri10's full-sized avatar
🐢

euri10

🐢
View GitHub Profile
This file has been truncated, but you can view the full file.
Attaching to dev_api_1
api_1 | INFO: Started server process [1]
api_1 | 2021-11-20 11:15:13,686 Started server process [1]
api_1 | INFO: Waiting for application startup.
api_1 | 2021-11-20 11:15:13,687 Waiting for application startup.
api_1 | INFO: Application startup complete.
api_1 | 2021-11-20 11:15:13,687 Application startup complete.
api_1 | INFO: Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)
api_1 | 2021-11-20 11:15:13,693 Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)
api_1 | [36.4609375, 36.4609375, 36.4609375, 36.4609375, 36.4609375]
import asyncio
import gc
import logging
import tracemalloc
from collections import OrderedDict
from fastapi import FastAPI
from memory_profiler import memory_usage
FORMAT = '%(asctime)-15s %(message)s'
@euri10
euri10 / machine.js
Last active August 28, 2021 13:11
Generated by XState Viz: https://xstate.js.org/viz
const get_jobs_created_ids = (context, event) => new Promise((resolve, reject) => {
// return reject('No query specified');
const data = event.value;
const formData = new FormData();
Array.from(data.files).forEach((file) => {
formData.append('files', file);
});
axios.post(`${baseUrl}/uploads/`, formData, {
withCredentials: true,
import asyncio
import logging
import time
from functools import lru_cache
import uvicorn
from aiocache import cached
from fastapi import FastAPI, APIRouter, Depends
logger = logging.getLogger(__name__)
@euri10
euri10 / toto.py
Created March 10, 2020 12:21
async cache bug
import asyncio
import logging
import time
from functools import lru_cache
import uvicorn
from async_lru import alru_cache
from fastapi import FastAPI, APIRouter, Depends
logger = logging.getLogger(__name__)
-- name: get_notes
-- record_class: NoteProduct
SELECT note.product_id, note.name , product_name, manufacturer
FROM nested.product
join nested.note on product.note = note.product_id;
-- name: get_notes_json
select coalesce(array_to_json(array_agg(row_to_json(response))),'[]')::character varying AS BODYFROM from (
SELECT (note.product_id , note.name) as note , product_name, manufacturer
FROM nested.product
class NgrokTunnel:
def __init__(self, port: str):
assert find_executable(
"ngrok"
), "ngrok command must be installed, see https://ngrok.com/"
self.port = port
def start(self, ngrok_die_check_delay: float = 0.5) -> Optional[str]:
logger.debug(f"Starting ngrok tunnel for port {self.port}")
import time
from contextvars import ContextVar
from typing import Dict, Tuple
import fastapi
import yappi
from starlette.middleware.base import BaseHTTPMiddleware
from starlette.requests import Request
from starlette.responses import Response
from starlette.types import ASGIApp
import logging
import asyncio
import uvicorn
from aio_pika import connect_robust, ExchangeType, IncomingMessage
from celery import Celery
from fastapi import FastAPI
from starlette.applications import Starlette
from starlette.requests import Request
from starlette.responses import JSONResponse
import asyncio
import functools
import ssl
from pathlib import Path
import pytest
from databases import Database
def async_adapter(wrapped_func):
"""