Search

Results include substring matches and semantically similar vals. Learn more
dhvanil avatar
val_Wr3Zuo6Ytx
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export const jsonOkExample = () => Response.json({ ok: true });
michaelwschultz avatar
generateImageFromHtml
@michaelwschultz
An interactive, runnable TypeScript val by michaelwschultz
Script
export async function generateImageFromHtml(
valUrl: string,
width: number = 800,
height: number = 480,
): Promise<Response> {
if (!valUrl) {
return new Response("No url provided", { status: 500 });
const apiKey = Deno.env.get("API_FLASH_KEY");
const generateUrl =
`https://api.apiflash.com/v1/urltoimage?access_key=${apiKey}&url=${valUrl}&width=${width}&height=${height}&format=png&fre
dhvanil avatar
val_YwQRbwgDeL
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export const jsonOkExample = () => Response.json({ ok: true });
LavaC avatar
getWttr
@LavaC
An interactive, runnable TypeScript val by LavaC
HTTP
export let getWttr = async ({ location }) => {
function convertBlobToDataUrl(blob) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => {
const dataUrl = reader.result;
resolve(dataUrl);
reader.onerror = () => {
reject(reader.error);
reader.readAsDataURL(blob);
andreterron avatar
axiosTest
@andreterron
An interactive, runnable TypeScript val by andreterron
Script
export const axiosTest = (async () => {
const { default: axios } = await import("npm:axios");
const res = await axios.get("https://jsonplaceholder.typicode.com/todos/1");
return res;
Timmy avatar
main
@Timmy
An interactive, runnable TypeScript val by Timmy
Cron
export async function main() {
let latestIssue = 643;
const init = (async () => {
const currentIssueNumber = await getIssueNumber;
console.log(currentIssueNumber, "--------");
if (currentIssueNumber > latestIssue) {
latestIssue = currentIssueNumber;
await email({
text:
`There is a new issue on JavaScript Weekly: https://javascriptweekly.com/issues ${latestIssue}`,
irvinebroque avatar
browserbasePuppeteerExample
@irvinebroque
Browserbase Browserbase offers a reliable, high performance serverless developer platform to run, manage, and monitor headless browsers at scale. Leverage our infrastructure to power your web automation and AI agents. Get started with Browserbase for free here . If you have any questions, reach out to developer@browserbase.com.
Script
### Browserbase
Browserbase offers a reliable, high performance serverless developer platform to run, manage, and monitor headless browsers a
Get started with Browserbase for free [here](browserbase.com).
If you have any questions, reach out to developer@browserbase.com.
const browser = await puppeteer.connect({
browserWSEndpoint: `wss://connect.browserbase.com?apiKey=${Deno.env.get("Y")}`,
const pages = await browser.pages();
const page = pages[0];
await page.goto("https://www.val.town");
const el = await page.waitForSelector("h1");
stevekrouse avatar
rssDemo10
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Cron
import { newRSSItems } from "https://esm.town/v/stevekrouse/newRSSItems";
export async function rssDemo10(interval) {
let items = await newRSSItems({
url: inkAndSwitchRssUrl,
lastRunAt: interval.lastRunAt,
if (items?.length)
return email({
text: JSON.stringify(items, null, 2),
subject: "New from Ink & Switch",
byjonathanleung avatar
get1
@byjonathanleung
An interactive, runnable TypeScript val by byjonathanleung
Script
export let get1 = (x) => {
return "hello world";
tempguy avatar
yellowYak
@tempguy
// This is an IIFE to allow the use of top-level await in Node.js
Script
// This is an IIFE to allow the use of top-level await in Node.js
(async () => {
try {
const options = {
uri: "https://website.com/",
formData: { field1: "value", field2: 2 },
const response = await cloudscraper.post(options);
console.log(response);
} catch (error) {
console.error(error);
dhvanil avatar
val_KbMWZdfs38
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export const jsonOkExample = () => Response.json({ ok: true });
rodrigotello avatar
vtInspoHTML
@rodrigotello
An interactive, runnable TypeScript val by rodrigotello
Script
export function vtInspoHTML(req, res) {
res.send(
valTownInspoList.map((valTownInspo) =>
`<h3>Daily Val Town inspiration</h3>
<h1>${valTownInspo.title}</h1>
<p>${valTownInspo.description}</p>
<a href="https://val.town/${valTownInspo.val}"><img src="https://val.town/v/${valTownInspo.val}.png" style="max-width:576px
<p>
</p>`
).join("\n"),
kylebutts avatar
postWebhook1
@kylebutts
An interactive, runnable TypeScript val by kylebutts
Script
export let postWebhook1 = async (req, res) => {
const a = await newRSSItems({
url: "https://elliot.website/editor/feed.rss",
lastRunAt: new Date("Mon, 31 Oct 2021 00:00:00 +0000"),
res.send(`
<h1>My latest RSS</h1>
<ul>${a
.map(
({ title, link, description, pubDate }) => `
<li>
rld avatar
runGET
@rld
// Forked from @stevekrouse.runGET
Script
import { id } from "https://esm.town/v/rld/id";
export let runGET = id(
"This is a GET request to the @rld.runGET endpoint in val.town",
// Forked from @stevekrouse.runGET
alp avatar
proxyFetch10
@alp
An interactive, runnable TypeScript val by alp
Script
import { fetch } from "https://esm.town/v/std/fetch";
export const proxyFetch10 = async (req, res) => {
const { url, options } = req.body;
try {
const response = await fetch(url, options);
return res.status(response.status).send(await response.text());
} catch (e) {
const errorMessage = e instanceof Error ? e.message : "Unknown error";
console.error("Failed to initiate fetch", e);
return res.status(500).send(`Failed to initiate fetch: ${errorMessage}`);