Search

Results include substring matches and semantically similar vals. Learn more
stevekrouse avatar
jsrExample
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
HTTP
import * as b from "jsr:@badrap/valita";
export default () => Response.json(Object.keys(b));
rodrigotello avatar
checkSite
@rodrigotello
An interactive, runnable TypeScript val by rodrigotello
Script
import { isUp as isUp2 } from "https://esm.town/v/brenton/isUp?v=8";
export const checkSite = () => {
const isUp = isUp2("https://rodrigotello.me/", 200);
if (!isUp) {
console.email(
"Unexpected status code when checking brntn.me, better go check to see what's happening!",
"brntn.me is down!"
pomdtr avatar
independentAmberCod
@pomdtr
An interactive, runnable TypeScript val by pomdtr
HTTP
let state = "cold"
export default function() {
const old = state
state = "hot"
return new Response(old)
janpaul123 avatar
valle_tmp_2702005215371008406643879034496836
@janpaul123
// This val responds with an HTML form to input the user's name and greet them
HTTP
// This val responds with an HTML form to input the user's name and greet them
export default async function(req: Request): Promise<Response> {
const htmlResponse = `
<form action="/" method="POST">
<label for="name">Enter your name:</label><br>
<input type="text" id="name" name="name"><br>
<input type="submit" value="Submit">
</form>
return new Response(htmlResponse, {
headers: { "Content-Type": "text/html" },
iamseeley avatar
oceanListener
@iamseeley
An interactive, runnable TypeScript val by iamseeley
Script
import { generateFish } from 'https://esm.town/v/iamseeley/generateFish';
document.addEventListener('DOMContentLoaded', (isOceanTheme) => {
if (isOceanTheme) {
const fishContainer = document.querySelector('.fish-container');
const bubbleContainer = document.querySelector('.bubble-container');
if (fishContainer) {
fishContainer.innerHTML = generateFish();
if (bubbleContainer) {
bubbleContainer.innerHTML = generateBubbles();
vtdocs avatar
guestbookExample
@vtdocs
Guestbook Example See @vtdocs.guestbook to set up your own interactive guestbook. This is an example for testing!
Script
# Guestbook Example
See [`@vtdocs.guestbook`](https://www.val.town/v/vtdocs.guestbook) to set up your own interactive guestbook.
This is an example for testing!
import { generateGuestbookSnippet } from "https://esm.town/v/vtdocs/generateGuestbookSnippet";
export const guestbookExample = (req: express.Request, res: express.Response) => {
res.send(generateGuestbookSnippet("vtdocs", "guestbook"));
ianvph avatar
blogRSSTracker
@ianvph
An interactive, runnable TypeScript val by ianvph
Cron
export async function blogRSSTracker() {
// gets newest blog from rss feed
const blogRSSLink = "https://posthog.com/rss.xml";
const response = await fetch(blogRSSLink);
const newestEntry =
(await parseXML(await response.text())).rss.channel
.item[0];
// checks if different from last blog captured
if (newestEntry.link == newestBlogLink) {
return "old blog";
nbbaier avatar
honoTanaEndpoint
@nbbaier
An interactive, runnable TypeScript val by nbbaier
Script
const token = Deno.env.get("tanaInputAPI");
export const honoTanaEndpoint = async (req: Request) => {
const app = new Hono();
app.get("/", async (c) => {
let { text, url } = c.req.query();
const payload: APIPlainNode = {
name: text,
children: [
type: "field",
attributeId: "cwi23sOzRSh8",
hydeptsa avatar
cal
@hydeptsa
An interactive, runnable TypeScript val by hydeptsa
HTTP
export default async function server(request: Request): Promise<Response> {
console.log("request", request);
try {
// Ensure Notion API key is set
const notionApiKey = Deno.env.get("HYDEPTSA_NOTION_API_TOKEN");
const databaseId = Deno.env.get("HYDEPTSA_EVENTS_DB_ID");
const datePropertyName = "When";
if (!notionApiKey || !databaseId) {
return new Response("Missing Notion API credentials", { status: 500 });
// Calculate the date 18 months ago
alexbowe avatar
userAgents
@alexbowe
// User Agent strings to rotate while scraping.
Script
// User Agent strings to rotate while scraping.
// Taken from https://gist.github.com/manthankool/e3b17d126571856198ddfc1bff7775b5/
export const USER_AGENTS = [
"Mozilla/5.0 (Macintosh; Intel Mac OS X 11_15) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.5392.175 Safari/537.36",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.4.263.6 Safari/537.36",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.5367.208 Safari/537.36",
"Mozilla/5.0 (Windows NT 11.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.5387.128 Safari/537.36",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.3616757
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.3616757
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.3616757
jdan avatar
coupleHoldingHands
@jdan
An interactive, runnable TypeScript val by jdan
Script
import { man } from "https://esm.town/v/jdan/man";
export const coupleHoldingHands = String.fromCodePoint(
man,
fitzpatrickSkinType("dark"),
zwj,
handshake,
zwj,
man,
fitzpatrickSkinType("medium-light"),
leon avatar
infiniteNewIdeas
@leon
An interactive, runnable TypeScript val by leon
HTTP
export default async function(req: Request): Promise<Response> {
return Response.json({
idea: `imagine that https://www.${crypto.randomUUID()}.com was a cool web site about ${crypto.randomUUID()}`,
nicot avatar
slackReplyToMessage
@nicot
An interactive, runnable TypeScript val by nicot
HTTP
export const slackReplyToMessage = async (req: Request) => {
const body = await req.json();
// Verify the request is genuine
if (body.token !== Deno.env.get("slackVerificationToken")) {
return new Response(undefined, { status: 401 });
// Respond to the initial challenge (when events are enabled)
if (body.challenge) {
return Response.json({ challenge: body.challenge });
// Reply to app_mention events
if (body.event.type === "app_mention") {
janpaul123 avatar
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" } });
healeycodes avatar
valEval
@healeycodes
An interactive, runnable TypeScript val by healeycodes
Script
export const valEval = async function (
expr: string | TemplateStringsArray
): Promise<[value: any, error: undefined | string]> {
const encoded = encodeURIComponent(expr.toString());
try {
const res = await fetch(`https://api.val.town/eval/${encoded}`);
return (await res.json()).data;
} catch (e) {
console.log(e.toString());
throw e;