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%22Optional%20title%22?q=function&page=80&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 20374 results for "function"(910ms)

worldclockscript.js2 matches

@evilmathwalnutsโ€ขUpdated 2 days ago
74
75 // Populate timezone dropdown with optgroups
76 function populateTimezoneSelect() {
77 // Clear existing options
78 timezoneSelect.innerHTML = '';
114
115 // Update the clock display
116 function updateClock() {
117 const selectedTimezone = timezoneSelect.value;
118 const now = new Date();

MyPortfolioREADME.md2 matches

@Dangariโ€ขUpdated 2 days ago
32- **TailwindCSS**: Utility-first CSS framework for styling
33- **Font Awesome**: Icon library
34- **Val Town**: Hosting and serverless functions
35
36## Project Structure
42โ”‚ โ”œโ”€โ”€ index.html # Main HTML file
43โ”‚ โ”œโ”€โ”€ styles.css # Custom CSS styles
44โ”‚ โ””โ”€โ”€ main.js # JavaScript functionality
45โ”œโ”€โ”€ assets/
46โ”‚ โ”œโ”€โ”€ favicon.svg # Site favicon

MyPortfoliomain.js14 matches

@Dangariโ€ขUpdated 2 days ago
1// Wait for DOM to be fully loaded
2document.addEventListener('DOMContentLoaded', function() {
3 // Initialize theme
4 initTheme();
14});
15
16// Theme toggle functionality
17function initTheme() {
18 const themeToggle = document.getElementById('theme-toggle');
19 const prefersDarkScheme = window.matchMedia('(prefers-color-scheme: dark)');
31
32 // Toggle theme when button is clicked
33 themeToggle.addEventListener('click', function() {
34 let theme;
35
47}
48
49// Mobile menu functionality
50function initMobileMenu() {
51 const mobileMenuButton = document.getElementById('mobile-menu-button');
52 const mobileMenu = document.getElementById('mobile-menu');
53
54 mobileMenuButton.addEventListener('click', function() {
55 mobileMenu.classList.toggle('hidden');
56
69 const mobileLinks = mobileMenu.querySelectorAll('a');
70 mobileLinks.forEach(link => {
71 link.addEventListener('click', function() {
72 mobileMenu.classList.add('hidden');
73 const icon = mobileMenuButton.querySelector('i');
79
80// Scroll animations
81function initScrollAnimations() {
82 // Animate sections when they come into view
83 const sections = document.querySelectorAll('section');
100 const navLinks = document.querySelectorAll('nav a[href^="#"]');
101
102 window.addEventListener('scroll', function() {
103 let current = '';
104
123
124// Contact form handling
125function initContactForm() {
126 const contactForm = document.getElementById('contact-form');
127 const formStatus = document.getElementById('form-status');
128
129 if (contactForm) {
130 contactForm.addEventListener('submit', async function(e) {
131 e.preventDefault();
132
188
189// Skill bar animation (for future use)
190function animateSkillBars() {
191 const skillBars = document.querySelectorAll('.skill-bar');
192
201// Smooth scroll for anchor links
202document.querySelectorAll('a[href^="#"]').forEach(anchor => {
203 anchor.addEventListener('click', function(e) {
204 e.preventDefault();
205

MUSALLindex.ts1 match

@otega07โ€ขUpdated 2 days ago
20// Initialize database on startup
21let dbInitialized = false;
22async function ensureDbInitialized() {
23 if (!dbInitialized) {
24 await initDatabase();

bananananaindex.ts3 matches

@yawnxyzโ€ขUpdated 2 days ago
1// A whimsical love story with bananas
2export default function (req: Request) {
3 return new Response(HTML, {
4 headers: {
241 // Simple banana click animation
242 document.querySelectorAll('.banana').forEach(banana => {
243 banana.addEventListener('click', function() {
244 this.style.transform = 'rotate(15deg) scale(1.2)';
245 setTimeout(() => {
252 const loveButton = document.getElementById('loveButton');
253 if (loveButton) {
254 loveButton.addEventListener('click', function() {
255 alert('๐Ÿ’– Their love will last forever! ๐ŸŒ');
256 });

aimemoryindex.html2 matches

@neverstewโ€ขUpdated 2 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 2 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 2 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 2 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 2 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

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
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",