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=49&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 22587 results for "function"(781ms)

playgroundwordpress.ts8 matches

@hessammehr•Updated 2 days ago
82
83// Fetch posts with optional parameters
84export async function getPosts(params: {
85 page?: number;
86 per_page?: number;
112
113// Fetch a single post by slug
114export async function getPostBySlug(slug: string): Promise<Post> {
115 const posts = await getPosts({ slug, embed: true });
116
123
124// Fetch pages with optional parameters
125export async function getPages(params: {
126 page?: number;
127 per_page?: number;
149
150// Fetch a single page by slug
151export async function getPageBySlug(slug: string): Promise<Page> {
152 const pages = await getPages({ slug, embed: true });
153
160
161// Fetch categories
162export async function getCategories(): Promise<Category[]> {
163 const url = `${API_URL}/categories?per_page=100`;
164 const response = await fetch(url);
172
173// Fetch tags
174export async function getTags(): Promise<Tag[]> {
175 const url = `${API_URL}/tags?per_page=100`;
176 const response = await fetch(url);
184
185// Fetch media
186export async function getMedia(id: number): Promise<Media> {
187 const url = `${API_URL}/media/${id}`;
188 const response = await fetch(url);
196
197// Fetch site info
198export async function getSiteInfo() {
199 const url = 'https://mehr-research.science/wp-json';
200 const response = await fetch(url);

playgroundREADME.md1 match

@hessammehr•Updated 2 days ago
8- `/src/components/` - Reusable UI components
9- `/src/layouts/` - Page layouts
10- `/src/lib/` - Utility functions and API clients
11- `/public/` - Static assets
12

demo-ai-mamain.js10 matches

@h0a•Updated 2 days ago
11const PORT = 3001;
12
13async function pdfToImages(pdfPath) {
14 return new Promise((resolve, reject) => {
15 const py = spawn('python', ['pdf_to_images.py', pdfPath]);
33}
34
35async function sendToClaude(images) {
36 const prompt = `
37You are an expert at reading real estate contract documents. Extract the following information and return it as a JSON object with these sections and fields:
129
130// Helper to clean $ from non-monetary fields
131function cleanValue(v, key) {
132 if (typeof v === 'string' && v.startsWith('$')) {
133 // Only keep $ for exact monetary field names
147
148// Helper to render a section as a Bootstrap card
149function renderSection(title, fields) {
150 if (title === 'Payment Plan') {
151 // Parse the installment data
238
239// Helper to render Parties Information
240function renderPartyTable(party, data) {
241 return `
242 <table class="table table-bordered mb-4">
337
338 <script>
339 function toggleJson() {
340 const content = document.getElementById('jsonContent');
341 content.style.display = content.style.display === 'none' ? 'block' : 'none';
380 const canvas = document.getElementById('pdf-preview');
381 const ctx = canvas.getContext('2d');
382 fileInput.addEventListener('change', function(e) {
383 const file = e.target.files[0];
384 if (file && file.type === 'application/pdf') {
385 const fileReader = new FileReader();
386 fileReader.onload = function() {
387 const typedarray = new Uint8Array(this.result);
388 pdfjsLib.getDocument(typedarray).promise.then(function(pdf) {
389 pdf.getPage(1).then(function(page) {
390 const viewport = page.getViewport({ scale: 0.9 });
391 canvas.width = viewport.width;

umbrellaRemindermain.tsx1 match

@louisjrdev•Updated 2 days ago
1export async function testReminder() {
2 fetch('https://jsonplaceholder.typicode.com/todos/1')
3 .then(response => response.json())

TownieValTownLogo.tsx1 match

@kenethcosam•Updated 2 days ago
1/** @jsxImportSource https://esm.sh/react@18.2.0?dev */
2
3export function ValTownLogo () {
4 return (
5 <svg

TownieuseUser.tsx1 match

@kenethcosam•Updated 2 days ago
3const USER_ENDPOINT = "/api/user";
4
5export function useUser() {
6 const [data, setData] = useState<any>(null);
7 const [loading, setLoading] = useState(true);

TownieuseUsageStats.ts1 match

@kenethcosam•Updated 2 days ago
1import { useEffect } from "react";
2
3export function useUsageStats(messages: any[], usages: any[]) {
4 useEffect(() => {
5 if (!messages?.length) return;

TownieuseScrollToBottom.tsx3 matches

@kenethcosam•Updated 2 days ago
7 *
8 * @param {Array} dependencies - Array of dependencies that trigger scrolling when changed
9 * @returns {Object} An object containing containerRef and scrollToBottom function
10 */
11export function useScrollToBottomContainer(dependencies = []) {
12 const containerRef = useRef(null);
13
28
29// body scroll version
30export function useScrollToBottom(dependencies = []) {
31 const bottomRef = useRef(null);
32

Townieuser-summary.ts1 match

@kenethcosam•Updated 2 days ago
6 * This includes a fallback to inference calls data when usage data is missing
7 */
8export async function getUserSummary() {
9 // First, get the standard grouped data from the usage table
10 const groupedUsageData = await sqlite.execute(`

TownieuseProject.tsx1 match

@kenethcosam•Updated 2 days ago
4const FILES_ENDPOINT = "/api/project-files";
5
6export function useProject(projectId: string, branchId?: string) {
7 const [data, setData] = useState<any>(null);
8 const [loading, setLoading] = useState(true);

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.