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/$%7Bart_info.art.src%7D?q=function&page=1&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 17344 results for "function"(722ms)

maine-bills-taxsummarize.ts2 matches

@cmknz•Updated 1 hour ago
13
14// Summarize the bills and update cache
15export function summarize(searchResults: SearchResult[]): Promise<string> {
16 // Bill context
17 const extractImportantInfo = JSON.stringify(searchResults.map(result => ({
36
37// Convert the chat completion to a string
38function convertChatCompletionToString(chat: ChatCompletion) {
39 return chat.choices[0].message.content;
40}

maine-bills-taxmain.tsx2 matches

@cmknz•Updated 1 hour ago
15
16// Main content body returned to the request
17export default function httpHandler(req: Request): Response {
18 return new Response(renderToString(<Content />), { headers: { "content-type": "text/html" } });
19}
20
21// Let's display it
22function Content() {
23 return (
24 <div>

maine-bills-taxsearch.ts2 matches

@cmknz•Updated 1 hour ago
3
4// Inject the search term in to the URL
5function getSearchURL(term: string) {
6 return `https://legislature.maine.gov/mrs-search/api/billtext?term=${term}&title=&legislature=132&lmSponsorPrimary=false&reqAmendExists=false&reqAmendAdoptH=false&reqAmendAdoptS=false&reqChapterExists=false&reqFNRequired=false&reqEmergency=false&reqGovernor=false&reqBond=false&reqMandate=false&reqPublicLand=false&showExtraParameters=false&mustHave=&mustNotHave=&offset=0&pageSize=12&sortByScore=false&showBillText=false&sortAscending=false&excludeOrders=false`;
7}
8
9// Query the Maine bill database
10export function search(term: string): Promise<SearchResult[]> {
11 return fetchText(getSearchURL(term)).then((res) => {
12 return JSON.parse(res).hits.hits;
7};
8
9export default async function(req: Request): Promise<Response> {
10 const searchParams = new URL(req.url).searchParams;
11 const discussionId = searchParams.get("discussion");
76
77// This takes an array and chunks it.
78function chunkArray<T>(array: T[], chunkSize: number): T[][] {
79 const chunks: T[][] = [];
80 for (let i = 0; i < array.length; i += chunkSize) {

maine-bills-taxcache.ts3 matches

@cmknz•Updated 1 hour ago
9
10// This is used as the `key` in our table
11function createIdHash(results: SearchResult[]) {
12 return results.map((result) => result._id).sort((a, b) => a.localeCompare(b)).join("-");
13}
16 * Check if the cache exists
17 */
18export function getCache(results: SearchResult[]): Promise<string | undefined> {
19 const id = createIdHash(results);
20 return sqlite.execute({ sql: `select value from bill_kv where key = ?`, args: [id] }).then((res) => {
35 * Set the cache
36 */
37export function setCache(results: SearchResult[], value: string): Promise<any> {
38 const id = createIdHash(results);
39 return sqlite.execute({ sql: `insert into bill_kv(key, value) values(?, ?)`, args: [id, value] });

productpaneldashboard.http.ts5 matches

@tijs•Updated 2 hours ago
10 * Handle the dashboardHome HTTP request
11 */
12export default async function (req: Request): Promise<Response> {
13 // Only allow GET requests
14 if (req.method !== "GET") {
64 * Create a login page response
65 */
66function createLoginPage(): Response {
67 const html = `<!DOCTYPE html>
68<html lang="en">
96
97 <script>
98 document.getElementById('loginForm').addEventListener('submit', function(e) {
99 e.preventDefault();
100
124 * Render the Vue-based dashboard HTML
125 */
126function renderVueDashboard(apps: any[]): string {
127 return `<!DOCTYPE html>
128<html lang="en">
592 * Render an error page
593 */
594function renderErrorPage(errorMessage: string): string {
595 return `<!DOCTYPE html>
596<html lang="en">

productpanelREADME.md2 matches

@tijs•Updated 2 hours ago
20### Key Vue Features Used
21
22- **Composition API**: Modern Vue 3 approach with `setup()` function
23- **Template syntax**: `v-for`, `v-if`, `v-model`, etc.
24- **Component props and emits**: Clean component API
551. Add new components to `components.ts` if they're reusable
562. Update the main dashboard template for layout changes
573. Add new reactive state and methods in the `setup()` function
58
59## Benefits Over the Previous Implementation

sqliteExplorerAppREADME.md1 match

@cmknz•Updated 2 hours ago
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
36- [x] add listener for cmd+enter to submit query
37

productpaneldebug-client.http.ts12 matches

@tijs•Updated 2 hours ago
6 */
7
8export default function(req: Request): Response {
9 return new Response(`
10// ProductPanel Dashboard Debug Utility
11
12(function() {
13 // Create debug panel
14 const debugPanel = document.createElement('div');
45
46 debugPanel.style.display = 'none';
47 toggleButton.addEventListener('click', function() {
48 debugPanel.style.display = debugPanel.style.display === 'none' ? 'block' : 'none';
49 });
50
51 // Debug log function
52 window.debugLog = function(message) {
53 const logDiv = document.getElementById('debug-log');
54 const entry = document.createElement('div');
62
63 // Fix app card event listeners
64 window.fixAppCards = function() {
65 debugLog('Fixing app card click handlers...');
66
70
71 // Attach direct onclick handlers
72 appCards.forEach(function(card, index) {
73 const appId = card.getAttribute('data-app-id');
74 debugLog('Processing card ' + index + ' with ID: ' + appId);
95 });
96
97 // Define the global handler function
98 window.handleAppCardClick = function(card) {
99 const appId = card.getAttribute('data-app-id');
100 const index = card.getAttribute('data-index');
106
107 // Update active card styling
108 document.querySelectorAll('.app-card').forEach(function(c) {
109 c.classList.remove('border-indigo-600');
110 c.classList.add('border-gray-200');
128
129 // Run automatic fixes when the page loads
130 window.addEventListener('load', function() {
131 debugLog('Page loaded, running automatic fixes...');
132
133 // Wait a moment to ensure the DOM is fully loaded
134 setTimeout(function() {
135 window.fixAppCards();
136 }, 1000);

mcp_testmain.tsx2 matches

@kucukkanat•Updated 2 hours ago
32 MCP (Model Context Protocol) is an open protocol developed by Anthropic that lets LLMs
33 interact with external tools and data sources. It allows AI agents to access data and execute
34 functionality in a standardized way across different applications.
35 </p>
36
77
78// Handler for our HTTP endpoint
79export default async function handler(req: Request): Promise<Response> {
80 try {
81 // Create a minimal MCP server

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 1 week 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": "*",