Search

Results include substring matches and semantically similar vals. Learn more
stainless_em avatar
favicon
@stainless_em
An interactive, runnable TypeScript val by stainless_em
Script
let inited = false;
let CanvasKit: Awaited<ReturnType<typeof CanvasKitInit>>;
declare global {
interface Array<T> {
* Returns the value of the last element in the array where predicate is true, and undefined
* otherwise.
* @param predicate findLast calls predicate once for each element of the array, in descending
* order, until it finds one where predicate returns true. If such an element is found, findLast
* immediately returns that element value. Otherwise, findLast returns undefined.
* @param thisArg If provided, it will be used as the this value for each invocation of
janpaul123 avatar
valle_tmp_52909322274216213030085201031243
@janpaul123
// This val greets the user with their inputted name
HTTP
// This val greets the user with their inputted name
export default async function(req: Request): Promise<Response> {
const formData = new URLSearchParams(await req.text());
const name = formData.get("name") || "stranger";
const htmlResponse = `<h1>Hello, ${name}!</h1>`;
return new Response(htmlResponse, {
headers: { "Content-Type": "text/html" },
adjectiveallison avatar
notify
@adjectiveallison
An interactive, runnable TypeScript val by adjectiveallison
HTTP
export async function notify(request: Request) {
if (request.method === "OPTIONS") {
return new Response("", {
headers: {
"Access-Control-Allow-Headers": "Content-Type",
"Access-Control-Allow-Origin": "*",
const body = await request.json();
if (!body.message) {
return Response.error();
const resp = await fetch("https://api.pushover.net/1/messages.json", {
janpaul123 avatar
valle_tmp_0233014610531885327677280675261011
@janpaul123
// This val responds with "Hello, World!"
HTTP
// This val responds with "Hello, World!"
export default async function main(req: Request): Promise<Response> {
return new Response("Hello, World!", {
headers: {
"Content-Type": "text/plain",
nbbaier avatar
lowdbTest
@nbbaier
Lowdb Example This val demonstrates the integration between valtown and lowdb . Read the Lodash section if you want to give superpowers to your DB.
HTTP
# [Lowdb](https://github.com/typicode/lowdb) Example
This val demonstrates the [integration between valtown and lowdb](https://val.town/v/pomdtr/lowdb).
Read the [Lodash section](https://github.com/typicode/lowdb#lodash) if you want to give superpowers to your DB.
type Post = {
id: number;
title: string;
created: string;
type Data = {
posts: Post[];
const { key } = extractValInfo(import.meta.url);
shreyasmakes avatar
EmailAlert
@shreyasmakes
An interactive, runnable TypeScript val by shreyasmakes
Cron
import { email } from "https://esm.town/v/std/email";
export default async function(interval: Interval) {
let weather = await getWeather("Brooklyn, NY");
let feelsLike = weather.current_condition[0].FeelsLikeF;
let description = weather.current_condition[0].weatherDesc[0].value;
await email({
subject: `Weather now is ${description} and ${feelsLike}°F`,
to: "",
stu43005 avatar
hololiveAnniversaryIcs
@stu43005
An interactive, runnable TypeScript val by stu43005
HTTP
export async function hololiveAnniversaryIcs(req: Request) {
// if (
// req.url
// && new URL(req.url).searchParams.get("token")
// !== process.env.apiSecretToken
// return new Response(null, {
// status: 401,
const data = await blob.getJSON("hololiveAnniversaryData") as { [key: string]: string }[];
const { error, value } = createEvents(data.map((item): EventAttributes => {
const [mm, dd] = item.日付.split("/").map((v) => parseInt(v, 10));
dhvanil avatar
val_Set64BkUDc
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_Set64BkUDc(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
// Model of self-referential patterns and consciousness emergence
// Exploring how patterns can "recognize" and respond to other patterns
function createConsciousPatterns(size, iterations) {
// Create initial pattern space
let patterns = Array(size).fill().map(() => ({
structure: Array(3).fill().map(() => Math.round(Math.random())),
koch avatar
reminders
@koch
An interactive, runnable TypeScript val by koch
Cron
export async function reminders(interval: Interval) {
function* walk(node, path = []) {
yield node;
if (node && Array.isArray(node.value)) {
const arr = node.value;
for (let i = 0; i < arr.length; i++) {
yield* walk(arr[i], [...path, i]);
const comingUp = [];
// Parsed markwhen document
const response = await fetch("https://markwhen.com/rob.json");
samwillis avatar
pglite2
@samwillis
PGlite on Val Town - A whole Postgres in your val All you need to do is first import the Deno xmlhttprequest polyfill and then PGlite: import "https://deno.land/x/xhr@0.1.0/mod.ts"; import { PGlite } from "https://cdn.jsdelivr.net/npm/@electric-sql/pglite/dist/index.js"; Importing using esm.sh doesn't seem to work, see https://github.com/electric-sql/pglite/issues/110
HTTP
PGlite on Val Town - A whole Postgres in your val
All you need to do is first import the Deno xmlhttprequest polyfill and then PGlite:
```js
Importing using esm.sh doesn't seem to work, see https://github.com/electric-sql/pglite/issues/110
let pg;
async function init() {
if (pg) return;
console.log(1);
pg = await PGlite.create();
console.log(2);
dharmatech avatar
rrp
@dharmatech
An interactive, runnable TypeScript val by dharmatech
Script
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
export let rrp = fetchJSON(
"https://markets.newyorkfed.org/api/rp/reverserepo/propositions/search.json?startDate=2022-05-01"
LavaC avatar
eventHandle
@LavaC
An interactive, runnable TypeScript val by LavaC
Script
export const eventHandle = async (req: Request) => {
const { Hono } = await import("npm:hono");
const app = new Hono();
app.get("/set", async (c) => {
const process_name = c.req.query("process_name") || "";
// console.log(c.req);
await set("currentState", process_name);
return c.text("state set to " + process_name);
app.get(
"/get",
codefromanywhere avatar
hi
@codefromanywhere
An interactive, runnable TypeScript val by codefromanywhere
HTTP
export const hi = (request:Request)=>{
return new Response("Hello, world");
pomdtr avatar
evalPost2
@pomdtr
An interactive, runnable TypeScript val by pomdtr
Script
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
console.log(
await fetchJSON(
"https://api.val.town/v1/eval",
method: "POST",
body: JSON.stringify({ code: "(a,b) => a+b", args: [1, 2] }),
tempguy avatar
streamwish
@tempguy
An interactive, runnable TypeScript val by tempguy
Script
function unpack(p, a, c, k) {
while (c--) {
if (k[c]) {
p = p.replace(new RegExp("\\b" + c.toString(a) + "\\b", "g"), k[c]);
return p;
function mat(r, l) {
return r.exec(l);
export async function streamwish(ctx) {
const _embed = await fetch(ctx.url);
const embed = await _embed.text();