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=1265&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 19140 results for "function"(2125ms)

openaiproxymain.tsx2 matches

@charmaine•Updated 3 months ago
17
18type User = { id: string; username: string; tier: string };
19export default async function(req: Request): Promise<Response> {
20 // Ensure only allowed pathnames are used
21 const { pathname, search } = new URL(req.url);
82
83// Free users are limited to gpt-4o-mini. Limit pro users to 10 expensive model requests.
84async function limitFreeModel(req: Request, user: User) {
85 const input = await req.json();
86 let model = "gpt-4o-mini";

sweetPeachEarthwormmain.tsx11 matches

@c0dergamer•Updated 3 months ago
25const PoweredByInfo = "";
26
27function Hero({
28 prompt,
29 setPrompt,
48
49 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
50 Turn your ideas into fully functional apps in{" "}
51 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
52 less than a second
132}
133
134function App() {
135 const previewRef = React.useRef<HTMLDivElement>(null);
136 const [prompt, setPrompt] = useState("");
187 });
188
189 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
190 setLoading(true);
191 setTimeout(() => handleSubmit(promptItem.prompt), 0);
192 }
193
194 async function handleSubmit(e: React.FormEvent | string) {
195 if (typeof e !== "string") {
196 e.preventDefault();
243 }
244
245 function handleVersionChange(direction: "back" | "forward") {
246 const { currentVersionIndex, versions } = versionHistory;
247 if (direction === "back" && currentVersionIndex > 0) {
932);
933
934function client() {
935 const path = window.location.pathname;
936 const root = createRoot(document.getElementById("root")!);
968}
969
970function extractCodeFromFence(text: string): string {
971 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
972 return htmlMatch ? htmlMatch[1].trim() : text;
973}
974
975async function generateCode(prompt: string, currentCode: string) {
976 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
977 if (starterPrompt) {
1018}
1019
1020export default async function cerebras_coder(req: Request): Promise<Response> {
1021 // Dynamic import for SQLite to avoid client-side import
1022 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1121 <meta property="og:site_name" content="Cerebras Coder">
1122 <meta property="og:url" content="https://cerebrascoder.com"/>
1123 <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."">
1124 <meta property="og:type" content="website">
1125 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">

decoratorsExamplemain.tsx4 matches

@stevekrouse•Updated 3 months ago
1function logged() {
2 return function(
3 target: any,
4 context: ClassMethodDecoratorContext,
5 ) {
6 const methodName = String(context.name);
7 return function(this: any, ...args: any[]) {
8 console.log(`Calling method ${methodName}`);
9 return target.call(this, ...args);
19}
20
21export default function testDecorators() {
22 const instance = new TestClass();
23 return instance.greet("Val Town");

boggleSolverTowniemain.tsx5 matches

@alexwein•Updated 3 months ago
22}
23
24function buildTrie(words: string[]): TrieNode {
25 const root = new TrieNode();
26 for (const word of words) {
37}
38
39function findBoggleWords(board: { x: number; y: number; letter: string }[], wordList: string[]): string[] {
40 const trie = buildTrie(wordList);
41 const foundWords = new Set<string>();
55 ];
56
57 function isValidCell(x: number, y: number): boolean {
58 return x >= 0 && x < cols && y >= 0 && y < rows;
59 }
60
61 function dfs(x: number, y: number, node: TrieNode, visited: Set<string>, currentWord: string) {
62 // Out of bounds or already visited cell
63 const cellKey = `${x},${y}`;
99}
100
101export default function boggleSolver(
102 board: { x: number; y: number; letter: string }[],
103 wordList: string[] = wordListCache || [],

mileiShowGraphmain.tsx3 matches

@stevekrouse•Updated 3 months ago
13} from "https://esm.sh/recharts@2.7.2?deps=react@18.2.0";
14
15function App({ tweetData }) {
16 const [selectedTweetId, setSelectedTweetId] = useState("1852746483306492004");
17 const [filteredData, setFilteredData] = useState([]);
123}
124
125function client() {
126 const tweetData = JSON.parse(document.getElementById("tweet-data").textContent);
127 createRoot(document.getElementById("root")).render(<App tweetData={tweetData} />);
129if (typeof document !== "undefined") { client(); }
130
131export default async function server(request: Request): Promise<Response> {
132 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
133

cerebras_codermain.tsx11 matches

@Devdezuk005g•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">

cerebras_codermain.tsx11 matches

@Mrboss•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">

TaskManagerAppmain.tsx6 matches

@arfan•Updated 3 months ago
25
26/** A form to create or edit a single task (used both stand-alone and in a modal). */
27function TaskForm({
28 task,
29 onSave,
179
180/** A table that displays tasks. */
181function TaskList({
182 tasks,
183 onEditClick,
323}
324
325function SettingsOverlay({
326 columnWidths,
327 onColumnWidthChange,
363}
364
365function App() {
366 const [tasks, setTasks] = useState<Task[]>([]);
367 const [editingTask, setEditingTask] = useState<Task | undefined>(undefined);
597}
598
599function client() {
600 const rootElement = document.getElementById("root");
601 if (rootElement) {
605if (typeof document !== "undefined") { client(); }
606
607export default async function server(request: Request): Promise<Response> {
608 return new Response(
609 `

easyAQImain.tsx1 match

@svbasi•Updated 3 months ago
7const cacheKey = location => "easyAQI_locationID_cache_" + encodeURIComponent(location);
8
9export async function easyAQI({ location }: {
10 location: string;
11}) {

redditAlertREADME.md2 matches

@svbasi•Updated 3 months ago
42 - Value: Your SERP API key.
43
44Without this key, the val will not function correctly.
45
46---
58- Key: `mentionsDiscord`
59- Value: Your Discord webhook URL.
60Notifications will be sent using this function:
61```
62 await discordWebhook({

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 3 weeks 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": "*",