Search

Results include substring matches and semantically similar vals. Learn more
pa avatar
gifStory
@pa
Generates a story and then a storyboard with 5 animated frames. Note : You'll need to fork this example (and un-comment some code) to run it with new input. Currently it renders cached output, for demo purposes (running takes 30-60s). 🪩 To fork, sign up for Substrate to get your own API key and $50 free credits
HTTP (deprecated)
Generates a story and then a storyboard with 5 animated frames.
**Note**: You'll need to fork this example (and un-comment some code) to run it with new input.
Currently it renders cached output, for demo purposes (running takes 30-60s).
🪩 To fork, [sign up for Substrate](https://substrate.run/signin) to get your own API key and $50 free credits
const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY") });
const topic = "a traveler lost in a rainforest";
const story = new ComputeText({
prompt: `tell me a story about ${topic}`,
story.cache_age = 60 * 60 * 24 * 7;
const sentencesSchema = z.object({
nimalu avatar
postWebhook1
@nimalu
An interactive, runnable TypeScript val by nimalu
Script
export let postWebhook1 = (req, res) => {
res.set("Content-Type", "text/html");
res.send(`<h1>Hello</h1>`);
stevekrouse avatar
myIP
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
export const myIP = () =>
fetchJSON("https://api.ipify.org?format=json");
neverstew avatar
generateQR
@neverstew
Generate QR codes Generate a QR code for any link instantly! Example https://neverstew-generateQR.web.val.run?url=https://neverstew.com
HTTP (deprecated)
# Generate QR codes
Generate a QR code for any link instantly!
## Example
[https://neverstew-generateQR.web.val.run?url=https://neverstew.com](https://neverstew-generateQR.web.val.run?url=https://nev
export async function generateQR(req: Request) {
let url: URL;
try {
url = new URL(new URL(req.url).searchParams.get("url"));
catch {
return new Response(
zane avatar
aqiPushGotify
@zane
AQI Alerts Get push notification alerts via Gotify when AQI is unhealthy near you. Set up Click Fork Change location (Line 7) to describe your location. It accepts fairly flexible English descriptions which it turns into locations via nominatim's geocoder API . Create an app in your Gotify Server and add your message endpoint URL w/ the app's API key (e.g., "https://push.example.de/message?token= ") as a Val Town Secret named "gotifyWebhookURL". 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
Cron
# AQI Alerts
Get push notification alerts via [Gotify](https://gotify.net/) when AQI is unhealthy near you.
## Set up
1. Click `Fork`
2. Change `location` (Line 7) to describe your location. It accepts fairly flexible English descriptions which it turns into
3. Create an app in your Gotify Server and add your message endpoint URL w/ the app's API key (e.g., "https://push.example.de
export async function aqiPushGotify(interval: Interval) {
const location = "Portland, Oregon"; // <-- change to place, city, or zip code
const data = await easyAQI({ location });
if (!interval.lastRunAt) {
galligan avatar
generateQR
@galligan
// fetch("https://api.val.town/v1/express/galligan.generateQR?url={url}"
Script
// fetch("https://api.val.town/v1/express/galligan.generateQR?url={url}"
// QR Code Generator
// 1. Right click on the bookmarks bar and add new bookmark
// 2. Give it any name (Ex: QR Code)
// 3. For the URL, enter the below value
// javascript:void(open('https://api.val.town/v1/express/ramkarthik.generateQR?url='+encodeURIComponent(location.href), 'O
// 4. Save the bookmark
// 5. When you are on any page, click the newly added bookmark
// It should generate a QR code that you can scan and open on your mobile
export async function generateQR(req, res) {
stevekrouse avatar
code_search_is_easy
@stevekrouse
Code Search is Easy Earlier this week, Tom MacWright posted Code Search is Hard . He describes the research he his doing to improve the code search experience of Val Town . It was a great read, and you might have seen it trending on Hacker News . As Val Town's most active user (behind Steve Krouse, one of the founders of Val Town), I for sure agree with Tom that search feature of Val Town needs improvements. But while reading his post, I immediately thought of a different approach to the problem. And a few hours later, Val Town Search was born. Do things that don't scale How does this new shiny search engine work? Well, it's quite simple. I wrote a Deno script that fetches all vals from the Val Town API. I pushed the data to a Github Repository I added a Github Action that runs the script every hour to refresh the data. I created a simple frontend on top of the Github Search API that allows you to search the data. It's hosted on Val Town (obviously). That was it. I didn't have to build a complex search engine, I just used the tools that were available to me. Is this a scalable solution for Val Town? Probably not. Am I abusing the Github API? Maybe. Does it work better than the current search feature of Val Town? Absolutely! I hope that the val.town engineers will come up with a search feature that will put my little project to shame. But for now, you won't find a better way to search for vals than Val Town Search .
HTTP (deprecated)
# Code Search is Easy
Earlier this week, Tom MacWright posted [Code Search is Hard](https://blog.val.town/blog/search-notes/). He describes the res
As Val Town's [most active user](https://www.val.town/v/pomdtr/leaderboard) (behind Steve Krouse, one of the founders of Val
![image.png](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/aedc62e9-afd9-4610-a2aa-58dd0a35a200/public)
## Do things that don't scale
How does this new shiny search engine work? Well, it's quite simple.
const val = extractValInfo(import.meta.url);
let handler = serveReadme({
val,
title: "Code search is easy",
nbbaier avatar
dbToApiBasicAuth
@nbbaier
Basic Auth for dbToAPI This val demonstrates adding Basic auth to a dbToAPI API via Hono's [https://hono.dev/middleware/builtin/basic-auth](Basic Auth middleware). Just pass createServer an object of type {username: string; password: string} . The authentication is added to all routes.
Script
# Basic Auth for [dbToAPI](https://www.val.town/v/nbbaier/dbToAPI)
This val demonstrates adding Basic auth to a [dbToAPI](https://www.val.town/v/nbbaier/dbToAPI) API via Hono's [https://hono.
const db = {
data: {
posts: [
id: 1,
title: "Magna pars studiorum elit, prodita quaerimus.",
id: 2,
title: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
user: {
stevekrouse avatar
blueSwordfish
@stevekrouse
This is an example call of @stevekrouse/insecureFetch
Script
This is an example call of @stevekrouse/insecureFetch
import { fetch } from "https://esm.town/v/std/fetch?v=5";
const url = "https://atmos.washington.edu/cgi-bin/uw.cgi?20240408";
const data = await fetch(url);
const text = await data.text();
console.log(text);
dayal avatar
myApi
@dayal
An interactive, runnable TypeScript val by dayal
Script
export function myApi(name) {
return "hi " + name;
bobbydigital avatar
boredActivities
@bobbydigital
// Activity suggestions for when you're bored
Script
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
// Activity suggestions for when you're bored
export let boredActivities = fetchJSON(
"https://www.boredapi.com/api/activity"
janpaul123 avatar
valle_tmp_6230585591494925520231921242577466
@janpaul123
// This script sets up a simple HTTP server for a comment box using Deno's Blob Storage for persistence.
HTTP (deprecated)
// This script sets up a simple HTTP server for a comment box using Deno's Blob Storage for persistence.
// Comments are stored in a JSON array in Blob Storage. When users submit a new comment, it is added to the array.
// The main page displays all stored comments along with a form to submit a new comment.
const key = "comments";
async function getComments(): Promise<Array<{ id: string; content: string }>> {
const comments = await blob.getJSON(key) as Array<{ id: string; content: string }> | undefined;
return comments ?? [];
async function addComment(content: string) {
const comments = await getComments();
comments.push({ id: ulid(), content });
stevekrouse avatar
notionDateMeDocNotify3
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
export let notionDateMeDocNotify3 = async ({ lastRunAt }: Interval) => {
let newDocs = await notionGetDatabaseEditedAfter({
auth: process.env.notion,
databaseId: "725cb1d741674413b933a37a50f1961f",
date: lastRunAt,
if (newDocs.length)
await email({
text: JSON.stringify(
newDocs.map(parseNotionDateDoc),
null,
stevekrouse avatar
mutateTestState
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
let { testState } = await import("https://esm.town/v/stevekrouse/testState");
export const mutateTestState = (state) => (testState = state);
webup avatar
completeSampleExplainCode
@webup
An interactive, runnable TypeScript val by webup
Script
export const completeSampleExplainCode = (async () => {
const prompt = `
class Log:
def __init__(self, path):
dirname = os.path.dirname(path)
os.makedirs(dirname, exist_ok=True)
f = open(path, "a+")
# Check that the file is newline-terminated
size = os.path.getsize(path)
if size > 0: