Search

Results include substring matches and semantically similar vals. Learn more
janpaul123 avatar
valle_tmp_25273384802368385202566002443081
@janpaul123
@jsxImportSource https://esm.sh/react
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react */
import valleGetValsContextWindow from "https://esm.town/v/janpaul123/valleGetValsContextWindow";
import archiveVal from "https://esm.town/v/nbbaier/archiveVal?v=10";
import _ from "npm:lodash@4";
import OpenAI from "npm:openai";
import { renderToString } from "npm:react-dom/server";
// Set these to your own
const username = "janpaul123";
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 (deprecated)
/** @jsxImportSource https://esm.sh/react */
import { renderToString } from "npm:react-dom/server";
import valTownBadge from "https://esm.town/v/jxnblk/valTownBadge?v=16";
import { imageToAscii } from "https://esm.town/v/maxm/imageToAscii";
perbhat avatar
monetaryBronzeMongoose
@perbhat
@jsxImportSource npm:react
HTTP (deprecated)
/** @jsxImportSource npm:react **/
import { useEffect, useState } from "npm:react";
import { renderToString } from "npm:react-dom@18/server";
const TrackpadScale = () => {
perbhat avatar
primitiveBronzeOwl
@perbhat
@jsxImportSource https://esm.sh/react
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react */
import React, { useEffect, useRef, useState } from "https://esm.sh/react";
import { renderToString } from "https://esm.sh/react-dom/server";
const ForceScale = () => {
__html: `
import React from 'https://esm.sh/react';
import ReactDOM from 'https://esm.sh/react-dom';
import { ForceScale } from '${import.meta.url}';
ReactDOM.hydrate(React.createElement(ForceScale), document.getElementById('root'));
</body>
stevekrouse avatar
dateme_home_react
@stevekrouse
@jsxImportSource https://esm.sh/react@18.2.0
Script
/** @jsxImportSource https://esm.sh/react@18.2.0 */
import { useEffect, useState } from "https://esm.sh/react@18.2.0";
async function getCurrentPosition(opts): Promise<GeolocationPosition> {
return new Promise((resolve, reject) => {
stevekrouse avatar
BIGweather
@stevekrouse
Big Weather Display Displays the current day's weather information BIG so you can see it from far away. Currently it's hardcoded for: prospect heights, brooklyn charts of the temp and % change of precipitation Probably easiest for you to fork it and change it to suit your needs vs making it customizable
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react */
import { exponentialBackoffMiddleware } from "https://esm.town/v/stevekrouse/exponentialBackoffMiddleware";
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
import React from "https://esm.sh/react";
import { renderToString } from "https://esm.sh/react-dom/server";
import tailwindURL from "https://esm.town/v/stevekrouse/tailwindURL";
neverstew avatar
ivoryPorpoise
@neverstew
@jsxImportSource https://esm.sh/preact
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/preact */
import { render } from "npm:preact-render-to-string";
import { App } from "https://cdn.esm.sh/v90/preact@10.6.4/esm/cjs";
const appHTML = () => {
beneskildsen avatar
initBonsaiState
@beneskildsen
An interactive, runnable TypeScript val by beneskildsen
Script
"T<T^T^T<T<T^T^T<T^T<T^T^T^T[<T<T^T<SVS<S^S^S>S>SVSVSVS<S^S^S>S>SVSVSVS<S^S][>T>T^T>T>T>T>T^T>T>T^T^T^T[<T<T<T^T^T^T[<S
initialPosition: { x: 45, y: 59 },
snips: {}, // clientID -> true, which clients have done a snip
return state;
ejfox avatar
VALLErun
@ejfox
The actual code for VALL-E: https://www.val.town/v/janpaul123/VALLE
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react */
import { renderToString } from "npm:react-dom/server";
consider it part of the current conversation. The conversation below is your recent interaction with the user.
You can use React but you don't have to.
currentCode = `/** @jsxImportSource https://esm.sh/react */
import React from "npm:react";
import { renderToString } from "npm:react-dom/server";
You can use React but you don't have to.
DON'T respond with a preamble (aside from saying "Certainly", "Of course", "Let's do it", or something similar) or further ex
/** @jsxImportSource https://esm.sh/react */
ubyk avatar
VALLErun
@ubyk
The actual code for VALL-E: https://www.val.town/v/janpaul123/VALLE
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react */
import { renderToString } from "npm:react-dom/server";
consider it part of the current conversation. The conversation below is your recent interaction with the user.
You can use React but you don't have to.
currentCode = `/** @jsxImportSource https://esm.sh/react */
import React from "npm:react";
import { renderToString } from "npm:react-dom/server";
You can use React but you don't have to.
DON'T respond with a preamble (aside from saying "Certainly", "Of course", "Let's do it", or something similar) or further ex
/** @jsxImportSource https://esm.sh/react */
liamdanielduffy avatar
serveReactDemo
@liamdanielduffy
An interactive, runnable TypeScript val by liamdanielduffy
Script
import { reactDemo } from "https://esm.town/v/liamdanielduffy/reactDemo";
import { serveAsHTML } from "https://esm.town/v/liamdanielduffy/serveAsHTML";
export function serveReactDemo(req, res) {
serveAsHTML(req, res, reactDemo());
triptych avatar
bio
@triptych
@jsxImportSource https://esm.sh/react
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react */
import { renderToString } from "npm:react-dom/server";
export default async function(req: Request) {
return new Response(
jonataaroeira avatar
webgen
@jonataaroeira
To-dos: Spruce up styles a bit Write this README ~Add a cache!~ ~Try moving style tag to the bottom by prompting so content appears immediately and then becomes styled~ didn't work b/c CSS parsing isn't progressive Need more prompting to get the model not to generate placeholder-y content Better root URL page / index page with links to some good sample generations
HTTP (deprecated)
Your description should include:
- What content is on the page
- Other elements like sidebars, links, images that may be in the page
- The author and origin of the page
- The stylistic aesthetic of the page
g avatar
serveUtils
@g
Serve Utils This val exports various utility functions, mainly the serve(commentFunction, contentType?) . It enables easy serving of different files, while allowing the use of all string characters: // this is possible const arr = ["Hello", 'world', `!`]; Townie Prompt This can be used as a replacement system prompt for Townie. Townie will: Write client-side applications with vanilla JavaScript Serve them as different assets, ie. index.html , style.css and main.js Use modern module syntax, including importing modules directly from esm.sh on the client side Not reuse the same script for the server and client logic CONTEXT Answer requests with TypeScript programs that are written for Deno's runtime environment in Val Town. 1. Your answer should be code that is complete and directly runnable. 2. There should be no comments like "more content here". 3. Your response should start with ```ts and end with ```, ie full code fences. No yapping about what you are doing and why. If necessary, include minimal instructions for the user to add secrets or other setup requirements. For changes to a single place within the code that only impact a few lines of code, respond with valid unified diff only, based on the code provided in the <current_code> tags in the system prompt. 1. Write valid unified diffs with change hunk headers. The file headers can be omitted. 2. Always based diffs off the latest version of the code provided in the <current_code> tags. 3. Ensure diffs use the ```diff language code fence. 4. If the diff is longer than 15 lines, too complex, or if you are not confident that it will work, respond with the full working code instead of creating a diff. 5. The decision to respond with a diff is one time. When you are asked to fix a simple bug, use a diff. The next request might ask for a more significant change, so respond with the complete fully working code containing the changes. Responses should omit any information about installing or running Deno or dependencies. Your val must export default an HTTP handler, which inputs and outputs web-standard Request and Response objects, respectively. This is almost the same interface as Cloudflare workers. The val should create a "export default async function server" which is the main function that gets executed on every HTTP request. When using libraries such as hono, you should `export default app.fetch`. When writing complete code, start with a multiline comment explaining how your approach will work, what libraries or API calls you will use. When changes are requested, do not overwrite the original comment, instead add the requested changes to the end if they are significant enough. QUIRKS Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's not practical for the user's request (e.g. if they ask for a particular animated gif). If you want an AI generated image, use https://maxm-imggenurl.web.val.run/the-description-of-your-image to dynamically generate one. Do not use the Deno KV module for storage. Do not use the alert() or input() methods. You do not have access to the file system. Do not attempt to access, read, write or serve anything from the file system. ENVIRONMENT VARIABLES Don't use any environment variables unless strictly necessary. For example use APIs that don't require a key. If you need environment variables use Deno.env.get('keyname') IMPORTS Prefix server-side imports with npm: This syntax only works if the script is only ran on the server side. Otherwise, imports should be prefixed with https://esm.sh/ for npm and deno dependencies to ensure compatibility in the browser. PERSISTENCE Only use backend storage if explicitly required. Otherwise make a simple static client-side site. If needed and if the user asks for something that requires persistence, use Val Town SQLite or Blob storage. Use the val's `import.meta.url` for the blob storage key or sqlite table name, unless specified by the user. ```ts // Blob Storage import { blob } from "https://esm.town/v/std/blob"; await blob.setJSON("myKey", { hello: "world" }); let blobDemo = await blob.getJSON("myKey"); let appKeys: { key: string; size: number; lastModified: string }[] = await blob.list("app_"); await blob.delete("myKey"); // SQLITE Storage import { sqlite } from "https://esm.town/v/stevekrouse/sqlite"; let KEY = new URL(import.meta.url).pathname.split("/").at(-1); (await sqlite.execute(`select * from ${KEY}_users where id = ?`, [1])).rows[0].id // If you are changing a SQLite table's schema, you should also change the table's name so it creates a fresh table, ie by adding _2 or _3 after it everywhere. Ensure that tables are created before they are used. ``` OPENAI If required, use the OpenAPI library as below. Notice that the api key must be omitted, as it is included during runtime: ```ts 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-4o-mini", max_tokens: 30, }); ``` TEMPLATE ```tsx /** * This template creates a hono app that serves a client-side application. * Use this template for any val you create for the user. * Ensure that server-side and client-side code is clearly separated to prevent errors. * * All imports that are not from `https://esm.town` should use `https://esm.sh` to ensure compatibility. * * DO NOT USE window.alert() */ import { serve } from 'https://esm.town/v/g/serveUtils'; import { Hono } from 'npm:hono'; function html() { /* <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <link rel="stylesheet" href="/styles.css"> <script type="module" src="/main.js" defer></script> </head> <body> <h1 id="h1El">Tap to get the current date.</h1> </body> </html> */ } function css() { /* body { height: 100vh; margin: 0; display: grid; place-items: center; background: #232323; color: white; font-family: sans-serif; } */ } function js() { /* import df from 'https://esm.sh/dateformat'; const h1El = document.getElementById('h1El'); document.body.addEventListener('click', (ev) => { ev.preventDefault(); h1El.textContent = df('HH:MM, dd/mm/yy'); }); */ } const app = new Hono(); app.get('/', serve(html, 'text/html')); app.get('/styles.css', serve(css, 'text/css')); app.get('/main.js', serve(js, 'text/javascript')); export default app.fetch; ```
Script
Townie will:
- Write client-side applications with vanilla JavaScript
- Serve them as different assets, ie. `index.html`, `style.css` and `main.js`
- Use modern module syntax, including importing modules directly from `esm.sh` on the client side
- Not reuse the same script for the server and client logic
~~~md
IMPORTS
Prefix server-side imports with npm:
This syntax only works if the script is only ran on the server side. Otherwise, imports should be prefixed with https://esm.s
PERSISTENCE
Only use backend storage if explicitly required. Otherwise make a simple static client-side site.
If needed and if the user asks for something that requires persistence, use Val Town SQLite or Blob storage. Use the val's `i
```tsx
* This template creates a hono app that serves a client-side application.
* Use this template for any val you create for the user.
* Ensure that server-side and client-side code is clearly separated to prevent errors.
* All imports that are not from `https://esm.town` should use `https://esm.sh` to ensure compatibility.
maxm avatar
requestCollector
@maxm
* This request collector val saves information about incoming requests * and displays summary statistics on the home page. It uses SQLite for * persistence and server-side React for rendering the UI. Users can click * on a request ID to view full details of that request.
HTTP
* and displays summary statistics on the home page. It uses SQLite for
* persistence and server-side React for rendering the UI. Users can click
* on a request ID to view full details of that request.
/** @jsxImportSource https://esm.sh/react */
import React from "https://esm.sh/react";
import { renderToString } from "https://esm.sh/react-dom/server";
interface RequestData {