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=28&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 18869 results for "function"(998ms)

luciaMagicLinkStarter

luciaMagicLinkStartermagic-links.ts4 matches

@stevekrouse•Updated 1 day ago
7
8// Hash a token using sha256
9function hashToken(token: string): string {
10 return encodeHexLowerCase(sha256(new TextEncoder().encode(token)));
11}
12
13// Create a magic link token for the given email
14export async function createMagicLinkToken(userEmail: string): Promise<string> {
15 const token = generateSessionToken();
16 const tokenHash = hashToken(token);
27
28// Send a magic link email
29export async function sendMagicLinkEmail(url: string, userEmail: string, token: string): Promise<boolean> {
30 try {
31 const magicLink = `${url}/auth/magic-link/${token}`;
55
56// Validate a magic link token and create a session
57export async function validateMagicLinkToken(token: string): Promise<{ valid: boolean; userId?: number }> {
58 const now = Math.floor(Date.now() / 1000);
59 const tokenHash = hashToken(token);
luciaMagicLinkStarter

luciaMagicLinkStarterApp.tsx1 match

@stevekrouse•Updated 1 day ago
16}
17
18export function App({ initialData }: { initialData: InitialData }) {
19 const [user, setUser] = useState<User | null>(initialData.user);
20 const [error, setError] = useState<string | null>(initialData.error);

untitled-7683README.md1 match

@Aib•Updated 1 day ago
1# untitled-7683// Full A-to-Z structure of a basic MuCute-style Minecraft PE client (simplified) // This mock is for learning purposes and replicates core client relay functions // You must have native MuCuteRelay library ready (compiled from: https://github.com/OpenMITM/MuCuteRelay)
2
3// Directory structure: // - app // - src/main/java/com/example/mucuteclient/MainActivity.java // - src/main/jniLibs/armeabi-v7a/libmucuterelay.so // - res/layout/activity_main.xml // - AndroidManifest.xml // - build.gradle
105 * @returns Dashboard HTML string
106 */
107function generateDashboardHTML(data: {
108 todos: any[];
109 metrics: any;
447 * @returns Log entry page HTML string
448 */
449function generateLogPageHTML(date: string) {
450 return html`
451 <!DOCTYPE html>
737 * @returns HTML string for pipeline stages
738 */
739function generatePipelineStages(leadsPipeline: any[]) {
740 // Define the stages in order
741 const stageOrder = [
770 * @returns Formatted priority string
771 */
772function renderPriority(priority: number): string {
773 switch (priority) {
774 case 1: return "🔥 CRITICAL";

nameSeeingServermain.tsx3 matches

@errormaestro•Updated 1 day ago
9 mostRecentName: z.optional(z.string().nullable()),
10});
11function handleGet(req: ExpressRequest, res: ExpressResponse) {
12 const response = zGetResponse.parse({ namesPreviouslySeen: namesPreviouslySeen.size, mostRecentName });
13 res.send(response);
19 force: z.optional(z.boolean()),
20});
21function handlePost(req: ExpressRequest, res: ExpressResponse) {
22 const body = zPostBody.safeParse(req.body);
23 if (!body.success) {
70 send: (json: any) => void;
71}
72export default async function(req: Request): Promise<Response> {
73 let resStatus = 200;
74
12 * Creates database tables and initial data
13 */
14export async function initializeSystem() {
15 try {
16 console.log("Starting system initialization...");

CareerCoach20Dayqueries.ts19 matches

@prashamtrivedi•Updated 1 day ago
5
6/**
7 * Database helper functions for the Career Coach application
8 * These functions handle all database interactions for the application
9 */
10
14 * Store a new interaction between the user and coach
15 */
16export async function storeInteraction(userInput: string, coachResponse: string, modelUsed: string) {
17 const timestamp = new Date().toISOString()
18 await sqlite.execute(`
27 * Get recent interactions, limited by count
28 */
29export async function getRecentInteractions(limit: number = 5) {
30 const result = await sqlite.execute(`
31 SELECT * FROM ${KEY}_interactions
42 * Create a new todo item
43 */
44export async function createTodo(todo: {
45 description: string
46 category: string
64 * Get all todos, optionally filtered by status
65 */
66export async function getTodos(status?: string) {
67 let query = `SELECT * FROM ${KEY}_todos`
68 let params: any[] = []
82 * Update a todo item
83 */
84export async function updateTodo(id: number, updates: {
85 description?: string
86 category?: string
121 * Get recently completed todos
122 */
123export async function getRecentCompletedTasks(limit: number = 5) {
124 const result = await sqlite.execute(`
125 SELECT * FROM ${KEY}_todos
137 * Store a new daily log
138 */
139export async function storeDailyLog(log: {
140 log_date: string
141 achievements: string
175 * Get recent daily logs
176 */
177export async function getRecentLogs(limit: number = 5) {
178 const result = await sqlite.execute(`
179 SELECT * FROM ${KEY}_daily_logs
190 * Update progress metrics for a specific date
191 */
192export async function updateProgressMetrics(metrics: {
193 metric_date: string
194 leads_contacted?: number
246 * Get the latest progress metrics
247 */
248export async function getProgressMetrics() {
249 const result = await sqlite.execute(`
250 SELECT * FROM ${KEY}_progress_metrics
269 * Get cumulative progress metrics
270 */
271export async function getCumulativeMetrics() {
272 const result = await sqlite.execute(`
273 SELECT
287 * Store a new coach analysis
288 */
289export async function storeAnalysis(analysis: {
290 analysis_date: string
291 analysis_type: string
327 * Get the latest analysis
328 */
329export async function getLatestAnalysis() {
330 const result = await sqlite.execute(`
331 SELECT * FROM ${KEY}_coach_analysis
351 * Add a new lead
352 */
353export async function addLead(lead: {
354 name: string
355 company?: string
385 * Get all leads, optionally filtered by status
386 */
387export async function getLeads(status?: string) {
388 let query = `SELECT * FROM ${KEY}_leads`
389 let params: any[] = []
403 * Get the current lead pipeline summary
404 */
405export async function getLeadsPipeline() {
406 const result = await sqlite.execute(`
407 SELECT status, COUNT(*) as count
428 * Update a lead's status and other information
429 */
430export async function updateLead(id: number, updates: {
431 name?: string
432 company?: string

nameSeeingServermain.tsx3 matches

@SimeonL•Updated 1 day ago
44});
45
46function handleGet(req: ExpressRequest, res: ExpressResponse) {
47 res.send({ namesPreviouslySeen: namesPreviouslySeen.size, mostRecentName });
48}
69const zPostErrorResponse403 = z.object({error: z.string(), correctPrefix: z.number()});
70
71function handlePost(req: ExpressRequest, res: ExpressResponse) {
72 const body = zPostBody.safeParse(req.body);
73 if (!body.success) {
111 send: (json: any) => void;
112}
113export default async function(req: Request): Promise<Response> {
114 let resStatus = 200;
115

CareerCoach20Daymigrations.ts1 match

@prashamtrivedi•Updated 1 day ago
5 * Creates all required tables if they don't already exist
6 */
7export async function initializeDatabase() {
8 // Generate a unique key based on this file's path to avoid collisions
9 const KEY = 'careerCoach'

nightbot-master-commandnew-file-9775.tsx3 matches

@jayden•Updated 1 day ago
5import Wiki from "npm:wikijs";
6
7function parseNightbotHeader(headerValue: string): Record<string, string> | null {
8 if (!headerValue) return null;
9 return headerValue.split("&").reduce((acc, param) => {
14}
15
16// map of built-in handler functions (e.g. weather)
17const commands: Record<
18 string,
201};
202
203export default async function server(request: Request): Promise<Response> {
204 console.log("incoming request:", request.url);
205 if (request.method !== "GET") {

getFileEmail4 file matches

@shouser•Updated 2 weeks ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 2 weeks ago
Simple functional CSS library for Val Town
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",