Search

Results include substring matches and semantically similar vals. Learn more
janpaul123 avatar
valle_tmp_94440105214223307666476397039723
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP
// Initialize sample stories and store them in blob storage
const SAMPLE_STORIES_KEY = "hn_sample_stories";
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
samarthpasala avatar
JokeGenerator
@samarthpasala
// Fetches a random joke.
Cron
import { email } from "https://esm.town/v/std/email?v=9";
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
dhvanil avatar
web_Fdwbcen36v
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_Fdwbcen36v(req) {
return new Response(`<!DOCTYPE html>
<html>
CHAN avatar
Valentine1
@CHAN
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
"Please don't do this to me, I'm fragile",
function App() {
const [noClicks, setNoClicks] = useState(0);
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
return new Response(
johndevor avatar
React___client
@johndevor
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
function HelloWorld() {
return (
</div>
function client() {
createRoot(document.getElementById("root")).render(<HelloWorld />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request) {
return new Response(`
djf avatar
aqi
@djf
AQI Alerts Get email alerts when AQI is unhealthy near you. Set up Click Fork Change location (Line 4) to describe your location. It accepts fairly flexible English descriptions which it turns into locations via nominatim's geocoder API . Click Run Background This val uses nominatim's geocoder to get your lat, lon, and air quality data from OpenAQ. It uses EPA's NowCast AQI Index calculation and severity levels. Learn more: https://www.val.town/v/stevekrouse.easyAQI
Script
import { email } from "https://esm.town/v/std/email?v=9";
import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI";
export async function aqi(interval: Interval) {
const location = "brooklyn navy yard"; // <-- change to place, city, or zip code
const data = await easyAQI({ location });
janpaul123 avatar
valle_tmp_6738558784733152514997198308998394
@janpaul123
// This val will serve an HTML page emulating a Hacker News clone.
HTTP
// It uses plain HTML and CSS to create the frontend. Links to stories will take you to pages with fake content.
export default async function(req: Request): Promise<Response> {
const url = new URL(req.url);
return serveHomePage();
function serveHomePage(): Response {
const htmlContent = `
"Content-Type": "text/html",
function serveStoryPage(title: string, content: string): Response {
const htmlContent = `
ayeh avatar
survivalRPGAdventure
@ayeh
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
"You find a relatively dry spot near the riverbank, listening to the rushing water while trying to rest and regain
function App() {
const [state, setState] = useState(initialState);
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
return new Response(`
stevekrouse avatar
genuineGrayWren
@stevekrouse
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
{ id: "yellowBorder", content: "<div style=\"border: 2px solid yellow;\">Yellow border</div>" },
function DraggableElement({ id, content, type, left, top, onDrop, isNew }) {
const [{ isDragging }, drag] = useDrag(() => ({
</div>
function cssStringToObject(cssString) {
return cssString.split(";").reduce((acc, rule) => {
</div>
function App() {
const [elements, setElements] = useState([]);
</DndProvider>
function client() {
createRoot(document.getElementById("root")).render(<App />);
client();
async function server(request: Request): Promise<Response> {
const url = new URL(request.url);
noah51022 avatar
marvelousIvorySeahorse
@noah51022
// Fetches a random joke.
Cron
"punchline": "A cat-tastrophe.",
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
return response.json();
export default async function(interval: Interval) {
try {
const randomJoke = await fetchRandomJoke();
nulo avatar
monitor_jmilei_tweets
@nulo
An interactive, runnable TypeScript val by nulo
Script
time integer,
json text
async function archiveTweet(id: string) {
const tweet = await SocialTools.getTweet(id);
if (tweet) {
+(new Date()) / 1000,
JSON.stringify(tweet),
export default async function(interval: Interval) {
for (const id of ["1852746483306492004", "1854170158949974029"]) {
await archiveTweet(id);
sjmre avatar
telegramSendMessage
@sjmre
An interactive, runnable TypeScript val by sjmre
Script
method: "POST",
body: JSON.stringify({ ...options }),
export async function telegramSendAudioMessage(chatId: string, audioData: Uint8Array, botToken: string): Promise<void> {
const url = `https://api.telegram.org/bot${botToken}/sendAudio`;
// Assuming FormData is available or correctly polyfilled
yieldray avatar
web
@yieldray
Debug ValTown's Web API
HTTP
export async function web(req: Request) {
return Response.json({
method: req.method,
fossforlife avatar
wiitdb_jsonl
@fossforlife
An interactive, runnable TypeScript val by fossforlife
HTTP
import { jsonArrayToJsonL } from "https://esm.town/v/fossforlife/jsonl";
import { parseXML } from "https://esm.town/v/stevekrouse/parseXML";
export default async function(req: Request): Promise<Response> {
try {
const xml = await fetch("https://ej-public-files.sfo3.cdn.digitaloceanspaces.com/wiitdb.xml");
ikbear avatar
Bio
@ikbear
@jsxImportSource https://esm.sh/react
HTTP
/** @jsxImportSource https://esm.sh/react */
import { renderToString } from "npm:react-dom/server";
export default async function(req: Request) {
return new Response(
renderToString(