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=862&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 10292 results for "function"(903ms)

icsviewermain.tsx6 matches

@prashamtrivedi•Updated 4 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function generateRandomColor() {
6 const hue = Math.floor(Math.random() * 360);
7 return `hsl(${hue}, 70%, 50%)`;
8}
9
10function parseICSDate(dateString: string): Date {
11 if (!dateString) return new Date();
12
36}
37
38function parseICSContent(content: string) {
39 try {
40 console.log("Parsing ICS content:", content);
75}
76
77function Calendar() {
78 const [events, setEvents] = useState([
79 {
309}
310
311function client() {
312 createRoot(document.getElementById("root")).render(<Calendar />);
313}
315if (typeof document !== "undefined") { client(); }
316
317export default async function server(request: Request): Promise<Response> {
318 return new Response(`
319 <html>

opengraphImageCreatormain.tsx3 matches

@itseieio•Updated 4 months ago
48}
49
50function App() {
51 const [backgroundImage, setBackgroundImage] = useState<string | null>(null);
52 const [backgroundConfig, setBackgroundConfig] = useState<BackgroundConfig>({
410}
411
412function client() {
413 createRoot(document.getElementById("root")).render(<App />);
414}
415if (typeof document !== "undefined") { client(); }
416
417export default async function server(request: Request): Promise<Response> {
418 return new Response(`
419 <html>

opengraphImageCreatormain.tsx3 matches

@stevekrouse•Updated 4 months ago
48}
49
50function App() {
51 const [backgroundImage, setBackgroundImage] = useState<string | null>(null);
52 const [backgroundConfig, setBackgroundConfig] = useState<BackgroundConfig>({
410}
411
412function client() {
413 createRoot(document.getElementById("root")).render(<App />);
414}
415if (typeof document !== "undefined") { client(); }
416
417export default async function server(request: Request): Promise<Response> {
418 return new Response(`
419 <html>

SermonGPTUImain.tsx5 matches

@manyone•Updated 4 months ago
78const endpointURL = "https://mjweaver01-sermongptapi.web.val.run";
79
80function App() {
81 const [question, setQuestion] = useState("");
82 const [response, setResponse] = useState("");
617}
618
619function client() {
620 const root = document.getElementById("root");
621 if (!root) throw new Error("Root element not found");
633}
634
635export default async function server(request: Request): Promise<Response> {
636 const { blob } = await import("https://esm.town/v/std/blob");
637
664}
665
666// Helper function to determine season based on current date
667function getSeason(date: Date): string {
668 const month = date.getMonth();
669 switch (true) {

emojiVectorEmbeddingsmain.tsx11 matches

@maxm•Updated 4 months ago
15]);
16// Get embedding for a single emoji
17async function getEmbedding(emoji: string): Promise<number[]> {
18 const result = await openai.embeddings.create({
19 input: emoji,
23}
24
25async function loadEmoji(e: string) {
26 const result = await sqlite.execute("SELECT 1 FROM emojis WHERE emoji = ?", [e]);
27 if (result.rows.length !== 0) {
43}
44
45async function loadAllEmojis() {
46 const batchSize = 20;
47 for (let i = 0; i < emojis.length; i += batchSize) {
54// await loadAllEmojis();
55
56export async function searchEmojis(query: string): Promise<string[]> {
57 return (await sqlite.execute(
58 `SELECT emoji
70// };
71
72// // Function to get all emojis (this is a subset for demonstration)
73
74// // Calculate cosine similarity between two vectors
75// function cosineSimilarity(vecA: number[], vecB: number[]): number {
76// const dotProduct = vecA.reduce((sum, a, i) => sum + a * vecB[i], 0);
77// const magnitudeA = Math.sqrt(vecA.reduce((sum, a) => sum + a * a, 0));
81
82// // Get embedding for a single emoji
83// async function getEmbedding(emoji: string): Promise<number[]> {
84// const result = await openai.embeddings.create({
85// input: emoji,
90
91// // Get embeddings for all emojis
92// async function getAllEmbeddings(): Promise<EmojiEmbedding[]> {
93// const emojis = getAllEmojis();
94// const embeddings: EmojiEmbedding[] = [];
116
117// // Find nearest neighbors for a given emoji
118// function findNearestNeighbors(
119// targetEmbedding: number[],
120// allEmbeddings: EmojiEmbedding[],
130// }
131
132// // Main function to demonstrate usage
133// async function main() {
134// try {
135// console.log("Getting embeddings for all emojis...");

SermonGPTAPImain.tsx2 matches

@mjweaver01•Updated 4 months ago
1export default async function server(request: Request): Promise<Response> {
2 const { blob } = await import("https://esm.town/v/std/blob");
3 const KEY = "sermon_generator";
182}
183
184function getSeason(date: Date): string {
185 const month = date.getMonth();
186 switch (true) {

randoDiscmain.tsx8 matches

@stevekrouse•Updated 4 months ago
6console.log(AnimatePresence);
7
8function ErrorMessage({ message }) {
9 return (
10 <div className="min-h-screen bg-gray-100 flex items-center justify-center p-4">
17}
18
19function Loader() {
20 return (
21 <div className="flex flex-col items-center justify-center min-h-screen bg-gray-100">
57}
58
59function shuffleArray(array) {
60 const shuffledArray = [...array];
61 for (let i = shuffledArray.length - 1; i > 0; i--) {
66}
67
68function RecordCard() {
69 const [records, setRecords] = useState([]);
70 const [currentRecordIndex, setCurrentRecordIndex] = useState(0);
77
78 useEffect(() => {
79 async function fetchReleases() {
80 try {
81 const response = await fetch("https://ashryanio-getallreleasesfromdiscogs.web.val.run");
130
131 useEffect(() => {
132 function handleKeydown(event) {
133 if (
134 event.target.tagName.toLowerCase() !== "input"
340}
341
342function client() {
343 const rootElement = document.getElementById("root");
344 if (!rootElement) {
359}
360
361export default async function server(request: Request): Promise<Response> {
362 const url = new URL(request.url);
363

Ms_Spanglermain.tsx11 matches

@arthrod•Updated 4 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});

gameplay_agentmain.tsx5 matches

@arthrod•Updated 4 months ago
83 /** The name of the agent. */
84 agentname: string;
85 /** The agent function. */
86 agent: Connect4Agent<T> | Connect4AsyncAgent<T>;
87}
99 /** The name of the agent. */
100 agentname: string;
101 /** The agent function. */
102 agent: PokerAgent<T> | PokerAsyncAgent<T>;
103}
121 * a variety of different http server libraries.
122 *
123 * To see how to write the agent functions,
124 * see the {@link Connect4Agent} and {@link PokerAgent}
125 *
134 * used with an http server that supports the fetch interface.
135 */
136export function agentHandler<
137 T extends Json = Json,
138>(
139 agents: AgentSpec<T>[],
140): (req: Request) => Promise<Response> {
141 return async function(request: Request): Promise<Response> {
142 if (request.method === "GET") {
143 return Response.json({

whoIsHiringmain.tsx3 matches

@dxaginfo•Updated 4 months ago
7import About from "https://esm.town/v/vawogbemi/whoIsHiringAbout";
8
9function App() {
10 const tabs = { "/": "Home", "/about": "About" };
11 const [activeTab, setActiveTab] = useState("/");
335}
336
337function ServerApp() {
338 return (
339 <html>
358}
359
360export default async function(req: Request): Promise<Response> {
361 const url = new URL(req.url);
362 if (url.pathname === "/api/stories") {

getFileEmail4 file matches

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

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago