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/?q=function&page=2388&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 30380 results for "function"(2626ms)

tangibleIvoryCanidaemain.tsx2 matches

@alexwein•Updated 4 months ago
2import d3 from "https://esm.sh/d3@7";
3
4export async function fabw(board) {
5 // Import d3 and Plot with a server-side compatible approach
6 const { document } = await import("https://esm.sh/linkedom@0.16.1").then((m) =>
52}
53
54export default async function(request: Request) {
55 try {
56 // Check if the request method is POST and has JSON content

bluesky_bot_templatemain.tsx5 matches

@alexwein•Updated 4 months ago
6});
7
8// Helper function to convert data URI to Uint8Array
9function convertDataURIToUint8Array(dataURI: string): Uint8Array {
10 const base64Data = dataURI.split(",")[1];
11 const binaryString = atob(base64Data);
17}
18
19// Helper function to fetch SVG and convert to base64
20async function fetchSVGAsBase64(url: string): Promise<string> {
21 const response = await fetch(url);
22 if (!response.ok) {
27}
28
29export default async function(interval: Interval) {
30 // Don't forget to set these environment variables in the val's settings.
31 const username = process.env.BLUESKY_USERNAME;

vividCopperWrenmain.tsx11 matches

@vishu44•Updated 4 months ago
26const PoweredByInfo = "";
27
28function Hero({
29 prompt,
30 setPrompt,
47
48 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
49 Turn your ideas into fully functional apps in{" "}
50 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
51 less than a second!
121}
122
123function App() {
124 const previewRef = React.useRef<HTMLDivElement>(null);
125 const [prompt, setPrompt] = useState("");
175 });
176
177 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
178 setLoading(true);
179 setTimeout(() => handleSubmit(promptItem.prompt), 0);
180 }
181
182 async function handleSubmit(e: React.FormEvent | string) {
183 if (typeof e !== "string") {
184 e.preventDefault();
231 }
232
233 function handleVersionChange(direction: "back" | "forward") {
234 const { currentVersionIndex, versions } = versionHistory;
235 if (direction === "back" && currentVersionIndex > 0) {
920);
921
922function client() {
923 const path = window.location.pathname;
924 const root = createRoot(document.getElementById("root")!);
956}
957
958function extractCodeFromFence(text: string): string {
959 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
960 return htmlMatch ? htmlMatch[1].trim() : text;
961}
962
963async function generateCode(prompt: string, currentCode: string) {
964 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
965 if (starterPrompt) {
1006}
1007
1008export default async function cerebras_coder(req: Request): Promise<Response> {
1009 // Dynamic import for SQLite to avoid client-side import
1010 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1109 <meta property="og:site_name" content="Cerebras Coder">
1110 <meta property="og:url" content="https://cerebrascoder.com"/>
1111 <meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1112 <meta property="og:type" content="website">
1113 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">

reverentAquaCuckoomain.tsx11 matches

@vishu44•Updated 4 months ago
26const PoweredByInfo = "";
27
28function Hero({
29 prompt,
30 setPrompt,
47
48 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
49 Turn your ideas into fully functional apps in{" "}
50 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
51 less than a second!
121}
122
123function App() {
124 const previewRef = React.useRef<HTMLDivElement>(null);
125 const [prompt, setPrompt] = useState("");
175 });
176
177 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
178 setLoading(true);
179 setTimeout(() => handleSubmit(promptItem.prompt), 0);
180 }
181
182 async function handleSubmit(e: React.FormEvent | string) {
183 if (typeof e !== "string") {
184 e.preventDefault();
231 }
232
233 function handleVersionChange(direction: "back" | "forward") {
234 const { currentVersionIndex, versions } = versionHistory;
235 if (direction === "back" && currentVersionIndex > 0) {
920);
921
922function client() {
923 const path = window.location.pathname;
924 const root = createRoot(document.getElementById("root")!);
956}
957
958function extractCodeFromFence(text: string): string {
959 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
960 return htmlMatch ? htmlMatch[1].trim() : text;
961}
962
963async function generateCode(prompt: string, currentCode: string) {
964 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
965 if (starterPrompt) {
1006}
1007
1008export default async function cerebras_coder(req: Request): Promise<Response> {
1009 // Dynamic import for SQLite to avoid client-side import
1010 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1109 <meta property="og:site_name" content="Cerebras Coder">
1110 <meta property="og:url" content="https://cerebrascoder.com"/>
1111 <meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1112 <meta property="og:type" content="website">
1113 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">

exuberantLimeReindeermain.tsx11 matches

@gunisettigokul•Updated 4 months ago
26const PoweredByInfo = "";
27
28function Hero({
29 prompt,
30 setPrompt,
47
48 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
49 Turn your ideas into fully functional apps in{" "}
50 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
51 less than a second!
121}
122
123function App() {
124 const previewRef = React.useRef<HTMLDivElement>(null);
125 const [prompt, setPrompt] = useState("");
175 });
176
177 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
178 setLoading(true);
179 setTimeout(() => handleSubmit(promptItem.prompt), 0);
180 }
181
182 async function handleSubmit(e: React.FormEvent | string) {
183 if (typeof e !== "string") {
184 e.preventDefault();
231 }
232
233 function handleVersionChange(direction: "back" | "forward") {
234 const { currentVersionIndex, versions } = versionHistory;
235 if (direction === "back" && currentVersionIndex > 0) {
920);
921
922function client() {
923 const path = window.location.pathname;
924 const root = createRoot(document.getElementById("root")!);
956}
957
958function extractCodeFromFence(text: string): string {
959 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
960 return htmlMatch ? htmlMatch[1].trim() : text;
961}
962
963async function generateCode(prompt: string, currentCode: string) {
964 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
965 if (starterPrompt) {
1006}
1007
1008export default async function cerebras_coder(req: Request): Promise<Response> {
1009 // Dynamic import for SQLite to avoid client-side import
1010 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1109 <meta property="og:site_name" content="Cerebras Coder">
1110 <meta property="og:url" content="https://cerebrascoder.com"/>
1111 <meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1112 <meta property="og:type" content="website">
1113 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">

cerebras_codermain.tsx11 matches

@gunisettigokul•Updated 4 months ago
26const PoweredByInfo = "";
27
28function Hero({
29 prompt,
30 setPrompt,
47
48 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
49 Turn your ideas into fully functional apps in{" "}
50 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
51 less than a second!
121}
122
123function App() {
124 const previewRef = React.useRef<HTMLDivElement>(null);
125 const [prompt, setPrompt] = useState("");
175 });
176
177 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
178 setLoading(true);
179 setTimeout(() => handleSubmit(promptItem.prompt), 0);
180 }
181
182 async function handleSubmit(e: React.FormEvent | string) {
183 if (typeof e !== "string") {
184 e.preventDefault();
231 }
232
233 function handleVersionChange(direction: "back" | "forward") {
234 const { currentVersionIndex, versions } = versionHistory;
235 if (direction === "back" && currentVersionIndex > 0) {
920);
921
922function client() {
923 const path = window.location.pathname;
924 const root = createRoot(document.getElementById("root")!);
956}
957
958function extractCodeFromFence(text: string): string {
959 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
960 return htmlMatch ? htmlMatch[1].trim() : text;
961}
962
963async function generateCode(prompt: string, currentCode: string) {
964 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
965 if (starterPrompt) {
1006}
1007
1008export default async function cerebras_coder(req: Request): Promise<Response> {
1009 // Dynamic import for SQLite to avoid client-side import
1010 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1109 <meta property="og:site_name" content="Cerebras Coder">
1110 <meta property="og:url" content="https://cerebrascoder.com"/>
1111 <meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1112 <meta property="og:type" content="website">
1113 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">

getLatestYouTubeVideoFromChannelmain.tsx1 match

@samkingco•Updated 4 months ago
1export async function getLatestYouTubeVideoFromChannel(channelId: string): Promise<
2 {
3 title: string;

rm_ios_testmain.tsx8 matches

@arfan•Updated 4 months ago
215 * Generates the main HTML shell, injecting the CSS and the client script.
216 */
217function generateHTML(importMetaUrl: string) {
218 return `
219<!DOCTYPE html>
236
237/**
238 * Server function that handles HTTP routes, DB setup, and returns HTML.
239 */
240export default async function server(request: Request): Promise<Response> {
241 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
242 const KEY = "rm_ios_test";
341 * React component that shows an individual app icon & title.
342 */
343function AppCard({ app, onEdit }: { app: App; onEdit: (app: App) => void }) {
344 // Click or "Enter" => open via iOS Shortcut
345 const handleClick = () => {
378 * Overlay to add or edit an app.
379 */
380function AppOverlay({
381 app,
382 onSave,
512 * Overlay for changing settings (e.g., grouping by category).
513 */
514function SettingsOverlay({
515 groupByCategory,
516 onChangeGroupByCategory,
558 * Main React component that displays the header, categories, apps, & state.
559 */
560function App() {
561 const [selectedCategory, setSelectedCategory] = useState("All");
562 const [apps, setApps] = useState<App[]>([]);
779 * Client entry-point to render the React App.
780 */
781function client() {
782 createRoot(document.getElementById("root")!).render(<App />);
783}

emailValHandlerNomain.tsx14 matches

@martinbowling•Updated 4 months ago
60import { pdfText } from "jsr:@pdf/pdftext";
61
62// Main controller function
63export default async function emailValHandler(receivedEmail) {
64 const openaiUrl = "https://api.openai.com/v1/chat/completions";
65 const openaiKey = Deno.env.get("OPENAI_API_KEY");
102
103// Extract attachments (if any)
104async function extractAttachments(email) {
105 if (!email.attachments || email.attachments.length === 0) {
106 return [];
119
120// Extract links from email text
121function extractLinks(text) {
122 const urlRegex = /(https?:\/\/[^\s]+)/g;
123 return text.match(urlRegex) || [];
125
126// Extract website markdown content
127async function extractWebsiteMarkdown(links, apiKey) {
128 const markdownResults = [];
129 const requestsPerMinute = 5;
170
171// Process image attachments with GPT-4V
172async function analyzeImage(imageAttachment, apiKey, transformedPrompt) {
173 try {
174 const response = await fetch("https://api.openai.com/v1/chat/completions", {
214
215// Transform the original prompt using the prompt transformer
216async function transformPrompt(emailText, openaiUrl, apiKey, model) {
217 const promptTransformerText =
218 `You are an AI assistant tasked with transforming user queries into structured research or information requests. Your goal is to take a simple query and expand it into a comprehensive research objective with specific formatting requirements.
304
305// Process all attachments (PDFs and Images)
306async function processAttachments(attachments, apiKey, transformedPrompt) {
307 const pdfTexts = [];
308 const imageAnalysis = [];
324}
325
326async function extractPdfText(attachments) {
327 const pdfTexts = [];
328
358
359// Generate the final prompt with all context
360function generateFinalPrompt(transformedPrompt, pdfTexts, imageAnalysis, websiteMarkdown, email) {
361 let contextDump = [];
362
382}
383
384// Helper function to send a request to OpenAI
385async function sendRequestToOpenAI(prompt, transformedPrompt, openaiUrl, apiKey, model) {
386 try {
387 // Debug logging for the prompt and transformed prompt
434}
435
436// Helper function to send a response back via email
437async function sendResponseByEmail(toEmail, responseContent) {
438 const subject = "AI Response to Your Email";
439 const text = `${responseContent}`;

tolerantOlivePonymain.tsx2 matches

@shawnsomething•Updated 4 months ago
2
3const service = new InferableService({
4 description: "My functions",
5 token: "sk-inf-val-29f8be75-ab85-49ac-8f68-7ed55f18c6bf",
6});
7
8service.registerFunction({
9 name: "date",
10 description: "Get the current date",
tuna

tuna9 file matches

@jxnblk•Updated 1 week 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.