Search

Results include substring matches and semantically similar vals. Learn more
yawnxyz avatar
jsonpub
@yawnxyz
// Initialize InstantDB
HTTP
// Add jq processing functions
async function jqFilter(input, filter) {
$('#jq-filter').on('keypress', async function(e) {
function updateCursor(e) {
function createCursorElement(peerId, cursor) {
function removeCursor(peerId) {
$(function() {
function saveJsonDoc(content, isNew = false) {
$('#json-input').bind('input', function() {
function updateDocsList(docs) {
willthereader avatar
InventionDetailstoJSONConverter
@willthereader
@jsxImportSource https://esm.sh/react
HTTP
function App() {
return; // Exit the function, but useEffect will resume after countdown
function client() {
async function server(request: Request): Promise<Response> {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
async function processLine(line) {
const completion = await openai.chat.completions.create({
console.error("Error in server function:", error);
async function checkRateLimit(blob, key) {
klekanger avatar
myApi
@klekanger
An interactive, runnable TypeScript val by klekanger
Script
export function myApi(name) {
return "hi " + name;
maxm avatar
asciiNycCameras
@maxm
ASCII NYC Traffic Cameras All of NYC's traffic cameras available as streaming ASCII images: https://maxm-asciinyccameras.web.val.run/ NYC has a bunch of traffic cameras and makes them available through static images like this one . If you refresh the page you'll see the image update every 2 seconds or so. I thought it might be fun to make these cameras viewable as an ASCII art video feed. I made a small library that takes most of its logic from this repo . You can see a basic example of how to convert any image to ASCII here . I pull in NYC GeoJSON from here and then hook up a Server-Sent Events endpoint to stream the ASCII updates to the browser. (Polling would work just as well, I've just been on a bit of a SSE kick lately.) Hilariously (and expectedly) The ASCII representation is about 4x the size of the the source jpeg and harder to see, but it has a retro-nostalgia look to it that is cool to me :)
HTTP
// Load and render GeoJSON data
d3.json("/nyc.geojson").then(function(data) {
svg.selectAll("path")
.attr("class", "link")
.on("click", function(event, d) {
showCamera(d.id);
.on("mouseover", function(event, d) {
d3.select(this).transition()
d3.select(this).raise();
.on("mouseout", function(event, d) {
d3.select(this).transition()
const source = new EventSource("/camera-text-stream/${c.req.param("id")}");
source.onopen = function(e) {
loadingInterval = setInterval(() => {
}, 100);
source.onmessage = function(e) {
document.querySelector('pre').innerHTML = JSON.parse(e.data);
source.onerror = function(e) {
if (loadingInterval) clearInterval(loadingInterval);
dhvanil avatar
val_3LoIzfb5xs
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_3LoIzfb5xs(req) {
try {
// Execute the code directly and capture its result
aanand700 avatar
sqliteExplorerApp
@aanand700
SQLite Explorer View and interact with your Val Town SQLite data. It's based off Steve's excellent SQLite Admin val, adding the ability to run SQLite queries directly in the interface. This new version has a revised UI and that's heavily inspired by LibSQL Studio by invisal . This is now more an SPA, with tables, queries and results showing up on the same page. Install Install the latest stable version (v86) by forking this val: Authentication Login to your SQLite Explorer with password authentication with your Val Town API Token as the password. Todos / Plans [ ] improve error handling [ ] improve table formatting [ ] sticky table headers [x] add codemirror [ ] add loading indication to the run button (initial version shipped) [ ] add ability to favorite queries [ ] add saving of last query run for a table (started) [ ] add visible output for non-query statements [ ] add schema viewing [ ] add refresh to table list sidebar after CREATE/DROP/ALTER statements [ ] add automatic execution of initial select query on double click [x] add views to the sidebar [ ] add triggers to sidebar [ ] add upload from SQL, CSV and JSON [ ] add ability to connect to a non-val town Turso database [x] fix wonky sidebar separator height problem (thanks to @stevekrouse) [x] make result tables scrollable [x] add export to CSV, and JSON (CSV and JSON helper functions written in this val . Thanks to @pomdtr for merging the initial version!) [x] add listener for cmd+enter to submit query
HTTP
- [x] make result tables scrollable
- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteE
- [x] add listener for cmd+enter to submit query
dhvanil avatar
val_bgSmvZkphg
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_bgSmvZkphg(req) {
try {
// Execute the code directly and capture its result
// Let's explore the Fibonacci sequence and golden ratio through a visual pattern
// This demonstrates how mathematical beauty emerges in nature
function createFibonacciSpiral(turns) {
const fib = [1, 1];
const spiral = [];
davitchanturia avatar
VALLE
@davitchanturia
VALL-E LLM code generation for vals! Make apps with a frontend, backend, and database. It's a bit of work to get this running, but it's worth it. Fork this val to your own profile. Make a folder for the temporary vals that get generated, take the ID from the URL, and put it in tempValsParentFolderId . If you want to use OpenAI models you need to set the OPENAI_API_KEY env var . If you want to use Anthropic models you need to set the ANTHROPIC_API_KEY env var . Create a Val Town API token , open the browser preview of this val, and use the API token as the password to log in.
HTTP
* Make a folder for the temporary vals that get generated, take the ID from the URL, and put it in `tempValsParentFolderId`.
* If you want to use OpenAI models you need to set the `OPENAI_API_KEY` [env var](https://www.val.town/settings/environment-v
* If you want to use Anthropic models you need to set the `ANTHROPIC_API_KEY` [env var](https://www.val.town/settings/environ
jeffreyyoung avatar
literaryIvorySlug
@jeffreyyoung
a simple poe bot things to note: don't put underscores (_) in the name, it stops working https://poe.com/lastattachment
HTTP
* Returns a response to the user's query
async function getResponse(req: Query, send: SendEventFn) {
send("meta", { content_type: "text/markdown" });
* Returns your bot's settings
async function getBotSettings(): Promise<BotSettings> {
return {
) => void;
function encodeEvent(event: string, data: any = {}) {
return new TextEncoder().encode(`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`);
export default async function(req: Request): Promise<Response> {
const reqBody = await req.json().catch((e) => {
dhvanil avatar
val_M1RP28Wp5V
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_M1RP28Wp5V(req) {
try {
// Execute the code directly and capture its result
dhvanil avatar
val_14OXBpUgJm
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export default async function handler(req) {
try {
const result = await (async () => {
acmu avatar
myApi
@acmu
列表接口
Script
import { nameList } from "https://esm.town/v/acmu/nameList";
export function myApi() {
return nameList;
dglazkov avatar
bbrun
@dglazkov
A simple chat app harness for your board Provides a very simple chat app UI for a Breadboard board. For now, requires you to be running a board server. This harness actually acts as a proxy to the board server run API endpoint , and puts a nice (well, somewhat nice) frontend on top of it. The frontend is somewhat limited in what it can show, currently supporting only LLMContent and array of LLMContent outputs, and only LLMContent array input. The script will look for the BB_LIVE_KEY in your Val Town environment, which must contain your board server API key. To use, create an HTTP val, then import the proxy function from this script and call it like this: import { proxy } from "https://esm.town/v/dglazkov/bbrun"; export default proxy( "url-to-the-board.bgl.json", );
Script
must contain your board server API key.
To use, create an HTTP val, then import the `proxy` function from this script and call it like this:
```ts
const DEFAULT_FRONTEND_MODULE = "https://esm.town/v/dglazkov/bbrunfe";
* You can supply these options as a second argument to the `proxy` function.
* These options are used to configure the frontend.
export const proxy = (url: string, options?: FrontendOptions) => {
return async function(req: Request): Promise<Response> {
if (req.method === "GET") {
threecordguy avatar
myApi
@threecordguy
An interactive, runnable TypeScript val by threecordguy
Script
export function myApi(name) {
return "hi " + name;
ryanlegler avatar
myApi
@ryanlegler
An interactive, runnable TypeScript val by ryanlegler
Script
export function myApi(name) {
return "hi " + name;