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/$%7BsvgDataUrl%7D?q=function&page=76&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 31571 results for "function"(4108ms)

MsgBoardqueries.ts2 matches

@roramigatorUpdated 4 days ago
10await createTables();
11
12export async function getMessages(limit = MESSAGE_LIMIT): Promise<Message[]> {
13 const messages = await sqlite.execute(
14 `SELECT * FROM ${tableName}
20}
21
22export async function insertMessage(content: string) {
23 await sqlite.execute(
24 `INSERT INTO ${tableName} (content)

MsgBoardmigrations.ts1 match

@roramigatorUpdated 4 days ago
3export const tableName = "reactHonoStarter_messages";
4
5export async function createTables() {
6 await sqlite.batch([
7 `CREATE TABLE IF NOT EXISTS ${tableName} (

MsgBoardMessageInput.tsx1 match

@roramigatorUpdated 4 days ago
3import type { Message } from "../shared/types.ts";
4
5export function MessageInput({ onSubmit }: { onSubmit: () => void }) {
6 const [message, setMessage] = React.useState("");
7

MsgBoardApp.tsx3 matches

@roramigatorUpdated 4 days ago
4import { MessageInput } from "./MessageInput.tsx";
5
6export function App(
7 { initialMessages = [], thisProjectURL }: { initialMessages?: Message[]; thisProjectURL?: string },
8) {
41}
42
43function MessageList({ messages }: { messages: Message[] }) {
44 const displayedMessages = messages.slice(0, MESSAGE_LIMIT);
45 return (
50}
51
52function MessageItem({ message }) {
53 const formattedDate = new Date(message.timestamp).toLocaleString();
54

rss-subhttp_rss_sub.tsx3 matches

@thomasvnUpdated 5 days ago
3const API_KEY = Deno.env.get("API_KEY");
4
5export default async function httpHandler(req: Request): Promise<Response> {
6 if (!validateApiKey(req)) {
7 return new Response("Unauthorized", { status: 401 });
72}
73
74function validateApiKey(req: Request): boolean {
75 const authHeader = req.headers.get("Authorization");
76 return authHeader === `Bearer ${API_KEY}`;
77}
78
79async function initializeDatabase() {
80 await sqlite.execute(`create table if not exists feed_urls(
81 id integer primary key autoincrement,

FarcasterSpacesanalytics.ts10 matches

@moeUpdated 5 days ago
3import { dbQuery } from './supabase.ts'
4
5export function handleAnalyticsEndpoints(app: Hono) {
6 app.get('/analytics', async (c) => {
7 // todo: load all data in parallel (postgress connection issue)
18}
19
20function renderTextTable(data: any[], title: string, props: string[]) {
21 const w: number = 78
22 const header = (' ┌── ' + title + ' ───').padEnd(w - 1, '─') + '┐ '
34}
35
36function queryHistoricalCountUsersOverPeriod() {
37 return analyticsQuery(`
38 select TO_CHAR(created_at, 'YYYY-MM-DD') as period, COUNT(distinct fid)
42 order by period desc`)
43}
44function topOpenLocations() {
45 return analyticsQuery(`
46 select param, COUNT(*)
51 limit 10`).then(miniappLocationDataTransformer)
52}
53function topScreens() {
54 return analyticsQuery(`
55 select param, COUNT(*)
61}
62
63function miniappLocationDataTransformer(data: any) {
64 return data.map((item: any) => {
65 return {
70}
71
72function getLocationText(param: string) {
73 let locationText = ''
74 if (param) {
87 return locationText
88}
89function getClientFidText(clientFid: any) {
90 if (!clientFid) return `[W] `
91 if (clientFid == 9152) return `[W] `
94}
95
96async function analyticsQuery(query: string, args: any[] = []) {
97 const result = await dbQuery(query, args)
98 return safeRows(result.rows)
99}
100
101function safeRows(rows: any[]) {
102 return rows.map((row) => {
103 const newRow: Record<string, any> = {}

CorneaApp.tsx1 match

@FrazonUpdated 5 days ago
2import { useState } from "https://esm.sh/react@18.2.0";
3
4export function App() {
5 const [clicked, setClicked] = useState(0);
6 return (

mcp-servermain.ts13 matches

@joshbeckmanUpdated 5 days ago
32};
33
34function postFilter(post: Post) {
35 return post.type == "post" || post.type == "page";
36}
37
38function buildTagsIndex(tags: Array<Tag>) {
39 return lunr(function() {
40 this.ref("id");
41 this.field("name");
50 });
51}
52function search(input: string, index: lunr.Index, searchData: Record<string, Post>) {
53 let results = index.search(input);
54
55 if ((results.length == 0) && (input.length > 2)) {
56 let tokens = lunr.tokenizer(input).filter(function(token, i) {
57 return token.str.length < 20;
58 });
59
60 if (tokens.length > 0) {
61 results = index.query(function(query) {
62 query.term(tokens, {
63 editDistance: Math.round(Math.sqrt(input.length / 2 - 1)),
90}
91
92function searchTags(input: string, index: lunr.Index, tags: Array<Tag>) {
93 let results = index.search(input);
94
95 if ((results.length == 0) && (input.length > 2)) {
96 let tokens = lunr.tokenizer(input).filter(function(token, i) {
97 return token.str.length < 20;
98 });
99
100 if (tokens.length > 0) {
101 results = index.query(function(query) {
102 query.term(tokens, {
103 editDistance: Math.round(Math.sqrt(input.length / 2 - 1)),
116 });
117}
118function formatPage(page: Post) {
119 return [
120 `# [${page.title}](${page.url.startsWith("http") ? page.url : SITE_URL + page.url})`,
135}
136
137function extractPostCategory(post: Post) {
138 if (post.type == "page") {
139 return "page";
160 * Uses a cached instance if available
161 */
162async function setupMcpServer(): Promise<McpServer> {
163 // Return cached instance if available
164 if (mcpServerInstance) {
521
522/**
523 * Val.town handler function for HTTP requests
524 * This will be exposed as a Val.town HTTP endpoint
525 */

ChatResourceViewer.tsx4 matches

@c15rUpdated 5 days ago
33 * - Supports fullscreen toggle
34 * - Simple component state management
35 * - Error handling with retry functionality
36 */
37export default function ResourceViewer({
38 fileViewerResult,
39 mcpClients = [],
247 }, [uri, serverName, retryCount]); // Remove loadResource from dependencies to prevent reload loop
248
249 // Fullscreen functionality
250 const enterFullscreen = () => {
251 setIsFullscreen(true);
256 };
257
258 // Retry functionality
259 const handleRetry = useCallback(() => {
260 setRetryCount(prev => prev + 1);

basic-html-starterscript.js1 match

@joestrouth1Updated 5 days ago
14scene.add(butterfly);
15
16renderer.setAnimationLoop(function animate(time) {
17 renderer.render(scene, camera);
18 butterfly.rotation.y += 0.01;
tuna

tuna9 file matches

@jxnblkUpdated 2 weeks ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouserUpdated 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.