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%22Optional%20title%22?q=function&page=93&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 20583 results for "function"(1406ms)

Towniequeries.tsx6 matches

@valdottown•Updated 3 days ago
7// but in the meantime, we can cache user info in memory
8const userIdCache: { [key: string]: any } = {};
9export async function getUser(bearerToken: string) {
10 if (userIdCache[bearerToken]) return userIdCache[bearerToken];
11
16}
17
18async function last24Hours(userId: string) {
19 const usage = await sqlite.execute(
20 `SELECT
40 "devto": 100, // hardcoded limit of $100 per day for dev.to, billed later
41};
42export async function overLimit(bearerToken: string) {
43 const user = await getUser(bearerToken);
44 const last24HourUsage = await last24Hours(user.id);
49}
50
51export async function insertInferenceCall({
52 usage_id,
53 input_tokens,
103}
104
105export async function startTrackingUsage({
106 bearerToken,
107 val_id,
145}
146
147export async function finishTrackingUsage({
148 rowid,
149 input_tokens,

acdctest_loading.html4 matches

@atul084•Updated 3 days ago
65 let errorResources = 0;
66
67 // Function to update loading status
68 function updateLoadingStatus() {
69 const loadedPercentage = Math.round((loadedResources / totalResources) * 100);
70 document.getElementById('loading-time').textContent =
72 }
73
74 // Function to extract filename from URL for display
75 function getFilenameFromUrl(url) {
76 const parts = url.split('/');
77 let filename = parts[parts.length - 1];

excel_to_roadmaproadmap.ts25 matches

@pmaxx•Updated 3 days ago
1export default async function (req: Request) {
2 // Parse the roadmap data
3 const roadmapData = [
586 ];
587
588 // Helper function to determine which quarter a date falls into
589 function getQuarter(dateStr) {
590 const date = new Date(dateStr);
591 for (let i = 0; i < quarters.length; i++) {
655
656 // Generate task cards
657 function generateTaskCards() {
658 const taskCardsContainer = document.getElementById('task-cards');
659 taskCardsContainer.innerHTML = '';
711 }
712
713 // Function to update visible tasks based on filters
714 function updateVisibleTasks() {
715 document.querySelectorAll('#task-cards .task-card').forEach(card => {
716 if (activeCategories.includes(card.dataset.category)) {
723
724 // Timeline Chart
725 function createTimelineChart() {
726 const ctx = document.getElementById('timeline-chart').getContext('2d');
727
774 },
775 ticks: {
776 callback: function(value, index, values) {
777 const date = new Date(value);
778 const month = date.getMonth();
796 tooltip: {
797 callbacks: {
798 label: function(context) {
799 const task = context.raw.task;
800 const startDate = new Date(task.startDate).toLocaleDateString();
826 }
827
828 // Function to update chart theme
829 function updateChartTheme() {
830 if (window.timelineChart) {
831 // Update colors
847 }
848
849 // Function to add quarter dividers and labels
850 function addQuarterMarkings() {
851 const markersContainer = document.getElementById('quarter-markers');
852 markersContainer.innerHTML = '';
884 }
885
886 // Function to add milestone markers
887 function addMilestoneMarkers() {
888 const milestones = roadmapData.filter(task => task.type === 'Milestone');
889 const markersContainer = document.getElementById('milestone-markers');
928 }
929
930 // Function to update chart based on filters
931 function updateChart() {
932 // Update dataset visibility
933 window.timelineChart.data.datasets.forEach(dataset => {
948 }
949
950 // Function to update chart data
951 function updateChartData() {
952 // Recreate datasets
953 const datasets = categories.map(category => {
982 }
983
984 // Tooltip functions
985 const tooltip = document.getElementById('tooltip');
986
987 function showTooltip(element, task) {
988 const rect = element.getBoundingClientRect();
989 const startDate = new Date(task.startDate).toLocaleDateString();
1006 }
1007
1008 function hideTooltip() {
1009 tooltip.style.opacity = '0';
1010 }
1011
1012 // Edit modal functions
1013 const editModal = document.getElementById('edit-modal');
1014 const closeModalBtn = document.getElementById('close-modal');
1017 const editForm = document.getElementById('edit-task-form');
1018
1019 function openEditModal(index) {
1020 const task = roadmapData[index];
1021
1033 }
1034
1035 function closeEditModal() {
1036 editModal.classList.remove('active');
1037 }

IdkbasicAgent.ts1 match

@ibrinzila•Updated 3 days ago
3 * This is useful for testing if the Val Town HTTP endpoints are working
4 */
5export default function(req: Request): Response {
6 // Get current timestamp
7 const timestamp = new Date().toISOString();

IdkdeepResearchAgent.ts7 matches

@ibrinzila•Updated 3 days ago
15 * 3. Compiling findings into a comprehensive report
16 */
17export default async function(req: Request): Promise<Response> {
18 console.log("Received request:", req.method, req.url);
19
101 }
102
103 // Only accept POST requests for API functionality
104 if (req.method !== "POST") {
105 return new Response(JSON.stringify({ error: "Method not allowed" }), {
169 * Conducts comprehensive research on a topic
170 */
171async function conductResearch(topic: string, depth: "light" | "medium" | "deep" = "medium"): Promise<ResearchReport> {
172 // Step 1: Break down the topic into subtopics
173 const subtopics = await generateSubtopics(topic, depth);
194 * Generates a list of subtopics for the main research topic
195 */
196async function generateSubtopics(topic: string, depth: string): Promise<string[]> {
197 const depthMap = {
198 "light": 3,
263 * Generates default subtopics if the AI-generated ones fail
264 */
265function generateDefaultSubtopics(topic: string, count: number): string[] {
266 const defaultSubtopics = [
267 `Overview of ${topic}`,
283 * Researches a specific subtopic in detail
284 */
285async function researchSubtopic(mainTopic: string, subtopic: string, depth: string): Promise<SubtopicResearch> {
286 const depthMap = {
287 "light": 300,
327 * Generates an executive summary based on all the research
328 */
329async function generateExecutiveSummary(topic: string, subtopicResearch: SubtopicResearch[]): Promise<string> {
330 try {
331 // Create a condensed version of the research to fit within token limits

IdksimpleTest.ts1 match

@ibrinzila•Updated 3 days ago
2 * Simple test to verify that HTTP endpoints are working
3 */
4export default function(req: Request): Response {
5 const html = `<!DOCTYPE html>
6<html lang="en">

IdktestAgent.ts1 match

@ibrinzila•Updated 3 days ago
3 * This will make a simple request to the agent and log the results
4 */
5export default async function(req: Request): Promise<Response> {
6 try {
7 // Get the URL of the current request to determine the agent URL

IdkREADME.md3 matches

@ibrinzila•Updated 3 days ago
1016. **Check Response Format**: If you're calling the API directly, ensure your request format is correct.
102
1037. **Run the Test Endpoint**: Use the test endpoint to verify basic functionality.
104
105## Customization
107You can modify the agent to suit your specific research needs:
108
109- Adjust the number of subtopics based on depth in the `generateSubtopics` function
110- Change the word count for each subtopic in the `researchSubtopic` function
111- Modify the system prompts to focus on specific aspects of research
112

IdkresearchInterface.ts2 matches

@ibrinzila•Updated 3 days ago
4 * A simple web interface to interact with the Deep Research Agent
5 */
6export default function(req: Request): Response {
7 // Get the current URL to determine the agent URL
8 const url = new URL(req.url);
113 <script>
114 // Simple markdown parser
115 function parseMarkdown(text) {
116 if (!text) return '';
117

New-Tweet-Alertmain.tsx3 matches

@amaan_eth•Updated 3 days ago
70}
71
72export default async function(req: Request): Promise<Response> {
73 if (req.method !== "POST") {
74 return new Response("This Val can only process POST requests from SocialData", {
104}
105
106async function sendEventToTelegram(event: NewTweetEvent): Promise<void> {
107 const tweet = event.data;
108 const user = tweet.user;
169}
170
171async function sendPhotoToTelegram(photoUrl: string): Promise<void> {
172 const telegramApiUrl = `https://api.telegram.org/bot${telegramBotApiToken}/sendPhoto`;
173

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.