Search

myApi
@timoc
An interactive, runnable TypeScript val by timoc
Script
export function myApi(name) {
return "hi " + name;
searchPostsForTheActuallyBot
@andreterron
An interactive, runnable TypeScript val by andreterron
Script
import { searchTweets } from "https://esm.town/v/andreterron/searchTweets";
export async function searchPostsForTheActuallyBot(accessToken: string): Promise<{
id: string;
text: string;
pocket
@andreterron
An interactive, runnable TypeScript val by andreterron
Script
export function pocket() {
return {
hello: () => { return 'hi there' }
aqi
@cai
AQI Alerts Get email alerts when AQI is unhealthy near you. Set up Click Fork Change location (Line 4) to describe your location. It accepts fairly flexible English descriptions which it turns into locations via nominatim's geocoder API . Click Run Background This val uses nominatim's geocoder to get your lat, lon, and air quality data from OpenAQ. It uses EPA's NowCast
AQI Index calculation and severity levels. Learn more: https://www.val.town/v/stevekrouse.easyAQI
Cron
import { email } from "https://esm.town/v/std/email?v=9";
import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
export async function aqi(interval: Interval) {
const location = "salt lake city"; // <-- change to place, city, or zip code
const data = await easyAQI({ location });
GDI_HelloWorld
@rozek
This val is part of a series of examples to introduce "val.town" in my computer science course at
Stuttgart University of Applied Sciences . The idea is to motivate even first-semester students not to wait but to put their
ideas into practice from the very beginning and implement web apps with
frontend and backend. It contains a very simple (but still a bit visually impressive) "Hello, World!"
web page made with Townie. This val is licensed under the MIT License.
HTTP
import { createRoot } from "https://esm.sh/react-dom/client";
function App() {
return (
</div>
function client() {
const root = document.getElementById('root');
client();
export default async function server(request: Request): Promise<Response> {
return new Response(`
cerebras_coder
@Danap
This is an AI code assistant powered by Cerebras , running llama3.3-70b. Inspired by Hassan's Llama Coder . Setup Sign up for Cerebras Get a Cerebras API Key Save it in a Val Town environment variable called CEREBRAS_API_KEY
HTTP
import { STARTER_PROMPTS } from "https://esm.town/v/stevekrouse/cerebras_coder_prompts";
function extractCodeFromFence(content: string): string {
const codeMatch = content.match(/```html\n([\s\S]*?)```/);
return codeMatch ? codeMatch[1].trim() : content.trim();
async function generateCode(prompt: string, currentCode: string) {
const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
totalTokens: completion.usage?.completion_tokens || 1,
function App() {
const [prompt, setPrompt] = useState('');
</div>
function client() {
// Add Tailwind CSS for styling
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
if (request.method === 'POST' && new URL(request.url).pathname === '/generate') {
amusedAquaHeron
@codefromanywhere
An interactive, runnable TypeScript val by codefromanywhere
HTTP
export default async function handler(request: Request) {
if (request.method !== "POST") {
return Response.json({ message: "This val responds to POST requests." }, {
linkInBioTemplate
@rasputinkaiser
@jsxImportSource https://esm.sh/react
HTTP
// ... (previous AuthContext, AuthProvider, and useAuth remain the same)
function App() {
// ... (App component remains the same)
function Home({ theme }) {
const { user } = useAuth();
</div>
function PromptGenerator() {
const [prompt, setPrompt] = useState('');
</div>
function Tools({ theme }) {
const isDark = theme === 'dark';
</div>
function Gallery({ theme }) {
const isDark = theme === 'dark';
fontStyle: 'italic',
// ... (client and server functions remain the same)
val_WzWC3no9LW
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_WzWC3no9LW(req) {
try {
// Execute the code directly and capture its result
valle_tmp_0114941516041842115534002538246594
@janpaul123
// This val responds with "Hello, world!"
HTTP
// This val responds with "Hello, world!"
export default async function(req: Request): Promise<Response> {
return new Response("Hello, world!");
claude_a17f63b5_0c2b_4964_9a77_9229fece4c33
@adagradschool
An interactive, runnable TypeScript val by adagradschool
HTTP
export default function handler(req) {
return new Response(`"\n <!DOCTYPE html>\n <html>\n <head>\n <title>Claude Chat Conversation</title>\n <meta charset=\"UTF-8\">\n <style>\n body {\n font-family: system-ui, -apple-system, sans-serif;\n line-height: 1.5;\n max-width: 800px;\n margin: 0 auto;\n padding: 20px;\n background: #f9fafb;\n }\n .message {\n margin: 20px 0;\n padding: 15px;\n border-radius: 8px;\n }\n .human {\n background: #e5e7eb;\n }\n .assistant {\n background: #dbeafe;\n }\n .role {\n font-weight: bold;\n margin-bottom: 8px;\n }\n </style>\n </head>\n <body>\n \n <div class=\"message human\">\n <div class=\"role\">Human</div>\n <div class=\"content\">This is an engineering proposal. Convert that into a tech talk about 10 minutes long</div>\n </div>\n \n <div class=\"message assistant\">\n <div class=\"role\">Claude</div>\n <div class=\"content\">Tech Talk: Optimizing Data Storage with Symbol TablesClick to open document\nThis tech talk covers the key aspects of your data optimization project in a format suitable for a 10-minute presentation. Would you like me to adjust any specific section or add more technical details to any part?</div>\n </div>\n \n <div class=\"message human\">\n <div class=\"role\">Human</div>\n <div class=\"content\">Write the script for it</div>\n </div>\n \n <div class=\"message assistant\">\n <div class=\"role\">Claude</div>\n <div class=\"content\">Tech Talk Script: Optimizing Data Storage with Symbol TablesClick to open document\nThis script should take about 10 minutes to deliver at a comfortable speaking pace. It maintains technical depth while remaining accessible and includes natural transitions between sections. Would you like me to adjust any particular section or add more technical details anywhere?\nKey features of the script:\n\nConversational tone while maintaining technical accuracy\nClear narrative arc from problem to solution to results\nTechnical details balanced with practical implications\nSpecific examples and metrics to support key points\nNatural breaking points for slides/demos if needed</div>\n </div>\n \n <div class=\"message human\">\n <div class=\"role\">Human</div>\n <div class=\"content\">Draw a mermaid diagram to show data flows in a decision flow</div>\n </div>\n \n <div class=\"message assistant\">\n <div class=\"role\">Claude</div>\n <div class=\"content\">I'll create a Mermaid diagram showing how data flows through the system, including the new symbol table optimization.\nDecision Flow System ArchitectureClick to open diagram\nThe diagram shows the complete flow of data through our system:\n\nClient sends input data to Router\nRouter directs request to Runner\nRunner:\n\nExecutes the decision flow\nCollects node results\nApplies symbol table deduplication\n\n\nDecision message sent via EventBridge\nArchiver:\n\nProcesses the message\nStores data across three tables:\n\nSymbol Table (new)\nDecision Table\nData Table\n\n\n\n\nExporter retrieves data via Decision History API\n\nThe color coding helps distinguish:\n\nPink: Services\nBlue: Databases\nYellow: Message bus\n\nWould you like me to modify any part of the diagram or add more detail to any specific component?</div>\n </div>\n \n <div class=\"message human\">\n <div class=\"role\">Human</div>\n <div class=\"content\">I meant in the decision flow, as the data flow through the nodes, how it accumulates node results</div>\n </div>\n \n <div class=\"message assistant\">\n <div class=\"role\">Claude</div>\n <div class=\"content\">Ah, I'll create a Mermaid diagram showing how data flows through nodes in a decision flow and how node results accumulate, both in the original format and with symbol table optimization.\nDecision Flow Node Results AccumulationClick to open diagram\nThis diagram contrasts the two approaches:\n\nOriginal Storage (top):\n\nEach node stores complete copies of all data\nData accumulates and duplicates as it flows through nodes\nNode 3 ends up storing three copies of the same values\n\n\nSymbol Table Storage (bottom):\n\nUnique key-value pairs stored once in symbol table\nNodes only store indexes to the symbol table\nNo data duplication\nEasy to reconstruct full state at any node using indexes\n\n\n\nColor coding:\n\nPink: Flow nodes\nLight blue: Original node results\nYellow: Symbol table entries\nBlue: Node result indexes\n\nThe optimization becomes more apparent as data flows through the nodes - while the original storage duplicates values at each step, the symbol table approach maintains a single copy of each unique value and uses lightweight indexes to reference them.\nWould you like me to adjust any part of the diagram or add more detail to better illustrate the data flow?</div>\n </div>\n \n <div class=\"message human\">\n <div class=\"role\">Human</div>\n <div class=\"content\">It will be with a technical member on the team, please come prepared to talk through a technical project that you've worked on previously. Be ready to walk through the specific pieces of the project you owned, the architecture of the system, and the impact of the decisions made. You should be prepared to describe the project for at least ~20 minutes, going into significant technical detail about key components, also feel free to prepare diagrams and slides if that will help you describe the project.</div>\n </div>\n \n <div class=\"message assistant\">\n <div class=\"role\">Claude</div>\n <div class=\"content\">I'll help you prepare for a technical deep dive interview by creating a comprehensive walkthrough of PEP 186 based on the document. Let's structure this with both a narrative outline and supporting diagrams.\nSystem ArchitectureClick to open diagram\nNode Result CompressionClick to open diagram\nHere's the technical deep dive outline for a 20-minute discussion:\n\nProject Overview (2 minutes)\n\nProblem: Rapidly growing Aurora storage costs\nGoals: 80% data reduction, 50% cost reduction for key customers\nPerformance constraints: <5ms latency impact\nKey customer impact: Isaac, Branch, and Zilch use cases\n\n\nTechnical Analysis (3 minutes)\n\nRoot cause: Data duplication in node results\nInitial compression analysis showing ~20.6% with basic approach\nTheoretical limits study using lz4 compression\nDecision to use symbol tables based on append-only nature of data\n\n\nCore Technical Solution (5 minutes)\n\nSymbolTableV2 class design:\npythonCopyclass SymbolTableV2(BaseModel):\n version: t.Literal[\"v2\"]\n tbl: list[orjson.Fragment] = []\n tix: list[SymbolTableRef] = []\n\nKey optimizations:\n\nKey-value pair deduplication vs value-only\nIndex-based references vs 64-bit hashes\nZSTD compression for serialized data\n\n\nStorage schema decisions and rationale for separate table\n\n\nSystem Architecture (4 minutes)\n\nPipeline components:\n\nRunner: Symbol table creation and compression\nEventBridge: Message transport\nArchiver: Persistence and version handling\nExporter: Decision history API integration\n\n\nDatabase schema evolution\nBackward compatibility handling\n\n\nEdge Cases & Challenges (3 minutes)\n\nAsync resumptions and out-of-order messages\nFlow of flows and nested decision handling\nLoop handling\nProvenance data preservation\nVersion compatibility during rollout\n\n\nResults & Impact (3 minutes)\n\nCompression improvement: 20.6% → 86%\nMessage size reduction: 65KB → 25KB\nCost impact for key customers\nPerformance metrics showing <5ms latency impact\nStorage growth rate flattening\n\n\n\nKey technical points to emphasize:\n\nWhy we chose a separate symbol table vs using the existing data table\nTrade-offs in moving deduplication upstream to Runner\nCompression algorithm selection and performance implications\nSchema design decisions and indexing strategy\nBackward compatibility approach\n\nQuestions to be prepared for:\n\nWhy not use database-level compression (TOAST)?\nAlternative approaches considered\nScalability implications\nRecovery and error handling\nPerformance monitoring and alerts\nFuture optimization opportunities\n\nWould you like me to expand on any of these sections or create additional diagrams to illustrate specific components?</div>\n </div>\n \n </body>\n </html>\n"`, {
headers: {

fal_sdxl
@turbo1912
fal/sdxl This val is an example usage sdxl with fal.ai's javascript client. https://www.fal.ai/models/stable-diffusion-xl The client offers a way for you to subscribe to queue updates. This is useful if you want to get notified when a function is done running, or if you want to get the logs as they are being generated. import fal from "npm:@fal-ai/serverless-client";
const result = await fal.subscribe(FUNCTION_ID, {
input: {
seed: 176400,
},
pollInterval: 5000,
logs: true,
onQueueUpdate: (update) => {
console.log(update.status);
if (update.status === "IN_PROGRESS") {
update.logs.map((log) => log.message).forEach(console.log);
}
},
});
console.log(result.url); The onQueueUpdate callback will be called every time the queue status changes. The update object contains the queue status data as documented on the status types section .
Script
https://www.fal.ai/models/stable-diffusion-xl
The client offers a way for you to subscribe to queue updates. This is useful if you want to get notified when a function is done running, or if you want to get the logs as they are being generated.
```js
import fal from "npm:@fal-ai/serverless-client";
const result = await fal.subscribe(FUNCTION_ID, {
input: {
expositionAgencyPage
@bladesquad
@jsxImportSource https://esm.sh/react
HTTP
[key: string]: string | null;
function ExpolineParticipationForm() {
const [step, setStep] = useState(0);
</div>
function client() {
createRoot(document.getElementById("root")).render(<ExpolineParticipationForm />);
width: 100%;
export default async function server(request: Request): Promise<Response> {
return new Response(`