Search

Results include substring matches and semantically similar vals. Learn more
brianleroux avatar
scrapecapfriendly
@brianleroux
An interactive, runnable TypeScript val by brianleroux
HTTP
export async function handler(request: Request) {
let url = "https://www.capfriendly.com/";
let res = await fetch(url);
let html = await res.text();
let doc = new DOMParser().parseFromString(html, "text/html");
let table = doc.querySelector("table#cf_homepage__teamTable");
let headers = Array.from(table.querySelectorAll("th")).map(h => h.textContent.trim()).map(e => e === "" ? "?" : e);
let rawRows = Array.from(table.querySelectorAll("tr")).map(r => {
let cells = Array.from(r.querySelectorAll("td"));
console.log(cells);
dhvanil avatar
web_5sTKT1xhCs
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_5sTKT1xhCs(req) {
return new Response(`<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gwern Branwen's Research</title>
<style>
body { font-family: 'Georgia', serif; margin: 20px; background-color: #eaeaea; }
header { background: #444; color: #fff; padding: 15px; text-align: center; }
janpaul123 avatar
valle_tmp_9687248893374514440365302223592
@janpaul123
// This val responds with "Hello World" to all incoming HTTP requests along with some crazy CSS gradients
HTTP
// This val responds with "Hello World" to all incoming HTTP requests along with some crazy CSS gradients
export default async function main(req: Request): Promise<Response> {
// CSS with crazy gradients
const css = `
body {
background: linear-gradient(45deg, #ee0979, #ff6a00, #ff6a00, #799f0c);
background-size: 400% 400%;
animation: gradient 15s ease infinite;
@keyframes gradient {
0% {
neverstew avatar
renderFormAndSaveData
@neverstew
An interactive, runnable TypeScript val by neverstew
HTTP
let { submittedEmailAddresses } = await import("https://esm.town/v/neverstew/submittedEmailAddresses");
export const renderFormAndSaveData = async (req: Request) => {
// A visit from a web browser? Serve a HTML page with a form
if (req.method === "GET") {
return new Response(
<!DOCTYPE html>
<html>
<head>
<title>Email Form</title>
</head>
stevekrouse avatar
weeklyTanPony
@stevekrouse
// This val demonstrates how to handle form data and display it back to the user
HTTP
// This val demonstrates how to handle form data and display it back to the user
export default async function server(req: Request): Promise<Response> {
if (req.method === 'POST') {
const formData = await req.formData();
const name = formData.get('name') || '';
return new Response(`
<html>
<body>
<h1>Form Submission Result</h1>
<p>Name: ${name}</p>
andreterron avatar
form_demo
@andreterron
Live demo: https://andreterron-form_demo.web.val.run Form results: https://www.val.town/v/andreterron.formResponses
HTTP
Live demo: https://andreterron-form_demo.web.val.run
Form results: https://www.val.town/v/andreterron.formResponses
export const form_demo = async (req: Request) => {
const title = "Val Town Forms";
const formEndpoint = "https://andreterron-form_handler.web.val.run";
return html(`
<html>
<head>
<title>${title}</title>
<meta charset="UTF-8" />
tempguy avatar
redMonkey
@tempguy
An interactive, runnable TypeScript val by tempguy
Script
const nanoid = customAlphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 10);
const baseUrl = "https://d000d.com";
export async function doodstream(ctx: Context) {
let url = ctx.url;
const id = url.split("/e/")[1];
const doodDataReq = await fetch(
`https://cool-proxy.koyeb.app/hdiuhmalkmc9d0ck7UCFVGBJHN?destination=`
+ encodeURIComponent(`${url}`),
method: "GET",
const doodData = await doodDataReq.text();
iamseeley avatar
MapUser
@iamseeley
An interactive, runnable TypeScript val by iamseeley
Script
/** @jsx jsx */
/** @jsxFrag Fragment */
interface MapboxProps {
city: string;
export default function MapboxComponent({ city }: MapboxProps) {
const mapContainer = <div id="map" style={{ width: '100%', height: '400px' }}></div>;
const initializeMap = () => {
Mapbox.accessToken = 'MAPBOX_ACCESS_TOKEN';
const map = new Mapbox.Map({
container: 'map',
dhvanil avatar
val_tlcH2AKDA2
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_tlcH2AKDA2(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const visualizeData = (data) => { const canvas = document.createElement('canvas'); const ctx = canvas.getContext(
// Return the result in a properly formatted response
return new Response(JSON.stringify({
result: result,
type: typeof result
headers: { 'Content-Type': 'application/json' }
yawnxyz avatar
translator
@yawnxyz
Press to talk, and get a translation! The app is set up so you can easily have a conversation between two people. The app will translate between the two selected languages, in each voice, as the speakers talk. Add your OpenAI API Key, and make sure to open in a separate window for Mic to work.
HTTP
Press to talk, and get a translation!
The app is set up so you can easily have a conversation between two people. The app will translate between the two selected l
Add your OpenAI API Key, and make sure to open in a separate window for Mic to work.
const app = new Hono();
const openai = new OpenAI(Deno.env.get("OPENAI_API_KEY_VOICE"));
class TranscriptionService {
async transcribeAudio(audioFile) {
try {
const transcription = await openai.audio.transcriptions.create({
file: audioFile,
adagradschool avatar
claude_1044d60c_6ca2_4bb0_a80c_e9eababc3ebd
@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
headers: {
"Content-Type": "text/html",
tokyotribe avatar
getWeather
@tokyotribe
Get Weather Simple function to get weather data from the free wttr.in service. import { getWeather } from "https://esm.town/v/stevekrouse/getWeather"; let weather = await getWeather("Brooklyn, NY"); console.log(weather.current_condition[0].FeelsLikeF)
HTTP
## Get Weather
Simple function to get weather data from the free [wttr.in](https://wttr.in/:help) service.
```ts
let weather = await getWeather("Brooklyn, NY");
console.log(weather.current_condition[0].FeelsLikeF)
export async function getWeather(location: string): Promise<WeatherResponse> {
return fetchJSON(`https://wttr.in/${location}?format=j1`);
export interface WeatherResponse {
current_condition: CurrentCondition[];
nearest_area: NearestArea[];
dhvanil avatar
web_YrdKpc0KUo
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_YrdKpc0KUo(req) {
return new Response(`<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Escape Plan Diagram</title>
<script src="https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"></script>
<style>
body {
lucaskohorst avatar
kalshi
@lucaskohorst
An interactive, runnable TypeScript val by lucaskohorst
HTTP
export default async function server(req: Request): Promise<Response> {
return new Response(
`<!DOCTYPE html>
<html>
<head>
<title>Kalshi Market Data</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>${css}</style>
</head>
moe avatar
frameHtml
@moe
@jsxImportSource npm:hono@3/jsx
Script
/** @jsxImportSource npm:hono@3/jsx */
export const frameHtml = (frame, baseUrl = "") => {
const prefixUrl = url => baseUrl && url.startsWith("/") ? `${baseUrl}${url}` : url
const aspectRatio = frame.aspectRatio || "1.91:1"
return (
<meta property="fc:frame" content="vNext" />
<meta property="of:version" content="vNext" />
<meta property="of:accepts:lens" content="1.0.0" />
<meta property="of:accepts:xmtp" content="2024-02-09" />
<meta property="fc:frame:image" content={prefixUrl(frame.image)} />