Skip to content

Instantly share code, notes, and snippets.

View mahenzon's full-sized avatar

Suren Khorenyan mahenzon

View GitHub Profile
@mahenzon
mahenzon / example-openai-api-call-ollama.py
Created October 4, 2025 20:05
Ollama example OpenAI API call
import requests
API_KEY = "EMPTY"
# BASE_URL = "http://localhost:12345/engines/llama.cpp/v1"
BASE_URL = "http://localhost:11223/v1"
URL = f"{BASE_URL}/chat/completions"
# MODEL = "ai/gemma3"
# MODEL = "ai/gemma3n"
MODEL = "gemma3:1b"
@mahenzon
mahenzon / .python-version
Created September 21, 2025 11:15
Python AI LLM example using langchain
3.13
@mahenzon
mahenzon / concat-annotation-example.py
Created August 23, 2025 18:42
Python Concatenate annotation example
from functools import wraps
from timeit import default_timer
from typing import reveal_type, Callable, Concatenate
type ExecutionTime = float
def with_execution_time[**P, T](
func: Callable[P, T],
) -> Callable[P, tuple[T, ExecutionTime]]:
@mahenzon
mahenzon / common.py
Created August 17, 2025 10:17
Python 3.12 ParamSpec example
import logging
# DEFAULT_LOG_FORMAT = "[%(asctime)s.%(msecs)03d] %(funcName)20s %(module)s:%(lineno)d %(levelname)-8s - %(message)s"
DEFAULT_LOG_FORMAT = (
"%(funcName)10s %(module)s:%(lineno)d %(levelname)-8s - %(message)s"
)
def configure_logging(level: int = logging.INFO) -> None:
logging.basicConfig(
@mahenzon
mahenzon / sqla-ms-sql-compile.md
Created August 11, 2025 21:08
SQLAlchemy code to to compile Microsoft SQL w/ latest version to support OFFSET/FETCH

ChatGPT 5 solution after several attempts and corrections.

You're right—just setting _server_version_info isn’t enough; the MSSQL dialect caches feature flags at init. We need to refresh those flags so the compiler knows OFFSET/FETCH is supported.

Use this function (note the call to _setup_version_attributes) and make sure your statement has ORDER BY and .offset(...):

from typing import Optional, Tuple, Union
@mahenzon
mahenzon / config.py
Created April 8, 2025 07:49
Example Telegram bot | Lerna × Suren
import os
TOKEN = os.getenv(
"BOT_TOKEN",
"123:abc",
)
@mahenzon
mahenzon / main.ipynb
Created April 3, 2025 07:36
Python Basics | Lerna × Suren
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mahenzon
mahenzon / main.ipynb
Created April 1, 2025 07:37
Python Intro | Lerna × Suren
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mahenzon
mahenzon / main.ipynb
Created February 16, 2025 09:07
Python functools.partial examples
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.