Skip to content

Instantly share code, notes, and snippets.

View zzstoatzz's full-sized avatar

nate nowack zzstoatzz

View GitHub Profile
from time import sleep
from prefect import flow
@flow
def sleepy(n: int = 3600):
sleep(n)
# /// script
# dependencies = ["prefect"]
# ///
import webbrowser
from dataclasses import dataclass, field
from datetime import datetime
from pathlib import Path
from typing import Any
from prefect import task
def some_fn(x: int, y: str) -> int:
return x + len(y)
some_task = task(some_fn)
print(some_task(x=1, y="hello"))
from typing import Annotated
from pydantic import Field
from pydantic_ai import Agent
# the Field description is respected by the LLM as it produces a list[HistoricEvent]
HistoricEvent = Annotated[str, Field(description="what, where, when, how, why - very concise")]
historic_event_brainstormer = Agent[None, list[HistoricEvent]](
"openai:gpt-4o",
# /// script
# dependencies = ["marvin@git+https://github.com/PrefectHQ/marvin.git@marvin-3"]
# ///
from typing import Annotated, Any, TypedDict
from pydantic import ConfigDict, Field, create_model
from pydantic_core import to_json
import marvin
# /// script
# dependencies = ["httpx", "pydantic-settings"]
# ///
from pathlib import Path
from typing import Any
import httpx
from pydantic import Field
from pydantic_settings import BaseSettings, SettingsConfigDict
@zzstoatzz
zzstoatzz / index.html
Last active December 14, 2024 08:35
html particles impl
<html>
<body style="margin:0;overflow:hidden;background:#000;">
<canvas id="c"></canvas>
<div style="position:fixed;top:1em;right:1em;background:rgba(0,0,0,0.85);color:#fff;padding:1.5em;border-radius:8px;min-width:200px;box-shadow:0 2px 10px rgba(0,0,0,0.5);">
<h3 style="margin:0 0 1em 0;font-family:system-ui;font-weight:400;">Particle Controls</h3>
<label style="display:block;margin-bottom:0.5em;font-family:system-ui;">Count: <span id="v" style="color:#8FBC8F;"></span></label>
<input id="count" type="range" min="10" max="2000" value="500" step="10" style="width:100%;margin-bottom:1em;">
<label style="display:block;margin-bottom:0.5em;font-family:system-ui;">Attraction: <span id="fv" style="color:#87CEEB;"></span></label>
<input id="force" type="range" min="-10000" max="10000" value="0" step="10" style="width:100%;">
</div>
@zzstoatzz
zzstoatzz / mcp_server.py
Last active December 7, 2024 05:18
reference mcp server impl
# echo OPENAI_API_KEY=$OPENAI_API_KEY > .env
# uv run --with marvin --with fastmcp fastmcp install mcp_server.py -f .env
# open -a Claude
import marvin
from fastmcp import FastMCP
server = FastMCP("Fruit server", dependencies=["marvin"])
@server.tool()
def generate_fruit(n: int, color: str) -> list[str]:
@zzstoatzz
zzstoatzz / quote_with_image.py
Last active December 6, 2024 06:11
its like quite bespoke spelling, but ive been digging in this SDK for a while :)
import httpx
from atproto import Client, models
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
"""set the following in your .env file
BSKY_USERNAME=your_username
BSKY_PASSWORD=your_password
"""
from pydantic import BaseModel
from prefect import flow
class MyModel(BaseModel):
my_int: int = 3
my_string: str = "foo"