Search

Results include substring matches and semantically similar vals. Learn more
stevekrouse avatar
axiosEx
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
export const axiosEx = (async () => {
const { default: axios } = await import("https://esm.sh/axios");
let r = await axios.get("https://api.github.com/users/stevekrouse/following");
return JSON.stringify(r);
janpaul123 avatar
valle_tmp_8041110507585893285251613526563
@janpaul123
// This approach uses vanilla JavaScript to create a sparkline SVG and includes a small animated cat GIF that moves around the screen.
HTTP
// This approach uses vanilla JavaScript to create a sparkline SVG and includes a small animated cat GIF that moves around th
// We'll use the `@stevekrouse/sparklineSVG` to create the sparkline and animate the cat using CSS and a bit of JavaScript.
export const sparklineEx2 = async (req: Request) => {
const data = [5, 10, 5, 20, 8, 15]; // Example data for the sparkline
const svg = sparklineSVG(data, { width: 100, height: 20 });
const html = `
<!DOCTYPE html>
<html>
<head>
<title>Sparkline SVG with Animated Cat</title>
aeaton avatar
kpunkShow
@aeaton
An interactive, runnable TypeScript val by aeaton
Script
export async function kpunkShow(url) {
const dom = await fetchHtmlDom(url);
const date = dom.querySelector(".postDate")?.textContent.trim();
const titleNode = dom.querySelector(".postTitle .postTitle");
const title = titleNode?.textContent.trim();
const id = new URL(titleNode?.getAttribute("href"), url).toString();
const trackNodes = dom.querySelectorAll(".postBody > ol > li");
const tracks = [...trackNodes].map((item) => {
const [artist, track] = item.textContent.split(" – ");
return { artist, track };
naserdehghan avatar
v1
@naserdehghan
An interactive, runnable TypeScript val by naserdehghan
HTTP
import { Hono } from "npm:hono@4";
const app = new Hono();
app.get("/", (ctx) => {
return ctx.json({ ok: true });
app.get("about", (ctx) => {
return ctx.text("About US");
export default app.fetch;
janpaul123 avatar
valle_tmp_0102751451670317635326502042755992
@janpaul123
// This script will respond with a basic HTML page, including styled content and an animated cat GIF.
HTTP
// This script will respond with a basic HTML page, including styled content and an animated cat GIF.
* HTTP Val: Hello World Example (HTML Response with CSS and Animated Cat GIF)
* This script will respond with a basic HTML page that says "Hello world" to any incoming HTTP request. It includes some coo
export default async function(req: Request): Promise<Response> {
const htmlContent = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
yawnxyz avatar
getContentFromUrl
@yawnxyz
getContentFromUrl Use this for summarizers. Combines https://r.jina.ai/URL and markdown.download's Youtube transcription getter to do its best to retrieve content from URLs. https://arstechnica.com/space/2024/06/nasa-indefinitely-delays-return-of-starliner-to-review-propulsion-data https://journals.asm.org/doi/10.1128/iai.00065-23 Usage: https://yawnxyz-getcontentfromurl.web.val.run/https://www.ncbi.nlm.nih.gov/pmc/articles/PMC10187409/ https://yawnxyz-getcontentfromurl.web.val.run/https://www.youtube.com/watch?v=gzsczZnS84Y&ab_channel=PhageDirectory
HTTP
## getContentFromUrl
Use this for summarizers.
Combines `https://r.jina.ai/URL` and markdown.download's Youtube transcription getter to do its best to retrieve content from
https://arstechnica.com/space/2024/06/nasa-indefinitely-delays-return-of-starliner-to-review-propulsion-data
https://journals.asm.org/doi/10.1128/iai.00065-23
Usage:
/** @jsx jsx */
const app = new Hono();
// https://www.crossref.org/blog/dois-and-matching-regular-expressions/
const DOI_REGEX = /\b(10\.\d{4,9}\/[-._;()\/:\w]+)\b/i;
rozek avatar
GDI_URLParserService
@rozek
This val is part of a series of examples to introduce "val.town" in my computer science course at Stuttgart University of Applied Sciences . The idea is to motivate even first-semester students not to wait but to put their ideas into practice from the very beginning and implement web apps with frontend and backend. It contains a very simple HTTP end point which extracts the URL path (after the val base URL) and any query/search parameters. In contrast to some other solutions (including the one suggested by Townie), this code takes into account that query parameters may appear multiple times in order to represent a list of values. In order to use it, send a request similar to the following https://rozek-gdi_urlparserservice.web.val.run/url/path?bool=true&number=3.14&string=text&list=false&list=2,72&list="hi!" The code was created using Townie - with only a few small manual corrections. This val is licensed under the MIT License.
HTTP
This val is part of a series of examples to introduce "val.town" in my computer science course at
[Stuttgart University of Applied Sciences](https://www.hft-stuttgart.com/).
The idea is to motivate even first-semester students not to wait but to put their
ideas into practice from the very beginning and implement web apps with
frontend and backend.
It contains a very simple HTTP end point which extracts the URL path (after the
export default async function(req: Request): Promise<Response> {
const url = new URL(req.url);
const path = url.pathname;
const query: Record<string, string[]> = {};
pomdtr avatar
turquoiseMinnow
@pomdtr
An interactive, runnable TypeScript val by pomdtr
HTTP
import { devtools } from "https://esm.town/v/pomdtr/devtools";
export default devtools((req) => {
return new Response("hello world");
neverstew avatar
readable
@neverstew
Readable Make any website instantly readable!
HTTP
# Readable
Make any website instantly readable!
export default async function(req: Request) {
let resp = await fetch(`https://${new URL(req.url).pathname.replace(/^https?:\/\//, '')}`, req);
let body = await resp.text();
let doc = new JSDOM(body);
let reader = new Readability(doc.window.document.cloneNode(true));
let article = reader.parse();
console.log(article.content);
return new Response(
janpaul123 avatar
valle_tmp_701816702132716405607952805626981
@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) {
const sampleStories = Array.from({ length: 30 }).map((_, idx) => ({
id: idx + 1,
title: `Sample Story ${idx + 1}`,
url: `https://example.com/story${idx + 1}`,
votes: Math.floor(Math.random() * 100),
tr3ntg avatar
testHTML
@tr3ntg
An interactive, runnable TypeScript val by tr3ntg
Script
export function testHTML(req: express.Request, res: express.Response) {
res.send(
"<html lang='en'>" +
"<head>" +
"<meta charset='utf-8'>" +
"<title>Hello World</title>" +
"</head>" +
"<body>" +
"<h1>Hello World</h1>" +
"</body>" +
curtcox avatar
sourceOnGithubExample
@curtcox
Example showing how to reference source in public github repos.
HTTP
Example showing how to reference source in public github repos.
exported_function,
exported_function_with_parameters,
exported_number,
exported_string_constant,
ExportedClass,
} from "https://raw.githubusercontent.com/curtcox/TypescriptSamples/main/ts/SampleExports.ts";
const app = new Hono();
app.get("/", (c) => {
return c.html(`
stevekrouse avatar
xeval
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
HTTP
export let xeval = async (req: Request) => {
let tweet, code, result;
try {
tweet = await fetchTweet(req.url);
code = tweet.text.split("```")[1]
.trim()
.replaceAll(/&lt;/g, "<")
.replaceAll(/&gt;/g, ">")
.replaceAll(/&amp;/g, "&");
result = await eval_(code, [req]);
janpaul123 avatar
valle_tmp_70427092421104433856545248978618
@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) {
const sampleStories = Array.from({ length: 30 }).map((_, idx) => ({
id: idx + 1,
title: faker.lorem.sentence(),
url: faker.internet.url(),
votes: Math.floor(Math.random() * 100),
tempguy avatar
plumOwl
@tempguy
An interactive, runnable TypeScript val by tempguy
HTTP
const Fetch = fetch;
interface ShowBox {
code: number;
msg: string;
server_runtime: number;
server_name: string;
data: {
link: string;
export default async function(req: Request): Promise<Response> {
const showbox = await Fetch("https://www.showbox.media/index/share_link?id=55137&type=1", {