Search

Results include substring matches and semantically similar vals. Learn more
robh3 avatar
friend
@robh3
An interactive, runnable TypeScript val by robh3
Script
import { S3Client } from "https://deno.land/x/s3_lite_client@0.6.1/mod.ts";
const cloudflareR2client = new S3Client({
endPoint: Deno.env.get("cloudflareR2Endpoint"), // This stores as secrets in val.town
let currentDate = new Date().toISOString(); // Otherwise, we take the current date
await cloudflareR2client.putObject("transcription-" + currentDate + ".json", req.body);
return Response.json({ ok: true });
maxm avatar
staticChess
@maxm
Check it out here: https://chess.maxmcd.com Plain, brutalist, no bloat chess. Every page is only html and css. Every chess move is made by clicking a link. Send a link to your friend and they'll send you one back to make your move. No silly animations or slick interactivity to trip up your gameplay. When Google indexes this site will we successfully compute all possible chess moves? Functionality is quite limited, and things might be broken. Please let me know if you find bugs! Inspired by this HN discussion about sites that have all possible game states of tic-tac-toe. I plan on extending this to support real gameplay. I think it could be a nice simple interface for long form games with friends. Might also be fun to add a static AI to play against. Feel free to PR any changes if you'd like to see something added.
HTTP
/** @jsxImportSource https://esm.sh/react */
import { analyticsHandlerWrapper } from "https://esm.town/v/maxm/valTownAnalytics";
import { Chess, Move, Square } from "npm:chess.js";
import minify from "npm:css-simple-minifier";
import { renderToString } from "npm:react-dom/server";
class StaticChess {
size = 8;
maxm avatar
valTownAnalytics
@maxm
Val Town Analytics WIP!
HTTP
/** @jsxImportSource https://esm.sh/react */
import { DateTime } from "https://cdn.skypack.dev/luxon@2.3.2";
import { extractValInfo } from "https://esm.town/v/pomdtr/extractValInfo?v=27";
import { sqlite } from "https://esm.town/v/std/sqlite?v=6";
import { renderToString } from "npm:react-dom/server";
const { author, name, httpEndpoint } = extractValInfo(import.meta.url);
sqlite.batch([
std avatar
openai
@std
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;
postpostscript avatar
authIdBase
@postpostscript
An interactive, runnable TypeScript val by postpostscript
Script
async function emailSignInLink(clientToken: string) {
qs.set("clientToken", clientToken);
const clientToken = qs.get("clientToken");
let clientPayload;
clientPayload = clientToken && await verifyThirdParty(clientToken, {
console.log("error verifying clientPayload", e);
if (!clientPayload) {
const { returnTo } = clientPayload;
redirectQS.set("clientToken", clientToken);
emailSignInLink(clientToken);
yawnxyz avatar
hnCloneLuciaOauth
@yawnxyz
Added Github Oauth support to the example this needed changes to lucia_middleware to take github auth and callback routes lucia_sqlite also needd changes to add a github_id field
HTTP (deprecated)
* Users can upvote each post exactly once and comment on stories in an infinitely nested style.
/** @jsxImportSource https://esm.sh/react */
import React, { useState, useEffect } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
import { luciaMiddleware } from "https://esm.town/v/yawnxyz/lucia_middleware_safe";
</html>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default luciaMiddleware(async function server(request: Request): Promise<Response> {
yawnxyz avatar
honoJsxHtmlTemplates
@yawnxyz
Base working example of combining Hono, React/JSX, and html templates
HTTP (deprecated)
Base working example of combining Hono, React/JSX, and html templates
/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
import { renderToString } from "npm:react-dom/server";
import { Hono } from 'npm:hono'
import { html } from 'npm:hono/html'
avkv avatar
staticChess
@avkv
Static Chess Check it out here: https://chess.maxmcd.com Plain, brutalist, no bloat chess. Every page is only html and css. Every chess move is made by clicking a link. Send a link to your friend and they'll send you one back to make your move. No silly animations or slick interactivity to trip up your gameplay. When Google indexes this site will we successfully compute all possible chess moves? Functionality is quite limited, and things might be broken. Please let me know if you find bugs! Inspired by this HN discussion about sites that have all possible game states of tic-tac-toe. I plan on extending this to support real gameplay. I think it could be a nice simple interface for long form games with friends. Might also be fun to add a static AI to play against. Feel free to PR any changes if you'd like to see something added.
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react */
import { Chess, Move, Square } from "npm:chess.js";
import minify from "npm:css-simple-minifier";
import { renderToString } from "npm:react-dom/server";
class StaticChess {
size = 8;
kortina avatar
shotclip
@kortina
SHOTCLIP Demo of embedding images with substrate , and querying them for semantic relevance. Use the query parameter prompt to control the search.
HTTP (deprecated)
/** @jsxImportSource npm:react **/
/** kortina
import process from "node:process";
import { renderToString } from "npm:react-dom@18/server";
import { QueryVectorStore, sb, Substrate } from "npm:substrate";
type ShotResult = {
parkerdavis avatar
blob_admin
@parkerdavis
Blob Admin This is a lightweight Blob Admin interface to view and debug your Blob data. Use this button to install the val: It uses basic authentication with your Val Town API Token as the password (leave the username field blank). TODO [x] /new - render a page to write a new blob key and value [x] /edit/:blob - render a page to edit a blob (prefilled with the existing content) [x] /delete/:blob - delete a blob and render success [ ] handle non-textual val properly [ ] add upload/download buttons [ ] merge edit and view pages [ ] add client side navigation using htmx [ ] use codemirror instead of a textarea for editing text blobs
HTTP (deprecated)
- [ ] merge edit and view pages
- [ ] add client side navigation using htmx
- [ ] use codemirror instead of a textarea for editing text blobs
taowen avatar
npmExample
@taowen
An interactive, runnable TypeScript val by taowen
Script
export let npmExample = (async () => {
const { HUMAN_PROMPT, AI_PROMPT, Client } = await import(
"npm:@anthropic-ai/sdk"
); // The Lodash library exported as ES modules.
const client = new Client(
"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"
console.log("size of prompt", prompt.length);
const result = await client.complete({
prompt,
beneskildsen avatar
snip
@beneskildsen
An interactive, runnable TypeScript val by beneskildsen
Script
import { decodeGrammar } from "https://esm.town/v/beneskildsen/decodeGrammar";
import { dispatch } from "https://esm.town/v/beneskildsen/dispatch";
export const snip = (x, y, clientID, grammar) => {
return dispatch(
type: "SNIP",
pos: { x, y },
clientID,
grammar: decodeGrammar(grammar),
bonsaiReducer,
stevekrouse avatar
ReloadScript
@stevekrouse
⚠️ Deprecated in favor of @stevekrouse/reloadOnSave
Script
import { createElement } from "https://esm.sh/react";
import { getCurrentValVersionNumber } from "https://esm.town/v/stevekrouse/getCurrentValVersionNumber?v=4";
import { parentReference } from "https://esm.town/v/stevekrouse/parentReference";
reloadOnVals(${JSON.stringify(vals)})
</script>`;
export const ReloadScriptReactElement = ({ vals } = { vals: [parentReference()] }) =>
createElement("script", {
type: "module",
stevekrouse avatar
googleClient
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
export const googleClient = async () => {
const { google } = await import("npm:googleapis");
const key = { client_id: "test", client_secret: "test" };
const client = new google.auth.OAuth2(key.client_id, key.client_secret, [
"https://example.com",
return client;
begoon avatar
slackbot
@begoon
A simple Slack chat bot prototype able to reply to mentions, channel messages containing keywords, add reactions and act on the slash commands.
HTTP
rototype able to reply to mentions, channel messages containing keywords, add reactions and act on the slash commands.
body: JSON.stringify({ channel, text, thread_ts }),
async function reaction(channel: string, timestamp: string, name: string = "thumbsup") {
return await fetchJSON(
"https://slack.com/api/reactions.add",
headers: { "Authorization": `Bearer ${SLACK_BOT_TOKEN}` },
await message(channel, "<@" + event.user + ">: all good!");
console.log("reaction", await reaction(channel, event.ts));
return Response.json({ ok: true });