Search

Results include substring matches and semantically similar vals. Learn more
dhvanil avatar
val_2ndWr7OczV
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_2ndWr7OczV(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const calculateHarmonicSeries = (terms) => {
let sum = 0;
for (let i = 1; i <= terms; i++) {
sum += 1 / i;
return sum;
return calculateHarmonicSeries(1000000);
janpaul123 avatar
valle_tmp_331733911360176721193636644811242
@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),
daisuke avatar
bsky
@daisuke
Showing my BlueSky posts using their public API
HTTP
Showing my BlueSky posts using their public API
/** @jsxImportSource npm:hono/jsx */
type Feed = {
feed: { post: { uri: string; author: { displayName: string; avatar: string }; record: { text: string } } }[];
export default async function(req: Request): Promise<Response> {
const url = "https://public.api.bsky.app/xrpc/app.bsky.feed.getAuthorFeed?actor=dai.bsky.social&filter=posts_no_replies";
const data: Feed = await fetch(url).then((r) => r.json());
return new Response(
(<html>
<head>
janpaul123 avatar
valle_tmp_87252716729376250552603497646944
@janpaul123
// Handle story submission
HTTP
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);
agmm avatar
blobmanager
@agmm
An interactive, runnable TypeScript val by agmm
Script
const app = new Hono();
function getValUrl() {
const val = rootRef();
return `https://${val.userHandle}-${val.valName}.web.val.run`;
const valUrl = getValUrl();
app.use(
basicAuth({
username: "admin",
password: Deno.env.get("MANAGER_KEY"),
app.get("/", async (c) => {
dhvanil avatar
val_d5Nrti5M28
@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;
patrickroumanoff avatar
status401
@patrickroumanoff
An interactive, runnable TypeScript val by patrickroumanoff
HTTP
export default async function(req: Request): Promise<Response> {
console.log(req.url);
if (req.headers.get("x-fd-healthprobe") == "1") {
return new Response("OK");
return new Response("Hello", {
status: 200,
statusText: "OK",
headers: {
// "WWW-Authenticate": "Basic realm=\"Access to OneTeam\"",
easrng avatar
vtTypes
@easrng
An interactive, runnable TypeScript val by easrng
HTTP
export default async function(req: Request): Promise<Response> {
const urls = [
"https://deno.land/x/deno@v1.40.2/cli/tsc/dts/lib.d.ts",
"https://deno.land/x/deno@v1.40.2/cli/tsc/dts/lib.dom.d.ts",
"https://deno.land/x/deno@v1.40.2/cli/tsc/dts/lib.dom.iterable.d.ts",
"https://deno.land/x/deno@v1.40.2/cli/tsc/dts/lib.dom.asynciterable.d.ts",
"https://deno.land/x/deno@v1.40.2/cli/tsc/dts/lib.webworker.d.ts",
"https://deno.land/x/deno@v1.40.2/cli/tsc/dts/lib.webworker.importscripts.d.ts",
"https://deno.land/x/deno@v1.40.2/cli/tsc/dts/lib.webworker.iterable.d.ts",
"https://deno.land/x/deno@v1.40.2/cli/tsc/dts/lib.scripthost.d.ts",
odicho avatar
entireGoldLark
@odicho
An interactive, runnable TypeScript val by odicho
HTTP
type: "json",
export type ServiceOptions = {
* If true, the service will ask for a key to access. The value of the key
* is stored as BB_SERVICE_KEY environment variable.
* Default: false.
private?: boolean;
* A way to specify inputs, overriding the default inputs provided by `invoke`.
* Default: undefined.
inputs?: Record<string, any>;
const kits = [
codefromanywhere avatar
relaxedSalmonHawk
@codefromanywhere
An interactive, runnable TypeScript val by codefromanywhere
HTTP
export default async function handler(request: Request) {
if (request.method !== "POST") {
return Response.json({ message: "This val responds to POST requests." }, {
status: 400,
try {
const body = await request.json();
return Response.json(body);
} catch (e) {
return Response.json({ message: "The body of this request was not JSON-encoded." }, {
status: 400,
iamseeley avatar
beigeMandrill
@iamseeley
An interactive, runnable TypeScript val by iamseeley
HTTP
export default async function (req: Request): Promise<Response> {
const { searchParams } = new URL(req.url);
// Default values
const title = searchParams.get('title') || 'Hello from val.town';
const bgColor = searchParams.get('bgColor') || '#e15a24';
const textColor = searchParams.get('textColor') || '#1A202C';
// Create SVG
const svg = `
<svg width="1200" height="630" xmlns="http://www.w3.org/2000/svg">
<defs>
pomdtr avatar
playground
@pomdtr
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
Script
# 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
type Log = {
level: string;
args: unknown[];
janpaul123 avatar
valle_tmp_065083194034399444924236047421617
@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),
janpaul123 avatar
valle_tmp_205216506430841331121632259852896
@janpaul123
// Response with "Hello World" in fancy HTML with silly gradients on every HTTP request
HTTP
// Response with "Hello World" in fancy HTML with silly gradients on every HTTP request
export default async function(req: Request): Promise<Response> {
const html = `
<!DOCTYPE html>
<html>
<head>
<style>
body {
background: linear-gradient(to right, pink, purple, skyblue);
font-family: 'Comic Sans MS', cursive, sans-serif;
vladimyr avatar
ittyRouterExample
@vladimyr
An interactive, runnable TypeScript val by vladimyr
HTTP
import { AutoRouter } from "npm:itty-router@5";
const router = AutoRouter();
router.get("/", () => "Hi from itty-router!");
export default denoServer(router.fetch);