Search
parseCalendarEventsTable
@liamdanielduffy
An interactive, runnable TypeScript val by liamdanielduffy
Script
export type TableRow = {
[key: string]: string;
export async function parseCalendarEventsTable(html: string): Promise<TableRow[]> {
const { DOMParser } = await import(
"https://deno.land/x/deno_dom/deno-dom-wasm.ts"
const parser = new DOMParser();
const doc = parser.parseFromString(html, "text/html");
const tables = doc.querySelectorAll("table");
const result: TableRow[][] = [];
tables.forEach((table) => {
val_RAE2AP0hsH
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export const jsonOkExample = () => Response.json({ ok: true });
getinnerfeelingscounter
@politelyinvinciblepointer
An interactive, runnable TypeScript val by politelyinvinciblepointer
Script
import { innerfeelingscounter } from "https://esm.town/v/politelyinvinciblepointer/innerfeelingscounter";
export function getinnerfeelingscounter() {
return innerfeelingscounter;
markdownExample
@neverstew
An interactive, runnable TypeScript val by neverstew
HTTP
export const markdownExample = async (req: Request) => {
const marked = await import("npm:marked");
return new Response(
marked.parse(`
Using Marked, a Markdown Parser
[Marked](https://marked.js.org) is a widely used markdown parser.
Here, we've imported it using \`const marked = await import("npm:marked");\`!
{ headers: { "Content-Type": "text/html" } },
stirringLavenderStoat
@wade
An interactive, runnable TypeScript val by wade
HTTP
export default async function(req: Request): Promise<Response> {
if (req.method !== "POST") {
return new Response(
JSON.stringify({ error: "Only POST requests are allowed" }),
{ status: 405, headers: { "Content-Type": "application/json" } },
let body: {
sourceCurrency?: string;
sourceAmount?: string | number;
destinationCurrency?: string;
try {
feed
@darcy
An interactive, runnable TypeScript val by darcy
Cron
import { fetch } from "https://esm.town/v/std/fetch";
export function feed() {
let _feed = following.map(async (name) => {
let req = await fetch(`https://api.val.town/v1/run/${name}.posts`);
let res = (req.status === 200) ? req.json() : {};
return res;
console.log(_feed);
return _feed;
pushSendNotification_negrel
@jrmann100
// https://github.com/web-push-libs/web-push/blob/v3.4.4/README.md#using-vapid-key-for-applicationserverkey
Script
// https://github.com/web-push-libs/web-push/blob/v3.4.4/README.md#using-vapid-key-for-applicationserverkey
function urlBase64ToUint8Array(b64) {
const padding = "=".repeat((4 - (b64.length % 4)) % 4);
const base64 = (b64 + padding)
.replace(/\-/g, "+")
.replace(/_/g, "/");
const rawData = globalThis.atob(base64);
const outputArray = new Uint8Array(rawData.length);
for (let i = 0; i < rawData.length; ++i) {
outputArray[i] = rawData.charCodeAt(i);
doit
@maksik
An interactive, runnable TypeScript val by maksik
Script
export async function doit() {
console.email("Hello!", "from Val Town");
valle_tmp_397893855838237934336717990875854
@janpaul123
// This HTTP val responds to all requests with "Hello world"
HTTP
// This HTTP val responds to all requests with "Hello world"
export default async function main(req: Request): Promise<Response> {
return new Response("Hello world", { headers: { "Content-Type": "text/plain" } });
hello
@root
An interactive, runnable TypeScript val by root
Script
export function hello(name) {
// return "wow~ your are 叼毛 open 了 Pandora" ;
return { message: "wow~ your are 叼毛 open 了 Pandora" };
// return eval("window.open('https://www.jd.com')") // 不允许
// return window.alert.call(null, '123') // nodejs 环境没有window
// return window // nodejs 环境没有window = null
getColor
@stevekrouse
Get common or "dominant" color from an image given a source URL
HTTP
Get common or "dominant" color from an image given a source URL
/** @jsxImportSource npm:hono@3/jsx */
const EXAMPLE_URL = "https://letsenhance.io/static/8f5e523ee6b2479e26ecc91b9c25261e/1015f/MainAfter.jpg";
const PERCENT_COVERAGE = 10; // lower is faster, but higher is more accurate
function getPixelIndex(numToRound) {
// Each pixel is 4 units long: r,g,b,a
const remainder = numToRound % 4;
if (remainder == 0) return numToRound;
return numToRound + 4 - remainder;
export async function getColor(src: string = EXAMPLE_URL): Promise<string> {
FigmaAvatarsMixerTest
@rodrigotello
An interactive, runnable TypeScript val by rodrigotello
Script
import process from "node:process";
export const FigmaAvatarsMixerTest = (async () => {
const apiToken = process.env.myFigmaAPIToken;
const fileKey =
parseFigmaURL(
"https://www.figma.com/file/XqiternEMTE2Gk8jHzG4Ui/AvatarMixerFileTest?type=design&node-id=0%3A1&mode=design&t=Mpjs48FGMgw77SXW-1",
).key;
return fetchFigmaFile(apiToken, fileKey);
ittyRouterExample
@tmcw
itty-router This is an example of using the Val Town Web API to integrate with itty-router . Server examples Hono Peko Itty Router Nhttp
HTTP
# itty-router
This is an example of using the Val Town [Web API](https://docs.val.town/api/web) to integrate with [itty-router](https://github.com/kwhitley/itty-router).
### Server examples
- [Hono](https://www.val.town/v/tmcw.honoExample)
- [Peko](https://www.val.town/v/tmcw.pekoExample)
- [Itty Router](https://www.val.town/v/tmcw.ittyRouterExample)
export const ittyRouterExample = async (request: Request) => {
const { Router, json } = await import("npm:itty-router@4");
const router = Router();
router.get("/", () => "Hi");
createValFromCljs
@liamdanielduffy
An interactive, runnable TypeScript val by liamdanielduffy
Script
import { updateValByName } from "https://esm.town/v/nbbaier/updateValByName";
export async function createValFromCljs(name: string, cljs: string) {
return updateValByName({
token: Deno.env.get("valtown"),
name,
code: compileCljsToES6(cljs),
me
@dthyresson
me Welcome to my Val town! I'm DT , a GP at Preston-Werner Ventures where I invest in early stage startups. I also work on RedwoodJS . I enjoy ☕️ and collecting 🖍 street art, 🧷 punk/new wave/rock poster art and ephemera (Madchester, The Haçienda, and Factory Records), vintage 🥁 🤖 drum machines & 🎹 synths. Have a look at my Vals: GraphQL Spotify Misc
HTTP
# me
Welcome to my Val town!
I'm [DT](https://www.thyresson.io), a GP at [Preston-Werner Ventures](https://prestonwernerventures.com) where I invest in early stage startups. I also work on [RedwoodJS](https:/www/redwoodjs.com).
I enjoy ☕️ and collecting 🖍 street art, 🧷 punk/new wave/rock poster art and ephemera (Madchester, The Haçienda, and Factory Records), vintage 🥁 🤖 drum machines & 🎹 synths.
Have a look at my Vals:
* [GraphQL](https://www.val.town/?folderId=044ed6ea-4cc7-11ef-961a-de64eea55b61)
* [Spotify](https://www.val.town/?folderId=4f65e290-4b8c-11ef-b05a-de64eea55b61)
* [Misc](https://www.val.town/?folderId=82bf4850-4ce2-11ef-b4af-de64eea55b61)
export function handler(request: Request) {
return Response.redirect('https://www.thyresson.io')