Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/$%7Burl%7D?q=function&page=2292&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=function

Returns an array of strings in format "username" or "username/projectName"

Found 29395 results for "function"(5518ms)

aiEmailAssistantmain.tsx10 matches

@simplescraper•Updated 4 months ago
3import { pdfText } from "jsr:@pdf/pdftext";
4
5// main controller function
6export async function emailValHandler(receivedEmail) {
7 const openaiUrl = "https://api.openai.com/v1/chat/completions";
8 const apiKey = Deno.env.get("OPENAI_KEY"); // replace this entire line with your OpenAI API key as a string, e.g., "sk-123..." or use environment variable: https://docs.val.town/reference/environment-variables/
48
49// extract attachments (if any)
50async function extractAttachments(email) {
51 if (!email.attachments || email.attachments.length === 0) {
52 return [];
64}
65
66async function extractPdfText(attachments) {
67 const pdfTexts = [];
68
97}
98
99// helper function to generate a prompt for openai
100function generatePrompt(email, pdfTexts, emailText) {
101 // extract the first name from the 'from' field if it exists
102 const senderName = email.from.split("<")[0].trim().split(" ")[0] || "";
121}
122
123// helper function to send a request to openai
124async function sendRequestToOpenAI(prompt, openaiUrl, apiKey, model) {
125 try {
126 // prepare the openai messages payload
161}
162
163// helper function to send a response back via email
164async function sendResponseByEmail(toEmail, responseContent) {
165 const subject = "AI Response to Your Email";
166 const text = `${responseContent}`;

welcomingAmethystMoosemain.tsx4 matches

@Saqib•Updated 4 months ago
3import React, { useState } from "https://esm.sh/react@18.2.0";
4
5function PaymentButton({ method, icon, onClick }) {
6 return (
7 <button
23}
24
25function App() {
26 const [status, setStatus] = useState("Ready to pay");
27
100}
101
102function client() {
103 createRoot(document.getElementById("root")).render(<App />);
104}
105if (typeof document !== "undefined") { client(); }
106
107export default async function server(request: Request): Promise<Response> {
108 if (request.method === "POST" && new URL(request.url).pathname === "/process-payment") {
109 try {

paymentGatewayWebmain.tsx4 matches

@Saqib•Updated 4 months ago
3import React, { useState } from "https://esm.sh/react@18.2.0";
4
5function PaymentButton({ method, icon, onClick }) {
6 return (
7 <button
23}
24
25function App() {
26 const [status, setStatus] = useState("Ready to pay");
27
100}
101
102function client() {
103 createRoot(document.getElementById("root")).render(<App />);
104}
105if (typeof document !== "undefined") { client(); }
106
107export default async function server(request: Request): Promise<Response> {
108 if (request.method === "POST" && new URL(request.url).pathname === "/process-payment") {
109 try {

Goldcalculatormain.tsx4 matches

@Madhu3283•Updated 4 months ago
4
5// Custom Logo Component
6function GoldLogo() {
7 return (
8 <svg
50}
51
52function GoldSellCalculator() {
53 const [goldWeight, setGoldWeight] = useState('');
54 const [goldPurity, setGoldPurity] = useState('24');
216}
217
218function client() {
219 const rootElement = document.getElementById("root");
220 if (rootElement) {
227}
228
229export default async function server(request: Request): Promise<Response> {
230 return new Response(`
231 <html>

postHogAPICapturemain.tsx1 match

@BunsDev•Updated 4 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function postHogAPICapture({ key, event, properties, distinct_id }: {
4 key: string;
5 event: string;

FetchBasicmain.tsx1 match

@BunsDev•Updated 4 months ago
1export default async function(req: Request): Promise<Response> {
2 // Setup CORS Headers
3 const headers = new Headers();

browserbaseUtilsmain.tsx2 matches

@toowired•Updated 4 months ago
5}
6
7export async function loadPageContent(url: string, options: LoadPageOptions = { textContent: false }) {
8 const browser = await puppeteer.connect({
9 browserWSEndpoint: `wss://connect.browserbase.com?apiKey=${Deno.env.get("BROWSERBASE_API_KEY")}`,
35}
36
37export async function screenshotPage(url: string, options: ScreenshotOptions = { fullPage: true }) {
38 const browser = await puppeteer.connect({
39 browserWSEndpoint: `wss://connect.browserbase.com?apiKey=${Deno.env.get("BROWSERBASE_API_KEY")}`,

vividBeigeFalconmain.tsx1 match

@lockiechen•Updated 4 months ago
1function add(a: number, b: number) {
2 return a + b;
3}

pngMakerAppmain.tsx3 matches

@g•Updated 4 months ago
6import { Hono } from 'npm:hono';
7
8function html() {
9 /*
10<!DOCTYPE html>
35}
36
37function css() {
38 /*
39body {
86}
87
88function js() {
89 /*
90import { createPolygotPng } from '/polypng.mjs';

oceanThememain.tsx1 match

@paswan•Updated 4 months ago
167 border-radius: 50%;
168 animation: rise infinite;
169 animation-timing-function: linear;
170 }
171
tuna

tuna9 file matches

@jxnblk•Updated 2 days ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
lost1991
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": "*",
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.