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?q=function&page=2843&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 35209 results for "function"(9253ms)

TestProjectintimateIndigoRook1 match

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

githubParsermain.tsx19 matches

@yawnxyz•Updated 5 months ago
182 const repoList = document.getElementById('repoList');
183 const ignoredPatternsTextarea = document.getElementById('ignoredPatterns');
184 async function updateRepoList() {
185 const repos = await db.repositories.toArray();
186 repoList.innerHTML = repos.map(repo =>
211 });
212
213 function displayRepoData(repo) {
214 resultArea.value = repo.content;
215 updateStats(repo.content);
217 }
218
219 function updateStats(content) {
220 const bytes = new TextEncoder().encode(content).length;
221 const kb = bytes / 1024;
227 }
228
229 function updateTokenCounts(tokenCounts) {
230 tokenCountCl100k.textContent = tokenCounts.cl100k_base.toLocaleString();
231 tokenCountP50k.textContent = tokenCounts.p50k_base.toLocaleString();
234 }
235
236 // Add this new function to parse the patterns
237 function parseIgnoredPatterns() {
238 return ignoredPatternsTextarea.value
239 .split('\\n')
243
244
245 async function fetchFileTypes(repoUrl) {
246 const response = await fetch('/file-types', {
247 method: 'POST',
257 }
258
259 function displayFileTypeSelector(fileTypes, ignoredPatterns) {
260 const fileTypeSelectorDiv = document.getElementById('fileTypeSelector');
261 const fileTypeList = document.getElementById('fileTypeList');
528});
529
530function getTiktokenSegments(encoder, inputText) {
531 try {
532 const tokens = encoder.encode(inputText);
566}
567
568function getFileExtension(filename) {
569 const parts = filename.split('.');
570 return parts.length > 1 ? '.' + parts.pop().toLowerCase() : 'no-extension';
572
573
574function getFileType(path) {
575 // Handle directories
576 if (path.endsWith('/')) {
587}
588
589async function fetchRepositoryContent(owner, repo, specifiedBranch = null, ignoredPatterns, selectedTypes = null) {
590 // First, try to get the default branch or use the specified branch
591 const repoInfoUrl = `https://api.github.com/repos/${owner}/${repo}`;
661}
662
663async function fetchFileContent(owner, repo, path, branch) {
664 const apiUrl = `https://api.github.com/repos/${owner}/${repo}/contents/${path}`;
665 const response = await fetch(apiUrl, {
678}
679
680function getIgnoredPatterns() {
681 return [
682 // Folders
754}
755
756function shouldIgnoreFile(path, ignoredPatterns) {
757 // Special case for README.md
758 if (path.toLowerCase() === 'readme.md') {
763}
764
765async function countTokens(text) {
766 const encoders = {
767 cl100k_base: get_encoding("cl100k_base"),
780}
781
782async function getTokenizedText(text) {
783 const encoder = get_encoding("cl100k_base");
784 const tokens = encoder.encode(text);
819});
820
821// Add new function to get repository file types
822async function getRepositoryFileTypes(owner, repo, specifiedBranch = null) {
823 const repoInfoUrl = `https://api.github.com/repos/${owner}/${repo}`;
824 const repoInfoResponse = await fetch(repoInfoUrl, {

r1main.tsx12 matches

@sboesen•Updated 5 months ago
4import { pdfText } from "jsr:@pdf/pdftext";
5
6// main controller function
7export default async function(receivedEmail) {
8 const apiKey = Deno.env.get("FIREWORKS_API_KEY");
9 const model = "accounts/fireworks/models/deepseek-r1";
53
54// extract attachments (if any)
55async function extractAttachments(email) {
56 if (!email.attachments || email.attachments.length === 0) {
57 return [];
69}
70
71async function extractPdfText(attachments) {
72 const pdfTexts = [];
73
102}
103
104// helper function to generate a prompt for AI
105function generatePrompt(email, pdfTexts, emailText) {
106 const senderName = email.from.split("<")[0].trim().split(" ")[0] || "User";
107 const fullSenderName = email.from.split("<")[0].trim() || "User";
131}
132
133// helper function to send a request to Fireworks.ai
134async function sendRequestToFireworks(prompt, apiKey, model) {
135 try {
136 const client = new OpenAI({
165}
166
167// helper function to parse the AI response
168function parseAIResponse(response) {
169 let parsedResponse = response;
170 let thinking = "";
183}
184
185// helper function to send a response back via email
186async function sendResponseByEmail(originalEmail, responseContent, thinking) {
187 const subject = originalEmail.subject.startsWith("Re:")
188 ? originalEmail.subject

p5Alohamain.tsx4 matches

@icezee•Updated 5 months ago
4import React from "https://esm.sh/react@18.2.0";
5
6function Sketch() {
7 const [p5Loaded, setP5Loaded] = React.useState(false);
8
38}
39
40function client() {
41 // Dynamically import React DOM to ensure it's only loaded in the browser
42 if (typeof window !== "undefined") {
50}
51
52// Only call client function in browser environment
53if (typeof window !== "undefined") { client(); }
54
55export default async function server(request: Request) {
56 return new Response(
57 `

uniqmain.tsx1 match

@genco•Updated 5 months ago
2import hash from "npm:hash-it";
3
4export async function newUniq(ns: string): Promise<Uniq> {
5 let u = new Uniq(ns);
6 await u.init();

appmain.tsx2 matches

@RIKKAEBI•Updated 5 months ago
8};
9
10function App() {
11 const [isPending, startTransition] = useTransition();
12 const [likes, setLikes] = useState(0);
43}
44
45export default async function server(request: Request): Promise<Response> {
46 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
47 const KEY = "app";

talkAbouttalkAbout1 match

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

OpenRouterChatCompletion_Testmain.tsx1 match

@rozek•Updated 5 months ago
1/**** a simple smoke test for val "OpenRouterChatCompletion" ****/
2
3 export default async function (Request:Request):Promise<Response> {
4 const OpenAIRequest = {
5 messages: [

cerebras_codermain.tsx11 matches

@Shashank_3•Updated 5 months ago
24);
25
26function Hero({
27 prompt,
28 setPrompt,
45
46 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
47 Turn your ideas into fully functional apps in{" "}
48 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
49 less than a second
116}
117
118function App() {
119 const previewRef = React.useRef<HTMLDivElement>(null);
120 const [prompt, setPrompt] = useState("");
170 });
171
172 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
173 setLoading(true);
174 setTimeout(() => handleSubmit(promptItem.prompt), 0);
175 }
176
177 async function handleSubmit(e: React.FormEvent | string) {
178 if (typeof e !== "string") {
179 e.preventDefault();
226 }
227
228 function handleVersionChange(direction: "back" | "forward") {
229 const { currentVersionIndex, versions } = versionHistory;
230 if (direction === "back" && currentVersionIndex > 0) {
974);
975
976function client() {
977 const path = window.location.pathname;
978 const root = createRoot(document.getElementById("root")!);
1010}
1011
1012function extractCodeFromFence(text: string): string {
1013 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1014 return htmlMatch ? htmlMatch[1].trim() : text;
1015}
1016
1017async function generateCode(prompt: string, currentCode: string) {
1018 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1019 if (starterPrompt) {
1060}
1061
1062export default async function cerebras_coder(req: Request): Promise<Response> {
1063 // Dynamic import for SQLite to avoid client-side import
1064 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1163 <meta property="og:site_name" content="Cerebras Coder">
1164 <meta property="og:url" content="https://cerebrascoder.com"/>
1165 <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."">
1166 <meta property="og:type" content="website">
1167 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">

clearMagentaFlyingfishmain.tsx1 match

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

discordWebhook2 file matches

@stevekrouse•Updated 3 weeks ago
Helper function to send Discord messages
tuna

tuna9 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.