Search
globalDocument
@easrng
An interactive, runnable TypeScript val by easrng
Script
const elementTypes = [
"HTMLTableColElement",
"HTMLFieldSetElement",
"SVGTSpanElement",
"HTMLDataListElement",
"SVGFEMergeElement",
"SVGFEGaussianBlurElement",
"SVGStyleElement",
"SVGViewElement",
"HTMLQuoteElement",
sendRandomChihuahuaToSlack
@metart43
An interactive, runnable TypeScript val by metart43
Script
export async function sendRandomChihuahuaToSlack() {
const dogAPIURL = new URL(
"https://dog.ceo/api/breed/chihuahua/images/random",
const dogApiResp = await fetch(dogAPIURL.href);
const { message } = await dogApiResp.json();
const res = await fetch(process.env.BROOKLAND_SLACK_WEBHOOK_URL, {
method: "POST",
body: JSON.stringify({
"text": `${message}`,
return res.statusText;
testingRunAllInValTown
@iamseeley
An interactive, runnable TypeScript val by iamseeley
HTTP
export default async function handler(req: Request): Promise<Response> {
const pythonCode = `
def greet(name):
message = f"Hello, {name}! Welcome to Val Town."
name_length = len(name)
reversed_name = name[::-1]
additional_info = f"Your name has {name_length} characters and reversed it is '{reversed_name}'."
# numpy
array = np.array([1, 2, 3, 4, 5])
array_sum = np.sum(array)
valle_tmp_4674518929569141580380318140624
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP
Here's the updated Hacker News clone with realistic sample data and a separate submission page, styled to look exactly like Hacker News:
ts
// Initialize sample stories and store them in blob storage
const SAMPLE_STORIES_KEY = "hn_realistic_sample_stories";
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
const sampleStories = Array.from({ length: 30 }).map((_, idx) => ({
id: idx + 1,
title: faker.company.catchPhrase(),
pythonHTTPVal
@rawwerks
pyodide 🤝 deno trick pyodide to execute python code in the deno runtime deno module source: py-town not all python packages are supported by pyodide
HTTP
# pyodide 🤝 deno
trick pyodide to execute python code in the deno runtime
deno module source: [py-town](https://github.com/iamseeley/py-town)
> not all python packages are supported by pyodide
let pyodide;
async function initializePyodide() {
if (!pyodide) {
pyodide = await loadPyodide({
indexURL: "https://cdn.jsdelivr.net/pyodide/v0.23.4/full/",
await pyodide.loadPackage("numpy");
View
@adamgonda
An interactive, runnable TypeScript val by adamgonda
Script
export function View(width, height) {
return { width, height };
peculiarTanMouse
@jamisonl
Bot for Cama discord server. To initialize new slash commands, you have to run a separate bit of code. This is for modifying their functionality
HTTP
Bot for Cama discord server. To initialize new slash commands, you have to run a separate bit of code. This is for modifying their functionality
// Bump version
let bank = await blob.getJSON("bank");
let bets = await blob.getJSON("bets");
const starting_amount = 5;
if (!bank) {
bank = {};
await blob.setJSON("bank", bank);
if (!bets) {
bets = [];
nyChargingStations
@tmcw
NYC Charging Stations Data Analysis https://tmcw-nychargingstations.web.val.run/ This analyzes some open data about electric car charging stations in New York State and bakes a website from it. Data is messy!
HTTP
# NYC Charging Stations Data Analysis
![CleanShot 2023-09-21 at 12.07.43@2x.png](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/646cccab-ca23-486d-d084-8a805e73ac00/public)
https://tmcw-nychargingstations.web.val.run/
This analyzes some [open data about electric car charging stations in New York State](https://data.ny.gov/Energy-Environment/Electric-Vehicle-Charging-Stations-in-New-York/7rrd-248n) and bakes a website from it. Data is messy!
export const nyChargingStations = (async () => {
const { csvParse } = await import("npm:d3-dsv");
const { group } = await import("npm:d3-array");
const { micromark } = await import("npm:micromark");
const rows = await fetch(
"https://data.ny.gov/api/views/7rrd-248n/rows.csv?accessType=DOWNLOAD&sorting=true",
web_Oj5sZZxXOR
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_Oj5sZZxXOR(req) {
return new Response(`<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Even More Unhinged Mermaid Diagram</title>
<script src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"></script>
<style>
body {
my_thing
@whatrocks
An interactive, runnable TypeScript val by whatrocks
Script
import { testy } from "https://esm.town/v/whatrocks/testy";
export let my_thing = testy;
libasp
@vladimyr
// SPDX-License-Identifier: 0BSD
Script
// SPDX-License-Identifier: 0BSD
export { HTTPError as HTTPError };
export type HashAlgorithm = "shake128" | "shake256";
const reLegacyAspeURI = /^aspe:(?:\/\/)?(?:(?<hostname>[^\s\/:]+)(?:\/|:))?(?<keyId>[A-Za-z0-9]{26})$/;
const reAspeURI = /^aspe:(?:\/\/(?<hostname>[^\s\/]+)\/)?(?<fingerprint>[A-Fa-f0-9]{40})$/;
export type AspeURI = ReturnType<typeof parseAspeURI>;
export function parseAspeURI(input: string) {
const match = input.match(reAspeURI);
if (!match) return null;
const { hostname, fingerprint } = match.groups;
val_QEZMJDAFaF
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export default async function handler(req) {
try {
const result = await (async () => {
function isPrime(num) {
if (num <= 1) return false;
for (let i = 2; i <= Math.sqrt(num); i++) {
if (num % i === 0) return false;
return true;
function findLowestThreeDigitPrime() {
for (let num = 100; num < 1000; num++) {
georgiaTechRegistration
@brownieinmotion
// ported from https://github.com/brownie-in-motion/gt-waitlist-bot
HTTP
// ported from https://github.com/brownie-in-motion/gt-waitlist-bot
const ENDPOINT = "https://oscar.gatech.edu/pls/bprod/bwckschd.p_disp_detail_sched";
const TERM = "202402";
export async function georgiaTechRegistration(request: Request): Promise<Response> {
const course = new URL(request.url).searchParams.get("courseId")?.toString();
if (course === undefined) return Response.json({ error: "missing courseId" });
const url = new URL(ENDPOINT);
url.searchParams.set("term_in", TERM);
url.searchParams.set("crn_in", course);
const data = await fetch(url);
midnightpubFeed
@vladimyr
// @see: https://git.sr.ht/~m15o/midnight-pub/tree/master/item/model/user.go#L28
HTTP
const BASE_URL = "https://midnight.pub";
// @see: https://git.sr.ht/~m15o/midnight-pub/tree/master/item/model/user.go#L28
const reUserFeed = /^\/(?<username>~[a-z0-9-_]+)\.(?<format>atom|rss)$/;
export default async function(req: Request): Promise<Response> {
const { pathname } = new URL(req.url);
const match = pathname.match(reUserFeed);
if (!match) {
return new Response(null, { status: 400 });
const { format, username } = match.groups;
const profileURL = new URL(`/${username}`, BASE_URL);
web_jvEOd6FdXL
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_jvEOd6FdXL(req) {
return new Response(`<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dr. Nefarious's EVIL PLAN #2: Operation Rubber Duck Uprising!</title>
<style>
body {
background-color: #000;