Search

Results include substring matches and semantically similar vals. Learn more
stungeye avatar
aqiInProgress
@stungeye
// # Email alerts when air is unhealthy near you
Cron
// # Email alerts when air is unhealthy near you
export async function aqiInProgress() {
async function mapLocationsToQuality(locations) {
const promises = Object.entries(locations).map(async ([name, id]) => {
const warningThresold = 75;
const results = await nowCastPMAQI({
location_id: id,
return {
name,
quality: {
tmcw avatar
gifEndpoint
@tmcw
Returning a tiny GIF from a val Here's that GIF: It's so small!
Express
# Returning a tiny GIF from a val
Here's that GIF:
![](https://tmcw-gifendpoint.express.val.run/)
It's so small!
import { Buffer } from "node:buffer";
export let gifEndpoint = (req, res) => {
res.set("Content-Type", "image/gif");
res.send(
Buffer.from("R0lGODdhAQABAPAAAP8AAAAAACwAAAAAAQABAAACAkQBADs=", "base64"),
kognise avatar
sendDailyValenceEmail
@kognise
An interactive, runnable TypeScript val by kognise
Cron
export async function sendDailyValenceEmail() {
await mail({
to: "Lexi Mattick <lexi.mattick@gmail.com>",
from: "Valence Tracker <kognise.onValenceReply@valtown.email>",
subject: "daily happiness check-in",
text: `
hello, me! this is your daily reminder to rate your happiness. you can do this any time today.
1 - terrible
2 - pretty bad
3 - meh
substrate avatar
intro
@substrate
Generate a story and summarize it using Substrate . 🪩 To fork, sign up for Substrate to get your own API key and $50 free credits.
HTTP (deprecated)
Generate a story and summarize it using [Substrate](https://substrate.run/).
🪩 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 story = new ComputeText({
prompt: "tell me a story, be concise",
max_tokens: 500,
const summary = new ComputeText({
prompt: sb.interpolate`summarize this story in one sentence. do not preface the summary: ${story.future.text}`,
max_tokens: 500,
const stream = await substrate.stream(summary);
stevekrouse avatar
happyLeapDay
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Cron
import { email } from "https://esm.town/v/std/email?v=9";
export const happyLeapDay = () => email({ subject: "Happy leap day!" });
rap avatar
emailMe
@rap
An interactive, runnable TypeScript val by rap
Script
import { welcomeEmail } from "https://esm.town/v/rodrigotello/welcomeEmail?v=142";
export let emailMe = console.email({
html: welcomeEmail,
subject: "Welcome to Val Town",
xiyouMc avatar
getValTownResp
@xiyouMc
An interactive, runnable TypeScript val by xiyouMc
Script
import { getValTown } from "https://esm.town/v/xiyouMc/getValTown";
export let getValTownResp = (async () => {
const s = getValTown;
console.log("aaa", s);
ellison0421 avatar
emailRandomJoke
@ellison0421
// Fetches a random joke.
Cron
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
const SAMPLE_JOKE = await response.json();
return SAMPLE_JOKE;
return response.json();
const randomJoke = await fetchRandomJoke();
const setup = randomJoke.setup;
const punchline = randomJoke.punchline;
neverstew avatar
run
@neverstew
An interactive, runnable TypeScript val by neverstew
Script
export async function run(
{ username, valName, data, token }: Params,
): Promise<Result> {
let url = `https://api.val.town/v1/run/${username}.${valName}`;
const headers: HeadersInit = {};
if (token)
headers.Authorization = `Bearer ${token}`;
const method = data ? "POST" : "GET";
const body = data ? JSON.stringify({ args: data }) : undefined;
const response = await fetch(url, { method, headers, body });
stevekrouse avatar
hnPrefixURL
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
export let hnPrefixURL = "https://news.ycombinator.com/item?id=";
ooo_ooo_oooooh avatar
doesAdamSux
@ooo_ooo_oooooh
An interactive, runnable TypeScript val by ooo_ooo_oooooh
Script
export function doesAdamSux() {
return "Yes stupid.";
simonw avatar
yellowToad
@simonw
An interactive, runnable TypeScript val by simonw
Script
const script = `
def mapFunction(r, i):
v = r * i
return v
x = [1, 2, 3, 4]
x
.map(mapFunction)
.filter(r => r * r)
.join(",")
const interpreter = jsPython();
val avatar
postWebhookTest1
@val
An interactive, runnable TypeScript val by val
Script
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
export let postWebhookTest1 = fetchJSON(
"https://api.val.town/express/@stevekrouse.postWebhook1",
method: "POST",
body: JSON.stringify({ name: "Steve" }),
stevekrouse avatar
postWebhook1
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Express
export let postWebhook1 = (req: express.Request, res: express.Response) => {
res.json({ data: `Hello + ${req.body.name}!` });
aeaton avatar
peelSessionArtistSession
@aeaton
An interactive, runnable TypeScript val by aeaton
Script
export async function peelSessionArtistSession(url) {
const dom = await fetchHtmlDom(url);
const headings = dom.querySelectorAll("h3");
const trackItems = [...headings].find((heading) =>
heading.textContent === "TRACKLIST"
).nextElementSibling.querySelectorAll("ul > li");
const tracks = [...trackItems].map((track) => track.textContent);
const date = headings[0].querySelector("strong").textContent.trim();
const artist = headings[0].querySelector("a").textContent.trim();
return { date, artist, tracks };