Search

Results include substring matches and semantically similar vals. Learn more
fields avatar
defineSlackApp
@fields
An interactive, runnable TypeScript val by fields
Script
export let defineSlackApp = async (req: express.Request, res: express.Response) => {
const text = req.body.text.trim();
res.status(200);
// /undefine
if (req.body.command == "/undefine") {
if (dictionary[text.toLowerCase()]) {
delete dictionary[text.toLowerCase()];
res.send(`Removed definition for *${text}*`);
res.send(`There is no definition for *${text}*`);
return;
panphora avatar
distance
@panphora
An interactive, runnable TypeScript val by panphora
HTTP
export default async function distance(req) {
const searchParams = new URL(req.url).searchParams;
const destinationA = encodeURIComponent(String(searchParams.get("a")).trim());
const destinationB = encodeURIComponent(String(searchParams.get("b")).trim());
const apiKey = Deno.env.get("GOOGLE_MAPS_API_KEY");
if (!apiKey) {
return new Response("Google Maps API key is not set", { status: 500 });
const response = await fetch(
`https://maps.googleapis.com/maps/api/distancematrix/json?destinations=${destinationA}&origins=${destinationB}&units=impe
if (!response.ok) {
dinavinter avatar
yjs_actor
@dinavinter
An interactive, runnable TypeScript val by dinavinter
Script
AnyActorLogic,
AnyStateMachine,
CallbackActorLogic,
EventObject,
InspectionEvent,
Observer,
Snapshot,
} from "https://esm.sh/xstate@5.19.2?target=esnext";
const map = new Map<string, ReturnType<typeof createActorFromYjs>>();
export function yjsActor(logic: AnyActorLogic, doc?: Y.Doc | string, input?: any) {
mattwd7 avatar
weatherBasedActivityAlerting
@mattwd7
///////////////////////
Cron
// USER-DEFINED VALUES
// Uses lat/long of San Francisco as an example
const latitude = Number(Deno.env.get("WEATHER_LATITUDE")) || 37.7749;
const longitude = Number(Deno.env.get("WEATHER_LONGITUDE")) || -122.4194;
const temperatureUnit = Deno.env.get("WEATHER_TEMPERATURE_UNIT") || "fahrenheit";
const windSpeedUnit = Deno.env.get("WEATHER_WIND_SPEED_UNIT") || "mph";
const precipitationUnit = Deno.env.get("WEATHER_PRECIPITATION_UNIT") || "inch";
const timezone = Deno.env.get("WEATHER_TIMEZONE") || "America/Los_Angeles";
// Activity weather criteria definitions using Open-Meteo API daily weather keys
// All daily weather keys listed at https://open-meteo.com/en/docs
tal avatar
fetchAndStore
@tal
An interactive, runnable TypeScript val by tal
Script
export async function fetchAndStore(opts: {
schoolYear: `${number}-${number}`;
month: string;
menuType: string;
const menuText = await fetchDOEMenu(opts);
const lines: ReturnType<typeof parseMenuLine>[] = await Promise
.all(menuText.split("\r\n").map(parseMenuLine));
const key = dateCalendarKey(opts);
doeMenuResponseStore[key] = {
lastFetchedAt: new Date(),
janpaul123 avatar
valle_tmp_318720770269803174245544142195994
@janpaul123
// This val will respond with "Hello, world!" to any HTTP request
HTTP
// This val will respond with "Hello, world!" to any HTTP request
export default async function (req: Request): Promise<Response> {
return new Response("Hello, world!");
iamseeley avatar
exampleTranslation
@iamseeley
An interactive, runnable TypeScript val by iamseeley
HTTP
export default async function handler(req) {
if (req.method === "GET") {
return new Response(`
<!DOCTYPE html>
<html>
<body>
<h2>Translate English to German</h2>
<form id="translationForm">
<label for="text">English Text:</label><br>
<input type="text" id="text" name="text"><br><br>
youhavetrouble avatar
ViewCounter
@youhavetrouble
View counter with unique visitor count
HTTP
/** View counter with unique visitor count */
export default async function(req: Request): Promise<Response> {
if (req.method !== "GET") {
return new Response("Method not allowed", {
status: 405,
headers: {
"Content-Type": "application/json",
let shouldIncrement = true;
if (!req.headers.get("User-Agent")) {
shouldIncrement = false;
nicosql avatar
extraordinaryApricotGuineafowl
@nicosql
An interactive, runnable TypeScript val by nicosql
HTTP
export default async function(req: Request): Promise<Response> {
const url = "https://get.conduitbi.com/conduitbi--5933c";
// Get the current domain
const domain = new URL(req.url).hostname;
// Generate QR code as SVG
const qr = await QRCode.toString(url, {
type: "svg",
width: 512, // High resolution
margin: 4,
color: {
dhvanil avatar
val_wdRvdd0aOO
@dhvanil
An interactive, runnable TypeScript val by dhvanil
Script
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++) {
leomp12 avatar
MyFooter
@leomp12
Fork this if you want to share random vals from your likes in your projects!
HTTP
Fork this if you want to share random vals from your likes in your projects!
const USERNAME = extractValInfo(import.meta.url).author;
const hello = Deno.env.get("HELLO_WORLD");
export async function MyFooter(logo = valTownLogoAuto) {
const recommendation = rootValRef().handle === USERNAME
? html`<span class="recommends">${await recommends()}</span>`
return html`
<footer>
Made by
<a href="https://val.town/u/${USERNAME}" target="_blank">@${USERNAME}</a>
dhvanil avatar
val_eG1c3tsZv0
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export const jsonOkExample = () => Response.json({ ok: true });
Eddien000 avatar
hopefulEmeraldChimpanzee
@Eddien000
An interactive, runnable TypeScript val by Eddien000
Script
export default function CarServiceMarketingStrategy() {
return {
businessOverview: {
name: "Car Services Pro",
services: [
"Car Shipping",
"Car Rental",
"Vehicle Transportation"
valueProposition: "Seamless, reliable, and convenient car services tailored to your needs"
socialMediaStrategy: {
temptemp avatar
radiodb
@temptemp
// await sqlite.execute(`DROP TABLE IF EXISTS SCHEDULE;`);
Script
// await sqlite.execute(`DROP TABLE IF EXISTS SCHEDULE;`);
await sqlite.execute(`
CREATE TABLE IF NOT EXISTS SCHEDULE (
id DATETIME PRIMARY KEY,
file TEXT,
p_index INTEGER
export async function schedulePush(id: Date, file: string, index: number) {
// console.log(id.toISOString(), file);
await sqlite.execute(
`INSERT INTO SCHEDULE (id,file,p_index) VALUES ('${id.toISOString()}','${file}',${index})`,
antonnyman avatar
forbud
@antonnyman
An interactive, runnable TypeScript val by antonnyman
HTTP
export const forbud = async (req: Request) => {
let counties = [
county: "Blekinge",
municipalities: [
key: "Karlshamn",
value: "",
key: "Karlskrona",
value: "",
key: "Olofström",
value: "",