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=11&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 31569 results for "function"(1329ms)

reddit-checkerreddit-monitor.ts7 matches

@sunnyatlightswitchโ€ขUpdated 1 day ago
42 * Fetches recent posts from a subreddit
43 */
44async function fetchSubredditPosts(subreddit: string, limit: number = 25): Promise<RedditPost[]> {
45 try {
46 const url = `https://www.reddit.com/r/${subreddit}/new.json?limit=${limit}`;
70 * Checks if a post contains any of the specified keywords
71 */
72function containsKeywords(post: RedditPost, keywords: string[]): boolean {
73 const searchText = `${post.title} ${post.selftext}`.toLowerCase();
74 return keywords.some(keyword => searchText.includes(keyword.toLowerCase()));
78 * Formats a post for notification
79 */
80function formatPost(post: RedditPost, matchedKeywords: string[]): string {
81 const redditUrl = `https://www.reddit.com${post.permalink}`;
82 const createdDate = new Date(post.created_utc * 1000).toLocaleString();
101 * Gets the last checked timestamp from storage
102 */
103async function getLastChecked(): Promise<number> {
104 try {
105 const data = await blob.getJSON("reddit_monitor_last_checked");
113 * Saves the last checked timestamp to storage
114 */
115async function saveLastChecked(timestamp: number): Promise<void> {
116 await blob.setJSON("reddit_monitor_last_checked", { timestamp });
117}
118
119/**
120 * Main monitoring function
121 */
122export default async function() {
123 console.log(`๐Ÿ” Starting Reddit monitor for r/${CONFIG.subreddit}`);
124 console.log(`๐Ÿ“‹ Keywords: ${CONFIG.keywords.join(', ')}`);

agatha-proxymain.tsx2 matches

@sammeltassenโ€ขUpdated 1 day ago
10const manifestBaseUrl = "https://agatha.arch.be/data/json/";
11
12async function fetchJson(id: string) {
13 const headers = new Headers([
14 ["referer", "https://agatha.arch.be/"],
20}
21
22export default async function(req: Request): Promise<Response> {
23 const url = new URL(req.url);
24 const params = url.searchParams;

untitled-6415main.ts1 match

@joshbeckmanโ€ขUpdated 1 day ago
12const FAST_MODEL = 'claude-3-5-haiku-latest';
13
14export default async function handler(request: Request) {
15 if (request.method !== "POST") {
16 return Response.json({ message: "This endpoint responds to POST requests." }, {
1export default async function (req: Request): Promise<Response> {
2 // Handle CORS preflight requests
3 if (req.method === 'OPTIONS') {

kaymain.tsx23 matches

@legalโ€ขUpdated 1 day ago
13 * - Bilingual support (English/Spanish) for UI elements.
14 * - Built with 'npm:pdf.js-extract' for robust server-side PDF text extraction.
15 * - Serves both the interactive HTML UI and the backend API endpoint from a single Val Town function.
16 *
17 * Configuration for the application (like agent definitions, UI text, and application settings)
18 * is defined directly in the main function handler below.
19 *
20 * Assumes the 'openai' secret, containing your OpenAI API key, is set in your Val Town environment.
41}
42
43// --- HTML Generation Function (Glassmorphism UI) ---
44function generateHtmlShell(
45 initialUrl,
46 initialText,
308 let currentLocale = APP_CONFIG.default_language || 'en';
309
310 // --- Localization Functions ---
311 function translate(key, replacements = {}) {
312 let text = locales[currentLocale]?.[key] || locales['en']?.[key] || key;
313 for (const placeholder in replacements) {
317 }
318
319 function applyTranslations() {
320 document.querySelectorAll('[data-translate]').forEach(el => {
321 const key = el.getAttribute('data-translate');
341 }
342
343 function setLocale(locale) {
344 if (locales[locale]) {
345 currentLocale = locale;
351 }
352
353 function updateLocaleButtons() {
354 document.querySelectorAll('.lang-btn').forEach(btn => btn.classList.toggle('active', btn.dataset.lang === currentLocale));
355 const linkHtml = \`<a href="\${APP_CONFIG.footer_powered_by_url}" target="_top">\${APP_CONFIG.footer_powered_by_link_text}</a>\`;
386 const resultsContainer = document.getElementById('results-content-cards');
387
388 // --- UI Update Functions ---
389 function setLoadingState(isLoading) {
390 submitButton.disabled = isLoading;
391 if (isLoading) {
402 }
403
404 function displayError(messageKey, replacements = {}) {
405 const message = translate(messageKey, replacements);
406 errorContainer.textContent = message;
410 }
411
412 function clearResults() {
413 ANALYSIS_AGENTS.forEach(agent => {
414 if (agent.ui_display_info) {
431 }
432
433 function updateLoadingProgress(percentage, statusKey, agentName = '') {
434 progressBar.style.width = \`\${percentage}%\`;
435 let statusText = translate(statusKey);
440 }
441
442 // --- Result Rendering Functions ---
443 function renderAgentResult(agentId, agentResultData, agentConfig) {
444 const card = document.getElementById(\`card-\${agentId}\`);
445 const contentEl = document.getElementById(\`content-\${agentId}\`);
649
650// --- Main Request Handler (Server Code) ---
651export default async function(req: Request) {
652 // --- Dynamic Imports ---
653 const { OpenAI } = await import("https://esm.town/v/std/openai");
812
813 // --- Helper: Extract Text using pdf.js-extract ---
814 async function extractPdfTextNative(data: ArrayBuffer, fileName: string, log: LogEntry[]): Promise<string | null> {
815 const agent = "PDF Extraction Agent";
816 try {
827 }
828
829 // --- Helper Function: Call OpenAI API ---
830 async function callOpenAI(
831 openai: OpenAI,
832 systemPrompt: string,
861 }
862
863 // --- Helper Function: Traverse References ---
864 async function traverseReferences(references: Reference[], log: LogEntry[]): Promise<Reference[]> {
865 const agent = "Reference Traversal Agent";
866 log.push({ agent, type: "step", message: `Traversing ${references.length} potential reference URLs... ` });
888
889 // --- Main Agent Flow Logic ---
890 async function runAgentFlow(
891 input: { documentUrl?: string; documentText?: string; documentFile?: File },
892 log: LogEntry[],
PreactHooks

PreactHookshooks.js23 matches

@Teddy2100โ€ขUpdated 1 day ago
1// Custom Hooks
2export function useAtom(key, defaultValue) {
3 const getValue = JSON.parse(localStorage.getItem(key));
4 const nanoStore = atom(getValue || defaultValue);
5 nanoStore.listen(function(value, old) {
6 localStorage.setItem(key, JSON.stringify(value));
7 });
15}
16
17export function useConsole(tag, color) {
18 const key = `%c[${tag.toUpperCase()}]`;
19 const style = `color: ${color}; font-weight: bold;`;
20 const logFunction = (...data) => console.log(key, style, ...data);
21 logFunction.log = (...data) => console.log(key, style, ...data);
22 logFunction.error = (...data) => console.error(key, style, ...data);
23 logFunction.warn = (...data) => console.warn(key, style, ...data);
24 logFunction.info = (...data) => console.info(key, style, ...data);
25 return logFunction;
26}
27
28export function useEventListener(func, setup) {
29 const callback = useCallback(func, []);
30 const { parentElement, parentEvent, runOnMount } = setup;
31 useEffect(function mount() {
32 const ctrl = new AbortController();
33 if (runOnMount === true) callback(null);
36 signal: ctrl.signal,
37 });
38 return function unmount() {
39 ctrl.abort();
40 };
46}
47
48export function useLibrary(url, callback) {
49 const [lib, setLib] = useState(null);
50 useEffect(function() {
51 // alert("useLibrary()");
52 if (!lib) return import(url).then(setLib);
56}
57
58export function useMQTT(setup) {
59 let connection = null;
60 return useEffect(() => {
61 const task = setTimeout(async function() {
62 const token = "b97eb957-1db6-4d2f-aa2e-1df60e99834c";
63 const mqtt = (await import("https://esm.sh/mqtt")).default; // mqtt/dist/mqtt.min.js
69 connection.on("end", () => setup.stop());
70 }, 250);
71 return function() {
72 if (connection) connection.end(true);
73 if (task) clearTimeout(task);
76}
77
78export function useNetworkStatus() {
79 const ctrl = new AbortController();
80 const [isOnline, setIsOnline] = useState(navigator.onLine);
88}
89
90export function useStyles(...args) {
91 return args.filter(Boolean).map(function(data) {
92 const isObject = typeof data == "object";
93 if (isObject) return css(data);
96}
97
98export function useSet(initialValues = []) {
99 const [set, setSet] = useState(() => new Set(initialValues));
100 const add = value => {
118}
119
120export function useObject(initial = {}) {
121 const [_, setObj] = useState(); // dummy to trigger updates
122 const ref = useRef({ ...initial });
150
151// Custom Helpers
152export function tryCatch(attempt, fail) {
153 try {
154 return attempt ? attempt() : true;

SON-GOKUREADME.md2 matches

@Itssongokuโ€ขUpdated 1 day ago
27- **Export/Import**: Backup and restore your BIN collection as JSON
28- **Local Storage**: Secure browser-based storage with automatic saving
29- **Copy Functions**: Copy BIN only or full card data with one click
30- **Generate Integration**: Quick access to card generator with selected BIN
31- **Featured BINs**: Pre-loaded collection with premium BIN examples
124โ”‚ โ”‚ โ”œโ”€โ”€ Card3D.tsx # 3D card component
125โ”‚ โ”‚ โ”œโ”€โ”€ BulkResults.tsx # Bulk generation results
126โ”‚ โ”‚ โ”œโ”€โ”€ BinLookup.tsx # BIN lookup functionality
127โ”‚ โ”‚ โ”œโ”€โ”€ BINExtrap.tsx # BIN collection management
128โ”‚ โ”‚ โ”œโ”€โ”€ TelegramLinks.tsx # Telegram channel and creator links

SON-GOKUCardGenerator.tsx1 match

@Itssongokuโ€ขUpdated 1 day ago
22}
23
24export default function CardGenerator({ onCardGenerated, onBulkGenerated, onGenerating }: CardGeneratorProps) {
25 const [selectedType, setSelectedType] = useState<CardType>('visa');
26 const [customBin, setCustomBin] = useState('');

SON-GOKUBulkResults.tsx3 matches

@Itssongokuโ€ขUpdated 1 day ago
11}
12
13export default function BulkResults({ cards, totalGenerated, generationTime, mode, onClose }: BulkResultsProps) {
14 const [selectedFormat, setSelectedFormat] = useState<'csv' | 'json' | 'text' | 'list'>('list');
15 const [currentPage, setCurrentPage] = useState(1);
261}
262
263export default function BulkResults({ result, onClose }: BulkResultsProps) {
264 const [selectedFormat, setSelectedFormat] = useState<'csv' | 'json' | 'text' | 'list'>('list');
265 const [currentPage, setCurrentPage] = useState(1);
541}
542
543export default function BulkResults({ cards, totalGenerated, generationTime, mode, onClose }: BulkResultsProps) {
544 const [selectedFormat, setSelectedFormat] = useState<'csv' | 'json' | 'text' | 'list'>('list');
545 const [currentPage, setCurrentPage] = useState(1);

SON-GOKUindex.ts4 matches

@Itssongokuโ€ขUpdated 1 day ago
58 }
59
60 // Import validation function
61 const { validateCardNumber } = await import("../shared/utils.ts");
62 const isValid = validateCardNumber(cardNumber);
80 }
81
82 // Import generation functions
83 const {
84 generateCardData,
183 }
184
185 // Import validation function
186 const { validateBulkFormat, getFormatExamples } = await import("../shared/utils.ts");
187
209 }
210
211 // Import validation function
212 const { validateBin, detectCardType } = await import("../shared/utils.ts");
213
tuna

tuna9 file matches

@jxnblkโ€ขUpdated 2 weeks ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouserโ€ขUpdated 2 months 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.