Skip to content

Instantly share code, notes, and snippets.

german_text = "Sprachkenntnisse sind ein wichtiger Bestandteil der Kommunikation."
class TranslatedString(BaseModel):
input_language: str = Field(
...,
description="The language of the original text, as 2-letter language code."
)
translation: str
print("SCHEMA:")
@intellectronica
intellectronica / asyncai.py
Last active September 23, 2024 19:45
Running multiple LLM calls in parallel with asyncio
import asyncio
from openai import AsyncOpenAI
import random
oai = AsyncOpenAI()
numbers = [str(random.randint(0, 123456789)) for _ in range(7)]
async def explain_number(number):
print(f'START: Explain the number {number}') # DEBUG
from fasthtml.common import *
app, rt = fast_app()
@app.get("/showtime")
def showtime():
return Script("document.getElementById('time').innerText = (new Date()).toLocaleTimeString();" id='showtimescript')
@app.get("/")
def home():
@intellectronica
intellectronica / redirect-to-archive-ph.js
Created October 25, 2024 13:20
Userscript (for running with your monkey extension of choice) to redirect paywalled site articles to their archive.ph copy
// ==UserScript==
// @name redirect-to-archive-ph
// @match *://*/*
// ==/UserScript==
(function() {
'use strict';
if (window.location.href.includes('archive.ph')) return;
@intellectronica
intellectronica / overcoming-bias-anthology-md.ipynb
Created December 14, 2024 21:42
overcoming-bias-anthology-md.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
  • You are representing the author of the source. Respond as if you are the author, based on the ideas in the source.
  • Your answers should be confident and to the point - typically one paragraph (3-5 sentences), followed by a list (7-13 key points), and finally a verbatim quote from the source.
  • After answering, always make a suggestion for 3-5 things I might want to explore next. Present them as a numbered list, so that I can simply respond with a number to trigger the next topic.
@intellectronica
intellectronica / boost-mastodon-posts.py
Created December 19, 2024 08:52
Boost all posts from a Fediverse account you follow (useful for boosting a bridged account's posts, for example)
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "Mastodon.py",
# ]
# ///
import os
from mastodon import Mastodon
from datetime import datetime, timedelta
$ llm templates show scripter
model: gpt-4o
name: scripter
system: 'You write Python tools as single files. They always start with this comment:
# /// script
# requires-python = ">=3.12"
# ///
model: gpt-4.1
system: |
You write Python tools as single file script.
They always start with this comment:
# /// script
# requires-python = ">=3.12"
# ///
These files can include dependencies on python packages from PyPI.
If they do, those dependencies are included in a list like this one in that same comment (here showing two dependencies):
@intellectronica
intellectronica / pydantic-ai-openai-strict.ipynb
Last active December 26, 2024 19:08
pydantic-ai-openai-strict.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.