Search

Results include substring matches and semantically similar vals. Learn more
thomasatflexos avatar
convertTodoItemsToGamePlans
@thomasatflexos
An interactive, runnable TypeScript val by thomasatflexos
Express
message: "Something went wrong!",
let finalResponse = choice.replace(/\n/g, "");
const { createClient } = await import(
"https://esm.sh/@supabase/supabase-js@2"
const supabase = createClient(
process.env.supabaseURL,
process.env.supabaseKey,
rdimartino avatar
notehub
@rdimartino
Notehub A set of helper functions for interacting with the Notehub API Requires NOTEHUB_CLIENT_ID and NOTEHUB_CLIENT_SECRET environment variables to be configured.
Script
A set of helper functions for interacting with the Notehub API
Requires `NOTEHUB_CLIENT_ID` and `NOTEHUB_CLIENT_SECRET` [environment variables](https://www.val.town/settings/environment-va
// Login into the Notehub API with a programmatic access client ID and client secret
// Returns the api token to be used for subsequent requests
const body = new URLSearchParams();
body.append("grant_type", "client_credentials");
body.append("client_id", Deno.env.get("NOTEHUB_CLIENT_ID"));
body.append("client_secret", Deno.env.get("NOTEHUB_CLIENT_SECRET"));
const res = await fetch("https://notehub.io/oauth2/token", {
turbo1912 avatar
fal_sdxl
@turbo1912
fal/sdxl This val is an example usage sdxl with fal.ai's javascript client. https://www.fal.ai/models/stable-diffusion-xl The client offers a way for you to subscribe to queue updates. This is useful if you want to get notified when a function is done running, or if you want to get the logs as they are being generated. import fal from "npm:@fal-ai/serverless-client"; const result = await fal.subscribe(FUNCTION_ID, { input: { seed: 176400, }, pollInterval: 5000, logs: true, onQueueUpdate: (update) => { console.log(update.status); if (update.status === "IN_PROGRESS") { update.logs.map((log) => log.message).forEach(console.log); } }, }); console.log(result.url); The onQueueUpdate callback will be called every time the queue status changes. The update object contains the queue status data as documented on the status types section .
Script
## fal/sdxl
This val is an example usage sdxl with fal.ai's javascript client.
https://www.fal.ai/models/stable-diffusion-xl
The client offers a way for you to subscribe to queue updates. This is useful if you want to get notified when a function is
```js
import fal from "npm:@fal-ai/serverless-client";
const result = await fal.subscribe(FUNCTION_ID, {
import fal from "npm:@fal-ai/serverless-client";
export let sdxl = async (input: { prompt: string }): Promise<{images: [{url: string}]}> => {
vladimyr avatar
googleFeelingLucky
@vladimyr
Google Feeling Lucky auto-redirect !lucky DuckDuckGo !Bangs offer the following shortcuts for Google's Feeling Lucky (going straight to the first result) search option: !fl - http://www.google.com/search?btnI&q={{{s}}} !gifl - http://google.com/search?btnI=1&q={{{s}}} !gluck - http://www.google.com/search?q={{{s}}}&btnI !lucky - http://www.google.com/search?q={{{s}}}&btnI Unfortunately, they don't work anymore due to redirect notices that get shown. This service enables you to skip redirect notice by altering your search from the original query e.g.: https://www.google.com/search?q=site:developer.mozilla.org+Object.hasOwn&btnI To the modified one made against this val's HTTP endpoint: https://vladimyr-googlefeelinglucky.web.val.run/?q=site:developer.mozilla.org+Object.hasOwn Additionally, you can define custom search shortcut inside your browser to allow a local bang-like experience: Name: Google Feeling Lucky Shortcut: !lucky URL with %s in place of query: https://vladimyr-googlefeelinglucky.web.val.run/?q=%s
HTTP (deprecated)
<https://vladimyr-googlefeelinglucky.web.val.run/?q=site:developer.mozilla.org+Object.hasOwn>
Additionally, you can define custom search shortcut inside your browser to allow a local bang-like experience:
- **Name:** Google Feeling Lucky
vidar avatar
testPostgres
@vidar
An interactive, runnable TypeScript val by vidar
Script
const postgres = await import("https://deno.land/x/postgres/mod.ts");
const client = new postgres.Client(process.env.neon);
await client.connect();
console.log(await client.queryObject`select * from authors;`);
ion avatar
movies
@ion
An interactive, runnable TypeScript val by ion
HTTP (deprecated)
"name": "The Godfather",
"description":
on the transformation of his youngest son, Michael, from reluctant family outsider to ruthless mafia boss.",
"rating": 9.2,
"image": "https://m.media-amazon.com/images/M/MV5BMTUyNjQwNzEtZDIzMC00ODc3LWI4MTgtNjQwOTQ5Mjc1M2E@.jpg",
ciebiada avatar
notionRecurringTasks
@ciebiada
An interactive, runnable TypeScript val by ciebiada
Cron
import process from "node:process";
import { Client } from "npm:@notionhq/client";
import dayjs from "npm:dayjs";
const DATABASE_ID = "519446a0d3ed47038fffd669b9ece770";
const notion = new Client({ auth: process.env.NOTION_API_KEY });
const intervalMapping = {
"Weekly": (date) => dayjs(date).add(1, "week"),
hash0000ff avatar
OpenAI
@hash0000ff
OpenAI - Docs ↗ Use OpenAI's chat completion API with std/openai . This integration enables access to OpenAI's language models without needing to acquire API keys. For free Val Town users, all calls are sent to gpt-4o-mini . Usage import { OpenAI } from "https://esm.town/v/std/openai"; const openai = new OpenAI(); const completion = await openai.chat.completions.create({ messages: [ { role: "user", content: "Say hello in a creative way" }, ], model: "gpt-4", max_tokens: 30, }); console.log(completion.choices[0].message.content); Limits While our wrapper simplifies the integration of OpenAI, there are a few limitations to keep in mind: Usage Quota : We limit each user to 10 requests per minute. Features : Chat completions is the only endpoint available. If these limits are too low, let us know! You can also get around the limitation by using your own keys: Create your own API key on OpenAI's website Create an environment variable named OPENAI_API_KEY Use the OpenAI client from npm:openai : import { OpenAI } from "npm:openai"; const openai = new OpenAI(); 📝 Edit docs
Script
3. Use the `OpenAI` client from `npm:openai`:
import { type ClientOptions, OpenAI as RawOpenAI } from "npm:openai";
* API Client for interfacing with the OpenAI API. Uses Val Town credentials.
private rawOpenAIClient: RawOpenAI;
* API Client for interfacing with the OpenAI API. Uses Val Town credentials.
[opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing ou
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
* @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as i
constructor(options: Omit<ClientOptions, "baseURL" | "apiKey" | "organization"> = {}) {
this.rawOpenAIClient = new RawOpenAI({
return this.rawOpenAIClient.chat;
git avatar
viem_auto_load_abi
@git
// Seaport 1.1 contract address
Script
import { whatsabi } from "npm:@shazow/whatsabi";
import { createPublicClient, http } from "npm:viem";
// Seaport 1.1 contract address
const address = "0x00000000006c3852cbEf3e08E8dF289169EdE581";
const client = createPublicClient({ chain: mainnet, transport: http() });
const { abi } = await whatsabi.autoload(address, { provider: client });
const result = await client.readContract({
abi,
vladimyr avatar
sqlitePublic
@vladimyr
An interactive, runnable TypeScript val by vladimyr
HTTP (deprecated)
import { createServer } from "https://esm.town/v/vladimyr/sqliteServer";
import { toHonoHandler } from "https://esm.town/v/vladimyr/toHonoHandler";
import { type ResultSet } from "npm:@libsql/client";
import { Hono } from "npm:hono";
import ky from "npm:ky";
fal avatar
sdxl
@fal
SDXL (fastest) https://www.fal.ai/models/stable-diffusion-xl link to val - https://www.val.town/v/fal/sdxl import * as fal from "npm:@fal-ai/serverless-client"; const result = await fal.subscribe("fal-ai/fast-sdxl", { input: { prompt: "photo of a rhino dressed suit and tie sitting at a table in a bar with a bar stools, award winning photography, Elke vogelsang" }, logs: true, onQueueUpdate: (update) => { if (update.status === "IN_PROGRESS") { update.logs.map((log) => log.message).forEach(console.log); } }, });
Script
```js
import * as fal from "npm:@fal-ai/serverless-client";
const result = await fal.subscribe("fal-ai/fast-sdxl", {
import fal from "npm:@fal-ai/serverless-client";
export let sdxl = async (
prompt: string,
jdan avatar
counterfeitPrompt
@jdan
An interactive, runnable TypeScript val by jdan
Script
import { createReActPrompt } from "https://esm.town/v/jdan/createReActPrompt";
export const counterfeitPrompt = createReActPrompt({
tools: [
`weigh(A: number[], B: number[]): "left" | "right" | "even"`,
bnorick avatar
reddit_alert_example
@bnorick
An interactive, runnable TypeScript val by bnorick
Script
"optiplex",
"t6[23]0",
"thin client",
{ pattern: "usff", strategy: "wordmatch" },
hardwareswap: [
"b450",
"thin client",
{ pattern: "usff", strategy: "wordmatch" },
augustveix avatar
OpticonReminder
@augustveix
New Stripe Subscription Handler This val receives webhooks from Stripe when we get a new subscriber to Val Town pro. The val: Verifies the signature to make sure it's really from Stripe Sends a message to our internal Discord channel Sends a thank you to the new subscriber If you send a GET request to this val, it responds with the thank you email – for ease of debugging. Setup If you want to set up something like this with your String account: Go to you Stripe Webhooks
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react */
import { email } from "https://esm.town/v/std/email?v=11";
import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook";
import { html } from "https://esm.town/v/stevekrouse/html";
import { thisValURL } from "https://esm.town/v/stevekrouse/thisValURL";
import { renderToString } from "npm:react-dom/server";
let welcomeEmail = renderToString(
<div style={{ maxWidth: "500px", fontFamily: "sans-serif" }}>
petermillspaugh avatar
retrievalPractice
@petermillspaugh
@jsxImportSource https://esm.sh/react
Script
/** @jsxImportSource https://esm.sh/react */
import { generateLessonHtml } from "https://esm.town/v/petermillspaugh/lessonTemplate";
import { renderToString } from "npm:react-dom/server";
* Work-in-progress! 👷‍♂️
const TITLE = "Retrieval practice";