Search

Results include substring matches and semantically similar vals. Learn more
dhvanil avatar
val_i4JBy56gt2
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_i4JBy56gt2(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
// Let's explore L-Systems to model organic growth and emergent complexity
// This demonstrates how simple rules can create complex, meaningful patterns
function createLSystem(axiom, rules, iterations) {
let result = axiom;
// Apply rules iteratively
for(let i = 0; i < iterations; i++) {
tempdev avatar
primewireUtils
@tempdev
An interactive, runnable TypeScript val by tempdev
Script
const NotFoundError = Error;
primewireApiKey,
primewireBase,
} from "https://raw.githubusercontent.com/Ciarands/mw-providers/dev/src/providers/sources/primewire/common.ts";
async function search(imdbId: string) {
const searchResult = await fetch(`${primewireBase}/api/v1/show?key=${primewireApiKey}&imdb_id=${imdbId}`);
return await searchResult.json().then((searchResult) => {
return searchResult.id;
async function getStreams(title: string) {
const titlePage = load(title);
spurushottam13 avatar
isSupported
@spurushottam13
An interactive, runnable TypeScript val by spurushottam13
Script
export async function isSupported(jsInterface) {
const caniuse = await import("npm:caniuse-api");
return caniuse.getSupport("border-radius");
tmcw avatar
npmExample
@tmcw
An interactive, runnable TypeScript val by tmcw
Script
export let npmExample = (async () => {
const { DOMParser } = await import(
"https://deno.land/x/deno_dom/deno-dom-wasm.ts"
return typeof DOMParser;
janpaul123 avatar
valle_tmp_42249988258651369468890296933772
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP
Here's the updated code to make the HN clone look exactly like Hacker News:
ts
// Initialize sample stories and store them in blob storage
const SAMPLE_STORIES_KEY = "hn_realistic_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.company.catchPhrase(),
dvdsgl avatar
val
@dvdsgl
Val Effects Effects for Val Town. HTTP Easily create effect-based HTTP Vals. import { Effect } from "npm:effect"; import * as Val from "https://esm.town/v/dvdsgl/val"; export default Val.http(req => Effect.gen(function*(){ return Response.json({ ok: true, love: "effect" }); }));
Script
# Val Effects
`Effects` for Val Town.
## HTTP
Easily create effect-based HTTP Vals.
```ts
export default Val.http(req => Effect.gen(function*(){
type Handler<T> = (req: Request) => T;
export function http<E>(effect: Handler<Effect.Effect<Response, E>>): Handler<Promise<Response>> {
return async req => {
const exit = await Effect.runPromiseExit(effect(req));
stevekrouse avatar
basicAuth
@stevekrouse
Val Town Basic Auth Add basic auth on top of any http val Usage Wrap your HTTP handler in the basicAuth middleware. import { basicAuth } from "https://esm.town/v/pomdtr/basicAuth"; function handler(req: Request) { return new Response("You are authenticated!"); } export default basicAuth(handler); To authenticate, paste an api token in the password prompt.
Script
# Val Town Basic Auth
Add basic auth on top of any http val
## Usage
Wrap your HTTP handler in the `basicAuth` middleware.
```typescript
function handler(req: Request) {
function extractToken(authorization) {
const parts = authorization.split(" ");
if (parts[0] == "Bearer") {
return parts[1];
dhvanil avatar
val_0dtPQXGmvn
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export const jsonOkExample = () => Response.json({ ok: true });
ridge avatar
fetchProxy
@ridge
// intended for GET requests to bypass some CORS problems.
Script
import { fetch } from "https://esm.town/v/std/fetch";
// intended for GET requests to bypass some CORS problems.
export async function fetchProxy(url) {
let response = await fetch(url);
return response.ok ? response.text() : "";
jeffreyyoung avatar
bot1
@jeffreyyoung
a simple poe bot things to note: don't put underscores (_) in the name, it stops working
HTTP
a simple poe bot
things to note:
- don't put underscores (_) in the name, it stops working
* Returns a response to the user's query
async function getResponse(req: Query, send: SendEventFn) {
send("meta", { content_type: "text/markdown" });
const lastMessage = req.query.at(-1);
const attachment = lastMessage.attachments.at(0)?.parsed_content;
if (!attachment) {
send("text", { text: "no attachments" });
dhvanil avatar
val_jkgkaOKFzC
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export default async function handler(req) {
try {
const result = await (async () => {
function isPrime(num) {
if (num <= 1) return false;
for (let i = 2; i <= Math.sqrt(num); i++) {
if (num % i === 0) return false;
return true;
function findLowestThreeDigitPrime() {
for (let num = 100; num < 1000; num++) {
dhvanil avatar
val_1UPDhSgHTH
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export const jsonOkExample = () => Response.json({ ok: true });
tempguy avatar
violetFerret
@tempguy
An interactive, runnable TypeScript val by tempguy
Cron
import { blob } from "https://esm.town/v/std/blob?v=12";
export default async function(interval: Interval) {
await fetch("https://tempguy-scarletsole.web.val.run/refresh");
const date = new Date();
await blob.setJSON("turnstileCron", { ptime: date.getTime(), ntime: interval.delay + interval.lastRunAt.getTime() });
steveb1313 avatar
GetPelotonWorkoutsAndSaveToAirTable
@steveb1313
An interactive, runnable TypeScript val by steveb1313
Script
export async function GetPelotonWorkoutsAndSaveToAirTable(
req: express.Request,
res: express.Response,
let response = await fetch("https://api.onepeloton.com/auth/login", {
method: "POST",
mode: "no-cors",
headers: {
"Content-Type": "application/json",
// 'Content-Type': 'application/x-www-form-urlencoded',
credentials: "include",
janpaul123 avatar
valle_tmp_39721090126249363719208307534445
@janpaul123
// This val simply responds with "Hello, World!" to any incoming request.
HTTP
// This val simply responds with "Hello, World!" to any incoming request.
export default async function main(req: Request): Promise<Response> {
return new Response("Hello, World!");