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/$%7Bsuccess?q=function&page=113&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 20658 results for "function"(689ms)

TetrisGameindex.ts14 matches

@ntaboisoe•Updated 3 days ago
1export default function handler(req: Request): Response {
2 const html = `<!DOCTYPE html>
3<html lang="en">
117
118 // Set canvas size to window size
119 function resizeCanvas() {
120 canvas.width = window.innerWidth;
121 canvas.height = window.innerHeight;
161
162 // Generate random buildings for the estate
163 function generateBuildings() {
164 buildings = [];
165
239
240 // Check collision with buildings
241 function checkBuildingCollision(x, y, radius) {
242 for (const building of buildings) {
243 // Calculate closest point on rectangle to circle
257 }
258
259 // Game functions
260 function updatePlayer() {
261 // Store previous position
262 const prevX = player.x;
290 }
291
292 function updateBot() {
293 // Calculate direction to player
294 const dx = player.x - bot.x;
343 }
344
345 function updateScore() {
346 elapsedTime = Math.floor((Date.now() - startTime) / 1000);
347 score = elapsedTime * 10; // 10 points per second
351 }
352
353 function drawBackground() {
354 // Draw colorful background
355 const grassColors = ['#a5d6a7', '#81c784', '#66bb6a', '#4caf50'];
365 }
366
367 function drawBuildings() {
368 // Draw all buildings
369 for (const building of buildings) {
408 }
409
410 function drawGame() {
411 // Clear canvas
412 ctx.clearRect(0, 0, canvas.width, canvas.height);
433 }
434
435 function gameLoop() {
436 if (!gameActive) return;
437
444 }
445
446 function gameOver() {
447 gameActive = false;
448 document.getElementById('final-score').textContent = score;
450 }
451
452 function restartGame() {
453 // Reset game state
454 gameActive = true;

Townie-05App.tsx1 match

@jxnblk•Updated 3 days ago
18});
19
20export function App() {
21 const [audio, setAudio] = useLocalStorage("AUDIO", false);
22 const user = useUser();

bsky-linesREADME.md1 match

@e69a756•Updated 3 days ago
12- Login form for Bluesky authentication
13- Display of user's liked posts
14- Search functionality to filter likes
15- Infinite scrolling for pagination
16- Responsive design

Townie-05useUser.tsx1 match

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

Townie-05useUsageStats.ts1 match

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

Townie-05useScrollToBottom.tsx3 matches

@jxnblk•Updated 3 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

Townie-05user-summary.ts1 match

@jxnblk•Updated 3 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(`

Townie-05useProject.tsx1 match

@jxnblk•Updated 3 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);

Townie-05useProjects.tsx1 match

@jxnblk•Updated 3 days ago
3const ENDPOINT = "/api/projects-loader";
4
5export function useProjects() {
6 const [data, setData] = useState<any>(null);
7 const [loading, setLoading] = useState(true);

Townie-05useLoadingFavicon.ts3 matches

@jxnblk•Updated 3 days ago
1import { useEffect } from "react";
2
3function setLoadingFavicon() {
4 document.querySelector('link[rel="icon"]').href = "/favicon-loading.svg";
5}
6function resetFavicon() {
7 document.querySelector('link[rel="icon"]').href = "/favicon.svg";
8}
9
10export function useLoadingFavicon(loading: boolean) {
11 useEffect(() => {
12 if (loading) setLoadingFavicon();

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.