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=1179&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 18147 results for "function"(4491ms)

photoEditingAIAppmain.tsx3 matches

@roysarajit143•Updated 3 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function App() {
6 const [uploadedImage, setUploadedImage] = useState(null);
7 const [generatedImage, setGeneratedImage] = useState(null);
137}
138
139function client() {
140 createRoot(document.getElementById("root")).render(<App />);
141}
142if (typeof document !== "undefined") { client(); }
143
144export default async function server(request: Request): Promise<Response> {
145 const { blob } = await import("https://esm.town/v/std/blob");
146 const { OpenAI } = await import("https://esm.town/v/std/openai");

originalTomatoLynxmain.tsx11 matches

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

cerebras_codermain.tsx11 matches

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

sipCalculatormain.tsx3 matches

@roysarajit143•Updated 3 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function SIPCalculator() {
6 const [monthlyInvestment, setMonthlyInvestment] = useState(5000);
7 const [expectedReturn, setExpectedReturn] = useState(12);
73}
74
75function client() {
76 createRoot(document.getElementById("root")).render(<SIPCalculator />);
77}
78if (typeof document !== "undefined") { client(); }
79
80export default async function server(request: Request): Promise<Response> {
81 return new Response(`
82 <html>

reactPinterestClonemain.tsx7 matches

@Ronu12_05•Updated 3 months ago
13}
14
15function Logo() {
16 return (
17 <div className="logo-container">
28}
29
30function BlogPostCard({ post, onDelete }) {
31 return (
32 <div className="blog-post-card">
50}
51
52function BlogPostForm({ onSubmit }) {
53 const [title, setTitle] = useState('');
54 const [content, setContent] = useState('');
111}
112
113function App() {
114 const [posts, setPosts] = useState<BlogPost[]>([]);
115 const [error, setError] = useState<string | null>(null);
116
117 useEffect(() => {
118 async function fetchPosts() {
119 try {
120 const response = await fetch('/get-posts');
220}
221
222function client() {
223 createRoot(document.getElementById("root")).render(<App />);
224}
225if (typeof document !== "undefined") { client(); }
226
227export default async function server(request: Request): Promise<Response> {
228 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
229 const KEY = "reactPinterestClone";

replaceEmojisWithImagesmain.tsx1 match

@tr3ntg•Updated 3 months ago
3const emojiHostBaseUrl = "https://majestic-sundae-60b0a3.netlify.app";
4
5export default async function replaceEmojisWithImages(html: string): Promise<string> {
6 let unemojiHtml = unemojify(html);
7

audioManagermain.tsx8 matches

@Foji•Updated 3 months ago
43
44export class AudioManager {
45 constructor(apiKey=null, uploadFunction = null, downloadFunction = null) {
46 this.openai = new OpenAI(apiKey);
47 this.uploadFunction = uploadFunction || this.blobUpload;
48 }
49
50 // valtown blob upload function
51 async blobUpload(buffer, key) {
52 try {
111 console.log(blob instanceof Blob); // Should be true
112 console.log(typeof blob); // Should be true
113 console.log(typeof blob.arrayBuffer); // Should be "function"
114 return blob;
115 }
164
165 async uploadAudio(blob, key) {
166 if (!this.uploadFunction) {
167 console.error("No upload function provided to upload audio");
168 return null;
169 }
170
171 // const buffer = await blob.arrayBuffer();
172 const res = await this.uploadFunction(blob, key);
173 if (res) {
174 return res;
180
181
182 // Function to fetch audio data and return as ArrayBuffer
183 async getAudioBuffer(url) {
184 const response = await fetch(url);

btcPriceAlertmain.tsx2 matches

@bhavesh108•Updated 3 months ago
6const THRESHOLD = 0.1; // 10 %
7
8async function welcome(btcPrice: number) {
9 let formattedBtcPrice = formatAsCurrency(btcPrice);
10 let text = `The BTC price is now ${formattedBtcPrice}.
18}
19
20export async function btcPriceAlert() {
21 let btcPrice = await currency("usd", "btc");
22 const lastBtcPrice: number | undefined = await blob.getJSON("lastBtcPrice");

filemain.tsx4 matches

@loading•Updated 3 months ago
22}
23
24function getFileEmote(file: RTCFile) {
25 const fileType = file.type.split("/")[0];
26 switch (fileType) {
59const buttonHover = Object.values(ButtonHover)[randomIndex];
60
61function App() {
62 const [showModal, setShowModal] = useState(false);
63 const [peerId, setPeerId] = useState("");
376}
377
378function client() {
379 render(<App />, document.getElementById("root")!);
380}
415`;
416
417export default async function server(request: Request): Promise<Response> {
418 const url = new URL(request.url);
419

bombCycloneOutageTrackermain.tsx7 matches

@andreterron•Updated 3 months ago
16import { PSE_OUTAGES_TABLE_NAME } from "https://esm.town/v/andreterron/PSEoutages";
17
18function formatXAxis(tickItem: number | Date) {
19 return format(tickItem, "MMM d h:mmaaa");
20}
21
22function App() {
23 const [outageData, setOutageData] = useState([]);
24 // const [regressionData, setRegressionData] = useState<any[]>([]);
25
26 useEffect(() => {
27 async function fetchData() {
28 const response = await fetch("/outages");
29 const json = await response.json();
46 });
47 });
48 function timeToX(time: number) {
49 return (time - firstEntry.time) / 1000 / 60 / 60 / 24;
50 }
51 function xToTime(x: number) {
52 return x * 60 * 60 * 24 * 1000 + firstEntry.time;
53 }
188}
189
190async function client() {
191 const ReactDOM = await import("https://esm.sh/react-dom@18");
192 console.log(ReactDOM);
196if (typeof document !== "undefined") { client(); }
197
198export default async function server(request: Request): Promise<Response> {
199 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
200

getFileEmail4 file matches

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

tuna8 file matches

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