Search

moveHead
@adamgonda
An interactive, runnable TypeScript val by adamgonda
Script
export function moveHead(head, dir) {
if (["RIGHT", "LEFT"].includes(dir)) {
return {
web_YhrAkPFife
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_YhrAkPFife(req) {
return new Response(`<!DOCTYPE html>
<html>

testCodemirrorTsBrowserEmacs
@saolsen
@jsxImportSource https://esm.sh/react
HTTP
/** @jsxImportSource https://esm.sh/react */
import { renderToString } from "npm:react-dom/server";
export default async function(req: Request): Promise<Response> {
return new Response(
renderToString(
<textarea id="editorSource" className="for-codemirror" name="editorSource">
{`let hasAnError: string = 10;
function increment(num: number) {
return num + 1;
increment('not a number');`}
aqi
@sincospi
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
import { email } from "https://esm.town/v/std/email?v=9";
import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
export async function aqi(interval: Interval) {
const location = "halandri 15234, greece"; // <-- change to place, city, or zip code
const data = await easyAQI({ location });

passionateScarletPrawn
@stevekrouse
👕 Shirtgen API Endpoint Shirtgen lets you generate AI-powered t-shirt designs with just a prompt! 🖋️ Choose between the standard "Flux Schnell" model or the enhanced "Pro" model. Perfect for creating unique custom apparel in seconds! 🚀 💡 How it Works Send a POST request to the endpoint with your design prompt. Toggle between Standard and Pro models using the useProModel flag. The AI generates a high-quality t-shirt design based on your prompt. 📥 Expected POST Data {
"prompt": "A retro sunset with palm trees 🌴🌅",
"useProModel": true
}
HTTP
import { createRoot } from "https://esm.sh/react-dom/client";
function App() {
const [prompt, setPrompt] = useState("");
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
client();
export default async function server(request: Request): Promise<Response> {
if (request.method === "GET") {
twitterRecentMentions
@charmaine
// This val fetches recent tweets about @SnapAR or Lens Studio
HTTP
import { socialDataSearch } from "https://esm.town/v/stevekrouse/socialDataSearch";
export default async function server(request: Request): Promise<Response> {
// Updated to just Specs post-launch
headers: { "Content-Type": "application/json" },
function retResponse(tweets: any[]): Response {
const sevenDaysAgo = new Date();
// Load Twitter widget asynchronously
window.twttr = (function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0],
t._e = [];
t.ready = function(f) {
t._e.push(f);

pipes
@pomdtr
An interactive, runnable TypeScript val by pomdtr
Script
ok: false;
error: Error;
export async function pipes(sql: string): Promise<Result> {
const origin = "https://pipes.turbot.com";
const pathname = `/api/latest/user/${user}/workspace/${workspace}/query`;

inTheBackgroundExample
@neverstew
inTheBackground With the addition of the "early return" feature of web handlers, you can now process short background tasks in vals. This can be really useful for occasions where an immediate response is required, with a subsequent update a few seconds later e.g. a Discord bot that calls ChatGPT needs to respond within a few seconds, which can be too fast for the AI to generate a response. We can instead reply immediately and then update that message later, inTheBackground Simply wrap something in inTheBackground and it will do just that! In this example, we log something a few seconds later than the web response is sent back.
HTTP
import { inTheBackground } from "https://esm.town/v/neverstew/inTheBackground";
import { sleep } from "https://esm.town/v/neverstew/sleep";
export default async function(req: Request): Promise<Response> {
inTheBackground(async () => {
await sleep(3000);

Snake
@adamgonda
An interactive, runnable TypeScript val by adamgonda
Script
export function Snake({ x, y, dir }) {
return {
body: [
qdrant
@dglazkov
Since Qdrant Cloud has a fairly strict CORS policy, here's a simple val that proxies calls to Qdrant Cloud API and makes them accessible from Web apps. To set up: fork this val add your QDRANT_API_KEY to your environment variables. This would limit usage of your proxy to your API key only. start using val as a proxy Use it as a 1:1 replacement for Qdrant API, except for one additional query string parameter: cluster_id -- the part of the Qdrant API endpoint before cloud.qdrant.io .
HTTP
"Access-Control-Max-Age": "2592000", // 30 days
} as Record<string, string>;
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response("ok", { headers: structuredClone(CORS_HEADERS) });
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];
MultiEncryptionKeyGenerator
@heltonteixeira
@jsxImportSource https://esm.sh/react
HTTP
import { md5 } from "https://esm.sh/js-md5";
// Helper function for SHA-256 encryption
async function sha256(message: string) {
const msgBuffer = new TextEncoder().encode(message);
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
// Helper function for Base64 encoding
function base64Encode(input: string): string {
return btoa(input);
// Custom Caesar Cipher encryption
function caesarCipher(input: string, shift: number = 3): string {
return input
// Custom XOR Encryption
function xorEncrypt(input: string, key: string = 'SECRET'): string {
return input
.join('');
function App() {
const [input, setInput] = useState('');
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
return new Response(`
emptyValUtils
@nbbaier
Empty Val Utils Handy utility functions to see if you have vals with no code lying around your account and to delete them (if you want to). Usage listEmptyVals import {listEmptyVals } from "https://esm.town/v/nbbaier/emptyValUtils";
console.log(await listEmptyVals(<user_id>)) deleteEmptyVals import {listEmptyVals } from "https://esm.town/v/nbbaier/emptyValUtils";
await deleteEmptyVals(<user_id>)
Script
# Empty Val Utils
Handy utility functions to see if you have vals with no code lying around your account and to delete them (if you want to).
## Usage
import { deleteVal } from "https://esm.town/v/neverstew/deleteVal";
export async function listEmptyVals(id: string) {
const token = Deno.env.get("valtown");
return res.filter((v) => (v.code.length === 0)).map(v => v.name);
export async function deleteEmptyVals(id: string) {
const token = Deno.env.get("valtown");
mdtort
@prashamtrivedi
@jsxImportSource https://esm.sh/react
HTTP
import DOMPurify from "https://esm.sh/dompurify";
function App() {
const [markdown, setMarkdown] = useState("");
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
client();
export default async function server(request: Request): Promise<Response> {
return new Response(