18};
19
20function renderForm(
21 valName: string,
22 prompt: string,
84 const writer = writable.getWriter();
85 const textEncoder = new TextEncoder();
86 function write(text) {
87 writer.write(textEncoder.encode(text));
88 }
109 (() => {
110 const scrollingElement = document.body;
111 const callback = function (mutationsList, observer) {
112 window.scrollTo({ left: 0, top: document.body.scrollHeight, behavior: "instant" });
113 };
147 role: "system",
148 content:
149 `Act as an expert software engineer. Always use best practices. Your response should start with \`\`\`ts and end with \`\`\`. Start your response with a comment explaining how your approach will work, what libraries or API calls you will use, and any tradeoffs you're making. Then write the code in a consise way, the simplest way to achieve the goal, though you can add some inline comments to explain your reasoning (not for every line, but for major groups of lines). Don't use any environment variables unless strictly necessary, for example use APIs that don't require a key, prefer internal function imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno functions where possible. The val should create a "export default async function main() {" which is the main function that gets executed, without any arguments. Don't return a Response object, just return a plain Javascript object, array, or string. Unless specified, don't add error handling, make sure that errors bubble up to the caller.`,
150 },
151 {
11// const KEY = "VOETBAL_SHIRT_HASH";
12
13export async function download() {
14 // Replace this URL with the website you want to track
15 const URL = "https://www.knvbshop.nl/nike-nederlands-elftal-thuisshirt-2024-2026.html#size=XL";
6];
7
8// Function to generate HTML for the prompt selector
9function generatePromptSelector() {
10 const options = prompts.map(prompt => `<option value="${prompt}">${prompt}</option>`).join("");
11
35 </div>
36 <script>
37 function handlePromptSelection() {
38 const select = document.getElementById('promptSelect');
39 const result = document.getElementById('result');
54}
55
56// HTTP handler function
57export async function promptSelectorHandler(req) {
58 const html = generatePromptSelector();
59 return new Response(html, {
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(
49};
50
51export default async function handler(req: Request): Promise<Response> {
52 const html = renderToString(
53 <html>
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
36- [x] add listener for cmd+enter to submit query
5import axios from "npm:axios@0.21.1";
6
7export default async function main() {
8 // Fetch weather data for Brooklyn, NY
9
1export default async function(req: Request): Promise<Response> {
2 const url = new URL(req.url);
3 const domain = url.searchParams.get("domain");
8)`);
9
10function two_decimals(number: number) {
11 return round(number, 2);
12}
20});
21
22async function add_city(coordinates: Coordinates): Promise<string> {
23 const searchParams = new URLSearchParams({
24 q: [
51type Coordinates = readonly [number, number];
52
53export async function city(coordinates: Coordinates): Promise<string> {
54 const key = coordinates.map(two_decimals).join(",");
55
64}
65
66export default async function(request: Request): Promise<Response> {
67 const searchParams = new URL(request.url).searchParams;
68
4const substrate = new Substrate({ apiKey: Deno.env.get("SUBSTRATE_API_KEY") });
5
6export default async function render(req: Request): Promise<Response> {
7 const url = new URL(req.url);
8 const searchParams = url.searchParams;
A helper function to build a file's email
Simple functional CSS library for Val Town
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.