Search

Results include substring matches and semantically similar vals. Learn more
char_lie avatar
art_app
@char_lie
An interactive, runnable TypeScript val by char_lie
HTTP (deprecated)
import { art_criticism_app } from "https://esm.town/v/char_lie/art_criticism_app";
export const art_app = async (req: Request) => {
const marked = await import("npm:marked");
const art_info = await art_criticism_app();
return new Response(
marked.parse(`
${art_info.idea}
![image info](${art_info.art.src})
*Verdict*: ${art_info.criticism}
{ headers: { "Content-Type": "text/html" } },
janpaul123 avatar
valle_tmp_37837502302405213008399027398504622
@janpaul123
An interactive, runnable TypeScript val by janpaul123
HTTP (deprecated)
const SAMPLE_STORIES_KEY = "hn_realistic_sample_stories";
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
const sampleStories = Array.from({ length: 30 }).map((_, idx) => ({
id: idx + 1,
title: faker.company.catchPhrase(),
url: faker.internet.url(),
votes: Math.floor(Math.random() * 100),
await blob.setJSON(SAMPLE_STORIES_KEY, sampleStories);
benlenarts avatar
SongTagger
@benlenarts
Spotify Playback A val to setting up some endpoints for Spotify play state.
HTTP (deprecated)
## Spotify Playback
A val to setting up some endpoints for Spotify play state.
// Uncomment this line for one run of the Val to create the DB lol
// await sqlite.execute(`create table if not exists SPOTIFY_AUTH_2(id text primary key, data text)`);
export const db = drizzle(sqlite as any);
export const table = sqliteTable("SPOTIFY_AUTH_2", {
id: text("id").primaryKey(),
data: text("data"),
const thisURL = thisWebURL();
const redirect_uri = thisURL + "/callback";
healeycodes avatar
htmlHello
@healeycodes
An interactive, runnable TypeScript val by healeycodes
Script
export const htmlHello = (req: express.Request, res: express.Response) => {
console.log(req, res);
return res.send(decodeURIComponent(req["options"]["headers"]["cookie"]));
kaz avatar
concentricCirclesApp
@kaz
* This app displays a thick horizontal line with a color gradient from dark red to yellow to light green. * Below each section, there's a text input field. Each color section can have up to 8 values. * It uses React for the UI and CSS for styling the gradient line and inputs. * It includes a reorder functionality for the items in each section and an expandable "Learn more" section.
HTTP
* This app displays a thick horizontal line with a color gradient from dark red to yellow to light green.
* Below each section, there's a text input field. Each color section can have up to 8 values.
* It uses React for the UI and CSS for styling the gradient line and inputs.
* It includes a reorder functionality for the items in each section and an expandable "Learn more" section.
/** @jsxImportSource https://esm.sh/react */
function App() {
const [redItems, setRedItems] = useState<string[]>([]);
const [yellowItems, setYellowItems] = useState<string[]>([]);
const [greenItems, setGreenItems] = useState<string[]>([]);
const [isReordering, setIsReordering] = useState(false);
nbbaier avatar
servePDF
@nbbaier
https://nbbaier-servePDF.web.val.run to view the PDF in browser https://nbbaier-servePDF.web.val.run/download to download the PDF
HTTP (deprecated)
- [https://nbbaier-servePDF.web.val.run](https://nbbaier-servePDF.web.val.run) to view the PDF in browser
- [https://nbbaier-servePDF.web.val.run/download](https://nbbaier-servePDF.web.val.run/download) to download the PDF
const pdfDoc = await PDFDocument.create();
const timesRomanFont = await pdfDoc.embedFont(StandardFonts.TimesRoman);
const fontSize = 30;
const page = pdfDoc.addPage();
const { width, height } = page.getSize();
page.drawText("Creating PDFs in JavaScript is awesome!", {
x: 50,
y: height - 4 * fontSize,
diit avatar
basicsWithBabishRss
@diit
An interactive, runnable TypeScript val by diit
Script
export async function basicsWithBabishRss(req: express.Request, res) {
const { Feed } = await import("npm:feed");
// function toTitleCase(str) {
// return str.replace(/\w\S*/g, function (txt) {
// return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
async function generateRssFeed() {
const { parseDocument } = await import("npm:htmlparser2");
const response = await fetch("https://basicswithbabish.co/episodes");
const body = await response.text();
const dom = parseDocument(body);
pomdtr avatar
turquoiseMinnow
@pomdtr
An interactive, runnable TypeScript val by pomdtr
HTTP (deprecated)
import { devtools } from "https://esm.town/v/pomdtr/devtools";
export default devtools((req) => {
return new Response("hello world");
janpaul123 avatar
valle_tmp_272229477861650756686636317711954
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP (deprecated)
const SAMPLE_STORIES_KEY = "hn_realistic_sample_stories";
// Initialize sample stories and store them in blob storage
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
const sampleStories = Array.from({ length: 30 }).map((_, idx) => ({
id: idx + 1,
title: faker.company.catchPhrase(),
url: faker.internet.url(),
votes: Math.floor(Math.random() * 100),
nate avatar
ping
@nate
An interactive, runnable TypeScript val by nate
Script
export let ping = () => {
return "pong";
antonnyman avatar
honoExample
@antonnyman
Hono Here's an example using the Hono server library with the Web API . It works great! Server examples Hono Peko Itty Router Nhttp
HTTP (deprecated)
# Hono
Here's an example using the [Hono](https://hono.dev/) server library with the [Web API](https://docs.val.town/api/web). It wo
### Server examples
- [Hono](https://www.val.town/v/tmcw.honoExample)
- [Peko](https://www.val.town/v/tmcw.pekoExample)
- [Itty Router](https://www.val.town/v/tmcw.ittyRouterExample)
export const honoExample = async (req: Request) => {
const { Hono } = await import("npm:hono@3");
const app = new Hono();
app.get("/", (c) => c.text("Hono?"));
tmcw avatar
parseEnglishExample
@tmcw
nclst The nclst tree format is an extremely useful tree structure used for natural language processing. This is an example of parsing a string of English text into a syntax tree.
Script
# nclst
The [nclst](https://github.com/syntax-tree/nlcst) tree format is an extremely useful tree structure used for natural language
export let parseEnglishExample = (async () => {
const { ParseEnglish } = await import("npm:parse-english");
return new ParseEnglish().parse("My name is Tom");
demo avatar
naclValidate
@demo
An interactive, runnable TypeScript val by demo
Script
import { Buffer } from "node:buffer";
export let naclValidate = async (publicKey, signature, timestamp, body) => {
const { default: nacl } = await import("npm:tweetnacl@1.0.3");
const isVerified = nacl.sign.detached.verify(
Buffer.from(timestamp + body),
Buffer.from(signature, "hex"),
Buffer.from(publicKey, "hex"),
return isVerified;
janpaul123 avatar
valle_tmp_37032806114103356497303187371446
@janpaul123
An interactive, runnable TypeScript val by janpaul123
HTTP (deprecated)
const SAMPLE_STORIES_KEY = "hn_realistic_sample_stories";
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
const sampleStories = Array.from({ length: 30 }).map((_, idx) => ({
id: idx + 1,
title: faker.company.catchPhrase(),
url: faker.internet.url(),
votes: Math.floor(Math.random() * 100),
await blob.setJSON(SAMPLE_STORIES_KEY, sampleStories);
chet avatar
watchWebsite
@chet
An interactive, runnable TypeScript val by chet
Script
export async function watchWebsite(url: string) {
const newHtml = await fetch(url).then(r => r.text());
const key = "watch:" + url;
let oldHtml = "";
try {
oldHtml = await blob.get(key).then(r => r.text());
} catch (error) {}
await blob.set(key, newHtml);
if (!oldHtml) return console.log("NO OLD", { oldHtml, newHtml });
const diff = diffHtml(oldHtml, newHtml);