Search
FaucetShardeum
@newbee
An interactive, runnable TypeScript val by newbee
Cron
export async function FaucetShardeum() {
const data = await fetch("https://discord.com/api/v9/interactions", {
method: "POST",
headers: {
accept: "*/*",
authorization:
"ODA2MDQ3NjA4NjY1NDA3NTA4.Gf0Zom.MUibDnGYs3MtAG3JTAqG4_0ckZBiCgthlK6dts",
"content-type":
"multipart/form-data; boundary=----WebKitFormBoundaryHiXGwNaz3lmFWI3R",
referrer:
valle_tmp_055129233547254859908847559300911
@janpaul123
// This val responds with an HTML form styled with CSS to input the user's name and greet them upon form submission
HTTP
// This val responds with an HTML form styled with CSS to input the user's name and greet them upon form submission
export default async function(req: Request): Promise<Response> {
if (req.method === "POST") {
const formData = new URLSearchParams(await req.text());
const name = formData.get("name") || "stranger";
const htmlResponse = `
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
embed
@pomdtr
An interactive, runnable TypeScript val by pomdtr
Script
const script = document.querySelector(`[src="https://esm.town/v/pomdtr/embed"]`);
if (!script) {
throw new Error("could not find script");
const wrapperID = script.getAttribute("data-element-id");
const wrapper = document.getElementById(wrapperID);
const code = wrapper.textContent;
const iframe = document.createElement("iframe", { is: "iframe" });
iframe.src = `https://easrng-playground.web.val.run?code=${encodeURIComponent(code)}`;
iframe.style.border = "none";
iframe.style.width = "500px";
flightRadar24
@raylu
usage: async function example() {
const discordUserId = "713159744516259880";
await @raylu.flightRadar24(
"bf721",
"01 Jan 2023",
"America/Los_Angeles",
discordUserId,
);
}
Script
usage:
```js
async function example() {
const discordUserId = "713159744516259880";
await @raylu.flightRadar24(
"bf721",
export const flightRadar24 = async (
flightNumber,
utcDepartureDate,
outputTZ,
helloResume
@iamseeley
🎨 styles for the hello, resume landing page
Script
## 🎨 styles for the [hello, resume](https://iamseeley-resumehandler.web.val.run/) landing page
export const helloResume = `
body {
padding: 5px;
margin-top: 32px;
background-color: #2c3e50;
font-family: 'Arial', sans-serif;
color: #ecf0f1;
@media (min-width: 640px) {
body {
val_6PIQpS4uDG
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_6PIQpS4uDG(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const generateRandomNumbers = (count) => {
const numbers = [];
for (let i = 0; i < count; i++) {
numbers.push(Math.random());
return numbers;
const analyzeDistribution = (numbers, bins) => {
cheerioExample
@xxxjjj
cheerio cheerio is a popular npm module that makes it easy to parse and manipulate HTML and XML. cheerio is modeled after a reduced version of jQuery . Note that it's pretty different than default browser DOM methods, so you can't call things like .appendChild or document.createElement when using cheerio: it's not based on a full-fledged DOM or browser implementation. But, in exchange it's a lot faster and simpler.
Script
# cheerio
[cheerio](https://cheerio.js.org/) is a popular npm module that makes it easy to parse and manipulate HTML and XML.
cheerio is modeled after a reduced version of [jQuery](https://jquery.com/). Note that it's pretty different than default browser DOM methods, so you can't call things like `.appendChild` or `document.createElement` when using cheerio: it's not based on a full-fledged DOM or browser implementation. But, in exchange it's a lot faster and simpler.
export let cheerioExample = (async () => {
const { default: $ } = await import("npm:cheerio");
const document = $(
`<select name="ctl00$bodyContentPlaceHolder$ddlistPlayDate" onchange="javascript:setTimeout('__doPostBack(\'ctl00$bodyContentPlaceHolder$ddlistPlayDate\',\'\')', 0)" id="ctl00_bodyContentPlaceHolder_ddlistPlayDate" ondatabinding="document.body.style.cursor = default;" style="width:160px;">
<option selected="selected" value="606">6/4/2024 8:00:00 PM</option>
<option selected="selected" value="606">6/5/2024 8:00:00 PM</option>
<option selected="selected" value="606">6/6/2024 8:00:00 PM</option>
returnFortyTwo
@rororowyourboat
An interactive, runnable TypeScript val by rororowyourboat
HTTP
export default async function server(request: Request): Promise<Response> {
// Check if the request method is GET
if (request.method === 'GET') {
// Return '42' as plain text
return new Response('42', {
headers: {
'Content-Type': 'text/plain',
'Access-Control-Allow-Origin': '*' // This allows requests from any origin
} else {
// If it's not a GET request, return a 405 Method Not Allowed error
claudeForwarder
@prabhanshu
// This val implements a function to call the Claude API using fetch.
HTTP
// This val implements a function to call the Claude API using fetch.
// It handles the API request and response processing.
// The Claude API key is expected to be provided in the request headers.
// CORS is enabled for all origins.
export default async function server(req: Request): Promise<Response> {
// Handle preflight requests
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
delightfulVioletAntlion
@onetruechaos
An interactive, runnable TypeScript val by onetruechaos
Cron
interface GameDeal {
id: number;
title: string;
platform: string;
url: string;
end_date: string | null;
created_at: string;
export default async function server(request: Request): Promise<Response> {
const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
const KEY = new URL(import.meta.url).pathname.split("/").at(-1);
authIdExampleCookiePrivate
@postpostscript
An interactive, runnable TypeScript val by postpostscript
HTTP
import {
authMiddlewareCookie,
userActionsDisplay,
type HonoEnv,
} from "https://esm.town/v/postpostscript/authMiddleware";
import { Layout } from "https://esm.town/v/postpostscript/Layout";
import { Hono } from "npm:hono";
const app = new Hono<HonoEnv>();
app.use("*", authMiddlewareCookie());
app.get("/", (c) => c.html(Layout`${userActionsDisplay(c.get("auth"))}` as string));
export default app.fetch;
valle_tmp_7848874273078958552804771654705
@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),
markdown_download
@curtcox
markdown.download Handy microservice/library to convert various data sources into markdown. Intended to make it easier to consume the web in ereaders Introductory blog post: https://taras.glek.net/post/markdown.download/ Package: https://jsr.io/@tarasglek/markdown-download Features Apply readability Further convert article into markdown to simplify it Allow webpages to be viewable as markdown via curl Serve markdown converted to html to browsers Extract youtube subtitles Source https://github.com/tarasglek/markdown-download https://www.val.town/v/taras/markdown_download License: MIT Usage:
https://markdown.download/ + URL Dev:
https://val.markdown.download/ + URL
HTTP
# markdown.download
Handy microservice/library to convert various data sources into markdown. Intended to make it easier to consume the web in ereaders
Introductory blog post: https://taras.glek.net/post/markdown.download/
Package: https://jsr.io/@tarasglek/markdown-download
### Features
- Apply readability
const isCloudflareWorker = typeof Request !== "undefined" && typeof Response !== "undefined";
// init async loading of modules
const AgentMarkdownImport = isCloudflareWorker ? import("npm:agentmarkdown@6.0.0") : null;
const TurndownService = isCloudflareWorker ? null : await import("npm:turndown@^7.1.3");
phpServe
@harveyfullstack
Serve a REST API in PHP syntax using php-wasm and Val Town.
HTTP
Serve a REST API in PHP syntax using php-wasm and Val Town.
const { PhpWeb } = await import("https://cdn.jsdelivr.net/npm/php-wasm/PhpWeb.mjs");
const php = new PhpWeb();
export default async function(req: Request): Promise<Response> {
let output = "";
let headers = new Headers();
php.addEventListener("output", (event: any) => {
output += event.detail.join("");
php.addEventListener("header", (event: any) => {
const [header, value] = event.detail.split(":");
valle_tmp_17314117069468577415194390357787
@janpaul123
An interactive, runnable TypeScript val by janpaul123
HTTP
export default async function main(req: Request): Promise<Response> {
const styles = `
<style>
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');
body {
background: linear-gradient(90deg, #f3ec78, #af4261);
font-family: 'Press Start 2P', cursive;
color: white;
display: flex;
justify-content: center;