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/$%7Bsuccess?q=function&page=2346&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 28949 results for "function"(3472ms)

simpleChatAPImain.tsx3 matches

@haeliyan•Updated 6 months ago
3import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
4
5function App() {
6 const [messages, setMessages] = useState([]);
7 const [newMessage, setNewMessage] = useState("");
243}
244
245function client() {
246 createRoot(document.getElementById("root")).render(<App />);
247}
248if (typeof document !== "undefined") { client(); }
249
250export default async function server(request: Request): Promise<Response> {
251 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
252 const KEY = "simpleChatAPI";

SermonGPTUImain.tsx5 matches

@manyone•Updated 6 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) {

legendaryRoseSwordfishmain.tsx3 matches

@ronr•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [participants, setParticipants] = useState([]);
7 const [logs, setLogs] = useState([]);
217}
218
219function client() {
220 createRoot(document.getElementById("root")).render(<App />);
221}
225}
226
227export default async function server(req: Request): Promise<Response> {
228 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
229 const SCHEMA_VERSION = 3;

linkInBioTemplatemain.tsx1 match

@dakota•Updated 6 months ago
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(

emojiVectorEmbeddingsmain.tsx11 matches

@maxm•Updated 6 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...");

fairAquaHeronmain.tsx1 match

@pomdtr•Updated 6 months ago
1export default async function() {
2 const body = await Deno.readFile("/opt/render/project/src/guest/index.ts");
3 return new Response(body);

SermonGPTAPImain.tsx2 matches

@mjweaver01•Updated 6 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) {

linearRegressionmain.tsx4 matches

@bao•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function linearRegression(x: number[], y: number[]) {
6 const n = x.length;
7
22}
23
24function App() {
25 const [inputData, setInputData] = useState('');
26 const [result, setResult] = useState<{ slope?: number; intercept?: number }>({});
107}
108
109function client() {
110 createRoot(document.getElementById("root")).render(<App />);
111}
112if (typeof document !== "undefined") { client(); }
113
114export default async function server(request: Request): Promise<Response> {
115 return new Response(`
116 <html>

blob_adminmain.tsx8 matches

@dakota•Updated 6 months ago
13}
14
15function Tooltip({ children, content }: TooltipProps) {
16 const [isVisible, setIsVisible] = useState(false);
17 const tooltipRef = useRef<HTMLDivElement>(null);
52}
53
54function formatBytes(bytes: number, decimals = 2) {
55 if (bytes === 0) return "0 Bytes";
56 const k = 1024;
61}
62
63function copyToClipboard(text: string) {
64 navigator.clipboard.writeText(text).then(() => {
65 console.log("Text copied to clipboard");
69}
70
71function ActionMenu({ blob, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
72 const [isOpen, setIsOpen] = useState(false);
73 const menuRef = useRef(null);
76
77 useEffect(() => {
78 function handleClickOutside(event) {
79 if (menuRef.current && !menuRef.current.contains(event.target)) {
80 event.stopPropagation();
158}
159
160function BlobItem({ blob, onSelect, isSelected, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
161 const [isLoading, setIsLoading] = useState(false);
162 const decodedKey = decodeURIComponent(blob.key);
219}
220
221function App({ initialEmail, initialProfile }) {
222 const encodeKey = (key: string) => encodeURIComponent(key);
223 const decodeKey = (key: string) => decodeURIComponent(key);
645}
646
647function client() {
648 const initialEmail = document.getElementById("root").getAttribute("data-email");
649 const initialProfile = JSON.parse(document.getElementById("root").getAttribute("data-profile"));

dailyThoughtPromptmain.tsx1 match

@chrisputnam9•Updated 6 months ago
4import { email } from "https://esm.town/v/std/email";
5
6export default async function(interval: Interval) {
7 const TOPICS = [
8 "Productivity",
tuna

tuna9 file matches

@jxnblk•Updated 17 hours ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
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.