Search

Results include substring matches and semantically similar vals. Learn more
janpaul123 avatar
valle_tmp_493882739904999215894176448564479
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP (deprecated)
// 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),
chet avatar
sailingNotifyCron
@chet
An interactive, runnable TypeScript val by chet
Cron
import { email } from "https://esm.town/v/std/email";
import process from "node:process";
export async function sailingNotifyCron({ lastRunAt }) {
const result = await sailingNotify("Fair Oaks, CA", 10);
parthstown avatar
properBlueLion
@parthstown
@jsxImportSource https://esm.sh/react
Script
/** @jsxImportSource https://esm.sh/react */
import { renderToString } from "npm:react-dom/server";
export const ShowName = (name: string) => {
return (
<div>
<h1>{name}</h1>
</div>
ashryanio avatar
routineTrackerApp
@ashryanio
Routine Tracker This is a little React component to make our 7yo's after school routine self-serve so she can be a bit more independent after school. To change the items in the list, modify the routineTasks array of objects: [ {name: "item", timed: false}, {name: "item 2", timed: true, duration: 2 * 60 } {name: "item 3", timed: false, requiresParent: true} ] You can set the parent password on this line: const PARENT_PASSWORD_HASH = simpleHash("1234"); Todos Make the parent password modal touch friendly Track dates/times of list completions Show a tracker of how many completions this week
HTTP
# Routine Tracker
This is a little React component to make our 7yo's after school routine self-serve so she can be a bit more independent after
To change the items in the list, modify the `routineTasks` array of objects:
```javascript
{name: "item", timed: false},
{name: "item 2", timed: true, duration: 2 * 60 }
/** @jsxImportSource https://esm.sh/react */
const routineTasks = [
{ name: "Feed fish", timed: false },
{ name: "Unpack bags", timed: false },
pom421 avatar
sqliteExplorerApp
@pom421
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 (deprecated)
# SQLite Explorer
View and interact with your Val Town SQLite data. It's based off Steve's excellent [SQLite Admin](https://www.val.town/v/stev
![image.webp](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/c8e102fd-39ca-4bfb-372a-8d36daf43900/public)
## Install
Install the latest stable version (v86) by forking this val:
[![Install Stable Release (v86)](https://stevekrouse-button.express.val.run/Install%20Stable%20Release%20(v81))](https://www.
/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
EditorSection,
MockTable,
Separator,
neverstew avatar
prettifyHtml
@neverstew
An interactive, runnable TypeScript val by neverstew
Script
import prettierPluginHtml from "https://unpkg.com/prettier@3.2.5/plugins/html.mjs";
import * as prettier from "npm:prettier/standalone.mjs";
export const prettifyHtml = (html: string) => prettier.format(html, { parser: "html", plugins: [prettierPluginHtml] });
easrng avatar
cohostSanitize
@easrng
// list pulled from dompurify
Script
type AgeRuleset = {
schema: Schema;
additionalVisitor: (hast: Nodes) => void;
const SECOND_AGE: AgeRuleset = {
schema: deepmerge(defaultSchema, {
attributes: {
"*": ["style"],
tagNames: ["video", "audio", "aside"], // consistency with current rules,
additionalVisitor(hast) {
visit(hast, "element", (node, index, parent) => {
roramigator avatar
focusForestApp
@roramigator
// This productivity app will create a forest as users maintain focus.
HTTP
// This productivity app will create a forest as users maintain focus.
// We'll use emojis to represent trees at different growth stages.
// The app will use client-side storage to persist the forest state.
/** @jsxImportSource https://esm.sh/react */
const GROWTH_STAGES = ['🌱', '🌿', '🌳'];
const FOCUS_THRESHOLD = 25 * 60 * 1000; // 25 minutes in milliseconds
function App() {
const [forest, setForest] = useState([]);
const [focusStartTime, setFocusStartTime] = useState(null);
const [currentTree, setCurrentTree] = useState(GROWTH_STAGES[0]);
moe avatar
ogImage
@moe
@jsxImportSource https://esm.sh/react
Script
/** @jsxImportSource https://esm.sh/react */
export async function ogImage(body) {
const svg = await satori(
body,
width: 1200,
height: 630,
fonts: await loadFonts(),
loadAdditionalAsset: async (code, segment) => {
console.log("loadAdditionalAsset", code, segment)
if (code === "emoji") {
janpaul123 avatar
valle_tmp_6558189023937331447348397779094
@janpaul123
// Serve main page with stories
HTTP (deprecated)
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: faker.lorem.sentence(),
url: faker.internet.url(),
votes: faker.datatype.number({ min: 0, max: 100 }),
await blob.setJSON(SAMPLE_STORIES_KEY, sampleStories);
envl avatar
anyjs
@envl
An interactive, runnable TypeScript val by envl
Script
export async function anyjs(req: Request) {
// const res = await @stevekrouse.eval_("8+8");
return Response.json(Array.from(req.headers.entries()));
// @stevekrouse.xeval
std avatar
API_URL
@std
Val Town API URL When Val Town code is run on Val Town servers we use a local URL so we can save time by skipping a roundtrip to the public internet. However, if you want to run your vals that use our API, ie std library vals, locally, you'll want to use our public API's URL, https://api.val.town . We recommend importing and using std/API_URL whenever you use our API so that you are always using the most efficient route. Example Usage import { API_URL } from "https://esm.town/v/std/API_URL"; const response = await fetch(`${API_URL}/v1/me`, { headers: { Authorization: `Bearer ${Deno.env.get("valtown")}`, Accept: "application/json", }, }); const data = await response.json(); console.log(data)
Script
# Val Town API URL
When Val Town code is run on Val Town servers we use a local URL so we can save time by skipping a roundtrip to the public in
## Example Usage
```ts
const response = await fetch(`${API_URL}/v1/me`, {
headers: {
function envOrUndefined(key: string): string | undefined {
// try/catch prevents crashes if the script doesn't have env access
try {
return Deno.env.get("VALTOWN_API_URL");
vidar avatar
testPostgres
@vidar
An interactive, runnable TypeScript val by vidar
Script
import process from "node:process";
export let testPostgres = (async () => {
const postgres = await import("https://deno.land/x/postgres/mod.ts");
const client = new postgres.Client(process.env.neon);
await client.connect();
console.log(await client.queryObject`select * from authors;`);
stevekrouse avatar
fal_demo
@stevekrouse
@jsxImportSource https://esm.sh/hono@latest/jsx
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
const app = new Hono();
app.get("/", (c) =>
c.html(
<html>
<head>
<title>Fal Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
suncin avatar
downloadMega
@suncin
An interactive, runnable TypeScript val by suncin
Script
export async function downloadMega(req, res) {
const { File } = await import("npm:megajs");
if (!req.query.url) {
res.status(400).json({ message: "The URL is required" });
return;
try {
const file = File.fromURL(req.query.url);
const stream = file.download();
stream
.on("open", () => {