Skip to content

Instantly share code, notes, and snippets.

View Msameim181's full-sized avatar
🫀
Engineering dreams through imagination and building to achieve the extraordinary

Mohammad Mahdi Samei Msameim181

🫀
Engineering dreams through imagination and building to achieve the extraordinary
View GitHub Profile
@Msameim181
Msameim181 / env2req.py
Last active September 29, 2022 06:35
convert environment.yml to requirement.txt
import yaml
with open("environment.yaml") as f:
environment_list = yaml.safe_load(f)
requirements = []
for dep in environment_list['dependencies']:
if isinstance(dep, str):
package, package_version = dep.split('=')
if package_version == '0':
continue
@Msameim181
Msameim181 / client.py
Last active December 30, 2023 16:44
SocketIO with FastAPI, Running with `uvicorn`. It can handle API routes and socket connections simultaneously.
import socketio
import asyncio
from abc import ABC, abstractmethod
from typing import Dict
import logging
import threading
import time
import sys
logger = logging.getLogger(__name__)
@Msameim181
Msameim181 / Pydantic-Pagination.py
Created November 16, 2024 06:41
Pydantic Pagination classes, Helps FastAPI to handle Pagination needed requests
from pydantic import BaseModel, Field
from typing import Optional, List, Generic, TypeVar
__all__ = ["Pagination", "PaginationResponse"]
T = TypeVar("T")
class Pagination(BaseModel):
offset: int = Field(1, ge=1)
limit: int = Field(10, ge=1, le=100)