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/image-url.jpg%20%22Image%20title%22?q=function&page=111&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 20677 results for "function"(885ms)

aimemoryindex.html2 matches

@neverstew•Updated 3 days ago
67 // Debug helper
68 const debug = {
69 log: function(message, data) {
70 const debugElement = document.getElementById('debug');
71 const timestamp = new Date().toISOString().split('T')[1].split('.')[0];
78 debugElement.appendChild(logEntry);
79 },
80 clear: function() {
81 document.getElementById('debug').innerHTML = '';
82 }

aimemoryindex.ts8 matches

@neverstew•Updated 3 days ago
10
11// Initialize the database table
12async function initializeDatabase() {
13 await sqlite.execute(`
14 CREATE TABLE IF NOT EXISTS ${MEMORY_TABLE} (
22
23// Save a new memory snippet
24async function saveMemory(content: string, tags: string = "") {
25 await sqlite.execute(
26 `INSERT INTO ${MEMORY_TABLE} (content, tags) VALUES (?, ?)`,
31
32// Search for relevant memories based on a query
33async function searchMemories(query: string): Promise<Array<{ id: number; content: string; tags: string; created_at: string }>> {
34 // Simple search implementation - could be improved with embeddings or more sophisticated search
35 const results = await sqlite.execute(
42
43// Get all memories from the database
44async function getAllMemories(): Promise<Array<{ id: number; content: string; tags: string; created_at: string }>> {
45 const results = await sqlite.execute(
46 `SELECT * FROM ${MEMORY_TABLE} ORDER BY created_at DESC`
51
52// Fallback response generator when OpenAI is not available
53function generateFallbackResponse(query: string, memories: Array<{ content: string; tags?: string }> = []) {
54 if (memories.length === 0) {
55 return `I don't have any memories stored yet. You can teach me by saving some information.`;
72
73// Generate a response using OpenAI, incorporating memories if available
74async function generateResponse(query: string, memories: Array<{ content: string; tags?: string }> = []) {
75 try {
76 // Format all memories as context
114
115// Process the incoming request
116async function processRequest(req: Request) {
117 // Initialize database on each request (only creates if not exists)
118 await initializeDatabase();
183
184// HTTP handler
185export default async function(req: Request) {
186 // Handle OPTIONS for CORS
187 if (req.method === "OPTIONS") {

HTOCHeader.tsx1 match

@homestocompare•Updated 3 days ago
2import React from "https://esm.sh/react@18.2.0";
3
4export default function Header() {
5 return (
6 <header className="bg-indigo-600 text-white shadow-md">

HTOCApp.tsx1 match

@homestocompare•Updated 3 days ago
13}
14
15export default function App({ initialData }: AppProps) {
16 const [properties, setProperties] = useState<Property[]>(initialData.properties);
17 const [loading, setLoading] = useState(false);

HTOCREADME.md1 match

@homestocompare•Updated 3 days ago
6
7- `types.ts` - TypeScript interfaces used throughout the application
8- `utils.ts` - Utility functions for formatting and data manipulation
9
10## Usage

HTOCutils.ts3 matches

@homestocompare•Updated 3 days ago
1// Format price as currency
2export function formatPrice(price: number): string {
3 return new Intl.NumberFormat('en-US', {
4 style: 'currency',
9
10// Format number with commas
11export function formatNumber(num: number): string {
12 return new Intl.NumberFormat('en-US').format(num);
13}
14
15// Format bathrooms (handle .5 for half baths)
16export function formatBathrooms(bathrooms: number): string {
17 return bathrooms % 1 === 0 ? bathrooms.toString() : bathrooms.toFixed(1);
18}

Jop-Apputils.ts5 matches

@Nixee•Updated 3 days ago
21}
22
23// Utility functions that work in both browser and Deno
24export function formatDate(dateString: string): string {
25 if (!dateString) return '';
26 const date = new Date(dateString);
32}
33
34export function formatTime(dateString: string): string {
35 if (!dateString) return '';
36 const date = new Date(dateString);
42
43// Validation utilities
44export function validateEmail(email: string): boolean {
45 const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
46 return re.test(email);
47}
48
49export function validateJobPosting(job: Partial<JobPosting>): { valid: boolean; error?: string } {
50 if (!job.title || job.title.trim() === '') {
51 return { valid: false, error: 'Job title is required' };

Jop-Appindex.js2 matches

@Nixee•Updated 3 days ago
1function app() {
2 return {
3 // State
218 },
219
220 // Utility functions
221 formatDate(dateString) {
222 if (!dateString) return '';

HTOCREADME.md3 matches

@homestocompare•Updated 3 days ago
1# Database Layer
2
3This directory contains the database schema and query functions for the House Hunter application.
4
5## Files
6
7- `migrations.ts` - Contains the database schema definitions and initial data seeding
8- `queries.ts` - Contains functions for querying the database
9
10## Schema
31## Usage
32
33The database is automatically initialized when the application starts. The `runMigrations` function creates the necessary tables and seeds initial data if needed.

HTOCqueries.ts4 matches

@homestocompare•Updated 3 days ago
32
33// Get all properties with optional filtering
34export async function getProperties(filters: PropertyFilters = {}): Promise<Property[]> {
35 let query = `SELECT * FROM ${PROPERTIES_TABLE} WHERE 1=1`;
36 const params: any[] = [];
85
86// Get a single property by ID
87export async function getPropertyById(id: number): Promise<Property | null> {
88 const result = await sqlite.execute(
89 `SELECT * FROM ${PROPERTIES_TABLE} WHERE id = ?`,
99
100// Get cities for dropdown
101export async function getCities(): Promise<string[]> {
102 const result = await sqlite.execute(
103 `SELECT DISTINCT city FROM ${PROPERTIES_TABLE} ORDER BY city ASC`
108
109// Get states for dropdown
110export async function getStates(): Promise<string[]> {
111 const result = await sqlite.execute(
112 `SELECT DISTINCT state FROM ${PROPERTIES_TABLE} ORDER BY state ASC`

getFileEmail4 file matches

@shouser•Updated 3 weeks ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 3 weeks ago
Simple functional CSS library for Val Town
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.