Search

Results include substring matches and semantically similar vals. Learn more
agmm avatar
mdToHtml
@agmm
An interactive, runnable TypeScript val by agmm
HTTP
import { render } from "https://esm.town/v/ije/md?v=2";
export default async function(req: Request): Promise<Response> {
const markdown = `
# Title
Some *test* here.
return new Response(render(markdown), {
status: 200,
headers: {
"Content-Type": "text/html",
dhvanil avatar
val_X6JYYp11Hg
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export default async function handler(req) {
try {
const result = await (async () => {
function isPrime(num) {
if (num <= 1) return false;
for (let i = 2; i <= Math.sqrt(num); i++) {
if (num % i === 0) return false;
return true;
function findLowestThreeDigitPrime() {
for (let num = 100; num < 1000; num++) {
aeaton avatar
fetchHtmlDom
@aeaton
An interactive, runnable TypeScript val by aeaton
Script
import { fetch } from "https://esm.town/v/std/fetch";
export async function fetchHtmlDom(url: string) {
const { DOMParser } = await import(
"https://deno.land/x/deno_dom/deno-dom-wasm.ts"
const response = await fetch(url);
const html = await response.text();
const parser = new DOMParser();
return parser.parseFromString(html, "text/html");
pomdtr avatar
orangeMite
@pomdtr
https://pomdtr-orangemite.web.val.run
HTTP
https://pomdtr-orangemite.web.val.run
export default function(req) {
return new Response(req.referrer, {
status: 200,
roadlabs avatar
keenScarletWoodpecker
@roadlabs
tldraw computer custom endpoint example This val is an example custom endpoint for tldraw computer 's data component. Usage To use this val with tldraw.computer, follow these steps: Fork this Val. Click the Copy endpoint button on your new Val. Open a project on tldraw.computer Create a Data component in your tldraw computer project In the Source dropdown, select Custom and the POST method Paste the endpoint into Data component's the HTTP Endpoint input. Run the component. To see the output, connect the Data component to a Text component. How it works In tldraw computer, you can configure a Data component to use a custom HTTP endpoint as its data source. You can also configure the request method, either GET or POST. If a Data component's request method is POST, then when the component next updates, it will send a POST request to the endpoint. The request's body will contain an array of the Data objects that the component had received as inputs. If the request method if GET, then the component will only make the request—its body will be empty. In both cases, the component will expect back a response that includes an array of Data objects these objects will be passed along as the data component's outputs. The endpoint (your forked version of this Val) can do whatever it likes between the request and response, but the response must include data in the correct format. If the format is wrong, the computer app will create a text data object instead that includes the response as plain text. Support If you're running into any difficulties, check out the #tldraw-computer channel on the tldraw discord.
HTTP
# tldraw computer custom endpoint example
This val is an example custom endpoint for [tldraw computer](tldraw.computer)'s data component.
### Usage
To use this val with tldraw.computer, follow these steps:
1. Fork this Val.
2. Click the **Copy endpoint** button on your new Val.
type BooleanData = {
type: "boolean";
text: "true" | "false" | "maybe";
name?: string | undefined;
pomdtr avatar
marp
@pomdtr
theme: gaia _class: lead paginate: true backgroundColor: "#fff" backgroundImage: url('https://marp.app/assets/hero-background.svg') Marp Markdown Presentation Ecosystem https://marp.app/ How to write slides Split pages by horizontal ruler ( --- ). It's very simple! :satisfied: # Slide 1 foobar --- # Slide 2 foobar
HTTP
theme: gaia
_class: lead
paginate: true
backgroundColor: "#fff"
backgroundImage: url('https://marp.app/assets/hero-background.svg')
![bg left:40% 80%](https://marp.app/assets/marp.svg)
export default async function() {
const { author, name } = extractValInfo(import.meta.url);
const { readme } = await api(`/v1/alias/${author}/${name}`);
const marp = new Marp();
logan avatar
emailMeWhenBadAirQuality
@logan
An interactive, runnable TypeScript val by logan
Script
export async function emailMeWhenBadAirQuality({ lat, long }: {
lat: number;
long: number;
// Get date and API key
const now = new Date();
const apiKey = process.env.WEATHER_BIT_API_KEY;
if (!apiKey) {
throw new Error("Must define WEATHER_BIT_API_KEY in secrets");
const res = await fetch(
`https://api.weatherbit.io/v2.0/current/airquality?lat=${lat}&lon=${long}&key=${apiKey}`,
jacoblee93 avatar
multipleKeysAndMemoryConversationChainExample
@jacoblee93
An interactive, runnable TypeScript val by jacoblee93
Script
export const multipleKeysAndMemoryConversationChainExample = (async () => {
const { ChatOpenAI } = await import(
"https://esm.sh/langchain/chat_models/openai"
const { BufferMemory } = await import("https://esm.sh/langchain/memory");
const {
ChatPromptTemplate,
SystemMessagePromptTemplate,
HumanMessagePromptTemplate,
MessagesPlaceholder,
} = await import("https://esm.sh/langchain/prompts");
sylvea avatar
ZineFairs
@sylvea
// Scrapes the stencil fairs website and gets the upcoming events
Cron
const WEBSITE_URL = "https://www.stencil.wiki/fairs";
interface Event {
name?: string;
dates?: string;
location?: string;
// Scrapes the stencil fairs website and gets the upcoming events
async function scrapeWebsiteAndGetEvents(url: string): Promise<Array<Event>> {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Failed to fetch ${url}: ${response.status} ${response.statusText}`);
jdan avatar
grimPinkLimpet
@jdan
// This approach will use the Notion API to update a block's color.
HTTP
// This approach will use the Notion API to update a block's color.
// We'll create a simple HTML page with a button, and use JavaScript to handle
// the click event and make a request to our Val Town function.
// The function will then make a request to the Notion API to update the block.
const app = new Hono();
// Main page with the button
app.get("/", (c) => {
return c.html(`
<!DOCTYPE html>
<html lang="en">
willthereader avatar
htmlExample
@willthereader
Returning HTML from the Val Town Web API This just lets you use the standard Response object with our Web API to return an HTML response from this Val.
HTTP
# Returning HTML from the Val Town Web API
This just lets you use the standard [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) object with our [We
export const htmlExample = () =>
new Response("<h1>Hello, world</h1>", {
headers: {
"Content-Type": "text/html",
maxm avatar
honoJSXExample
@maxm
@jsxImportSource npm:hono@3/jsx
HTTP
/** @jsxImportSource npm:hono@3/jsx */
export const honoExample = () => {
const jsx = <div>Test {1 + 1}</div>;
return new Response(jsx.toString(), {
headers: {
"Content-Type": "text/html",
mjweaver01 avatar
FindFraudTrendsUsingGPT
@mjweaver01
FraudTrendsGPT Generate real-time Fraud Trend Reports using GPT-4o Goal This agent is designed to find trends in merchant transaction reports, and produce a real time report. Reports are complete with relevant data tables and Mermaid charts. Semi-Data-Agnostic This agent is semi-agnostic to the data provided. Meaning, it will provide a report so long as the provided data is shaped similarly, or the prompt is updated to support the new data shape. Agent Reusability Moreover, this agent can be rewritten for any number of use cases. With some variable renaming, and rewriting of the prompt, this should produce very accurate data analytic reports for any data provided.
HTTP
# FraudTrendsGPT
> Generate real-time Fraud Trend Reports using GPT-4o
## Goal
This agent is designed to find trends in merchant transaction reports, and produce a real time report.
Reports are complete with relevant data tables and Mermaid charts.
## Semi-Data-Agnostic
const trendGPT = async (data, onData) => {
const openai = new OpenAI();
const chatStream = await openai.chat.completions.create({
messages: [
bingo16 avatar
newChatGPT35
@bingo16
An interactive, runnable TypeScript val by bingo16
Script
export let newChatGPT35 = async ({ req, res }) => {
const postData = {
model: "gpt-3.5-turbo",
messages: [
{ role: "system", content: "You are a powerful chatGPT assistant." },
role: "user",
content: "请介绍一下你自己",
const getCompletion = async () => {
const response = await fetch("https://api.openai.com/v1/chat/completions", {
method: "POST",
briscoe avatar
getTodaysInfo
@briscoe
An interactive, runnable TypeScript val by briscoe
Script
export const getTodaysInfo = (async (req: Interval, res: express.Response) => {
const tides = await getTideTimes();
const pool = await getPoolTimes();
const tidesString = `<strong>High tides</strong>: ${
tides.filter((t) => t.tide === "High Tide").map((t) =>
`${t.time} (${t.height})`
).join(" & ")
let poolString = "<strong>Pool times today</strong>";
if (pool.today.length > 0)
poolString += `<ul> ${