Skip to content

Instantly share code, notes, and snippets.

@sharmuz
sharmuz / pickling.py
Last active November 5, 2025 10:49
A useful pattern to serialize a model (or other object) when JSON won't cut it.
# /// script
# requires-python = ">=3.14"
# dependencies = []
# ///
import copyreg
import pickle
import random
from pathlib import Path
from typing import Any, Callable, Self
@sharmuz
sharmuz / LICENCE
Created November 4, 2025 09:08
This is the default licence for all repositories and gists I have made publicly available on my Github profile, where no licence is present in the repository/gist itself.
MIT License
Copyright (c) sharmuz.
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:
@sharmuz
sharmuz / agent_using_mcp.py
Last active November 5, 2025 10:55
Basic MCP usage
#!/usr/bin/env -S uv run --script
#
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "pydantic-ai-slim[anthropic,cli,mcp]"
# ]
# ///
import asyncio