Search

Results include substring matches and semantically similar vals. Learn more
eralp avatar
self
@eralp
An interactive, runnable TypeScript val by eralp
Script
import { fetch } from "https://esm.town/v/std/fetch";
export let self = async () {
const response = await fetch("https://api.val.town/eval/@eralp.self")
const json = await response.json();
return json.data;
stnkvcs avatar
getAirtableDataAPI
@stnkvcs
// Initialize Airtable configuration
HTTP
// Initialize Airtable configuration
const airtableApiKey = Deno.env.get("AIRTABLE_API_KEY");
const baseId = Deno.env.get("AIRTABLE_BASE_ID");
const tableName = Deno.env.get("AIRTABLE_TABLE_NAME");
async function fetchAirtableData(uid: string) {
if (!airtableApiKey || !baseId || !tableName) {
throw new Error("Missing Airtable environment variables");
const url = `https://api.airtable.com/v0/${baseId}/${tableName}?filterByFormula=UID%3D%22${encodeURIComponent(uid)}%22`;
const response = await fetch(url, {
headers: {
bingo16 avatar
testConnect
@bingo16
An interactive, runnable TypeScript val by bingo16
Script
export let testConnect = async ({ req, res }) => {
console.log("connect establisted!");
return "connect successful!";
parthstown avatar
youthfulCoffeeDolphin
@parthstown
An interactive, runnable TypeScript val by parthstown
HTTP
export default async function(req: Request): Promise<Response> {
return Response.json(req.body);
janpaul123 avatar
valle_tmp_719883516769855647473989346238055
@janpaul123
// This is a simple Express HTTP val that returns "Hello, World!" when accessed.
HTTP
// This is a simple Express HTTP val that returns "Hello, World!" when accessed.
// It uses the Express framework to handle HTTP requests.
import express from "npm:express";
const app = express();
app.get("/", (req, res) => {
res.send("Hello, World!");
export default app.fetch;
browserbase avatar
browserbaseUtils
@browserbase
Utils to loadPageContent() and screenshotPage() . Browserbase Browserbase offers a reliable, high performance serverless developer platform to run, manage, and monitor headless browsers at scale. Leverage our infrastructure to power your web automation and AI agents. Get started with Browserbase for free here . If you have any questions, reach out to developer@browserbase.com.
Script
Utils to `loadPageContent()` and `screenshotPage()`.
### Browserbase
Browserbase offers a reliable, high performance serverless developer platform to run, manage, and monitor headless browsers a
Get started with Browserbase for free [here](https://www.browserbase.com).
If you have any questions, reach out to developer@browserbase.com.
export interface LoadPageContentOptions {
textContent: boolean;
export async function loadPageContent(url: string, options: LoadPageContentOptions = { textContent: false }) {
const browser = await puppeteer.connect({
browserWSEndpoint: `wss://connect.browserbase.com?apiKey=${Deno.env.get("BROWSERBASE_API_KEY")}`,
dhvanil avatar
val_5jRwwTodiK
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export default async function handler(req) {
try {
const result = await (async () => {
function isPrime(num) {
if (num <= 1) return false;
for (let i = 2; i <= Math.sqrt(num); i++) {
if (num % i === 0) return false;
return true;
function findLowestThreeDigitPrime() {
for (let num = 100; num < 1000; num++) {
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" });
shaya avatar
getSofZmanShma
@shaya
An interactive, runnable TypeScript val by shaya
Script
import { fetch } from "https://esm.town/v/std/fetch";
export async function getSofZmanShma(city) {
console.log({ city });
const today = new Date().toISOString().split("T")[0];
const data = await (
await fetch(
`https://www.hebcal.com/zmanim?cfg=json&city=${city}&date=${today}`
).json();
console.log(data.times.sofZemanShma);
return data.times.sofZemanShma;
dhvanil avatar
val_8omNGabJ8G
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export default async function handler(req) {
try {
const result = await (async () => {
function findLowestThreeDigitFibonacci() {
let fib = [0, 1];
let nextFib = 1;
while (nextFib < 1000) {
nextFib = fib[fib.length - 1] + fib[fib.length - 2];
fib.push(nextFib);
return fib.filter(num => num >= 100 && num < 1000);
tmcw avatar
bandcampWrapped
@tmcw
Bandcamp Wrapped It's Spotify Wrapped, but for Bandcamp! . Bandcamp is for people who buy their music and probably most of them hoard MP3s. Like me. And this val helps those people turn their Bandcamp purchases of 2024 into HTML or Markdown suitable for blog posts on their blogs, which is probably a segment that has some overlap with the people who are wacky enough to buy their music instead of streaming it from some service. Because Bandcamp doesn't have an API, this hinges on you going to your purchases page, copying the purchases, and pasting it in. Thanks to the ability of the system clipboard to contain HTML , the same technology that makes copy-and-pasted text have unpredictable and annoying font and boldness choices also lets this parse and reformat that purchases page into something shareable. I would love for this to support embeds as well, but I haven't found a strategy yet: Bandcamp embeds use album IDs in the URLs, which are not exposed in the content on the purchases page. I'd have to scrape Bandcamp for that, which would probably inevitably be blocked by some 'bot protection' system. Also read about this on macwright.com .
HTTP
# Bandcamp Wrapped
It's Spotify Wrapped, but for [Bandcamp!](https://bandcamp.com/). Bandcamp is for people who buy their music and probably mos
turn their Bandcamp purchases of 2024 into HTML or Markdown suitable for blog posts on their blogs, which is probably a segme
wacky enough to buy their music instead of streaming it from some service.
Because Bandcamp doesn't have an API, this hinges on you going to your purchases page, copying the purchases, and pasting it
the ability of [the system clipboard to contain HTML](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem), the sa
export default async function(req: Request): Promise<Response> {
return new Response(
<link rel="stylesheet" href="https://unpkg.com/missing.css@1.1.3">
<main>
qqyule avatar
tomatoCaterpillar
@qqyule
An interactive, runnable TypeScript val by qqyule
HTTP
export default async function (req: Request): Promise<Response> {
return Response.json({ ok: true })
jrmann100 avatar
valStorage
@jrmann100
An interactive, runnable TypeScript val by jrmann100
Script
export default <T,>() => {
const storageKey = whoami()[0];
return {
storageKey: storageKey,
get() {
return blob.getJSON(this.storageKey) as Promise<T | undefined>;
set(value: T | undefined) {
if (value === undefined) {
return blob.delete(this.storageKey);
return blob.setJSON(this.storageKey, value);
jplhomer avatar
honoExample
@jplhomer
// Forked from @tmcw.honoExample
Script
export const honoExample = async (req: Request) => {
const { Hono } = await import("npm:hono");
const app = new Hono();
app.get("/", (c) => c.text("Hono yes?"));
app.get("/yeah", (c) => c.text("Routing ok!"));
return app.fetch(req);
// Forked from @tmcw.honoExample
sdan avatar
getWeather
@sdan
An interactive, runnable TypeScript val by sdan
Script
export async function getWeather(city: string) {
try {
const response = await fetch(`https://wttr.in/${city}?format=j1`);
if (!response.ok) {
throw new Error(`Failed to fetch data for ${city}`);
const jsonData = await response.json();
const feelsLikeF = jsonData.current_condition[0].FeelsLikeF;
const weatherDescription =
jsonData.current_condition[0].weatherDesc[0].value;
return `${city}: feels like ${feelsLikeF}, ${weatherDescription}`;