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/$%7Bart_info.art.src%7D?q=function&page=1762&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 22813 results for "function"(4693ms)

portfolioSitemain.tsx14 matches

@shegosthato•Updated 6 months ago
4
5// Custom Icons
6function MoonIcon(props) {
7 return (
8 <svg
23}
24
25function SunIcon(props) {
26 return (
27 <svg
50}
51
52function GithubIcon(props) {
53 return (
54 <svg
65}
66
67function MailIcon(props) {
68 return (
69 <svg
85}
86
87function LinkedinIcon(props) {
88 return (
89 <svg
101
102// Custom Button Component
103function Button({
104 children,
105 variant = 'primary',
133
134// Custom Card Components
135function Card({ children, className = '' }) {
136 return (
137 <div className={`bg-white dark:bg-gray-800 rounded-lg shadow-md ${className}`}>
141}
142
143function CardHeader({ children, className = '' }) {
144 return (
145 <div className={`p-4 border-b border-gray-200 dark:border-gray-700 ${className}`}>
149}
150
151function CardTitle({ children, className = '' }) {
152 return (
153 <h3 className={`text-xl font-semibold text-gray-900 dark:text-gray-100 ${className}`}>
157}
158
159function CardContent({ children, className = '' }) {
160 return (
161 <div className={`p-4 ${className}`}>
166
167// Custom Switch Component
168function Switch({ checked, onCheckedChange }) {
169 return (
170 <button
190}
191
192function App() {
193 const [theme, setTheme] = useState<'light' | 'dark'>('light');
194
349}
350
351function client() {
352 createRoot(document.getElementById("root")).render(<App />);
353}
354if (typeof document !== "undefined") { client(); }
355
356export default async function server(request: Request): Promise<Response> {
357 return new Response(`
358 <!DOCTYPE html>

Albertmain.tsx11 matches

@jidun•Updated 6 months ago
153 const typingIndicator = document.querySelector('.typing-indicator');
154
155 function addMessage(content, type) {
156 const messageElement = document.createElement('div');
157 messageElement.classList.add('message', type);
161 }
162
163 function loadChatHistories() {
164 try {
165 const savedChatsRaw = localStorage.getItem('chatHistories');
167
168 chatHistorySelect.innerHTML = '';
169 savedChats.forEach(function(chat, index) {
170 const option = document.createElement('option');
171 option.value = index;
178 }
179
180 function saveChat() {
181 try {
182 const chatName = prompt('Enter a name for this chat history:') || ('Chat ' + Date.now());
183 const messages = Array.from(chatMessages.children).map(function(msg) {
184 return {
185 content: msg.textContent,
200 }
201
202 function loadSelectedChat() {
203 try {
204 const selectedIndex = chatHistorySelect.value;
211 if (selectedChat) {
212 chatMessages.innerHTML = '';
213 selectedChat.messages.forEach(function(msg) {
214 addMessage(msg.content, msg.type === 'user' ? 'user-message' : 'ai-message');
215 });
221 }
222
223 function deleteSelectedChat() {
224 try {
225 const selectedIndex = chatHistorySelect.value;
239 }
240
241 async function sendMessage() {
242 const message = messageInput.value.trim();
243 if (!message) return;
270 loadButton.addEventListener('click', loadSelectedChat);
271 deleteButton.addEventListener('click', deleteSelectedChat);
272 messageInput.addEventListener('keypress', function(e) {
273 if (e.key === 'Enter') sendMessage();
274 });
308 } catch (error) {
309 console.error("OpenAI error:", error);
310 return c.json({ response: "Neural networks malfunctioning. Try again, human." });
311 }
312});

Ms_Spanglermain.tsx11 matches

@jidun•Updated 6 months ago
153 const typingIndicator = document.querySelector('.typing-indicator');
154
155 function addMessage(content, type) {
156 const messageElement = document.createElement('div');
157 messageElement.classList.add('message', type);
161 }
162
163 function loadChatHistories() {
164 try {
165 const savedChatsRaw = localStorage.getItem('chatHistories');
167
168 chatHistorySelect.innerHTML = '';
169 savedChats.forEach(function(chat, index) {
170 const option = document.createElement('option');
171 option.value = index;
178 }
179
180 function saveChat() {
181 try {
182 const chatName = prompt('Enter a name for this chat history:') || ('Chat ' + Date.now());
183 const messages = Array.from(chatMessages.children).map(function(msg) {
184 return {
185 content: msg.textContent,
200 }
201
202 function loadSelectedChat() {
203 try {
204 const selectedIndex = chatHistorySelect.value;
211 if (selectedChat) {
212 chatMessages.innerHTML = '';
213 selectedChat.messages.forEach(function(msg) {
214 addMessage(msg.content, msg.type === 'user' ? 'user-message' : 'ai-message');
215 });
221 }
222
223 function deleteSelectedChat() {
224 try {
225 const selectedIndex = chatHistorySelect.value;
239 }
240
241 async function sendMessage() {
242 const message = messageInput.value.trim();
243 if (!message) return;
270 loadButton.addEventListener('click', loadSelectedChat);
271 deleteButton.addEventListener('click', deleteSelectedChat);
272 messageInput.addEventListener('keypress', function(e) {
273 if (e.key === 'Enter') sendMessage();
274 });
308 } catch (error) {
309 console.error("OpenAI error:", error);
310 return c.json({ response: "Neural networks malfunctioning. Try again, human." });
311 }
312});

cerebras_codermain.tsx5 matches

@franklyc•Updated 6 months ago
6import { tomorrow } from "https://esm.sh/react-syntax-highlighter/dist/esm/styles/prism";
7
8function App() {
9 const [prompt, setPrompt] = useState("hello llamapalooza");
10 const [code, setCode] = useState("");
18 >(null);
19
20 async function handleSubmit(e: React.FormEvent) {
21 e.preventDefault();
22 setLoading(true);
97}
98
99function client() {
100 createRoot(document.getElementById("root")!).render(<App />);
101}
105}
106
107function extractCodeFromFence(text: string): string {
108 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
109 return htmlMatch ? htmlMatch[1].trim() : text;
110}
111
112export default async function server(req: Request): Promise<Response> {
113 if (req.method === "POST") {
114 const client = new Cerebras();

effortlessAquamarineHookwormmain.tsx8 matches

@nsafouane•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function ThemeToggle({ isDarkMode, toggleTheme }) {
6 return (
7 <div className="theme-toggle-container">
21}
22
23function BlogPost({ title, content, timestamp, author, preview = false }) {
24 const truncatedContent = preview
25 ? content.length > 200
49}
50
51function Navigation({ currentPage, setCurrentPage, isDarkMode, toggleTheme }) {
52 return (
53 <nav className="main-nav">
71}
72
73function HomePage({ posts, currentPage, setCurrentPage, totalPages }) {
74 return (
75 <div className="home-page">
110}
111
112function Dashboard({ postCount, totalViews, posts, fetchDashboardStats }) {
113 const [title, setTitle] = useState("");
114 const [content, setContent] = useState("");
257}
258
259function BlogApp() {
260 const [posts, setPosts] = useState([]);
261 const [dashboard, setDashboard] = useState({ postCount: 0, totalViews: 0 });
341}
342
343function client() {
344 createRoot(document.getElementById("root")).render(<BlogApp />);
345}
346if (typeof document !== "undefined") { client(); }
347
348export default async function server(request: Request): Promise<Response> {
349 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
350 const KEY = "effortlessAquamarineHookworm";

multilingualchatroommain.tsx9 matches

@lloydpearsoniv•Updated 6 months ago
93};
94
95function Banner({ message, isVisible, language }) {
96 if (!isVisible) return null;
97 return <div className="banner">{message[language] || message.en}</div>;
98}
99
100function UserList({ users, t }) {
101 return (
102 <div className="user-list">
113}
114
115function Sidebar({ users, language, handleLanguageChange, roomUrl, copyToClipboard, copied, t }) {
116 return (
117 <div className="sidebar">
149}
150
151function TypingIndicator({ typingUsers, t }) {
152 if (typingUsers.length === 0) return null;
153
164}
165
166function App() {
167 const [messages, setMessages] = useState([]);
168 const [inputMessage, setInputMessage] = useState("");
490}
491
492function client() {
493 createRoot(document.getElementById("root")).render(<App />);
494}
495if (typeof document !== "undefined") { client(); }
496
497export default async function server(request: Request): Promise<Response> {
498 const url = new URL(request.url);
499 const { blob } = await import("https://esm.town/v/std/blob");
508 const TIME_WINDOW = 60 * 1000; // 1 minute
509
510 async function checkRateLimit() {
511 const now = Date.now();
512 const rateLimit = await blob.getJSON(RATE_LIMIT_KEY) || { count: 0, timestamp: now };
523 }
524
525 async function translateText(text: string, targetLanguage: string, sourceLanguage: string): Promise<string> {
526 const cacheKey = `${KEY}_translation_${sourceLanguage}_${targetLanguage}_${text}`;
527 const cachedTranslation = await blob.getJSON(cacheKey);

scraper_templateREADME.md1 match

@lloydpearsoniv•Updated 6 months ago
133. Adjust the if statement to detect changes and update your blob
14
154. Craft a message to be sent with `sendNotification()` function

expositionAgencyPagemain.tsx3 matches

@bladesquad•Updated 6 months ago
54}
55
56function ExpolineParticipationForm() {
57 const [step, setStep] = useState(0);
58 const [formData, setFormData] = useState({
310}
311
312function client() {
313 createRoot(document.getElementById("root")).render(<ExpolineParticipationForm />);
314}
491`;
492
493export default async function server(request: Request): Promise<Response> {
494 return new Response(`
495 <html>

blueskymain.tsx1 match

@pomdtr•Updated 6 months ago
5const { author, name } = extractValInfo(import.meta.url);
6
7export async function forwarder(e: Email) {
8 let attachments: AttachmentData[] = [];
9 for (const f of e.attachments) {

Send_Errors_to_Emailmain.tsx1 match

@bmitchinson•Updated 6 months ago
1import { email } from "https://esm.town/v/std/email";
2
3export default async function server(request: Request): Promise<Response> {
4 // Retrieve secret from environment variables
5 const SECRET_KEY = Deno.env.get("ERROR_REPORT_SECRET");

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.