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/$2?q=function&page=36&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 29280 results for "function"(925ms)

FileDumpThingutils.ts1 match

@sacredlindsay•Updated 15 hours ago
13 * Simple and reliable approach to detect binary files
14 */
15export function isTextContent(buffer: Uint8Array): boolean {
16 // Convert buffer to string and check for null bytes
17 const str = new TextDecoder().decode(buffer);

FileDumpThingutils.ts1 match

@sacredlindsay•Updated 15 hours ago
6 * @returns Promise resolving to complete buffer of stdin data
7 */
8export async function readStdinToBuffer(): Promise<Uint8Array> {
9 try {
10 const buf = new Uint8Array(1024);

FileDumpThingupload.ts2 matches

@sacredlindsay•Updated 15 hours ago
5const API_URL = `https://filedumpthing.val.run/api/upload`;
6
7async function main() {
8 try {
9 // Get filename from args or use a temporary name (will be replaced with appropriate extension)
71}
72
73// Run the main function only once
74if (import.meta.main) {
75 main();

FileDumpThingREADME.md1 match

@sacredlindsay•Updated 15 hours ago
55
56- **Shared**: Code shared between frontend and backend
57 - `utils.ts`: Shared types and utility functions
58 - `mimetype.ts`: MIME type detection for various file formats
59

FileDumpThingmimetype.ts2 matches

@sacredlindsay•Updated 15 hours ago
22
23// Helper to get mime type from filename
24export function getMimeType(fileName: string): string {
25 const fileExtension = fileName.split('.').pop()?.toLowerCase() || '';
26 return mimeTypes[fileExtension] || 'application/octet-stream';
28
29// Get MIME type with special handling for video files
30export function getContentTypeHeaders(key: string): Record<string, string> {
31 const fileExtension = key.split('.').pop()?.toLowerCase() || '';
32 const mimeType = getMimeType(key);

FileDumpThingFileDumper.tsx1 match

@sacredlindsay•Updated 15 hours ago
5import { ContentState } from "../../shared/utils.ts";
6
7export function FileDumper() {
8 const [content, setContent] = useState<ContentState>({ type: "text", value: "" });
9 const [uploadedUrl, setUploadedUrl] = useState("");

FileDumpThingApp.tsx1 match

@sacredlindsay•Updated 15 hours ago
3import { FileDumper } from "./FileDumper.tsx";
4
5export function App() {
6 return (
7 <div>

xxxclearinghouse_validatorindex.ts18 matches

@toowired•Updated 15 hours ago
62};
63
64// Main validation function
65export default async function validateUserRequest(requestData: any): Promise<ValidationResult> {
66 try {
67 // Input sanitization and basic validation
121
122// Input sanitization
123function sanitizeInput(requestData: any): any {
124 const sanitized = {
125 query: '',
181
182// Rate limiting check
183async function checkRateLimit(userId: string): Promise<ValidationResult> {
184 try {
185 const rateLimitKey = `rate_limit_${userId}`;
228
229// Query validation
230function validateQuery(query: string): ValidationResult {
231 // Check length
232 if (query.length < CONFIG.MIN_QUERY_LENGTH) {
270
271// Website validation
272function validateWebsites(websites: string[]): ValidationResult {
273 if (websites.length === 0) {
274 return {
302
303// Discount validation
304function validateDiscount(minimumDiscount: number): ValidationResult {
305 if (minimumDiscount < CONFIG.MIN_DISCOUNT || minimumDiscount > CONFIG.MAX_DISCOUNT) {
306 return {
314
315// Content appropriateness validation
316function validateContent(query: string): ValidationResult {
317 // Add any additional content validation here
318 // For adult products, we need to ensure appropriate terminology
338
339// Request logging for monitoring
340async function logRequest(requestData: any): Promise<void> {
341 try {
342 const logEntry = {
364}
365
366// Utility function to get validation statistics
367export async function getValidationStats(): Promise<any> {
368 try {
369 const logs: any[] = await blob.getJSON('recent_validation_logs') || [];
386}
387
388// Helper function to get top queries
389function getTopQueries(logs: any[]): any[] {
390 const queryCounts = logs.reduce((counts, log) => {
391 counts[log.query] = (counts[log.query] || 0) + 1;
399}
400
401// Helper function to get requests per hour
402function getRequestsPerHour(logs: any[]): number {
403 if (logs.length === 0) return 0;
404
411}
412
413// Cleanup function to remove old rate limit data
414export async function cleanupRateLimits(): Promise<void> {
415 try {
416 // This would typically be called by a scheduled job
417 // For now, it's just a utility function
418 console.log('Rate limit cleanup completed');
419 } catch (error) {

xxxclearinghouse_urlscraperindex.ts9 matches

@toowired•Updated 15 hours ago
68};
69
70// Advanced scraping function with error handling and rate limiting
71async function scrapeWebsite(query: string, websiteUrl: string): Promise<ScrapingResult> {
72 const startTime = Date.now();
73 const results: ScrapingResult = {
162}
163
164// HTML parsing function using regex patterns (since DOMParser isn't available in server context)
165async function parseProductsFromHTML(html: string, siteConfig: any, baseUrl: string): Promise<any[]> {
166 const products: any[] = [];
167
192
193// Extract product data using regex patterns
194async function extractProductData(productHtml: string, siteConfig: any, baseUrl: string): Promise<any> {
195 const product: any = {
196 source: new URL(baseUrl).hostname,
250}
251
252// Main export function
253export default async function urlScrapeTemplate(query: string, website: string): Promise<ScrapingResult> {
254 try {
255 // Input validation
297}
298
299// Utility function for testing
300export async function testScrapeTemplate(): Promise<void> {
301 const testSites = [
302 'lovehoney.com.au',

xxxclearinghouse_orchestratorindex.ts8 matches

@toowired•Updated 15 hours ago
46];
47
48export default async function orchestrator(request: Request): Promise<Response> {
49 // CORS handling
50 if (request.method === 'OPTIONS') {
223
224// Simplified request validation
225async function validateRequest(requestBody: any): Promise<ProcessedRequest> {
226 try {
227 // Default values
267}
268
269// Simplified scraping function that calls our URL scrape template
270async function scrapeWebsite(query: string, website: string): Promise<any> {
271 // This would normally import and call the actual URL scrape template
272 // For now, we'll simulate the call with a simplified version
313
314// Product consolidation and deduplication
315async function consolidateProducts(products: any[], minimumDiscount: number): Promise<any[]> {
316 if (!products || products.length === 0) {
317 return [];
356
357// Generate a unique product ID
358function generateProductId(product: any): string {
359 const source = product.source || 'unknown';
360 const title = product.title || 'untitled';
365
366// Calculate summary statistics
367function calculateSummary(results: ScrapingResult[], products: any[]): any {
368 const successfulSites = results.filter(r => r.status === 'success').length;
369 const totalProducts = products.length;
387
388// Health check endpoint
389export async function healthCheck(): Promise<Response> {
390 return new Response(JSON.stringify({
391 status: 'healthy',
tuna

tuna9 file matches

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