Skip to content

Instantly share code, notes, and snippets.

View ftnext's full-sized avatar

nikkie ftnext

View GitHub Profile
<!DOCTYPE html>
<html>
<body>
DuckDB Wasm Example from <a href="https://github.com/duckdb/duckdb-wasm/blob/v1.29.0/examples/plain-html/index.html"
target="_blank">plain-text example</a>
<script>
const getDb = async () => {
const duckdb = window.duckdbduckdbWasm;
if (window._db) return window._db;
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "wasmtime",
# ]
# ///
# ref: https://docs.wasmtime.dev/lang-python.html
from wasmtime import Store, Module, Instance
store = Store()
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "httpx",
# "python-json-logger",
# "rich",
# ]
# ///
# Based on: https://gist.github.com/ftnext/70cca003272a626bea11396e41b342e0
import logging
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "returns",
# ]
# ///
from collections.abc import Iterable
from pathlib import Path
from returns.result import Result, Success, Failure, safe
import logging
import os
from google.adk.cli.utils.agent_loader import AgentLoader
# logger name: https://github.com/google/adk-python/blob/v1.2.1/src/google/adk/cli/utils/agent_loader.py#L25
agent_loader_logger = logging.getLogger("google_adk.google.adk.cli.utils.agent_loader")
agent_loader_logger.setLevel(logging.DEBUG)
console_handler = logging.StreamHandler()
console_handler.setFormatter(logging.Formatter("%(name)s:%(funcName)s:%(lineno)d - %(message)s"))
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "tqdm",
# ]
# ///
import os
from urllib.request import urlopen
from tqdm import tqdm
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "httpx",
# "tqdm",
# ]
# ///
import os
import httpx
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "requests",
# "tqdm",
# ]
# ///
import os
import requests
# ref: https://github.com/ftnext/fastapi-playground/blob/d57513e38ce92f932c151935605b693cc91c32de/apiroute/app.py
# uvx --with fastapi uvicorn app:app --log-level info --reload
import json
import logging
from fastapi import APIRouter, Body, FastAPI, Request, Response
from fastapi.routing import APIRoute
logger = logging.getLogger("uvicorn.myapp") # hack to easy logging