Search

Results include substring matches and semantically similar vals. Learn more
stevekrouse avatar
plotLinkeDOMSRRExample
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
HTTP
export default async function() {
const document = parseHTML("<a>").document;
const chart = Plot.plot({
document,
marks: [
Plot.rectY({ length: 10000 }, Plot.binX({ y: "count" }, { x: Math.random })),
return new Response(
`${chart}`.replace(
/^<svg /,
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.1\" ",
janpaul123 avatar
valle_tmp_1112761154422132706439156901497722
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP
// Initialize sample stories and store them in blob storage
const SAMPLE_STORIES_KEY = "hn_sample_stories";
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
const sampleStories = Array.from({ length: 30 }).map((_, idx) => ({
id: idx + 1,
title: `Sample Story ${idx + 1}`,
url: `https://example.com/story${idx + 1}`,
votes: Math.floor(Math.random() * 100),
git avatar
confetti
@git
An interactive, runnable TypeScript val by git
HTTP
export default async () =>
new Response(
`<script type="module">
import confetti from "https://esm.sh/canvas-confetti";
confetti();
</script>`,
{ headers: { "Content-Type": "text/html" } },
u avatar
refresher
@u
An interactive, runnable TypeScript val by u
RPC (deprecated)
export async function refresher(name: string) {
let resp = "";
if (refreshData[name] === undefined) {
await alert(
name,
`Tracking setup successful for ${name}! \uD83D\uDE00`,
resp = `Setup successful for ${name}!`;
else {
resp = `Refresh successful for ${name}!`;
refreshData[name] = Date.now();
dhvanil avatar
val_l2VXZwPEB5
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export default async function handler(req) {
try {
const result = await (async () => {
function fibonacci() {
let a = 0, b = 1;
while (b < 1000) {
let temp = b;
b = a + b;
a = temp;
return b;
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
const result = await (async () => {
// 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 = [];
// Generate Fibonacci numbers
yawnxyz avatar
blobAdmin
@yawnxyz
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 [x] add upload/download buttons [ ] Use modals for create/upload/edit/view/delete page (htmx ?) [ ] handle non-textual blobs properly [ ] use codemirror instead of a textarea for editing text blobs
HTTP
# Blob Admin
This is a lightweight Blob Admin interface to view and debug your Blob data.
![b7321ca2cd80899250589b9aa08bc3cae9c7cea276282561194e7fc537259b46.png](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/311a
Use this button to install the val:
[![](https://stevekrouse-button.express.val.run/Install)](https://www.val.town/v/stevekrouse/blob_admin_app/fork)
It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/s
/** @jsxImportSource https://esm.sh/hono@4.0.8/jsx **/
const app = new Hono();
app.use(
jsxRenderer(({ children }) => {
janpaul123 avatar
valle_tmp_880820168898077728093213546584606
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP
// Initialize sample stories and store them in blob storage
const SAMPLE_STORIES_KEY = "hn_sample_stories";
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
const sampleStories = Array.from({ length: 30 }).map((_, idx) => ({
id: idx + 1,
title: `Sample Story ${idx + 1}`,
url: `https://example.com/story${idx + 1}`,
votes: Math.floor(Math.random() * 100),
kj9 avatar
summary
@kj9
// await sqlite.execute("CREATE TABLE IF NOT EXISTS tweets (published TEXT PRIMARY KEY, entry TEXT NOT NULL)");
HTTP
// await sqlite.execute("CREATE TABLE IF NOT EXISTS tweets (published TEXT PRIMARY KEY, entry TEXT NOT NULL)");
const db = drizzle(sqlite as any);
const tweets = sqliteTable("tweets", {
key: text("published"),
value: text("entry").notNull(),
const result = await db.select({
tweet: tweets.value,
}).from(tweets).orderBy(desc(tweets.key)).limit(10);
const resultJson = JSON.stringify(result);
const apiKey = Deno.env.get("GEMINI_API_KEY");
stevekrouse avatar
webEx
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
export const webEx = (req: Request) => Response.json("hello world");
janpaul123 avatar
valle_tmp_995219357277216706778609883256759
@janpaul123
This code sets up a simple comment box system. * It leverages Deno's blob storage for persistence, * and renders an HTML form to accept new comments, * while displaying all existing comments.
HTTP
/** This code sets up a simple comment box system.
* It leverages Deno's blob storage for persistence,
* and renders an HTML form to accept new comments,
* while displaying all existing comments.
// Key for blob storage
const COMMENTS_KEY = "comments_storage";
// HTML template for the form and comments list
const getHtml = (comments: string[]) => `
<html>
<head>
pettan avatar
generateRAdioDjRss
@pettan
An interactive, runnable TypeScript val by pettan
Express (deprecated)
export const generateRAdioDjRss = async (
_req: express.Request,
res: express.Response
const rssItems = previousDjs.map((dj) => {
const djImgSrc = `https://r-a-d.io/api/dj-image/${encodeURIComponent(
dj.djimage
const djMessage =
dj.djtext === "" || dj.djtext === "x"
: `${dj.djname} says: ${dj.djtext}`;
const threadMessage =
jamisonl avatar
copperMammal
@jamisonl
Bot for Cama discord server. To initialize new slash commands, you have to run a separate bit of code. This is for modifying their functionality
HTTP
Bot for Cama discord server. To initialize new slash commands, you have to run a separate bit of code. This is for modifying
let bank = await blob.getJSON("bank");
let bets = await blob.getJSON("bets");
const starting_amount = 5;
if (!bank) {
bank = {};
await blob.setJSON("bank", bank);
if (!bets) {
bets = [];
await blob.setJSON("bets", bets);
tmcw avatar
styleSystem
@tmcw
@jsxImportSource npm:hono/jsx
Script
/** @jsxImportSource npm:hono/jsx */
import { ofStyle } from "https://esm.town/v/tmcw/ofStyle";
import { Context } from "npm:hono@3.8.1";
export function styleSystem() {
function StyleTag() {
return (
<style
dangerouslySetInnerHTML={{ __html: ofStyle }}
const styleRoute = (c: Context) => {
return c.body(null);
return { styleRoute, StyleTag };
aquapi avatar
Vix
@aquapi
An interactive, runnable TypeScript val by aquapi
HTTP
console.time("Startup 500 routes");
let uwu = wrap()();
for (let i = 0; i < 500; i++) {
uwu = uwu.stdPetition({
path: `/${i}/:id/${i}`,
method: "GET",
f: () => "Hi",
i++;
const fetch = composeResponse({})(uwu.unwrap());
console.timeEnd("Startup 500 routes");