Search

Results include substring matches and semantically similar vals. Learn more
dhvanil avatar
val_bH5VlbZAwW
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_bH5VlbZAwW(req) {
try {
const result = await (async () => {
function generateArrayProblem() {
const operations = ['find duplicates', 'remove duplicates', 'find missing numbers', 'rotate array'];
const constraint = constraints[Math.floor(Math.random() * constraints.length)];
return `Write a function to ${operation} in a ${size} array ${constraint}.`;
console.log(generateArrayProblem());
koop12345 avatar
voiceToTextBot
@koop12345
// Telegram Bot API Token (requires setting in Val Town environment)
Script
import { OpenAI } from "https://esm.town/v/std/openai";
// Telegram Bot API Token (requires setting in Val Town environment)
console.error("Telegram Bot Token is not configured");
export default async function server(request: Request) {
if (request.method === "POST") {
const voiceBlob = await voiceFileResponse.blob();
// Convert voice to text using OpenAI Whisper
const openai = new OpenAI();
const transcription = await openai.audio.transcriptions.create({
file: voiceBlob,
headers: { "Content-Type": "text/html; charset=utf-8" },
// Helper function to send message back to Telegram
async function sendTelegramMessage(chatId: number, text: string) {
try {
dhvanil avatar
val_K1OL6VfLJs
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_K1OL6VfLJs(req) {
try {
// Execute the code directly and capture its result
sean_smyth avatar
myApi
@sean_smyth
An interactive, runnable TypeScript val by sean_smyth
Script
export function myApi(name = "placeholder", blurg = "blurg") {
return `Hi ${name} + ${blurg}`;
stevekrouse avatar
sleep
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
export function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
monu_shaw avatar
variableIvoryEgret
@monu_shaw
An interactive, runnable TypeScript val by monu_shaw
HTTP
export default async function(req: Request): Promise<Response> {
let params = new URLSearchParams(req.url);
let name = params.get("https://monu_shaw-variableivoryegret.web.val.run/?passcode");
prashamtrivedi avatar
tokencounter
@prashamtrivedi
@jsxImportSource https://esm.sh/react
HTTP
import { createRoot } from "https://esm.sh/react-dom/client";
function App() {
const [systemPrompt, setSystemPrompt] = useState("");
localStorage.setItem(key, value);
const handleApiKeyChange = (e, setFunction, storageKey) => {
const value = e.target.value;
setFunction(value);
saveApiKey(storageKey, value);
const parsedTools = JSON.parse(tools);
modelOptions.functionDeclarations = parsedTools;
} catch (error) {
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
const url = new URL(request.url);
pkingo avatar
myApi
@pkingo
An interactive, runnable TypeScript val by pkingo
Script
export function myApi(name) {
return "hi " + name;
dhvanil avatar
val_8NcFl97ieh
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_8NcFl97ieh(req) {
try {
const body = await req.text();
// Create a function from the provided code and execute it
const userFunction = async () => {
const findPrimes = (n) => {
// Execute and capture the result
const result = await userFunction();
// Handle different types of results
geanu02 avatar
myApi
@geanu02
An interactive, runnable TypeScript val by geanu02
Script
export function myApi(name) {
return "hi " + name;
stevekrouse avatar
webassemblyExample
@stevekrouse
// Forked from @mkeller7.webassemblyExample
Script
const importObj = {};
const { instance } = await WebAssembly.instantiate(source.buffer, importObj);
const addTwo = instance.exports.addTwo as CallableFunction;
return addTwo(20, 31);
// Forked from @mkeller7.webassemblyExample
maxm avatar
passkeys_demo
@maxm
Passkeys Demo Passkeys are pretty neat! I wanted to get a demo working in Val Town so I ported over https://github.com/maximousblk/passkeys-demo. One challenge was that the original extensively uses DenoKV store with compound keys and values. I created @stevekrouse/DenoSyntheticKV as a replacement for DenoKV. It uses SuperJSON to encode the keys and values. You can find the client-side script for the main page here: @stevekrouse/passkey_script
HTTP
// UTILS
function generateJWT(userId: string) {
return new SignJWT({ userId }).setProtectedHeader({ alg: "HS256" }).sign(SECRET);
function verifyJWT(token: string) {
return jwtVerify(token, SECRET);
function generateRandomString() {
return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
airon21 avatar
myApi
@airon21
An interactive, runnable TypeScript val by airon21
Script
export function myApi(name) {
return "hi " + name;
dhvanil avatar
val_rP0fdOu8JK
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_rP0fdOu8JK(req) {
try {
// Execute the code directly and capture its result
kamenxrider avatar
falDemoApp
@kamenxrider
@jsxImportSource https://esm.sh/react
HTTP
import { falProxyRequest } from "https://esm.town/v/stevekrouse/falProxyRequest";
function App() {
const [prompt, setPrompt] = useState("");
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(req: Request): Promise<Response> {
const url = new URL(req.url);