Search
duckdbExample
@ychahwan
DuckDB DuckDB works on Val Town, with only one small tweak! We're basically using DuckDB in the same way you'd use it with a browser - using the WASM package with its dependencies fetched from jsdelivr . The only trick is to create the worker ourselves rather than using duckdb.createWorker . DuckDB's built-in createWorker method doesn't specify a worker type, which causes type to default to classic , and Deno (our runtime) doesn't support classic workers.
Script
import { fetch } from "https://esm.town/v/std/fetch";
export let duckdbExample = (async () => {
async function createWorker(url: string) {
const workerScript = await fetch(url);
const workerURL = URL.createObjectURL(await workerScript.blob());
val_7kR931x6hU
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_7kR931x6hU(req) {
try {
// Execute the code directly and capture its result

whoIsHiring
@vawogbemi
WIP Searcher for HN whos hiring posts HonoJs doesn't support render for async components so the style is off for the home page. And the state changes don't register in html rendering so thinking of using react instead.
HTTP
import About from "https://esm.town/v/vawogbemi/whoIsHiringAbout";
function App() {
const tabs = { "/": "Home", "/about": "About" };
: <About />}
function ServerApp() {
return (
hydrateRoot(document.getElementById("root"), <App />);
export default async function(req: Request): Promise<Response> {
const url = new URL(req.url);
generateOpenGraphTags
@dthyresson
// Helper function to escape HTML special characters
Script
type?: string;
export function generateOpenGraphTags(data: OpenGraphData): string {
const { title, description, image, url, type = "website" } = data;
`.trim();
// Helper function to escape HTML special characters
function escapeHtml(str: string): string {
return str
Hello_World
@rozek
(just a simple experiment with Val.Town)
HTTP
const TrackingTable = 'Hello_World'
const Granularity = 15*60*1000
export default async function (Request:Request):Promise<Response> {
if (Request.method !== 'GET') {
return new Response('Method Not Allowed', { status:405 })

status
@stevekrouse
Moved to https://www.val.town/x/stevekrouse/status
HTTP
import { renderToString } from "npm:react-dom/server";
function StatusRow({ rows }) {
return (
</div>
function StatusSection({ url, rows }) {
const sectionRows = rows.filter(row => row[0] === url);
</div>
export default async function(req: Request): Promise<Response> {
const { rows } = await sqlite.execute(
twitterAuthHandler
@andreterron
An interactive, runnable TypeScript val by andreterron
Script
import { redirectResponse } from "https://esm.town/v/andreterron/redirectResponse";
import { nanoid } from "https://esm.town/v/stevekrouse/nanoid?v=3";
export async function twitterAuthHandler(
req: Request,
{ client_id, client_secret, redirect_uri, scopes, storage }: {
aqi
@debugtheworldbot
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";
export async function aqi(interval: Interval) {
const location = "shanghai"; // <-- change to place, city, or zip code
const data = await easyAQI({ location });
union69
@git
An interactive, runnable TypeScript val by git
HTTP
export default async function(req: Request): Promise<Response> {
const url = new URL(req.url);
const passedUrl = url.searchParams.get("url");
splendidSapphireMockingbird
@maxm
An interactive, runnable TypeScript val by maxm
HTTP
export default async function (req: Request): Promise<Response> {
console.log(req)
return Response.json({ ok: true })
getValsContextWindow
@janpaul123
An interactive, runnable TypeScript val by janpaul123
Script
export default async function getValsContextWindow(model: any) {
prompt: "Write a val that uses OpenAI",
code: `import { OpenAI } from "https://esm.town/v/std/openai";
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
export default async function(req: Request) {
function tsResponse(code) {
Our Blob SDK also includes some utility functions to make working with blobs easier.
"\n```ts\nexport default async function (req: Request): Promise<Response> {\n return Response.json(\"Hello world\")\n}\n```",
"\n```ts\nexport default async function(req: Request): Promise<Response> {\n const query = new URL(req.url).searchParams;\n\n // Read name from the querystring or body. Defaults to \"you\" if not present.\n const name = query.get(\"name\") || (await req.json().catch(() => ({}))).name || \"you\";\n\n // Returns the HTML response\n return new Response(`<h1>Hi ${name}!</h1>`, {\n headers: { \"Content-Type\": \"text/html\" },\n });\n}\n```",
valle_tmp_50233488852596886867290577619636
@janpaul123
// This val will respond to any request with "Hello, world!"
HTTP
// This val will respond to any request with "Hello, world!"
export default async function(req: Request): Promise<Response> {
return new Response("Hello, world!", { headers: { "Content-Type": "text/plain" } });
anime
@tempguy
@jsxImportSource npm:hono@3/jsx
HTTP
let streams = []
function initPlayer() {
const video = document.querySelector("media-player");
loadServer(streams[0])
function loadServer(val) {
const player = document.querySelector("media-player");
JSON.stringify(results)
};function loadVideo(index){const videoStream=videoData[index].stream[0];const quality=videoStream.qualities.unknown;const url=quality.url;if(quality.type==='m3u8'){if(Hls.isSupported()){const hls=new Hls();hls.loadSource(url);hls.attachMedia(videoElement);}else if(videoElement.canPlayType('application/vnd.apple.mpegurl')){videoElement.src=url;}}else if(quality.type==='mp4'){videoElement.src=url;}videoElement.load();videoElement.play();}</script></body></html>`,
app.get("/", async (c) => {
falImageGen
@isidentical
* Generates an image with Stable Diffusion XL through fal.ai
*
* @param {string} prompt - The input prompt to send to SDXL model.
* @returns {Promise<string>} A promise that resolves to the URL of the image.
Script
* @param {string} prompt - The input prompt to send to SDXL model.
* @returns {Promise<string>} A promise that resolves to the URL of the image.
export async function generateImage(
input: string,
): Promise<{ url: string }> {