Skip to content

Instantly share code, notes, and snippets.

View infnetdanpro's full-sized avatar

infnetdanpro

  • Alar
  • Montenegro
View GitHub Profile
@infnetdanpro
infnetdanpro / ufw_log_analyzer.py
Last active February 11, 2024 16:12
UFW Log analyzer
from collections import defaultdict
import re
log_entry_pattern = re.compile(r"\bSRC=([\d.]+)\b")
def parse_log(log_file):
src_ip_counts = defaultdict(int)
with open(log_file, "r") as f:
@infnetdanpro
infnetdanpro / starlette_asyncio_gather_background_tasks.py
Last active October 21, 2023 15:19
Starlette Gather Background Tasks
import asyncio
import httpx
import uvicorn
from starlette.applications import Starlette
from starlette.background import BackgroundTasks
from starlette.responses import JSONResponse
from starlette.routing import Route
client = httpx.AsyncClient()
from dataclasses import dataclass, field, asdict
@dataclass
class Schedule:
id: int
name: str
@dataclass
class Company:
tcp-keepalive 0
tcp-backlog 65536
slave-serve-stale-data yes
slave-read-only yes
maxclients 10000
maxmemory 8589934592
rdbcompression no
rdbchecksum no
appendonly no