Search

Results include substring matches and semantically similar vals. Learn more
easrng avatar
nodejs
@easrng
An interactive, runnable TypeScript val by easrng
Script
export async function nodejs() {
const token =
(await runVal("easrng.nodejsInternals", {
action: "create",
})) as string;
return async (code) =>
await runVal("easrng.nodejsInternals", {
action: "eval",
token,
code,
dhvanil avatar
val_PJEj4CadkM
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_PJEj4CadkM(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const calculatePi = (iterations) => {
let pi = 0;
let divisor = 1;
for (let i = 0; i < iterations; i++) {
pi += (i % 2 === 0 ? 1 : -1) / divisor;
divisor += 2;
tehmantra avatar
kaiterra_prometheus
@tehmantra
// Fetches air quality sensor data from Kaiterra in prometheus line format
Script
// Fetches air quality sensor data from Kaiterra in prometheus line format
export async function kaiterra_prometheus(
req: express.Request,
res: express.Response,
let id = req.query.id;
let kiosk_res = await fetch(
`https://dashboard.kaiterra.com/v1/account/me/kiosk/data/v2/${id}`,
let kiosk_data = await kiosk_res.json();
let prometheus_data = kiosk_data.indoor.flatMap((indoor_data) =>
indoor_data.data.flatMap((data) =>
demo avatar
discordInteractionHook
@demo
An interactive, runnable TypeScript val by demo
Script
export let discordInteractionHook = async (
req: express.Request,
res: express.Response,
// https://discord.com/developers/applications/<application_id>/information
const pub = process.env.personalBotPublicKey;
if (!(await naclValidateRequest(req, pub))) {
return res.status(401).end("invalid request signature");
// Handle ping request
// https://discord.com/developers/docs/interactions/receiving-and-responding#receiving-an-interaction
if (req.body["type"] == 1) {
janpaul123 avatar
valle_tmp_5348120470989651484969606140059
@janpaul123
// This val responds with an HTML form to input the user's name and greets them upon form submission
HTTP
// This val responds with an HTML form to input the user's name and greets them upon form submission
export default async function(req: Request): Promise<Response> {
if (req.method === "POST") {
const formData = new URLSearchParams(await req.text());
const name = formData.get("name") || "stranger";
const greeting = `Hello, ${name}!`;
const funFact = "Did you know that the first email was sent in 1971?";
const htmlResponse = `
<h1>${greeting}</h1>
<p>${funFact}</p>
dhvanil avatar
val_M1RP28Wp5V
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_M1RP28Wp5V(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
// Test for temporal anomalies and precision
const testTemporalBehavior = () => {
const results = [];
// Test 1: High precision time measurements
const start = performance.now();
for(let i = 0; i < 1000000; i++) {
pomdtr avatar
jsoninvoice_editor_script
@pomdtr
An interactive, runnable TypeScript val by pomdtr
HTTP
const editor = document.getElementById("editor");
const preview = document.getElementById("preview") as HTMLIFrameElement;
const printBtn = document.getElementById("print-btn") as HTMLButtonElement;
const copyBtn = document.getElementById("copy-btn") as HTMLButtonElement;
const formatBtn = document.getElementById("format-btn") as HTMLButtonElement;
const languageSelector = document.getElementById("languages") as HTMLSelectElement;
const currencySelector = document.getElementById("currencies") as HTMLSelectElement;
async function updatePreview() {
try {
const code = JSON.parse(editor.code);
yuval_dikerman avatar
catFact
@yuval_dikerman
An interactive, runnable TypeScript val by yuval_dikerman
HTTP
export let catFact = async (request: Request): Promise<Response> => {
let cat = await fetch("https://catfact.ninja/fact");
let { fact } = await cat.json();
const prompt =
"Rewrite this fact about cats as if it was written for 3 year old:\n\n" +
fact;
const story = await fetch("https://api.openai.com/v1/chat/completions", {
method: "POST",
body: JSON.stringify({
model: "gpt-3.5-turbo",
shane98c avatar
aqi
@shane98c
An interactive, runnable TypeScript val by shane98c
Cron
export let aqi = async () => {
let pm25 = (
await fetchJSON(
"https://api.openaq.org/v2/latest?" +
new URLSearchParams({
limit: "10",
page: "1",
location: "Saint Paul",
offset: "0",
sort: "desc",
dhvanil avatar
val_QrWukp63gM
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_QrWukp63gM(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
// Creating a simple model of order emerging from chaos
// Inspired by Conway's Game of Life but with a philosophical twist
// This represents how patterns and meaning can emerge from simple rules
function createLifePattern(size, iterations) {
// Initialize random grid (chaos)
let grid = Array(size).fill().map(() =>
janpaul123 avatar
valle_tmp_290532195688157024602543648883546
@janpaul123
// We will create an HTTP val that responds with "Hello world" on every request.
HTTP
// We will create an HTTP val that responds with "Hello world" on every request.
// We will use Deno's built-in HTTP module to create the server and handle incoming requests.
// Define the main function that will handle HTTP requests
export default async function main(_req: Request) {
// Return a simple Response with "Hello world"
return new Response("Hello world");
dhvanil avatar
val_Ky1DCGTe7O
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_Ky1DCGTe7O(req) {
try {
// Execute the code directly
const findPrimes = (max) => {
const primes = [];
for (let num = 2; num < max; num++) {
let isPrime = true;
for (let i = 2; i <= Math.sqrt(num); i++) {
if (num % i === 0) {
isPrime = false;
websandbox avatar
create
@websandbox
An interactive, runnable TypeScript val by websandbox
Script
export async function create({ code, token }: { code: string; token: string }) {
const { error, details, url } = await (await fetch("https://websandbox-createAPI.web.val.run", {
body: JSON.stringify({ code, token }),
method: "POST",
})).json();
if (error) {
const e = new Error(error);
if (details) {
(e as any).details = details;
return url;
vladimyr avatar
valTownLogo_test2
@vladimyr
An interactive, runnable TypeScript val by vladimyr
HTTP
valTownLogoBlack,
valTownLogoWhite,
valTownMarkBlack,
valTownMarkWhite,
} from "https://esm.town/v/postpostscript/valTownLogo";
export default async function(req: Request): Promise<Response> {
const html = `
<html>
<head>
<title>vt logo test</title>
janpaul123 avatar
valle_tmp_459423574352421057264033168224449
@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),