This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // MIT License | |
| // Copyright (c) 2025 Marcelo Trylesinski | |
| // | |
| // Permission is hereby granted, free of charge, to any person obtaining a copy | |
| // of this software and associated documentation files (the "Software"), to deal | |
| // in the Software without restriction, including without limitation the rights | |
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| // copies of the Software, and to permit persons to whom the Software is | |
| // furnished to do so, subject to the following conditions: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from mcp.server import FastMCP | |
| import logfire | |
| import uvicorn | |
| logfire.configure() | |
| server = FastMCP("Summarizer") | |
| app = server.sse_app() | |
| logfire.instrument_starlette(app) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from fastapi import FastAPI | |
| import httpx | |
| from typer import Typer, Context | |
| app = FastAPI() | |
| @app.get("/") | |
| def read_root(): | |
| return {"Hello": "World"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def a(n: int) -> int: | |
| records = 0 | |
| for _ in range(n): | |
| for _ in range(n): | |
| for _ in range(n): | |
| records += 1 | |
| return records | |
| def sum_a(n: int) -> int: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pydantic import BaseModel | |
| BaseModel.model_config['protected_namespaces'] = () | |
| class Potato(BaseModel): | |
| model_potato: str | |
| class Carrot(BaseModel): | |
| model_carrot: str |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import Any, Collection, List, TypeVar, Annotated | |
| from annotated_types import MinLen | |
| from pydantic import BaseModel | |
| _CollectionT = TypeVar("_CollectionT", bound=Collection[Any]) | |
| NonEmpty = Annotated[_CollectionT, MinLen(1)] | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import Type, Callable, Any | |
| from bson.objectid import ObjectId, InvalidId | |
| from pydantic import BaseModel, ValidationError | |
| from pydantic_core import CoreSchema, core_schema | |
| class PydanticObjectId(ObjectId): | |
| @classmethod | |
| def __get_pydantic_core_schema__( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import importlib | |
| import pkgutil | |
| def get_public_objects(package_name, parent_module=""): | |
| objects = [] | |
| full_package_name = ( | |
| parent_module + "." + package_name if parent_module else package_name | |
| ) | |
| package = importlib.import_module(full_package_name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Create a virtual environment, and run a different python process.""" | |
| import os | |
| import subprocess | |
| import tempfile | |
| import venv | |
| with tempfile.TemporaryDirectory() as temp_dir: | |
| VENV_PATH = os.path.join(temp_dir, "venv") | |
| venv.create(VENV_PATH, with_pip=True) | |
| python_exe = os.path.join(VENV_PATH, "bin", "python") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Creates a new monorepo by fusing multiple repositories | |
| # Mainly copied from http://www.sevangelatos.com/monorepo/ | |
| # Child repositories that are going to be fused | |
| CHILDREN="repo_lib_a repo_lib_b" | |
| # Name of the created monorepo | |
| MONOREPO="monorepo" |
NewerOlder