Search

Results include substring matches and semantically similar vals. Learn more
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",
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));
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);
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);
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())),
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: "",
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");
stevekrouse avatar
valWall
@stevekrouse
Inspired by https://www.val.town/v/ejfox/valcontributionchart
HTTP
Inspired by https://www.val.town/v/ejfox/valcontributionchart
// import { getVals, getValsWithVersions } from "./api.js";
const app = new Hono();
app.use(appendTrailingSlash());
app.get("/graph/:username?", async (c) => {
console.log("graph:", c.req.param("username") || c.req.query("username"));
const username = c.req.param("username") || c.req.query("username");
if (!username) {
return c.html(`<p class="text-red-500">Error: Username is required</p>`);
try {
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();
easrng avatar
nodejsSample
@easrng
// run node.js code in your val
Script
import { nodejs } from "https://esm.town/v/easrng/nodejs";
// run node.js code in your val
export const nodejsSample = (async () => {
const nodeEval = await nodejs();
console.log(await nodeEval("2 + 2"));
console.log(await nodeEval("typeof require"));
pomdtr avatar
dotShortcut
@pomdtr
Dot Shortcut This val adds a github-like dot shortcut to your website, redirecting to the val.town editor. Usage Add the following script tag to your website head. <script type="module" src="https://esm.town/v/pomdtr/dotShortcut"></script>
Script
# Dot Shortcut
This val adds a github-like dot shortcut to your website, redirecting to the val.town editor.
## Usage
Add the following script tag to your website head.
```html
<script type="module" src="https://esm.town/v/pomdtr/dotShortcut"></script>
document.addEventListener("keydown", async (event) => {
if (event.key != ".") {
return;
if (document.activeElement != document.body) {