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/$1?q=function&page=23&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 28754 results for "function"(3454ms)

notessqlite.tsx3 matches

@cosmopaolo•Updated 1 day ago
1import { sqlite } from "https://esm.town/v/std/sqlite";
2
3async function getRoom(roomName: string) {
4 const result = await sqlite.execute(
5 "SELECT content, lastModified FROM rooms WHERE name = ?",
14}
15
16async function saveRoom(roomName: string, data: RoomData) {
17 await sqlite.execute(
18 `
24}
25
26async function initDb() {
27 await sqlite.execute(`
28 CREATE TABLE IF NOT EXISTS rooms(

Glanceriframe.tsx1 match

@lightweight•Updated 1 day ago
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
2
3export function IframeContent({ data, content }) {
4 // const { content, contentURL, docsURL } = config;
5 // console.log("content: ", content);
Gardenon

Gardenonindex.html13 matches

@Llad•Updated 1 day ago
239
240 // Fetch all plants
241 async function fetchPlants() {
242 try {
243 const response = await fetch('/api/plants');
251
252 // Render plants on the map and in the list
253 function renderPlants() {
254 // Clear existing plants (but preserve placeholder)
255 gardenMap.querySelectorAll('.plant:not(.placeholder)').forEach(el => el.remove());
331
332 // Create a placeholder plant on the map
333 function createPlaceholderPlant(x, y) {
334 // Remove existing placeholder if any
335 removePlaceholderPlant();
364
365 // Remove placeholder plant from the map
366 function removePlaceholderPlant() {
367 if (placeholderPlant && placeholderPlant.element) {
368 placeholderPlant.element.remove();
372
373 // Select a plant to edit
374 function selectPlant(plant) {
375 // Cancel move mode if active
376 if (isMovingPlant) {
405
406 // Clear the form
407 function clearForm() {
408 // Remove placeholder plant if it exists
409 removePlaceholderPlant();
431
432 // Start move mode
433 function startMoveMode() {
434 if (!selectedPlant) {
435 alert('Please select a plant to move.');
445
446 // Cancel move mode
447 function cancelMoveMode() {
448 isMovingPlant = false;
449 mapInstructions.textContent = 'Tap anywhere on the map to add a plant';
454
455 // Move plant to new position
456 function movePlantTo(x, y) {
457 if (!selectedPlant) return;
458
478
479 // Add a new plant at the clicked position
480 function addPlantAt(x, y) {
481 // Cancel move mode if active
482 if (isMovingPlant) {
504
505 // Save plant data
506 async function savePlant(plantData) {
507 try {
508 let response;
543
544 // Update placeholder plant when diameter changes
545 function updatePlaceholderPlant() {
546 if (placeholderPlant && placeholderPlant.element) {
547 const newDiameter = parseFloat(plantDiameterInput.value) || 50;
553
554 // Delete a plant
555 async function deletePlant(id) {
556 if (!confirm('Are you sure you want to delete this plant?')) {
557 return;

fotmobexport.ts5 matches

@cemugur70•Updated 1 day ago
10}
11
12export function createFullExcelData(data: ExportData): any[][] {
13 const { rankings, formatDetected, selectedWeek } = data;
14
79}
80
81export function createIddaaOnlyExcelData(data: ExportData): any[][] {
82 const { rankings } = data;
83
137}
138
139export function createPoissonOnlyExcelData(data: ExportData): any[][] {
140 const { rankings } = data;
141
191}
192
193export function createAccuracyReportExcelData(data: ExportData): any[][] {
194 const { accuracyStats, allWeeksData } = data;
195
219}
220
221export function createMultiWeekExcelData(data: ExportData): { [sheetName: string]: any[][] } {
222 const { allWeeksData, formatDetected } = data;
223 const sheets: { [sheetName: string]: any[][] } = {};

fotmobindex.html13 matches

@cemugur70•Updated 1 day ago
441 let currentWeek = 6;
442
443 async function processFile() {
444 const fileInput = document.getElementById('fileInput');
445 const file = fileInput.files[0];
510 }
511
512 function createWeekSelector() {
513 const weekButtons = document.getElementById('weekButtons');
514 weekButtons.innerHTML = '';
552 }
553
554 async function analyzeWeek(selectedWeek) {
555 currentWeek = selectedWeek;
556
585 }
586
587 function displayResults(rankings, week) {
588 const tbody = document.getElementById('rankingsBody');
589 tbody.innerHTML = '';
648 }
649
650 function updateAccuracyStats() {
651 if (!analysisData || !analysisData.accuracyStats) return;
652
665 }
666
667 async function exportToExcel() {
668 if (!analysisData) {
669 showStatus('Önce analiz yapılmalı!', 'error');
692 }
693
694 async function exportIddaaOnly() {
695 if (!analysisData) {
696 showStatus('Önce analiz yapılmalı!', 'error');
719 }
720
721 async function exportPoissonOnly() {
722 if (!analysisData) {
723 showStatus('Önce analiz yapılmalı!', 'error');
746 }
747
748 async function testBettingAccuracy() {
749 if (!analysisData) {
750 showStatus('Önce analiz yapılmalı!', 'error');
780 }
781
782 function downloadExcel(data, filename, sheetName = 'Sheet1') {
783 // Create workbook and worksheet
784 const wb = XLSX.utils.book_new();
806 }
807
808 function downloadMultiSheetExcel(sheetsData, filename) {
809 // Create workbook
810 const wb = XLSX.utils.book_new();
838 }
839
840 function updateProgress(percentage, text) {
841 document.getElementById('progressFill').style.width = percentage + '%';
842 document.getElementById('statusText').textContent = text;
843 }
844
845 function showStatus(message, type = 'info') {
846 const statusDiv = document.getElementById('statusText');
847 statusDiv.textContent = message;

fotmobindex.ts8 matches

@cemugur70•Updated 1 day ago
225});
226
227function organizeMatches(matches: any[][], headers: string[]) {
228 const weeklyData: { [key: number]: MatchData[] } = {};
229 const allMatches: MatchData[] = [];
308}
309
310function calculateWeeklyPowerScoresWithPoisson(
311 targetWeek: number,
312 allMatches: MatchData[],
344}
345
346function calculatePoissonPrediction(
347 homeTeam: string,
348 awayTeam: string,
420}
421
422function calculateAccuracyStats(allMatches: MatchData[], weeklyData: { [key: number]: MatchData[] }) {
423 let totalPredictions = 0;
424 let exactMatches = 0;
487}
488
489function getMatchResult(score: string): string {
490 const match = score.match(/(\d+)\s*-\s*(\d+)/);
491 if (!match) return 'draw';
497}
498
499function getPredictedResult(prediction: any): string {
500 if (prediction.homeWinProb > prediction.drawProb && prediction.homeWinProb > prediction.awayWinProb) return 'home';
501 if (prediction.awayWinProb > prediction.homeWinProb && prediction.awayWinProb > prediction.drawProb) return 'away';
503}
504
505function getActualTotalGoals(score: string): number {
506 const match = score.match(/(\d+)\s*-\s*(\d+)/);
507 if (!match) return 0;
509}
510
511function checkBetSuccess(recommendedBet: string, actualGoals: number, score: string): boolean {
512 const hasHomeGoal = score.match(/(\d+)\s*-\s*(\d+)/) && parseInt(score.match(/(\d+)\s*-\s*(\d+)/)![1]) > 0;
513 const hasAwayGoal = score.match(/(\d+)\s*-\s*(\d+)/) && parseInt(score.match(/(\d+)\s*-\s*(\d+)/)![2]) > 0;
Gardenon

Gardenonindex.ts1 match

@Llad•Updated 1 day ago
19
20// Initialize database
21async function initDatabase() {
22 await sqlite.execute(`CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
23 id INTEGER PRIMARY KEY AUTOINCREMENT,

fotmobcalculations.ts9 matches

@cemugur70•Updated 1 day ago
1// Football analysis calculation functions
2import type {
3 MatchData,
9} from './types.ts';
10
11export function poissonProbability(lambda: number, k: number): number {
12 if (lambda <= 0) return 0;
13 const numerator = Math.pow(lambda, k) * Math.exp(-lambda);
16}
17
18export function factorial(n: number): number {
19 if (n <= 1) return 1;
20 let result = 1;
25}
26
27export function calculateLeagueAverages(allMatches: MatchData[], maxWeek: number): LeagueAverages {
28 const validMatches = allMatches.filter(match =>
29 match.week < maxWeek &&
72}
73
74export function calculateTeamStrength(
75 teamName: string,
76 isHome: boolean,
139}
140
141export function calculateOverUnderAnalysis(homeXgAvg: number, awayXgAvg: number): OverUnderAnalysis {
142 let under25 = 0, under35 = 0;
143 let bttsNo = 0;
193}
194
195export function calculateMostLikelyScore(homeXgAvg: number, awayXgAvg: number): { homeGoals: number; awayGoals: number; probability: number } {
196 let maxProbability = 0;
197 let bestHomeGoals = 0;
215}
216
217export function calculateWinProbabilities(homeXgAvg: number, awayXgAvg: number): WinProbabilities {
218 let homeWinProb = 0;
219 let drawProb = 0;
243}
244
245export function calculatePowerScore(teamName: string, isHome: boolean, targetWeek: number, allMatches: MatchData[]): number {
246 if (targetWeek === 1) return 0;
247

LiveStormMCPindex.ts1 match

@supagroova•Updated 1 day ago
229
230/**
231 * Val.town handler function for HTTP requests
232 * This will be exposed as a Val.town HTTP endpoint
233 */

LiveStormMCPREADME.md1 match

@supagroova•Updated 1 day ago
49
50- `index.ts`: Main entry point with HTTP trigger
51- `livestorm.ts`: Functions to fetch and parse the OpenAPI definition
52- `mcp.ts`: MCP server setup and configuration
53

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.