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/$%7Burl%7D?q=function&page=45&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 19269 results for "function"(1231ms)

cerebras_coderindex.html1 match

@msd•Updated 3 days ago
19 <meta property="og:site_name" content="Cerebras Coder">
20 <meta property="og:url" content="https://cerebrascoder.com"/>
21 <meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
22 <meta property="og:type" content="website">
23 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">

cerebras_codergenerate-code.ts2 matches

@msd•Updated 3 days ago
2import STARTER_PROMPTS from "../public/starter-prompts.js";
3
4function extractCodeFromFence(text: string): string {
5 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
6 return htmlMatch ? htmlMatch[1].trim() : text;
7}
8
9export async function generateCode(prompt: string, currentCode: string) {
10 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
11 if (starterPrompt) {

simple-scrabble-apiapi.tsx10 matches

@bry•Updated 4 days ago
120};
121
122export async function handler(req: Request): Promise<Response> {
123 if (req.method === "OPTIONS") {
124 return new Response(null, {
179}
180
181function paginate<T>(items: T[], options: PaginationOptions): PaginationResult<T> {
182 const { page, size, totalItems, basePath } = options;
183
220}
221
222function handleRootRoute(req: Request): Response {
223 const url = new URL(req.url);
224 const baseUrl = `${url.protocol}//${url.host}`;
237}
238
239async function handleDictionaryRoute(req: Request): Promise<Response> {
240 const currentTime = Date.now();
241 if (!dictionaryCache.length || (currentTime - dictionaryCacheTimestamp > CACHE_TTL)) {
292}
293
294async function handleBoardsRoute(req: Request): Promise<Response> {
295 const currentTime = Date.now();
296 if (!boardsCache.length || (currentTime - boardsCacheTimestamp > CACHE_TTL)) {
320}
321
322function generatePermutations(str: string): string[] {
323 const result: string[] = [];
324
325 function permute(arr: string[], m: string[] = []) {
326 if (arr.length === 0) {
327 result.push(m.join(""));
339}
340
341function handleRearrangeRoute(req: Request): Response {
342 const url = new URL(req.url);
343 const path = url.pathname;
413}
414
415function calculateScrabbleScore(word: string): number {
416 return word
417 .toLowerCase()
422}
423
424function handleScoreRoute(req: Request): Response {
425 const url = new URL(req.url);
426 const path = url.pathname;

weatherApp.tsx1 match

@anand_g•Updated 4 days ago
2import { useState } from "https://esm.sh/react@18.2.0";
3
4export function App() {
5 const [clicked, setClicked] = useState(0);
6 return (
1// signup-alerts-service.ts - Service for handling role toggle functionality
2import { withErrorHandling } from "https://esm.town/v/ktodaz/Discord_Bot_Services/error-handling.tsx";
3import { blob } from "https://esm.town/v/std/blob";
14
15// Toggle role for a user (for the command processor)
16export async function toggleSignupsAlert(
17 guildId: string,
18 userId: string,
111
112// Create response messages based on toggle result
113export function createToggleSignupsAlertResponseMessage(
114 result: { success: boolean; action: string; roleName?: string; error?: string },
115): string {
126
127// Get toggleable roles in a guild - used for autocomplete
128export async function getSignupAlertsRoles(
129 guildId: string,
130): Promise<{ success: boolean; roles?: Array<{ id: string; name: string }>; error?: string }> {
207
208// Handle role autocomplete interaction
209export async function handleRoleAutocomplete(interaction: any): Promise<Response> {
210 try {
211 const guildId = interaction.guild_id;
1// toggle-server-helper-pings-service.ts - Service for handling server helper ping toggle functionality
2import { fetch } from "https://esm.town/v/std/fetch";
3
10
11// Toggle server helper pings role for a user
12export async function toggleServerHelperPings(
13 guildId: string,
14 userId: string,
101
102// Create response messages based on toggle result
103export function createToggleServerHelperPingsResponseMessage(
104 result: { success: boolean; action: string; roleName?: string; error?: string },
105): string {

Discord_Bot_Servicestoggle-role-service.tsx7 matches

@ktodaz•Updated 4 days ago
1// toggle-role-service.ts - Service for handling role toggle functionality
2import { withErrorHandling } from "https://esm.town/v/ktodaz/Discord_Bot_Services/error-handling.tsx";
3import { fetch } from "https://esm.town/v/std/fetch";
12
13// Check if user has permission to toggle roles
14async function hasPermission(guildId: string, userId: string): Promise<{
15 hasPermission: boolean;
16 isAdmin: boolean;
93
94// Toggle role for a user (for the command processor)
95export async function toggleRole(
96 guildId: string,
97 userId: string,
178
179// Create response messages based on toggle result
180export function createToggleRoleResponseMessage(
181 result: { success: boolean; action: string; roleName?: string; error?: string },
182): string {
192}
193
194// Then modify your getToggleableRoles function to use the error handling wrapper
195export async function getToggleableRoles(guildId: string): Promise<{
196 success: boolean;
197 roles?: Array<{ id: string; name: string }>;
249
250// Handle role autocomplete interaction
251export async function handleRoleAutocomplete(interaction: any): Promise<Response> {
252 try {
253 const guildId = interaction.guild_id;

slacktest.ts9 matches

@dinavinter•Updated 4 days ago
213
214// -------------------------------
215// Custom Functions
216// https://api.slack.com/automation/functions/custom
217// -------------------------------
218
219app.function("fetch_user_details", async ({ payload, context: { client, functionExecutionId } }) => {
220 try {
221 // Requires users:read scope
224 });
225 const user = userInfo.user!;
226 await client.functions.completeSuccess({
227 function_execution_id: functionExecutionId!,
228 outputs: {
229 full_name: user.real_name || user.profile?.real_name_normalized || user.profile?.real_name,
239 } catch (e) {
240 console.error(e);
241 await client.functions.completeError({
242 function_execution_id: functionExecutionId!,
243 error: `Failed to respond to fetch_user_details function event (${e})`,
244 });
245 }
261(async () => await sm.start())();
262
263export default async function handler(req: Request) {
264 return Response.json(
265 await app.client.conversations.replies({

mandateagents.ts3 matches

@salon•Updated 4 days ago
6
7// Summarizer Agent (unchanged, but shown for completeness)
8export async function summarizerAgent(
9 input: AgentInput<{ textToSummarize: string }>,
10 context: AgentContext,
52
53// Fetch Agent (Now fetches and parses RSS feeds for headlines)
54export async function fetchAgent(
55 input: AgentInput<{ url_from_input?: string; maxHeadlines?: number }>, // Added maxHeadlines
56 context: AgentContext,
206
207// Combiner Agent (Adapted to handle new headline structure from FetchAgent)
208export async function combinerAgent(
209 input: AgentInput<{
210 summary?: string;

govaltownmain.tsx2 matches

@bradnoble•Updated 4 days ago
22 let colorIndex = 0;
23
24 // Function to change the heading color
25 function changeHeadingColor() {
26 const heading = document.getElementById('colorful-heading');
27 heading.style.color = colors[colorIndex];

getFileEmail4 file matches

@shouser•Updated 2 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.