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/image-url.jpg%20%22Optional%20title%22?q=function&page=2027&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 28754 results for "function"(1863ms)

cerebras_coderindex2 matches

@zenkoder•Updated 3 months ago
3import { createProject, getCode, getNextVersionNumber, insertVersion } from "./database/queries";
4
5async function servePublicFile(path: string): Promise<Response> {
6 const url = new URL("./public/" + path, import.meta.url);
7 const text = await (await fetch(url, {
20await createTables();
21
22export default async function cerebras_coder(req: Request): Promise<Response> {
23 if (req.method === "POST") {
24 let { prompt, currentCode, versionHistory, projectId } = await req.json();

cerebras_coderindex7 matches

@zenkoder•Updated 3 months ago
23);
24
25function Hero({
26 prompt,
27 setPrompt,
44
45 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
46 Turn your ideas into fully functional apps in{" "}
47 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
48 less than a second
115}
116
117function App() {
118 const previewRef = React.useRef<HTMLDivElement>(null);
119 const [prompt, setPrompt] = useState("");
169 });
170
171 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
172 setLoading(true);
173 setTimeout(() => handleSubmit(promptItem.prompt), 0);
174 }
175
176 async function handleSubmit(e: React.FormEvent | string) {
177 if (typeof e !== "string") {
178 e.preventDefault();
225 }
226
227 function handleVersionChange(direction: "back" | "forward") {
228 const { currentVersionIndex, versions } = versionHistory;
229 if (direction === "back" && currentVersionIndex > 0) {
973);
974
975function client() {
976 const path = window.location.pathname;
977 const root = createRoot(document.getElementById("root")!);

cerebras_codergenerate-code2 matches

@zenkoder•Updated 3 months ago
2import STARTER_PROMPTS from "../public/starter-prompts.js";
3
4function extractCodeFromFence(text: string): string {
5 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
6 return htmlMatch ? htmlMatch[1].trim() : text;
7}
8
9export async function generateCode(prompt: string, currentCode: string) {
10 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
11 if (starterPrompt) {

openTanMockingbirdsharpSapphireImpala1 match

@Bhargav•Updated 3 months ago
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}

enterpriseExpenseManagementmain.tsx5 matches

@ashh•Updated 3 months ago
14}
15
16function App() {
17 const [expenses, setExpenses] = useState<Expense[]>([]);
18 const [newExpense, setNewExpense] = useState<Partial<Expense>>({
28 }, []);
29
30 async function fetchExpenses() {
31 try {
32 const response = await fetch('/expenses');
38 }
39
40 async function submitExpense() {
41 try {
42 const response = await fetch('/submit-expense', {
141}
142
143function client() {
144 createRoot(document.getElementById("root")).render(<App />);
145}
146if (typeof document !== "undefined") { client(); }
147
148export default async function server(request: Request): Promise<Response> {
149 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
150 const KEY = "enterpriseExpenseManagement";

valentinemain.tsx3 matches

@tarosakamo2•Updated 3 months ago
13];
14
15function App() {
16 const [noClicks, setNoClicks] = useState(0);
17 const [isValentine, setIsValentine] = useState(false);
98}
99
100function client() {
101 createRoot(document.getElementById("root")).render(<App />);
102}
103if (typeof document !== "undefined") { client(); }
104
105export default async function server(request: Request): Promise<Response> {
106 return new Response(
107 `

execmain.tsx3 matches

@saharsh•Updated 3 months ago
45`;
46
47function getYesterdayDateRange(): { startDate: string; endDate: string } {
48 const now = new Date();
49 const yesterday = new Date(now.setDate(now.getDate() - 1));
56}
57
58export async function exec(interval: Interval) {
59 const apiKey = Deno.env.get("LINEAR_API_KEY");
60 if (!apiKey) {
132 });
133
134 function determineMatchedContext(
135 history: any[],
136 startDate: string,

percentileCalculatormain.tsx3 matches

@omkar08•Updated 3 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function PercentileCalculator() {
6 const [longExams, setLongExams] = useState([0, 0, 0]);
7 const [finalExam, setFinalExam] = useState(0);
65}
66
67function client() {
68 createRoot(document.getElementById("root")).render(<PercentileCalculator />);
69}
70if (typeof document !== "undefined") { client(); }
71
72export default async function server(request: Request): Promise<Response> {
73 return new Response(`
74 <html>

reactHonoExampleMessageInput.tsx1 match

@stevekrouse•Updated 3 months ago
3import type { Message } from "../shared/types.ts";
4
5export function MessageInput({ onSubmit }: { onSubmit: () => void }) {
6 const [message, setMessage] = React.useState("");
7

researchAgentemailHandler3 matches

@charmainetest•Updated 3 months ago
4import { OpenAI } from "npm:openai";
5
6function emailValHandlerExtra(inboundEmail: Email) {
7 console.log("Received email:", {
8 from: inboundEmail.from,
21}
22
23function pm(...lines: string[]): string {
24 return lines.join("\n");
25}
26
27export async function emailValHandler(inboundEmail: Email) {
28 const userPrompt = pm(
29 `From: ${inboundEmail.from}`,

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 1 month ago
Simple functional CSS library for Val Town
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.