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=2184&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 30525 results for "function"(5335ms)

reactWeatherDashboardmain.tsx4 matches

@nik•Updated 3 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function WeatherDashboard() {
6 const [location, setLocation] = useState({ latitude: 40.7128, longitude: -74.0060 }); // Default to NYC
7 const [weather, setWeather] = useState(null);
28
29 useEffect(() => {
30 async function fetchWeather() {
31 try {
32 const response = await fetch(
152};
153
154function client() {
155 createRoot(document.getElementById("root")).render(<WeatherDashboard />);
156}
157if (typeof document !== "undefined") { client(); }
158
159export default async function server(request: Request): Promise<Response> {
160 return new Response(`
161 <html>

OpenTelemetryCollectorindex.ts2 matches

@fiberplane•Updated 3 months ago
47
48/**
49 * Export a function that wraps the incoming request,
50 * then injects the Deno env vars into the Hono app befoe
51 * executing the api entrypoint (`app.fetch`)
52 */
53export default async function(req: Request): Promise<Response> {
54 const env = Deno.env.toObject();
55 // NOTE - Adding the entire env object will also expose the following values to your api handlers:

ecstaticSalmonOrangutanmain.tsx7 matches

@keval•Updated 3 months ago
4import { marked } from "https://esm.sh/marked@9.0.0";
5
6function App() {
7 const [messages, setMessages] = useState([
8 {
9 role: 'assistant',
10 content: 'šŸ‘‹ Hello! I\'m an advanced AI assistant. I can help you with various tasks, answer questions, and even assist with code snippets!\n\nFeel free to explore my capabilities:\n\n```javascript\n// Try asking me about coding\nfunction exampleAIHelp() {\n return "AI is here to assist you!";\n}\n```\n\nšŸš€ What would you like to know today?'
11 }
12 ]);
49 const renderMarkdown = (content) => {
50 const markedContent = marked.parse(content, {
51 highlight: function(code, lang) {
52 return `<pre><code class="language-${lang || 'plaintext'}">${escapeHtml(code)}</code></pre>`;
53 }
164}
165
166function client() {
167 createRoot(document.getElementById("root")).render(<App />);
168}
169if (typeof document !== "undefined") { client(); }
170
171export default async function server(request: Request): Promise<Response> {
172 if (request.method === "POST" && new URL(request.url).pathname === "/chat") {
173 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
199 ];
200
201 // Advanced Fallback Generation Function
202 function generateFallbackResponse(userInput: string): string {
203 const keywords = userInput.toLowerCase().split(/\s+/);
204

OpenTelemetryCollectoropenapi.ts1 match

@fiberplane•Updated 3 months ago
3 * with a better experience
4 */
5export function getOpenAPISpec() {
6 return {
7 openapi: "3.0.0",

OpenTelemetryCollectorqueries.ts1 match

@fiberplane•Updated 3 months ago
8 * @TODO - Need to implement `end_time` column for this query to work
9 */
10export function findTraces(db: DBType) {
11 const REFERENCE QUERY = `
12SELECT trace_id, MAX(end_time) as end_time

loopyLettersmain.tsx5 matches

@alexwein•Updated 3 months ago
30};
31
32function InstructionsModal({ onClose }) {
33 return (
34 <div className="modal-overlay">
50}
51
52function GameOverModal({ elapsedTime, onPlayAgain }) {
53 return (
54 <div className="modal-overlay">
62}
63
64function App() {
65 const [wordlist, setWordlist] = useState([]);
66 const [currentWordIndex, setCurrentWordIndex] = useState(0);
358}
359
360function client() {
361 createRoot(document.getElementById("root")).render(<App />);
362}
366}
367
368export default async function server(request: Request): Promise<Response> {
369 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
370

blob_adminmain.tsx8 matches

@kaleidawave•Updated 3 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"));

redditAlertREADME.md2 matches

@Daniyal_007•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({

redditAlertmain.tsx1 match

@Daniyal_007•Updated 3 months ago
12const isProd = true;
13
14export async function redditAlert({ lastRunAt }: Interval) {
15 if (!SERP_API_KEY || !DISCORD_API_KEY) {
16 console.error("Missing SERP_API_KEY or Discord webhook URL. Exiting.");

redditAlertREADME.md2 matches

@Ali12•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({
tuna

tuna9 file matches

@jxnblk•Updated 1 week 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.