Skip to content

Instantly share code, notes, and snippets.

View AivanF's full-sized avatar
🎯
Focusing

Áivan AivanF

🎯
Focusing
View GitHub Profile
@AivanF
AivanF / asynctestws.py
Created March 7, 2025 04:30
FastAPI / Starlette: Async WebSocket test client
import asyncio
import json
import typing
from starlette.testclient import TestClient, WebSocketTestSession
from starlette.types import Message
class AsyncWebSocketTestSession(WebSocketTestSession):
receive_timeout = None
@AivanF
AivanF / aivanf_timeout.py
Created March 6, 2025 03:22
Workaround for not working pytest-timeout
import asyncio
import functools
import pytest
def aivanf_timeout(timeout: float = 60):
def inner(func):
@functools.wraps(func)
async def wrapper(*args, **kwargs):
@AivanF
AivanF / Docker-Compose.sublime-build
Last active November 5, 2024 08:32
Docker Compose build system for Sublime Text
{
"shell_cmd": "echo 'Please click \"Tools -> Build With\" or Shift+Cmd+B and choose a specific command'",
"variants": [
{
"name": "Up interactive",
"shell_cmd": "CMD=\"docker-compose -f $file up\"; echo \"\\$CMD\n\"; bash -c \"\\$CMD\""
},
{
"name": "Up Detached",
"shell_cmd": "CMD=\"docker-compose -f $file up -d\"; echo \"\\$CMD\n\"; bash -c \"\\$CMD\""
@AivanF
AivanF / Factorio-EventLib-Description.md
Last active September 20, 2023 18:51
Factorio Lua EventLib by AivanF

The script is intended be used for simpler migration from a single control.lua file to libs with Factorio's builtin lualib.event_handler.

Single file:

-- control.lua
script.on_init(on_init)
script.on_configuration_changed(on_configuration_changed)
script.on_event({defines.events.on_built_entity, defines.events.on_robot_built_entity}, handler1)
script.on_event(defines.events.on_entity_died, handler2)