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=1075&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 17289 results for "function"(1135ms)

cerebras_codermain.tsx11 matches

@kwt00•Updated 3 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) {
1000);
1001
1002function client() {
1003 const path = window.location.pathname;
1004 const root = createRoot(document.getElementById("root")!);
1036}
1037
1038function extractCodeFromFence(text: string): string {
1039 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1040 return htmlMatch ? htmlMatch[1].trim() : text;
1041}
1042
1043async function generateCode(prompt: string, currentCode: string) {
1044 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1045 if (starterPrompt) {
1086}
1087
1088export default async function cerebras_coder(req: Request): Promise<Response> {
1089 // Dynamic import for SQLite to avoid client-side import
1090 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1189 <meta property="og:site_name" content="Cerebras Coder">
1190 <meta property="og:url" content="https://cerebrascoder.com"/>
1191 <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."">
1192 <meta property="og:type" content="website">
1193 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">

lotterymahaGamemain.tsx3 matches

@funjo•Updated 3 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function WalletApp() {
6 const [mode, setMode] = useState('login');
7 const [username, setUsername] = useState('');
514}
515
516function client() {
517 createRoot(document.getElementById("root")).render(<WalletApp />);
518}
520if (typeof document !== "undefined") { client(); }
521
522export default async function server(request: Request): Promise<Response> {
523 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
524 const KEY = "lotterymahaGame";

labUploadUploadmain.tsx1 match

@todepond•Updated 3 months ago
2import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
3
4export default async function(req: Request): Promise<Response> {
5 let json;
6 try {

blobStoragemain.tsx8 matches

@kamenxrider•Updated 3 months ago
13}
14
15function Tooltip({ children, content }: TooltipProps) {
16 const [isVisible, setIsVisible] = useState(false);
17 const tooltipRef = useRef<HTMLDivElement>(null);
52}
53
54function formatBytes(bytes: number, decimals = 2) {
55 if (bytes === 0) return "0 Bytes";
56 const k = 1024;
61}
62
63function copyToClipboard(text: string) {
64 navigator.clipboard.writeText(text).then(() => {
65 console.log("Text copied to clipboard");
69}
70
71function ActionMenu({ blob, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
72 const [isOpen, setIsOpen] = useState(false);
73 const menuRef = useRef(null);
76
77 useEffect(() => {
78 function handleClickOutside(event) {
79 if (menuRef.current && !menuRef.current.contains(event.target)) {
80 event.stopPropagation();
158}
159
160function BlobItem({ blob, onSelect, isSelected, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
161 const [isLoading, setIsLoading] = useState(false);
162 const decodedKey = decodeURIComponent(blob.key);
219}
220
221function App({ initialEmail, initialProfile }) {
222 const encodeKey = (key: string) => encodeURIComponent(key);
223 const decodeKey = (key: string) => decodeURIComponent(key);
645}
646
647function client() {
648 const initialEmail = document.getElementById("root").getAttribute("data-email");
649 const initialProfile = JSON.parse(document.getElementById("root").getAttribute("data-profile"));

emailValHandlermain.tsx14 matches

@martinbowling•Updated 3 months ago
58import { pdfText } from "jsr:@pdf/pdftext";
59
60// Main controller function
61export default async function emailValHandler(receivedEmail) {
62 const openaiUrl = "https://api.openai.com/v1/chat/completions";
63 const openaiKey = Deno.env.get("OPENAI_API_KEY");
100
101// Extract attachments (if any)
102async function extractAttachments(email) {
103 if (!email.attachments || email.attachments.length === 0) {
104 return [];
117
118// Extract links from email text
119function extractLinks(text) {
120 const urlRegex = /(https?:\/\/[^\s]+)/g;
121 return text.match(urlRegex) || [];
123
124// Extract website markdown content
125async function extractWebsiteMarkdown(links, apiKey) {
126 const markdownResults = [];
127 const requestsPerMinute = 5;
177
178// Process image attachments with GPT-4V
179async function analyzeImage(imageAttachment, apiKey, transformedPrompt) {
180 try {
181 const response = await fetch("https://api.openai.com/v1/chat/completions", {
221
222// Transform the original prompt using the prompt transformer
223async function transformPrompt(emailText, openaiUrl, apiKey, model) {
224 const promptTransformerText =
225 `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.
311
312// Process all attachments (PDFs and Images)
313async function processAttachments(attachments, apiKey, transformedPrompt) {
314 const pdfTexts = [];
315 const imageAnalysis = [];
331}
332
333async function extractPdfText(attachments) {
334 const pdfTexts = [];
335
365
366// Generate the final prompt with all context
367function generateFinalPrompt(transformedPrompt, pdfTexts, imageAnalysis, websiteMarkdown, email) {
368 let contextDump = [];
369
387}
388
389// Helper function to send a request to OpenAI
390async function sendRequestToOpenAI(prompt, transformedPrompt, openaiUrl, apiKey, model) {
391 try {
392 // Debug logging for the prompt and transformed prompt
439}
440
441// Helper function to send a response back via email
442async function sendResponseByEmail(toEmail, responseContent) {
443 const subject = "AI Response to Your Email";
444 const text = `${responseContent}`;

blob_adminmain.tsx8 matches

@sethblanchard•Updated 3 months ago
13}
14
15function Tooltip({ children, content }: TooltipProps) {
16 const [isVisible, setIsVisible] = useState(false);
17 const tooltipRef = useRef<HTMLDivElement>(null);
52}
53
54function formatBytes(bytes: number, decimals = 2) {
55 if (bytes === 0) return "0 Bytes";
56 const k = 1024;
61}
62
63function copyToClipboard(text: string) {
64 navigator.clipboard.writeText(text).then(() => {
65 console.log("Text copied to clipboard");
69}
70
71function ActionMenu({ blob, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
72 const [isOpen, setIsOpen] = useState(false);
73 const menuRef = useRef(null);
76
77 useEffect(() => {
78 function handleClickOutside(event) {
79 if (menuRef.current && !menuRef.current.contains(event.target)) {
80 event.stopPropagation();
158}
159
160function BlobItem({ blob, onSelect, isSelected, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
161 const [isLoading, setIsLoading] = useState(false);
162 const decodedKey = decodeURIComponent(blob.key);
219}
220
221function App({ initialEmail, initialProfile }) {
222 const encodeKey = (key: string) => encodeURIComponent(key);
223 const decodeKey = (key: string) => decodeURIComponent(key);
645}
646
647function client() {
648 const initialEmail = document.getElementById("root").getAttribute("data-email");
649 const initialProfile = JSON.parse(document.getElementById("root").getAttribute("data-profile"));

tangibleIvoryCanidaemain.tsx2 matches

@alexwein•Updated 3 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 3 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 3 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 3 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">

getFileEmail4 file matches

@shouser•Updated 1 week ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 1 week ago
Simple functional CSS library for Val Town
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",