Search

Results include substring matches and semantically similar vals. Learn more
dhvanil avatar
val_CQqfNR6svd
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_CQqfNR6svd(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const getImageData = async () => { const img = new Image(); img.src = 'https://example.com/path-to-mandelbrot-ima
// Return the result in a properly formatted response
return new Response(JSON.stringify({
result: result,
type: typeof result
headers: { 'Content-Type': 'application/json' }
dhvanil avatar
val_zFIaCfbFds
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_zFIaCfbFds(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const calculateFractalDimension = (points) => { const boxCount = (size) => { let count = 0; for (let i = 0; i < p
// Return the result in a properly formatted response
return new Response(JSON.stringify({
result: result,
type: typeof result
headers: { 'Content-Type': 'application/json' }
dhvanil avatar
val_7Pb2YNVSqH
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_7Pb2YNVSqH(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const chiSquaredTest = (observed, expected) => { const chiSquared = observed.reduce((sum, obs, index) => sum + Ma
// Return the result in a properly formatted response
return new Response(JSON.stringify({
result: result,
type: typeof result
headers: { 'Content-Type': 'application/json' }
dthyresson avatar
playMeASong
@dthyresson
Play me a song Search and if we find it, it'll open the song in Spotify! Feeling Lucky? Play a random song . Like a band? Play one of their tracks.
HTTP
# Play me a song
Search and if we find it, it'll open the song in Spotify!
Feeling Lucky? Play a [random song](https://dthyresson-playrandomsong.web.val.run).
Like a band? Play [one](https://dthyresson-playrandomsong.web.val.run?artist=New+Order) of their tracks.
/** @jsxImportSource npm:hono@3/jsx */
type Track = {
id: number | null;
artist: string;
title: string;
track_id: string | null;
dhvanil avatar
val_eYhhIv3Mvd
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_eYhhIv3Mvd(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
// Let's try one more time with a very simple art
const heart = `
<3 <3
<3 <3
<3 <3
return heart;
janpaul123 avatar
valle_tmp_98577615540709697524214250928494
@janpaul123
// This val will serve an HTML page emulating a Hacker News clone.
HTTP
// This val will serve an HTML page emulating a Hacker News clone.
// It uses plain HTML and CSS to create the frontend. Eventually,
// we can make it interactive with additional scripts.
export default async function(req: Request): Promise<Response> {
const url = new URL(req.url);
const pathname = url.pathname;
// If the user navigates to a specific story page
if (pathname.startsWith("/story/")) {
const storyId = pathname.split("/")[2];
return new Response(renderStoryPage(storyId), {
curtcox avatar
Chatio
@curtcox
An interactive, runnable TypeScript val by curtcox
HTTP
import { chatio } from "https://esm.town/v/curtcox/_chatio";
export const Chatio = (req: Request) => {
return chatio(req);
dhvanil avatar
val_1JZbRgM75w
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export default async function handler(req) {
try {
const result = await (async () => {
return 100;
return Response.json({ success: true, result });
} catch (error) {
return Response.json({
success: false,
error: error.message
}, { status: 500 });
iamseeley avatar
EditLinkModal
@iamseeley
An interactive, runnable TypeScript val by iamseeley
Script
/** @jsx jsx */
/** @jsxFrag Fragment */
export default function EditLinkModal({ username, linkId, label, url }) {
return (
<div id="edit-link-modal" className="fixed inset-0 flex items-center justify-center bg-black bg-opacity-50">
<div className="bg-white rounded-lg shadow-xl p-8 w-full max-w-md mx-4 mt-4 mb-0">
<h2 className="text-xl font-bold mb-4">Edit Link</h2>
<form action={`/links/${linkId}`} method="put" className="space-y-4" hx-push-url={`/edit-profile/${username}`}>
<input
type="text"
janpaul123 avatar
valle_tmp_2933423436079547503473880922680217
@janpaul123
// This val will respond with a simple HTML page with fun CSS styles like crazy fonts and gradients
HTTP
// This val will respond with a simple HTML page with fun CSS styles like crazy fonts and gradients
export default async function main(): Promise<Response> {
const htmlContent = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello World</title>
<style>
body {
postpostscript avatar
html
@postpostscript
html: create sanitized HTML using tagged templates Examples import { html } from "https://esm.town/v/postpostscript/html" const unsafeInput = "<script>alert(1)</script>" console.log(html`Value: ${unsafeInput}`) // Value: &lt;script&gt;alert(1)&lt;/script&gt; These can be combined -- HTML marked as safe (instance is RawHTML ) will be directly inserted: const scripts = html`<script>alert(1)</script>` console.log(html`<head> ${scripts} </head>`.toString()) // <head> // <script>alert(1)</script> // </head> To easily create HTTP Response outputs like @stevekrouse/html, use the htmlResponse utility: import { html, htmlResponse } from "https://esm.town/v/postpostscript/html"; export default function(req: Request) { return htmlResponse` Request URL: ${decodeURIComponent(req.url)} `; } Tests: @postpostscript/htmlTest
Script
# html: create sanitized HTML using tagged templates
## Examples
```ts
const unsafeInput = "<script>alert(1)</script>"
console.log(html`Value: ${unsafeInput}`)
// Value: &lt;script&gt;alert(1)&lt;/script&gt;
export class RawHTML extends String {
constructor(value: unknown) {
if (value instanceof RawHTML) {
super(value);
dhvanil avatar
web_JaU2oUlDg0
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_JaU2oUlDg0(req) {
return new Response(`<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Retro Space Interface</title>
<style>
body {
margin: 0;
websandbox avatar
createAPI
@websandbox
An interactive, runnable TypeScript val by websandbox
HTTP
const cors = {
"access-control-allow-origin": "*",
"access-control-allow-headers": "*",
export default async function(req: Request): Promise<Response> {
try {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: cors,
if (req.method !== "POST") {
throw new Error("must POST");
janpaul123 avatar
valle_tmp_8772577792541712013582363429356
@janpaul123
// This val will respond to any request with an HTML "Hello, world!" message with some fun CSS styles and an animated cat
HTTP
// This val will respond to any request with an HTML "Hello, world!" message with some fun CSS styles and an animated cat
export default async function(req: Request): Promise<Response> {
const html = `
<html>
<head>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
dhvanil avatar
val_wKbtsxNAcg
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_wKbtsxNAcg(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
// Create a pixel art bunny
const bunnyAscii = `
( °w° )
return bunnyAscii;
// Return the result in a properly formatted response
return new Response(JSON.stringify({