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=4&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 24880 results for "function"(593ms)

ValodcronDailyBrief.ts1 match

@tigrankโ€ขUpdated 1 hour ago
1import { sendDailyBriefing } from "./sendDailyBrief.ts";
2
3export async function cronDailyBrief() {
4 try {
5 const chatId = Deno.env.get("TELEGRAM_CHAT_ID");

ValodApp.tsx2 matches

@tigrankโ€ขUpdated 1 hour ago
62};
63
64export function App() {
65 const [memories, setMemories] = useState<Memory[]>([]);
66 const [loading, setLoading] = useState(true);
139 const data = await response.json();
140
141 // Change the sorting function to show memories in chronological order
142 const sortedMemories = [...data].sort((a, b) => {
143 const dateA = a.createdDate || 0;

untitled-2706Booking.tsx1 match

@reemgalal28โ€ขUpdated 1 hour ago
3import type { ServiceType, TimeSlot } from "../../shared/types.ts";
4
5export default function Booking() {
6 const [services, setServices] = useState<ServiceType[]>([]);
7 const [selectedService, setSelectedService] = useState<string>('');

untitled-2706Chat.tsx1 match

@reemgalal28โ€ขUpdated 1 hour ago
3import type { ChatMessage } from "../../shared/types.ts";
4
5export default function Chat() {
6 const [messages, setMessages] = useState<ChatMessage[]>([]);
7 const [newMessage, setNewMessage] = useState('');

untitled-2706Blog.tsx1 match

@reemgalal28โ€ขUpdated 1 hour ago
3import type { BlogPost } from "../../shared/types.ts";
4
5export default function Blog() {
6 const [posts, setPosts] = useState<BlogPost[]>([]);
7 const [selectedPost, setSelectedPost] = useState<BlogPost | null>(null);

untitled-2706App.tsx2 matches

@reemgalal28โ€ขUpdated 1 hour ago
7type ActiveSection = 'home' | 'blog' | 'chat' | 'booking';
8
9export default function App() {
10 const [activeSection, setActiveSection] = useState<ActiveSection>('home');
11
106}
107
108function HomePage({ setActiveSection }: { setActiveSection: (section: ActiveSection) => void }) {
109 return (
110 <div>

untitled-2706queries.ts10 matches

@reemgalal28โ€ขUpdated 1 hour ago
3
4// Blog queries
5export async function getAllBlogPosts(): Promise<BlogPost[]> {
6 const rows = await sqlite.execute(
7 "SELECT * FROM blog_posts ORDER BY created_at DESC"
14}
15
16export async function getBlogPost(id: number): Promise<BlogPost | null> {
17 const rows = await sqlite.execute(
18 "SELECT * FROM blog_posts WHERE id = ?",
29}
30
31export async function createBlogPost(post: Omit<BlogPost, 'id' | 'created_at' | 'updated_at'>): Promise<number> {
32 const result = await sqlite.execute(
33 `INSERT INTO blog_posts (title, content, excerpt, author, tags)
40
41// Chat queries
42export async function getRecentChatMessages(limit: number = 50): Promise<ChatMessage[]> {
43 const rows = await sqlite.execute(
44 `SELECT * FROM chat_messages
51}
52
53export async function addChatMessage(username: string, message: string): Promise<ChatMessage> {
54 const result = await sqlite.execute(
55 "INSERT INTO chat_messages (username, message) VALUES (?, ?)",
66
67// Appointment queries
68export async function getAllAppointments(): Promise<Appointment[]> {
69 const rows = await sqlite.execute(
70 "SELECT * FROM appointments ORDER BY appointment_date, appointment_time"
74}
75
76export async function createAppointment(appointment: Omit<Appointment, 'id' | 'created_at'>): Promise<number> {
77 const result = await sqlite.execute(
78 `INSERT INTO appointments
94}
95
96export async function updateAppointmentStatus(id: number, status: string): Promise<void> {
97 await sqlite.execute(
98 "UPDATE appointments SET status = ? WHERE id = ?",
101}
102
103export async function getAppointmentsByDate(date: string): Promise<Appointment[]> {
104 const rows = await sqlite.execute(
105 "SELECT * FROM appointments WHERE appointment_date = ? ORDER BY appointment_time",
110}
111
112export async function isTimeSlotAvailable(date: string, time: string): Promise<boolean> {
113 const rows = await sqlite.execute(
114 `SELECT COUNT(*) as count FROM appointments

untitled-2706migrations.ts2 matches

@reemgalal28โ€ขUpdated 1 hour ago
1import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
2
3export async function runMigrations() {
4 // Blog posts table
5 await sqlite.execute(`
49}
50
51async function seedBlogPosts() {
52 const posts = [
53 {

untitled-2706README.md1 match

@reemgalal28โ€ขUpdated 1 hour ago
16โ”‚ โ”œโ”€โ”€ database/
17โ”‚ โ”‚ โ”œโ”€โ”€ migrations.ts # Database schema setup
18โ”‚ โ”‚ โ””โ”€โ”€ queries.ts # Database query functions
19โ”‚ โ”œโ”€โ”€ routes/
20โ”‚ โ”‚ โ”œโ”€โ”€ blog.ts # Blog API endpoints

untitled-4336main.tsx15 matches

@Getโ€ขUpdated 1 hour ago
74`;
75
76// --- Type Definitions (Simplified for Crux functionality) ---
77interface CruxPoint {
78 order: number;
94}
95
96// --- HTML Generation Function (Adapted for Crux UI) ---
97function generateHtmlShell(valTownUrl) {
98 return `
99<!DOCTYPE html>
518
519
520 function displayError(message) {
521 errorContainer.innerHTML = \`<div class="error-message">\${message}</div>\`;
522 }
523
524 function renderInteractiveUIFromCruxData(data) {
525 data.crux_points.sort((a, b) => a.order - b.order);
526 originalInstructionSpan.textContent = data.original_instruction;
559 }
560
561 function buildInteractiveSentenceStructure(data) {
562 const instruction = data.original_instruction;
563 const cruxPoints = data.crux_points;
618 }
619
620 function populateCruxDropdown(cruxOrder, alternativesArray, originalPhrase) {
621 const state = cruxElementStates[cruxOrder];
622 if (!state || !state.wrapper) return;
677 }
678
679 function handleCruxMultiSelectChange(cruxOrder, value, isChecked) {
680 const state = cruxElementStates[cruxOrder];
681 if (!state) return;
709 }
710
711 function updateCruxDisplay(cruxOrder) {
712 const state = cruxElementStates[cruxOrder];
713 if (!state || !state.wrapper) return;
726 }
727
728 function updateChildCruxDropdown(childCruxOrder, parentSelectedValue, data) {
729 const childCruxData = data.crux_points.find(c => c.order === childCruxOrder);
730 const childState = cruxElementStates[childCruxOrder];
759 }
760
761 function updateInteractiveSentence() {
762 const instruction = currentJsonData.original_instruction;
763 const cruxPoints = currentJsonData.crux_points.sort((a, b) => a.order - b.order); // Ensure order
800
801// --- Main Request Handler (Server Code) ---
802export default async function(req: Request) {
803 // --- Dynamic Imports ---
804 const { OpenAI } = await import("https://esm.town/v/std/openai"); // Updated import path
805 const { z } = await import("npm:zod"); // For input validation
806
807 // --- Helper Function: Call OpenAI API ---
808 async function callOpenAIForCrux(
809 openai: OpenAI, // Instance passed in
810 systemPrompt: string,
833
834 // --- Core Logic: Analyze Instruction for Cruxes ---
835 async function analyzeInstructionForCruxes(
836 userInstruction: string,
837 ): Promise<object | ErrorResponse>

getFileEmail4 file matches

@shouserโ€ขUpdated 1 month ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblkโ€ขUpdated 1 month 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.