Search

Results include substring matches and semantically similar vals. Learn more
invisal avatar
sqlite_explorer
@invisal
An interactive, runnable TypeScript val by invisal
HTTP (deprecated)
export { default } from "https://esm.town/v/stevekrouse/amaranthYak";
stevekrouse avatar
rssDemo10
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Cron
import { newRSSItems } from "https://esm.town/v/stevekrouse/newRSSItems";
export async function rssDemo10(interval) {
let items = await newRSSItems({
url: inkAndSwitchRssUrl,
lastRunAt: interval.lastRunAt,
if (items?.length)
return email({
text: JSON.stringify(items, null, 2),
subject: "New from Ink & Switch",
sqlite avatar
refreshDB
@sqlite
An interactive, runnable TypeScript val by sqlite
Cron
import { valtownToSQLite } from "https://esm.town/v/pomdtr/valTownToSQLite";
export default async function(interval: Interval) {
await valtownToSQLite();
bcongdon avatar
easyAQI
@bcongdon
easyAQI Get the Air Quality Index (AQI) for a location via open data sources. It's "easy" because it strings together multiple lower-level APIs to give you a simple interface for AQI. Accepts a location in basically any string format (ie "downtown manhattan") Uses Nominatim to turn that into longitude and latitude Finds the closest sensor to you on OpenAQ Pulls the readings from OpenAQ Calculates the AQI via EPA's NowCAST algorithm Uses EPA's ranking to classify the severity of the score (ie "Unhealthy for Sensitive Groups") It uses blob storage to cache the openai location id for your location string to skip a couple steps for the next time. Example usage @stevekrouse.easyAQI({ location: "brooklyn navy yard" }) // Returns { "aqi": 23.6, "severity": "Good" } Forkable example: val.town/v/stevekrouse.easyAQIExample Also useful for getting alerts when the AQI is unhealthy near you: https://www.val.town/v/stevekrouse.aqi
Script
# easyAQI
Get the Air Quality Index (AQI) for a location via open data sources.
It's "easy" because it strings together multiple lower-level APIs to give you a simple interface for AQI.
1. Accepts a location in basically any string format (ie "downtown manhattan")
2. Uses [Nominatim](https://nominatim.org/) to turn that into longitude and latitude
3. Finds the closest sensor to you on [OpenAQ](https://openaq.org/)
const cacheKey = location => "easyAQI_locationID_cache_" + encodeURIComponent(location);
export async function easyAQI({ location }: {
location: string;
let openAQLocation = await blob.getJSON(cacheKey(location));
odin avatar
consoleEmailEx
@odin
// email yourself as easily as logging to the console
Script
// email yourself as easily as logging to the console
export let consoleEmailEx = (() => {
console.email("message"); // any JSON object can be the message
console.email({ html: "<h1>hello html emails!</h1>" }); // you can send HTML emails
console.email({ hi: "there" }, "Subject Line"); // optional second arg is the subject line
console.email({ html: "<b>hi!</b>", subject: "Subject accepted here too" });
juliendorra avatar
mockdevices
@juliendorra
An interactive, runnable TypeScript val by juliendorra
Script
export let mockdevices = (user) => {
// use user name to select devices
let devices = [];
let id = 0;
for (let letter of user) {
// add a device if charcode is even
if (letter.charCodeAt() % 2 === 0) {
// pick type
let type;
if (letter.charCodeAt() % 3 === 0) {
generatecoll avatar
greenLobster
@generatecoll
HTML example This is an example of how to return an HTML response. You can also preview it at https://andreterron-htmlExample.web.val.run?name=Andre
HTTP (deprecated)
# HTML example
This is an example of how to return an HTML response.
You can also preview it at https://andreterron-htmlExample.web.val.run?name=Andre
// View at https://andreterron-htmlExample.web.val.run?name=Andre
export default async function(req: Request): Promise<Response> {
const query = new URL(req.url).searchParams;
// Read name from the querystring or body. Defaults to "you" if not present.
const name = query.get("name") || (await req.json().catch(() => ({}))).name || "you";
// Returns the HTML response
return new Response(`<h1>Hi!</h1>`, {
petermillspaugh avatar
createNewsletters
@petermillspaugh
An interactive, runnable TypeScript val by petermillspaugh
Script
import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
export async function createNewslettersTable() {
await sqlite.execute(
CREATE TABLE IF NOT EXISTS newsletters (
id INTEGER PRIMARY KEY,
subject TEXT NOT NULL UNIQUE,
web_url TEXT NOT NULL UNIQUE,
target_send_date TIMESTAMP NOT NULL UNIQUE
andreterron avatar
debugSessionId
@andreterron
An interactive, runnable TypeScript val by andreterron
Script
export const debugSessionId = async (req, res) => {
res.set("Set-Cookie", "sessionid=helloworld; Path=/; HttpOnly");
res.send({ hello: "world" });
technobabble avatar
consoleEmailEx
@technobabble
// email yourself as easily as logging to the console
Script
// email yourself as easily as logging to the console
export let consoleEmailEx = (() => {
console.email("message"); // any JSON object can be the message
console.email({ html: "<h1>hello html emails!</h1>" }); // you can send HTML emails
console.email({ hi: "there" }, "Subject Line"); // optional second arg is the subject line
console.email({ html: "<b>hi!</b>", subject: "Subject accepted here too" });
tmcw avatar
typeboxExample
@tmcw
This val demonstrates how TypeBox objects are interchangeable with JSON Schema objects - if you run JSON.stringify() on one of them, you immediately get a JSON Schema validator. They do, in memory, have additional methods and information, but their easy conversion to JSON Schema objects is a major win.
Script
This val demonstrates how [TypeBox](https://github.com/sinclairzx81/typebox) objects
are interchangeable with [JSON Schema](https://json-schema.org/) objects - if you run
`JSON.stringify()` on one of them, you immediately get a JSON Schema validator.
They do, in memory, have additional methods and information, but their easy conversion
to JSON Schema objects is a major win.
import { Type } from "npm:@sinclair/typebox"
const querystring = Type.Object({
v: Type.Optional(Type.Integer({ minimum: 0 })),
console.log(JSON.stringify(querystring))
// {"type":"object","properties":{"v":{"minimum":0,"type":"integer"}}}
andre avatar
aqi
@andre
AQI Alerts Get email alerts when AQI is unhealthy near you. Set up Click Fork Change location (Line 4) to describe your location. It accepts fairly flexible English descriptions which it turns into locations via nominatim's geocoder API . 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 email alerts when AQI is unhealthy near you.
![](https://i.imgur.com/hB56X7o.png)
## Set up
1. Click `Fork`
2. Change `location` (Line 4) to describe your location. It accepts fairly flexible English descriptions which it turns into
export async function aqi(interval: Interval) {
const location = "brooklyn navy yard"; // <-- change to place, city, or zip code
const data = await easyAQI({ location });
if (!interval.lastRunAt) {
amywng avatar
emailRandomJoke
@amywng
// Fetches a random joke.
Cron
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
return response.json();
const randomJoke = await fetchRandomJoke();
const setup = randomJoke.setup;
const punchline = randomJoke.punchline;
// Sends an email with the joke.
export const emailRandomJoke = email({
pj0 avatar
aqi_lefkada
@pj0
AQI Alerts Get email alerts when AQI is unhealthy near you. 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 email alerts when AQI is unhealthy near you.
## 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
export async function aqi(interval: Interval) {
const location = "lefkada greece"; // <-- change to place, city, or zip code
const data = await easyAQI({ location });
if (!interval.lastRunAt) {
email({
stevekrouse avatar
dateMeNYWomen
@stevekrouse
// date me docs of women in nyc
Script
import { fetchDateMeProfiles } from "https://esm.town/v/stevekrouse/fetchDateMeProfiles";
// date me docs of women in nyc
export let dateMeNYWomen = fetchDateMeProfiles().then((
profiles,
profiles.filter((profile) =>
profile.Location?.includes("NYC") && profile.Gender?.includes("F")