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=92&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 20195 results for "function"(2045ms)

Blogscript.js43 matches

@Danchiโ€ขUpdated 2 days ago
14 content: `<p>Web development is constantly evolving, and staying up-to-date with the latest practices is essential for creating modern, efficient websites. Here are 10 tips that every web developer should know:</p>
15 <h2>1. Embrace Modern JavaScript</h2>
16 <p>ES6+ features like arrow functions, destructuring, and async/await make your code cleaner and more maintainable. Don't be afraid to use them!</p>
17 <h2>2. Optimize for Performance</h2>
18 <p>Performance is crucial for user experience. Use tools like Lighthouse to identify and fix performance issues.</p>
40 name: "John Doe",
41 avatar: "https://randomuser.me/api/portraits/men/32.jpg",
42 bio: "Full-stack developer with a passion for creating beautiful, functional websites."
43 },
44 date: "2023-05-15",
235 name: "John Doe",
236 avatar: "https://randomuser.me/api/portraits/men/32.jpg",
237 bio: "Full-stack developer with a passion for creating beautiful, functional websites.",
238 email: "john.doe@example.com",
239 website: "https://johndoe.com",
304
305// Save data to localStorage
306function saveData() {
307 localStorage.setItem('blogPosts', JSON.stringify(blogPosts));
308 localStorage.setItem('users', JSON.stringify(users));
323}
324
325// Function to format date
326function formatDate(dateString) {
327 const options = { year: 'numeric', month: 'long', day: 'numeric' };
328 return new Date(dateString).toLocaleDateString(undefined, options);
329}
330
331// Function to create post card HTML
332function createPostCard(post) {
333 return `
334 <div class="post-card">
356}
357
358// Function to create author card HTML
359function createAuthorCard(user) {
360 return `
361 <div class="author-card">
378}
379
380// Function to create comment HTML
381function createCommentHTML(comment) {
382 return `
383 <div class="comment" data-id="${comment.id}">
404}
405
406// Home page functionality
407const featuredPostsContainer = document.getElementById('featuredPosts');
408const trendingAuthorsContainer = document.getElementById('trendingAuthors');
432}
433
434// Explore page functionality
435const allPostsContainer = document.getElementById('allPosts');
436const categoryFilter = document.getElementById('categoryFilter');
447let filteredPosts = [...blogPosts];
448
449// Function to filter and display posts
450function filterAndDisplayPosts() {
451 // Apply category filter
452 if (categoryFilter && categoryFilter.value !== 'all') {
491}
492
493// Function to update pagination
494function updatePagination() {
495 if (!pageNumbers) return;
496
528}
529
530// Function to display posts for current page
531function displayPostsForCurrentPage() {
532 if (!allPostsContainer) return;
533
618}
619
620// Create post page functionality
621const blogForm = document.getElementById('blogForm');
622const postTitleInput = document.getElementById('postTitle');
642}
643
644// Rich text editor functionality
645if (editorButtons && postContentEditor) {
646 editorButtons.forEach(button => {
710}
711
712// Save draft functionality
713if (saveDraftBtn) {
714 saveDraftBtn.addEventListener('click', () => {
741}
742
743// Individual blog post page functionality
744const blogPostContainer = document.getElementById('blogPost');
745const likeBtn = document.getElementById('likeBtn');
766const postId = urlParams.get('id');
767
768// Function to display blog post
769function displayBlogPost() {
770 if (!blogPostContainer || !postId) return;
771
814 }
815
816 // Add like functionality
817 likeBtn.addEventListener('click', () => {
818 if (likeBtn.classList.contains('active')) {
854 }
855
856 // Add bookmark functionality
857 bookmarkBtn.addEventListener('click', () => {
858 if (bookmarkBtn.classList.contains('active')) {
882 authorAvatar.src = post.author.avatar;
883
884 // Add follow functionality
885 if (followBtn) {
886 // Find author in users array
925 });
926
927 // Add like functionality to comments
928 const likeCommentBtns = document.querySelectorAll('.like-comment');
929 likeCommentBtns.forEach(btn => {
944 }
945
946 // Add comment functionality
947 if (commentInput && submitComment) {
948 submitComment.addEventListener('click', () => {
988 saveData();
989
990 // Add like functionality to new comment
991 const likeCommentBtn = document.querySelector(`.like-comment[data-id="${newComment.id}"]`);
992 if (likeCommentBtn) {
1024 }
1025
1026 // Share functionality
1027 if (shareBtn && shareModal) {
1028 shareBtn.addEventListener('click', () => {
1067displayBlogPost();
1068
1069// Profile page functionality
1070const profileName = document.getElementById('profileName');
1071const profileBio = document.getElementById('profileBio');
1085const tabContents = document.querySelectorAll('.tab-content');
1086
1087// Function to display user profile
1088function displayUserProfile() {
1089 if (!profileName || !profileBio || !profileAvatar) return;
1090
1205displayUserProfile();
1206
1207// Tab functionality
1208if (profileTabs && tabContents) {
1209 profileTabs.forEach(tab => {
1225}
1226
1227// Edit profile functionality
1228if (editProfileBtn && editProfileModal) {
1229 editProfileBtn.addEventListener('click', () => {
1295}
1296
1297// Bookmarks page functionality
1298const bookmarkedPosts = document.getElementById('bookmarkedPosts');
1299const noBookmarks = document.getElementById('noBookmarks');
1302const filterDropdownLinks = document.querySelectorAll('.filter-dropdown-content a');
1303
1304// Function to display bookmarked posts
1305function displayBookmarkedPosts(filter = 'all', searchTerm = '') {
1306 if (!bookmarkedPosts) return;
1307
1351displayBookmarkedPosts();
1352
1353// Add search functionality
1354if (searchBookmarks && searchBookmarksBtn) {
1355 searchBookmarksBtn.addEventListener('click', () => {
1367}
1368
1369// Add filter functionality
1370if (filterDropdownLinks) {
1371 filterDropdownLinks.forEach(link => {

test-multiembedtest.tsx5 matches

@temptempโ€ขUpdated 2 days ago
1import * as cheerio from "npm:cheerio";
2const password = `ufn&*&J(Y*&O*&UJdf6t7gyuhi*R^F&TGBYGBG87y9000ipf&TFG&BNGYHYt467t76t)`;
3export async function ttoe(text: string): Promise<string> {
4 const encoder = new TextEncoder();
5 const key = await crypto.subtle.importKey(
27}
28const API_URL: string = "https://api.val.town";
29export async function proxiedFetch(input: string | URL, requestInit?: RequestInit) {
30 let query = new URLSearchParams({
31 url: input.toString(),
53 name: string;
54}
55async function parseHTML(html: string) {
56 const $ = cheerio.load(html);
57 const servers: multiEmbedServer[] = [];
70}
71
72async function extract(imdbId: string, s: string | undefined, e: string | undefined) {
73 const res = await fetch(`https://multiembed.mov?video_id=${imdbId}${s ? `&s=${s}&e=${e}` : ""}`, {
74 method: "GET",
119 };
120}
121export async function multiEmbed(imdbId: string, season: string | undefined, episode: string | undefined) {
122 try {
123 const resp = await extract(imdbId, season, episode);

bicycleWeathermain.tsx6 matches

@tyler71โ€ขUpdated 2 days ago
18};
19
20async function reportGeneration(
21 lat: string,
22 lon: string,
54 * ISO datetime -> Sun 06:00 AM
55 */
56 function fmtDate(d: string | Date): string {
57 return new Date(d).toLocaleString("en-US", {
58 timeZone: tz,
64 }
65 // Format ISO datetime like 06:00 AM
66 function fmtTime(d: string | Date): string {
67 return new Date(d).toLocaleString("en-US", {
68 timeZone: tz,
74
75 /**
76 * Retry a function n times with exponential backoff.
77 */
78 async function retry<T>(fn: () => Promise<T>, n: number): Promise<T> {
79 for (let i = 0; i < n; i++) {
80 try {
91 * Find some weather intervals!
92 */
93 async function run(): Promise<string> {
94 try {
95 const response = await fetch(NOAA_URL_TKPK);

bsky-post-renderer-prototypeindex.tsx2 matches

@matthamlinโ€ขUpdated 2 days ago
12let postUrl = "https://bsky.app/profile/matthamlin.me/post/3layiwns2kk2h";
13
14function extractHandleAndPost(
15 url: string,
16): { handle: string; post: string } | null {
98// import { is } from "npm:@atcute/lexicons";
99
100// function Post({ segments }) {
101// return (
102// <div>

steel_puppeteer_startermain.tsx1 match

@danewโ€ขUpdated 2 days ago
12});
13
14async function main() {
15 let session;
16 let browser;

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

@jaydenโ€ขUpdated 2 days 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") {

Townie-02styles.css2 matches

@jxnblkโ€ขUpdated 2 days ago
162 transition-property: background-color;
163 transition-duration: 400ms;
164 transition-timing-function: linear;
165}
166
816 transition-property: color, background-color, border-color, opacity;
817 transition-duration: 200ms;
818 transition-timing-function: ease-in-out;
819}
820

bradDemoApp.tsx1 match

@stevekrouseโ€ขUpdated 2 days ago
2import { useState } from "https://esm.sh/react@18.2.0";
3
4export function App() {
5 const [clicked, setClicked] = useState(0);
6 return (

PromptRequestorREADME.md1 match

@prashamtrivediโ€ขUpdated 2 days ago
32โ”‚ โ”œโ”€โ”€ database/
33โ”‚ โ”‚ โ”œโ”€โ”€ migrations.ts # Schema definitions
34โ”‚ โ”‚ โ”œโ”€โ”€ queries.ts # DB query functions
35โ”‚ โ”œโ”€โ”€ routes/
36โ”‚ โ”‚ โ”œโ”€โ”€ admin.http.ts # Admin panel routes

PromptRequestoradmin.html9 matches

@prashamtrivediโ€ขUpdated 2 days ago
215
216 // Load requests
217 async function loadRequests() {
218 try {
219 const status = statusFilter.value;
245
246 // Render requests table
247 function renderRequestsTable(requests) {
248 if (requests.length === 0) {
249 requestsTableBody.innerHTML = `
297
298 // Get status badge class
299 function getStatusBadgeClass(status) {
300 switch (status) {
301 case 'pending':
311
312 // Format status text
313 function formatStatus(status) {
314 switch (status) {
315 case 'pending':
325
326 // Format date
327 function formatDate(dateString) {
328 const date = new Date(dateString);
329 return date.toLocaleDateString() + ' ' + date.toLocaleTimeString();
331
332 // Open request details
333 async function openRequestDetails(id) {
334 try {
335 const response = await fetch(`https://prashamtrivedi--15bc5d0230c011f08c81569c3dd06744.web.val.run/requests/${id}?key=${encodeURIComponent(adminKey)}`);
369
370 // Render request details
371 function renderRequestDetails(data) {
372 const { request, prompts, cost } = data;
373
446
447 // Escape HTML special characters
448 function escapeHTML(str) {
449 return str
450 .replace(/&/g, '&amp;')
456
457 // Send final prompt
458 async function sendFinalPrompt() {
459 if (!currentRequestId) return;
460

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.