Search
val_hhGpnm1tf9
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_hhGpnm1tf9(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
function generateAllProblems() {
const arrayProblems = [
"Implement a function to find the missing number in an array of 1 to N",
"Write a function to rotate an array by k positions",
"Create a function to merge two sorted arrays",
"Implement a function to find the longest increasing subsequence",
exaltedChocolateHamster
@heettike
An interactive, runnable TypeScript val by heettike
Script
export default async function scrapeBookMyShow() {
const url = "https://in.bookmyshow.com/explore/home/mumbai"; // Example URL, you may need to adjust this
const response = await fetch(url, {
headers: {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
const html = await response.text();
const parser = new DOMParser();
testPost
@bingo16
An interactive, runnable TypeScript val by bingo16
Script
export let testPost = async ({ req, res }) => {
res.json("hello: ");
extutil
@gloodata
An interactive, runnable TypeScript val by gloodata
Script
export function replyJSON(data: any, status: number) {
return new Response(JSON.stringify(data), {
status,
headers: { "Content-Type": "application/json" },
export function replyText(data: string, status: number) {
return new Response(data, {
status,
headers: { "Content-Type": "text/plain" },
export function opNotFoundError(opName: string) {
return {
httpBasicAuthenticationExample
@kaleidawave
An interactive, runnable TypeScript val by kaleidawave
HTTP
export default async function(req: Request): Promise<Response> {
if (req.headers.get("Sec-Fetch-Dest") === "iframe") {
return new Response("Skipping auth from iframe", { status: 200 });
const headers = new Headers({
"WWW-Authenticate": "Basic realm=\"Access to the staging site\", charset=\"UTF-8\"",
const requestAuthHeader = req.headers.get("Authorization");
if (requestAuthHeader?.startsWith("Basic")) {
const [username, password] = atob(requestAuthHeader!.slice("Basic".length)).split(":");
if (username === Deno.env.get("PRIVATE_USERNAME") && password === Deno.env.get("PRIVATE_PASSWORD")) {
return new Response(`Welcome ${username}`, { status: 200 });
transmitter
@curtcox
Echo incoming request as JSON See https://developer.mozilla.org/en-US/docs/Web/API/Request
HTTP
# Echo incoming request as JSON
See https://developer.mozilla.org/en-US/docs/Web/API/Request
import { blob } from "https://esm.town/v/std/blob";
export const transmitter = async (req: Request) => {
const searchParams = new URL(req.url).searchParams;
const channels = await blob.getJSON("channels");
return Response.json(channels[searchParams.get("channel")]);
OptimalSlogans
@gabefletch
An interactive, runnable TypeScript val by gabefletch
HTTP
const textList = [
"\"look ma, I don't pay for spotify\"",
"\"to optimize or not to optimize\"",
"\"did you follow the instructions?\"",
"\"hacker!!!\"",
"\"oh, there's a way\"",
"\"what is iOS? You mean iPhone?\"",
"\"my android has had that for years\"",
"\"is that even legal?\"",
"\"yes, really\"",
Upload_onchain_blobs_to_IPFS
@stevedylandev
An interactive, runnable TypeScript val by stevedylandev
Script
const JWT = Deno.env.get("PINATA_JWT");
const uploadFile = async () => {
try {
const url = "https://blobscan.com/tx/0xc239185ec981528648ec17b9d0647f3b0aa259006a1087e73a0a075f056e9a4a";
const hash = new URL(url).pathname.split("/").pop();
let data = new FormData();
if (hash.startsWith("0x0")) {
const hash = new URL(url).pathname.split("/").pop();
const urlStream = await fetch(`https://api.blobscan.com/blobs/${hash}`);
const arrayBuffer = await urlStream.arrayBuffer();
fetchHTML
@beneskildsen
An interactive, runnable TypeScript val by beneskildsen
Script
import { fetch } from "https://esm.town/v/std/fetch";
export const fetchHTML = (async () => {
let f = await fetch("https://api.val.town/express/@beneskildsen.serveHTML", {
method: "GET",
headers: {
"Content-Type": "text/html",
console.log(f);
let t = JSON.parse(await f.text());
console.log(t);
return t.html;
poembuilder3
@stevekrouse
@jsxImportSource npm:hono@3/jsx
HTTP
/** @jsxImportSource npm:hono@3/jsx */
sqlite.execute(`
CREATE TABLE IF NOT EXISTS poemlines3 (
id INTEGER PRIMARY KEY autoincrement,
line TEXT,
safe TEXT
const app = new Hono();
app.get("/", async (c) => {
const poem = await sqlite.execute(`SELECT id, line FROM poemlines3 WHERE safe='SAFE'`);
return c.html(
robPikeIO
@peterqliu
robpike.io A re-implementation of https://robpike.io/
HTTP
# robpike.io
A re-implementation of https://robpike.io/
const msg = new TextEncoder().encode("ssss");
const initialDelay = 20;
export default async function(req: Request): Promise<Response> {
let timerId: number | undefined;
const body = new ReadableStream({
start(controller) {
let currentDelay = initialDelay;
function writeToStream() {
updateTempToWundergroundandWeatherCloud
@flafi87
An interactive, runnable TypeScript val by flafi87
Cron
export default async function(interval: Interval) {
const THINGSPEAK_CHANNEL_ID = Deno.env.get("THINGSPEAK_CHANNEL_ID");
const WUNDERGROUND_ID_PW = Deno.env.get("WUNDERGROUND_ID_PW");
const WEATHERCLOUD_STATION_ID = Deno.env.get("WEATHERCLOUD_STATION_ID");
const WEATHERCLOUD_KEY = Deno.env.get("WEATHERCLOUD_KEY");
const wundergroundUrl =
`https://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?${WUNDERGROUND_ID_PW}`;
const weatherCloudUrl = `https://api.weathercloud.net/v01/set/wid/${WEATHERCLOUD_STATION_ID}/key/${WEATHERCLOUD_KEY}`;
function formatDateString(dateString) {
// Parse the date string to a Date object
pyodideDataAnalysis
@iamseeley
An interactive, runnable TypeScript val by iamseeley
HTTP
export const pyodideExample = () => {
const html = `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Data Analysis with Pyodide</title>
<script type="text/javascript" src="https://cdn.jsdelivr.net/pyodide/v0.25.1/full/pyodide.js"></script>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
editor
@pomdtr
https://twitter.com/wesbos/status/1757146305153974684
HTTP
<https://twitter.com/wesbos/status/1757146305153974684>
import { html } from "https://esm.town/v/stevekrouse/html?v=5";
export default function() {
return html(`
<body
contenteditable
onLoad="document.body.innerHTML = localStorage.getItem('📓')"
oninput="localStorage.setItem('📓', document.body.innerHTML)"
></body>`);