Search

Results include substring matches and semantically similar vals. Learn more
tempguy avatar
orangeSole
@tempguy
// "button-click=ZEhKMVpTLVF0LVBTLVF0LVBqLVY0TFMtUXpOLTBjdEwtMC1WMy1Qai1WLVFOLTAtUHktUHotUDMtUERnLTU=&button-referer=",
Script
const baseURLReq = await fetch(
"https://multiembed.mov?video_id=114472&tmdb=1&s=1&e=2",
method: "GET",
redirect: "manual",
const baseURL = await baseURLReq.headers.get("location");
const headers = {
"accept":
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exch
"content-type": "application/x-www-form-urlencoded",
"Referer": baseURL,
dhvanil avatar
val_rSdr9CumnJ
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_rSdr9CumnJ(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
// Test for floating point precision anomalies
function testFloatingPointPrecision() {
const results = [];
// Test 1: Basic arithmetic that should equal 1
const test1 = 0.1 + 0.2 + 0.7;
results.push({
nbbaier avatar
micromarkTest
@nbbaier
An interactive, runnable TypeScript val by nbbaier
Script
import { buildLayout } from "https://esm.town/v/nbbaier/buildLayout";
export const micromarkTest = async (
req: express.Request,
res: express.Response
const { micromark } = await import("npm:micromark");
const md = "*emphasis* and **strong**";
res.send(
buildLayout({
body: micromark(md),
// res.send(micromark(md));
dhvanil avatar
val_bH5VlbZAwW
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_bH5VlbZAwW(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
function generateArrayProblem() {
const operations = ['find duplicates', 'remove duplicates', 'find missing numbers', 'rotate array'];
const sizes = ['small', 'medium', 'large'];
const constraints = ['in O(n) time', 'using constant space', 'without using extra space'];
const operation = operations[Math.floor(Math.random() * operations.length)];
const size = sizes[Math.floor(Math.random() * sizes.length)];
janpaul123 avatar
valle_tmp_26658746570535136802306869503814
@janpaul123
An interactive, runnable TypeScript val by janpaul123
HTTP
export default async function main(req: Request): Promise<Response> {
// Helper functions for Blob storage
async function getBlob(key: string): Promise<any> {
const response = await fetch(`https://api.val.town/v/std/blob-${key}`);
if (!response.ok) throw new Error("Error fetching blob data");
return response.json();
async function setBlob(key: string, data: any): Promise<void> {
const response = await fetch(`https://api.val.town/v/std/blob-${key}`, {
method: "POST",
headers: { "Content-Type": "application/json" },
janpaul123 avatar
valle_tmp_555105500793107210304339105611282
@janpaul123
// This val serves an HTML page with a form to enter your name.
HTTP
// This val serves an HTML page with a form to enter your name.
// When the form is submitted, it greets you with "Hello, <name>!".
export default async function(req: Request): Promise<Response> {
let name = "";
if (req.method === "POST") {
const formData = await req.formData();
name = formData.get("name") as string || "";
const html = `
<!DOCTYPE html>
<html lang="en">
janpaul123 avatar
valle_tmp_130746396595421232473002690954744
@janpaul123
This code sets up a simple comment box system styled with Tailwind CSS. * It leverages Deno's blob storage for persistence, * and renders an HTML form to accept new comments, * while displaying all existing comments.
HTTP
/** This code sets up a simple comment box system styled with Tailwind CSS.
* It leverages Deno's blob storage for persistence,
* and renders an HTML form to accept new comments,
* while displaying all existing comments.
// Key for blob storage
const COMMENTS_KEY = "comments_storage";
// HTML template for the form and comments list
const getHtml = (comments: string[]) => `
<html>
<head>
nbbaier avatar
sentryTesting
@nbbaier
// app.post("/tunnel", async (c) => {
HTTP
const app = new Hono();
const SENTRY_KEY = Deno.env.get("SENTRY_KEY") as string;
const SENTRY_HOST = Deno.env.get("SENTRY_HOST") as string;
const SENTRY_PROJECT_ID = Deno.env.get("SENTRY_PROJECT_ID") as string;
const jsEndpoint = "sentry.js";
app.get("/", c =>
c.html(html`<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
stevekrouse avatar
blob_admin_home
@stevekrouse
@jsxImportSource https://esm.sh/hono@3.9.2/jsx
Script
/** @jsxImportSource https://esm.sh/hono@3.9.2/jsx **/
export async function blob_admin_home() {
let blobs = await blob.list();
return (
<div>
<style>{css}</style>
<h1>Blob Admin</h1>
<a href="/new" style={{ marginBottom: "1em", display: "inline-block" }}>New Blob</a>
<table>
<thead>
git avatar
faucets
@git
An interactive, runnable TypeScript val by git
HTTP
export default async function(req: Request): Promise<Response> {
return new Response(
JSON.stringify(
asset: "eth",
links: [
"https://covalenthq.com/faucet/#form",
"https://faucet.quicknode.com/ethereum/sepolia",
"https://infura.io/faucet/sepolia",
asset: "usdc",
links: ["https://faucet.circle.com"],
uvis avatar
vueHelloWorld
@uvis
// https://uvis-vuehelloworld.web.val.run/
HTTP
// https://uvis-vuehelloworld.web.val.run/
export const vueHelloWorld = () =>
new Response(
<!DOCTYPE html>
<html>
<head>
<title>Vue Val</title>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>
<body>
temptemp avatar
cfetch
@temptemp
// using cf cache to speed up things.
Script
// using cf cache to speed up things.
const key = "b540c24b3817eaad0241a2baffdd493229c279357c134cd0a1ade2388c398b7d";
const uuid = "1fd98a05-4959-42bc4-2f83-2c487c1cde6d";
const build = `https://${uuid}.cloudflarepreviews.com/?url=`;
export async function cfetch(input: string | URL, requestInit?: RequestInit) {
return fetch(`${build}${encodeURIComponent(input.toString())}`, {
...requestInit,
headers: {
// "X-CF-Token": `${key}`,
// "cf-raw-http": "true",
janpaul123 avatar
valle_tmp_95010852208558675148806336933602
@janpaul123
// This val serves an HTML page with an input field to enter a name. Upon form submission, it greets the user with the entered name in a pop style.
HTTP
// This val serves an HTML page with an input field to enter a name. Upon form submission, it greets the user with the entere
// We'll enhance the UI with a modern pop effect for the greeting message.
export default async function(req: Request): Promise<Response> {
const html = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Greetings Form</title>
ejfox avatar
todaystats
@ejfox
* This tool fetches real-time data from various free APIs to create a JSON object * representing the current state of the world from different perspectives. * Data is cached for 30 minutes using Val Town's SQLite database to reduce API calls and improve performance.
HTTP
* This tool fetches real-time data from various free APIs to create a JSON object
* representing the current state of the world from different perspectives.
* Data is cached for 30 minutes using Val Town's SQLite database to reduce API calls and improve performance.
const CACHE_DURATION = 30 * 60 * 1000; // 30 minutes in milliseconds
const KEY = new URL(import.meta.url).pathname.split("/").at(-1);
// Ensure the table exists
async function ensureTableExists() {
await sqlite.execute(`
CREATE TABLE IF NOT EXISTS ${KEY}_world_state (
id INTEGER PRIMARY KEY AUTOINCREMENT,
stevekrouse avatar
docFeedbackForm
@stevekrouse
Val Town Docs Feedback Form & Handler Live form Val Town Docs YouTube tutorial that explains v17 of this val This feedback form was linked on our docs site. This val renders an HTML form, including pre-fills the user's email address if they've submitted the form in the past (via a cookie), and pre-fills the URL by grabbing it out of the query params. It handles form submissions, including parsing the form, saving the data into @stevekrouse.docsFeedback , a private JSON val, and then returns a thank you message, and set's the user's email address as a cookie, to save them some keystrokes the next time they fill out the form. Another val, @stevekrouse.formFeedbackAlert , polls on an interval for new form submissions, and if it finds any, forwards them on a private Val Town discord channel. There are a number of subtleties to the way each of some features are implemented. A user submitted three pieces of feedback in quick succession, so I thought it'd be nice if we remembered user's email addresses after their first form submissions. There are classically two ways to do this, cookies or localstorage. I choose cookies. It requires setting them in the response header and getting them out of the request header. I used a Deno library to parse the cookie but I set it manually because that seemed simpler. You may be wondering about how I'm getting the referrer out of the query params instead of from the HTTP Referrer header. I tried that at first, but it's increasingly difficult to get path data from it due to more restrictive security policies . So instead I decided to include the URL data in a query param. I get it there via this script in my blog's site: function updateFeedback(ref) { let feedback = [...document.getElementsByTagName('a')].find(e => e.innerText == 'Feedback') feedback.setAttribute('href', "https://stevekrouse-docfeedbackform.web.val.run/?ref=" + ref) } setTimeout(() => updateFeedback(document.location.href), 100); navigation.addEventListener('navigate', e => updateFeedback(e.destination.url)); Finally, you may be wondering why I queue up feedback in @stevekrouse.docsFeedback , a private JSON val, and then process it via @stevekrouse.formFeedbackAlert instead of sending it along to Discord directly in this val. I tried that originally but it felt too slow to wait for the API call to Discord before returning the "Thanks for your feedback" message. This is where the context.waitUntil method (that Cloudflare workers and Vercel Edge Functions support) would really come in handy – those allow you to return a Response, and then continue to compute. Currently Val Town requires you to stop all compute with the returning of your Response, so the only way to compute afterwards is to queue it up for another val to take over, and that's what I'm doing here.
HTTP
# Val Town Docs Feedback Form & Handler
* [Live form](https://stevekrouse-docFeedbackForm.web.val.run)
* [Val Town Docs](https://docs.val.town)
* [YouTube tutorial](https://www.youtube.com/watch?v=AEaYaWf5B-I) that explains [v17 of this val](https://www.val.town/v/stev
This feedback form was linked on our docs site.
![Screenshot 2023-09-07 at 14.24.25@2x.png](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/eec56deb-a070-4d34-f040-c9e55e06
export let docFeedbackForm = async (req: Request) => {
if (req.method === "POST") {
let formData = await req.formData();
docsFeedback.push({