Search

Results include substring matches and semantically similar vals. Learn more
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";
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"));
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",
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();
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
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"),
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
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;
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()}`,
iheartjankboteko avatar
iheartJankBoteko
@iheartjankboteko
An interactive, runnable TypeScript val by iheartjankboteko
HTTP
export default async function (req: Request): Promise<Response> {
return Response.json({ ok: true })
pomdtr avatar
orangeMite
@pomdtr
https://pomdtr-orangemite.web.val.run
HTTP
https://pomdtr-orangemite.web.val.run
export default function(req) {
return new Response(req.referrer, {
status: 200,
dhvanil avatar
val_X6JYYp11Hg
@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++) {
arfan avatar
zARCHIVE_html_Pages
@arfan
// Shared HTML components
HTTP
const MESSAGE_STORAGE_KEY = new URL(import.meta.url).pathname.split("/").at(-1) + "_user_messages";
// Shared HTML components
function getPageHeader(pageTitle: string) {
return `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>${pageTitle} - Val Town Example</title>