Search

Results include substring matches and semantically similar vals. Learn more
websandbox avatar
cleanup
@websandbox
An interactive, runnable TypeScript val by websandbox
Cron
export default async function(interval: Interval) {
for (const b of await blob.list("play_")) {
if ((new Date(b.lastModified).valueOf() + EXPIRY) < Date.now()) {
try {
const resolved = await alias({
username: "websandbox",
valName: b.key,
token: Deno.env.get("valtown"),
await deleteVal({
id: resolved.id,
pomdtr avatar
jsoninvoice_homepage
@pomdtr
@jsxImportSource npm:hono/jsx
Script
/** @jsxImportSource npm:hono/jsx */
const invoice: Invoice = {
id: "20240401",
issued: "2024-01-01",
due: "2024-01-15",
currencies: [{ code: "USD" }, { code: "EUR", rate: 0.94 }],
tax: 10,
from: {
name: "Achille Lacoin",
to: {
cjpais avatar
simpleWeather
@cjpais
// Forked from @patrickjm.simpleWeather
Script
export let simpleWeather = async (city: string) =>
weather2(city)
.then(({ current_condition, weather }) => ({
c: current_condition[0],
w: weather,
.then(({ c, w }) => ({
temp: `${c.temp_F}`,
feelsLike: `${c.FeelsLikeF}`,
description: c.weatherDesc?.[0]?.value,
windSpeed: `${c.windspeedMiles}mph`,
omgwtfbrblolttyl avatar
readFileEndpoint
@omgwtfbrblolttyl
An interactive, runnable TypeScript val by omgwtfbrblolttyl
Express (deprecated)
export const readFileEndpoint = async (
req: express.Request,
res: express.Response,
if (req.method !== "GET") {
console.log("wrong method", req.method);
return res.status(404).json({ msg: "Not found" });
const path = req.query["path"];
if (!path || typeof path !== "string") {
return res.status(400).json({
msg: "Missing or invalid 'path' query parameter",
jamisonl avatar
obnoxiousAmaranthCamel
@jamisonl
Bot for Cama discord server. To initialize new slash commands, you have to run a separate bit of code. This is for modifying their functionality
HTTP
Bot for Cama discord server. To initialize new slash commands, you have to run a separate bit of code. This is for modifying
// Bump version
let bank = await blob.getJSON("bank");
let bets = await blob.getJSON("bets");
const starting_amount = 5;
if (!bank) {
bank = {};
await blob.setJSON("bank", bank);
if (!bets) {
bets = [];
bnorick avatar
check_reddit
@bnorick
An interactive, runnable TypeScript val by bnorick
Script
let { checkRedditState } = await import("https://esm.town/v/bnorick/checkRedditState");
export let check_reddit = async ({ check = null, toggle = null }) => {
if (check) {
check = Object.assign({
fetch_limit: 10,
force: false,
enable_toggle: Boolean(toggleSubreddits),
}, check);
// let before = @me.checkRedditState["x"].last;
let result = await reddit_matches({
taras avatar
cors_proxy
@taras
curl 'https://taras-free_open_router.web.val.run/api/v1/chat/completions' \ -H 'accept: application/json' \ -H 'authorization: Bearer THIS_IS_OVERRIDEN_ON_SERVER' \ -H 'content-type: application/json' \ --data-raw '{ "model": "auto", "temperature": 0, "messages": [ { "role": "system", "content": "stuff" }, { "role": "user", "content": "hello" } ], "stream": true }'
HTTP
curl 'https://taras-free_open_router.web.val.run/api/v1/chat/completions' \
-H 'accept: application/json' \
-H 'authorization: Bearer THIS_IS_OVERRIDEN_ON_SERVER' \
-H 'content-type: application/json' \
--data-raw '{
"model": "auto",
// Define a common set of CORS headers
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
easrng avatar
consoleTests
@easrng
An interactive, runnable TypeScript val by easrng
Script
console.assert(2 + 2 === 4, "2 + 2 === 4");
console.assert(2 + 2 === 5, "2 + 2 === 5");
console.clear();
console.count("count");
console.count("count");
console.countReset("count");
console.count("count");
console.debug("debug");
console.dir({ dir: { hello: "world" } });
console.dirxml("dirxml");
rodrigotello avatar
inspoHTML
@rodrigotello
An interactive, runnable TypeScript val by rodrigotello
Script
import { valTownInspoList } from "https://esm.town/v/rodrigotello/valTownInspoList";
export function inspoHTML(req, res) {
res.send(
valTownInspoList.map((d) => `
<div>
<div>${d.title}</div>
<div>${d.description}</div>
<iframe src="https://www.val.town/embed/${d.val}"></iframe>
</div>`).join(""),
chris_symbiote avatar
postSaveMessage
@chris_symbiote
An interactive, runnable TypeScript val by chris_symbiote
Script
import { messages } from "https://esm.town/v/chris_symbiote/messages";
export const postSaveMessage = (req: express.Request, res: express.Response) => {
messages.push({
message: ">>>" + req.body.message,
res.send({ message: "Added" });
janpaul123 avatar
valle_tmp_64963667921389725194653754787096
@janpaul123
* Wordle game implementation in HTML with fun CSS animations and colors. * * This script dynamically generates the HTML and CSS for a Wordle game and supports user interaction.
HTTP
* Wordle game implementation in HTML with fun CSS animations and colors.
* This script dynamically generates the HTML and CSS for a Wordle game and supports user interaction.
export default async function main(req: Request): Promise<Response> {
const styles = `
<style>
body {
font-family: 'Comic Sans MS', cursive, sans-serif;
background: linear-gradient(90deg, #ff7acc, #00fff0, #ff9e00, #ff0054);
animation: gradient 3s infinite;
margin: 0;
stevekrouse avatar
r2
@stevekrouse
r2 wrapper Save blobs without leaving Val Town! Only for Val Town Pro users to limit abuse. We get 10gb free, so as long as nobody abuses this, I won't put any strict limits on it. If you want to use more than 10gb, let me know, and we can bill you for it. All data in this bucket is public if you know it's name! This val, @stevekrouse.r2, is the "SDK" for @stevekrouse.r2Proxy . Setup This val requires you to setup public key auth, which is really just three clicks here: https://blog.val.town/public-key-auth-val-town-users-can-be-your-users [Optional] You can setup a helper function so you don't have to pass your keys every time: let blob = (key, value) => @stevekrouse.r2(key, value, @me.exportedKeys) Warning: Do not make your blob function public or unlisted. That would allow anyone to use it. Usage await @me.blob("demo", { hello: "world" }); return @me.blob("demo"); // {hello: "world"} Example usage: https://www.val.town/v/stevekrouse.r2Demo
Script
# r2 wrapper
Save blobs without leaving Val Town! Only for Val Town Pro users to limit abuse.
We get 10gb free, so as long as nobody abuses this, I won't put any strict limits on it. If you want to use more than 10gb, l
**All data in this bucket is public if you know it's name!**
This val, @stevekrouse.r2, is the "SDK" for [@stevekrouse.r2Proxy](https://www.val.town/v/stevekrouse.r2Proxy).
## Setup
export async function r2(key, value?, keys?) {
// GET
if (value === undefined) {
let handle = whoami().at(-1).slice(1).split(".")[0]
panphora avatar
twitterOpenGraphImage
@panphora
An interactive, runnable TypeScript val by panphora
HTTP
export let twitterOpenGraphImage = (async (req: Request) => {
const query = new URL(req.url).searchParams;
const site = query.get("site");
const scale = query.get("scale");
const scrollTo = query.get("scrollTo");
const darkMode = query.get("darkMode");
const removeSelectors = query.get("remove");
const { PuppeteerDeno } = await import(
"https://deno.land/x/puppeteer@16.2.0/src/deno/Puppeteer.ts"
const puppeteer = new PuppeteerDeno({
janpaul123 avatar
valle_tmp_642242117750307901497006663363
@janpaul123
* This approach will create a simple HTML page with embedded CSS for the wild styling and a bit of JavaScript to handle the game logic of Wordle. * We'll use vanilla JavaScript and HTML for simplicity, no external libraries or frameworks are necessary. * The CSS will include bold color gradients, vibrant fonts, and other "crazy" styles.
HTTP
* This approach will create a simple HTML page with embedded CSS for the wild styling and a bit of JavaScript to handle the
* We'll use vanilla JavaScript and HTML for simplicity, no external libraries or frameworks are necessary.
* The CSS will include bold color gradients, vibrant fonts, and other "crazy" styles.
export default async function main(req: Request): Response {
const htmlContent = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
danielhenrymantilla avatar
handler
@danielhenrymantilla
An interactive, runnable TypeScript val by danielhenrymantilla
Script
import { bodies } from "https://esm.town/v/danielhenrymantilla/bodies";
export const handler = (req, res) => {
bodies.push(req.body);
res.text(req.body.token);