Search

Results include substring matches and semantically similar vals. Learn more
laidlaw avatar
books
@laidlaw
@jsxImportSource npm:hono@3/jsx
HTTP (deprecated)
/** @jsxImportSource npm:hono@3/jsx */
const openai = new OpenAI();
function esmTown(url) {
return fetch(url, {
headers: {
"User-Agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.142.86 Safari/537
}).then(r => r.text());
const app = new Hono();
export default app.fetch;
yawnxyz avatar
translate
@yawnxyz
Translator using a public deepl api
HTTP (deprecated)
# [Translator](https://yieldray-translate.web.val.run)
using a [public deepl api](https://deepl.deno.dev)
if (import.meta.main) Deno.serve(translate);
export async function translate(req: Request) {
if (req.method === "POST") {
return await fetch("https://deepl.deno.dev/translate", {
method: "POST",
body: await req.text(),
return new Response(html, { headers: { "content-type": "text/html" } });
const html = `
janpaul123 avatar
valle_tmp_90775096713594030038814365860220246
@janpaul123
// Define interface for Story object
HTTP (deprecated)
// Define interface for Story object
interface Story {
id: number;
title: string;
url: string;
points: number;
const app = new Hono();
const BLOB_KEY = "hacker_news_stories";
// Add 30 fake sample stories
async function initializeStories() {
std avatar
fetch
@std
Proxied fetch - Docs ↗ The Javascript Fetch API is directly available within a Val. However sometimes fetch calls are blocked by the receiving server for using particular IP addresses. Additionally, network blips or unreliable web services may lead to failures if not handled properly. The Val Town standard library contains an alternative version, std/fetch , that wraps the JavaScript Fetch API to provide additional functionality. The fetch function from std/fetch reroutes requests using a proxy vendor so that requests obtain different IP addresses. It also automatically retries failed requests several times. Note that using std/fetch will be significantly slower than directly calling the Javascript Fetch API due to extra network hops. Usage After importing std/fetch , the fetch method is used with the same signature as the Javascript Fetch API. import { fetch } from "https://esm.town/v/std/fetch"; let result = await fetch("https://api64.ipify.org?format=json"); let json = await result.json(); console.log(json.ip); If you run the above code multiple times, you'll see that it returns different IP addresses, because std/fetch uses proxies so that each request is made from a different IP address. 📝 Edit docs
Script
# Proxied fetch - [Docs ↗](https://docs.val.town/std/fetch)
The Javascript [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) is directly available within a Val. Ho
The Val Town standard library contains an alternative version, [`std/fetch`](https://www.val.town/v/std/fetch), that wraps th
## Usage
After importing [`std/fetch`](https://www.val.town/v/std/fetch), the fetch method is used with the same signature as the Java
```ts title="Example" val
* Wraps the JavaScript Fetch function to anonymize where the request is
* coming from ([Docs ↗](https://docs.val.town/std/fetch))
* @param {string | URL} input - The URL to fetch
* @param {RequestInit} [requestInit] - Optional configuration data (HTTP
stevekrouse avatar
dude
@stevekrouse
Run squint in val.town!
Script
Run squint in val.town!
import * as squint from "npm:squint-cljs";
globalThis.squint_core = squint;
const program = `(js/console.log (+ 1 2 3))`;
let theString = squint.compileString(program, { repl: true, "elide-imports": true });
console.log(theString);
theString = theString.replace(`'squint-cljs/core.js'`, `'npm:squint-cljs/core.js'`);
const AsyncFunction = Object.getPrototypeOf(async function() {}).constructor;
await new AsyncFunction(theString)();
neverstew avatar
announcement
@neverstew
// Forked from @tmcw.htmlExample
Script
export const announcement = async (req: Request) => {
const { html } = await import("https://deno.land/x/html_escape/html.ts");
const params = new URL(req.url).searchParams;
const text = params.get("text") || "ANNOUNCEMENT";
return new Response(
html`
<html>
<style>
body {
display: flex;
jdan avatar
closedChocolateMarmoset
@jdan
@jsxImportSource https://esm.sh/react
HTTP
/** @jsxImportSource https://esm.sh/react */
cytoscape.use(dagre);
const TITLE_SELECTOR = "#firstHeading > span";
const MAX_SELECTIONS = 2;
function labelPredicate(label) {
return label === "Father" || label === "Mother" || /^Parent/.test(label);
async function* crawlWikipedia(
url: string,
generation: number = 0,
visited: Set<string> = new Set(),
overengineered avatar
status
@overengineered
Uptime Status Page This is the status page for the data generated by this uptime cron: @stevekrouse/uptime
HTTP
# Uptime Status Page
This is the status page for the data generated by this uptime cron: @stevekrouse/uptime
<div align="center">
<img src="https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/67a1d35e-c37c-41a4-0e5a-03a9ba585d00/public" width="700px"/>
</div>
/** @jsxImportSource npm:preact */
await sqlite.execute(
"CREATE TABLE IF NOT EXISTS meter_users (id INTEGER PRIMARY KEY AUTOINCREMENT, email TEXT, session TEXT, salt TEXT, code TE
function BasicLayout(props) {
return (
arash2060 avatar
VALLErun
@arash2060
The actual code for VALL-E: https://www.val.town/v/janpaul123/VALLE
HTTP (deprecated)
The actual code for VALL-E: https://www.val.town/v/janpaul123/VALLE
/** @jsxImportSource https://esm.sh/react */
function parseSearchReplaceBlocks(content: string): Array<{ searchStart: string; searchEnd: string; replace: string }> {
content = content.replaceAll("\r\n", "\n");
const regex =
/\[SEARCH_START_SINGLE_LINE\]\n([\s\S]*?)\n\[\/SEARCH_START_SINGLE_LINE\]\s*\[SEARCH_END_SINGLE_LINE\]\n([\s\S]*?)\n?\[\/
const blocks = [];
let match;
while ((match = regex.exec(content)) !== null) {
blocks.push({
stevekrouse avatar
honoZodSwaggerUi
@stevekrouse
@jsxImportSource https://esm.sh/hono@3.9.2/jsx
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/hono@3.9.2/jsx **/
const ParamsSchema = z.object({
id: z
.string()
.min(3)
.openapi({
param: {
name: "id",
in: "path",
example: "1212121",
rapfl avatar
zottify
@rapfl
@jsxImportSource https://esm.sh/preact
HTTP
/** @jsxImportSource https://esm.sh/preact */
const replicate = new Replicate({
auth: Deno.env.get("REPLICATE_API_TOKEN"),
export default async function(req: Request) {
if (req.method === "POST") {
const formData = await req.formData();
const textPrompt = formData.get("textPrompt");
const formattedPrompt =
`Take the description that follows and imagine it vividly as a masterful painting, describing character, action, settin
${textPrompt}
root avatar
hello
@root
An interactive, runnable TypeScript val by root
Script
export function hello(name) {
// return "wow~ your are 叼毛 open 了 Pandora" ;
return { message: "wow~ your are 叼毛 open 了 Pandora" };
// return eval("window.open('https://www.jd.com')") // 不允许
// return window.alert.call(null, '123') // nodejs 环境没有window
// return window // nodejs 环境没有window = null
yawnxyz avatar
honoJsxAlpineReactive
@yawnxyz
Basic demo of getting reactive Alpine.js working on a hono/jsx "backend" For server <> frontend interaction, do form POST submissions (or potentially POST json to the public val address?) https://alpinejs.dev/start-here#building-a-counter
HTTP (deprecated)
Basic demo of getting reactive Alpine.js working on a hono/jsx "backend"
- For server <> frontend interaction, do form POST submissions (or potentially POST json to the public val address?)
https://alpinejs.dev/start-here#building-a-counter
/** @jsx jsx */
const app = new Hono();
// Server-side rendering
app.get("/", async (c) => {
const html = (
<html>
<head>
maxm avatar
postmanClone
@maxm
* This val creates a Postman-like interface for testing HTTP requests directly in the browser. * It uses React for the UI and the Fetch API to make requests. * The server function serves the HTML and handles the API requests.
HTTP
* This val creates a Postman-like interface for testing HTTP requests directly in the browser.
* It uses React for the UI and the Fetch API to make requests.
* The server function serves the HTML and handles the API requests.
/** @jsxImportSource https://esm.sh/react */
function App() {
const [url, setUrl] = useState('https://jsonplaceholder.typicode.com/posts/1');
const [method, setMethod] = useState('GET');
const [headers, setHeaders] = useState('');
const [body, setBody] = useState('');
const [response, setResponse] = useState('');
easrng avatar
playground
@easrng
playground edit, run, and embed vals without requiring an account (or even js enabled!) caveats: logs don't stream I haven't set up codemirror only script vals supported everything else should be fully functional. you can prefill the editor with code: https://easrng-playground.web.val.run/?code=console.log(1) a val: https://easrng-playground.web.val.run/?load=easrng/playground some other url: https://easrng-playground.web.val.run/?load=https://any/other/url
HTTP (deprecated)
# playground
## edit, run, and embed vals without requiring an account (or even js enabled!)
[![open](https://easrng-button.express.val.run/open)](https://easrng-playground.web.val.run/)
caveats:
- logs don't stream
- I haven't set up codemirror
// (c) easrng 2024 all rights reserved
/** @jsx jsx */
/** @jsxFrag Fragment */
createContext,