Search

Results include substring matches and semantically similar vals. Learn more
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:
gio avatar
convenientAzureSparrow
@gio
// Your Telnyx API Key
Cron
const axios = require("axios");
// Your Telnyx API Key
const apiKey = "your_api_key";
// Function to send SMS
async function sendSMS(to, from) {
try {
const response = await axios.post(
"https://api.telnyx.com/v2/messages",
from: from, // Your Telnyx phone number
to: to, // Recipient's phone number
neverstew avatar
evalUrl
@neverstew
An interactive, runnable TypeScript val by neverstew
Script
import { raw } from "https://esm.town/v/neverstew/raw";
export const evalUrl = async (val: `@${string}.${string}`) =>
encodeURI(
"https://api.val.town/v1/eval/" + await raw(val),
eugenechantk avatar
VALLE
@eugenechantk
VALL-E LLM code generation for vals! Make apps with a frontend, backend, and database. It's a bit of work to get this running, but it's worth it. Fork this val to your own profile. Make a folder for the temporary vals that get generated, take the ID from the URL, and put it in tempValsParentFolderId . If you want to use OpenAI models you need to set the OPENAI_API_KEY env var . If you want to use Anthropic models you need to set the ANTHROPIC_API_KEY env var . Create a Val Town API token , open the browser preview of this val, and use the API token as the password to log in.
HTTP (deprecated)
# VALL-E
LLM code generation for vals! Make apps with a frontend, backend, and database.
It's a bit of work to get this running, but it's worth it.
* Fork this val to your own profile.
* Make a folder for the temporary vals that get generated, take the ID from the URL, and put it in `tempValsParentFolderId`.
* If you want to use OpenAI models you need to set the `OPENAI_API_KEY` [env var](https://www.val.town/settings/environment-v
// Set these to your own
export default VALLErun({
username: extractValInfo(import.meta.url).author,
// Make a folder, navigate to it, and get this from the URL.
willthereader avatar
umbrellaReminder
@willthereader
ā˜”ļø Umbrella reminder if there's rain today Setup Fork this val šŸ‘‰ https://val.town/v/stevekrouse.umbrellaReminder/fork Customize the location (line 2). You can supply any free-form description of a location. āš ļø Only works for US-based locations (where weather.gov covers). How it works Geocodes an free-form description of a location to latitude and longitude ā€“ @stevekrouse.nominatimSearch Converts a latitude and longitude to weather.gov grid ā€“ @stevekrouse.weatherGovGrid Gets the hourly forecast for that grid Filters the forecast for periods that are today and >30% chance of rain If there are any, it formats them appropriately, and sends me an email
Script
# ā˜”ļø Umbrella reminder if there's rain today
![Screenshot 2023-09-14 at 12.31.32.png](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/d82916ca-f8d9-4b49-88c6-420ab67a770
## Setup
1. Fork this val šŸ‘‰ https://val.town/v/stevekrouse.umbrellaReminder/fork
2. Customize the `location` (line 2). You can supply any free-form description of a location.
āš ļø Only works for US-based locations (where weather.gov covers).
export const umbrellaReminder = async () => {
let location = "bushwick, brooklyn"; // <---- customize this line
let [{ lat, lon }] = await nominatimSearch({
q: location,
iakovos avatar
fetchTextWithCaching
@iakovos
An interactive, runnable TypeScript val by iakovos
Script
export const fetchTextWithCaching = async (url: string): Promise<string | null> => {
const cacheItem = feedCache[url];
const headers: Record<string, string> = {};
if (cacheItem?.etag) {
headers["If-None-Match"] = cacheItem.etag;
if (cacheItem?.lastModified) {
headers["If-Modified-Since"] = cacheItem.lastModified;
try {
const response = await fetch(url, { headers });
if (response.status === 304) {
iamseeley avatar
formStyles
@iamseeley
An interactive, runnable TypeScript val by iamseeley
Script
export const formStyles = `
body {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
background-color: #f8f9fa;
margin: auto;
padding: 20px;
color: #212529;
max-width: 624px;
header {
padding-top: .25rem;
pdebieamzn avatar
pdfExtractText
@pdebieamzn
An interactive, runnable TypeScript val by pdebieamzn
Script
import { PDFExtract, PDFExtractOptions } from "npm:pdf.js-extract";
export default async function pdfExtractText(data: ArrayBuffer) {
const pdfExtract = new PDFExtract();
// const req = await fetch("https://morth.nic.in/sites/default/files/dd12-13_0.pdf");
// const data = await req.arrayBuffer();
const options: PDFExtractOptions = {}; /* see below */
const pdf = await pdfExtract.extractBuffer(data, options);
const text = pdf.pages.flatMap(p => p.content).map(c => c.str).join("\n");
return text;
rodrigotello avatar
FigmaFrameToHTML
@rodrigotello
Figma Frame To HTML TL;DR: you can see a Figma board in a website
Script
# Figma Frame To HTML
TL;DR: you can see a Figma board in a website
![An image of a screenshot of Figma the visual design software and a browser, showing how something drawn in Figma can be ren
import { FigmaFrameObjectToHTMLTest } from "https://esm.town/v/rodrigotello/FigmaFrameObjectToHTMLTest";
export async function FigmaFrameToHTML(
req: express.Request,
res: express.Response,
return res.send(`${FigmaFrameObjectToHTMLTest}`);
mgruel avatar
delay
@mgruel
An interactive, runnable TypeScript val by mgruel
Script
export const delay = async (ms: number) =>
new Promise((resolve) => setTimeout(resolve, ms));
andreterron avatar
tidbytX
@andreterron
An interactive, runnable TypeScript val by andreterron
Script
export async function tidbytX({ size = 7, bg = 0xffffff80, x: xColor = 0x9d174dff }: {
// b91c1c
// fecdd3
// 0x881337ff
// gray: 0xffffff80
// red: 0x9d174dff
// white-ish: 0xfecdd3ff
size?: number;
bg?: number;
x?: number;
Joelsrubin avatar
redSpoonbill
@Joelsrubin
An interactive, runnable TypeScript val by Joelsrubin
Script
export async function getTopTenBattingAverage() {
const data = await fetch(
"http://sports.core.api.espn.com/v2/sports/baseball/leagues/mlb/seasons/2024/types/2/leaders?lang=en&region=us",
const response = await data.json();
const promises = response.categories.find((cat) => cat.name === "avg").leaders.map((l) => l.athlete.$ref).slice(0, 10)
.map((
l,
) => fetch(l).then(response => response.json()));
const finalList = await Promise.all(promises);
const names = finalList.map((a, idx) => `${idx + 1}: ${a.fullName}`).join(", ");