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=8&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 18191 results for "function"(1571ms)

glifTestmain.tsx1 match

@jonbo•Updated 22 hours ago
1export default async function(req: Request): Promise<Response> {
2 return Response.json({
3 image_url: "https://jon.bo/IMG_9387.png",

testPondiversegetCreations1 match

@argmn•Updated 22 hours ago
3import { TABLE_NAME } from "./updateTable";
4
5export default async function(req: Request): Promise<Response> {
6 // First, get the row IDs of all rows that are older than 25 hours old
7 const res = await sqlite.execute(`

blob_adminapp.tsx7 matches

@fredmoon•Updated 22 hours ago
10}
11
12function Tooltip({ children, content }: TooltipProps) {
13 const [isVisible, setIsVisible] = useState(false);
14 const tooltipRef = useRef<HTMLDivElement>(null);
49}
50
51function formatBytes(bytes: number, decimals = 2) {
52 if (bytes === 0) return "0 Bytes";
53 const k = 1024;
58}
59
60function copyToClipboard(text: string) {
61 navigator.clipboard.writeText(text).then(() => {
62 console.log("Text copied to clipboard");
66}
67
68function ActionMenu({ blob, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
69 const [isOpen, setIsOpen] = useState(false);
70 const menuRef = useRef(null);
73
74 useEffect(() => {
75 function handleClickOutside(event) {
76 if (menuRef.current && !menuRef.current.contains(event.target)) {
77 event.stopPropagation();
155}
156
157function BlobItem({ blob, onSelect, isSelected, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
158 const [isLoading, setIsLoading] = useState(false);
159 const decodedKey = decodeURIComponent(blob.key);
216}
217
218function App({ initialEmail, initialProfile, sourceURL }) {
219 const encodeKey = (key: string) => encodeURIComponent(key);
220 const decodeKey = (key: string) => decodeURIComponent(key);

testPondiversegetCreation1 match

@argmn•Updated 22 hours ago
3import { TABLE_NAME } from "./updateTable";
4
5export default async function(req: Request): Promise<Response> {
6 const url = new URL(req.url);
7 const id = url.searchParams.get("id");

untitled-2604new-file-9513.tsx12 matches

@al0•Updated 22 hours ago
3// Fecha: 05 de mayo de 2025
4
5export default async function handler(req) {
6 // Configuración CORS para permitir solicitudes desde cualquier origen
7 const headers = {
112
113// Función para llamar a la API de OpenAI
114async function callOpenAI(apiKey, prompt, model, temperature, maxTokens) {
115 const url = 'https://api.openai.com/v1/chat/completions';
116
171
172// Función para llamar a la API de Claude (Anthropic)
173async function callClaude(apiKey, prompt, model, temperature, maxTokens) {
174 const url = 'https://api.anthropic.com/v1/messages';
175
237
238// Función para renderizar la interfaz de usuario
239function renderUI() {
240 return `
241 <!DOCTYPE html>
398 const tempSlider = document.getElementById('temperature');
399 const tempValue = document.getElementById('temperatureValue');
400 tempSlider.addEventListener('input', function() {
401 tempValue.textContent = tempSlider.value;
402 });
404 // Cambiar entre pestañas
405 const tabs = document.querySelectorAll('.tab');
406 tabs.forEach(function(tab) {
407 tab.addEventListener('click', function() {
408 const tabName = tab.getAttribute('data-tab');
409
410 // Desactivar todas las pestañas
411 document.querySelectorAll('.tab').forEach(function(t) {
412 t.classList.remove('active');
413 });
414 document.querySelectorAll('.tab-content').forEach(function(c) {
415 c.classList.remove('active');
416 });
433 const modelSelect = document.getElementById('model');
434
435 providerSelect.addEventListener('change', function() {
436 const provider = providerSelect.value;
437
451 });
452
453 function addOption(select, value, text) {
454 const option = document.createElement('option');
455 option.value = value;
463 const rawResult = document.getElementById('rawResult');
464
465 submitBtn.addEventListener('click', async function() {
466 const provider = document.getElementById('provider').value;
467 const apiKey = document.getElementById('apiKey').value;

testPondiversedeleteCreation1 match

@argmn•Updated 22 hours ago
4import { TABLE_NAME } from "./updateTable";
5
6export default async function(req: Request): Promise<Response> {
7 // body contains:
8 // - id (number)

morningmailmain.tsx4 matches

@flymaster•Updated 22 hours ago
2import { email } from "https://esm.town/v/std/email";
3
4function links(): string {
5 var links = "- [Gisnep](https://gisnep.com)\n";
6 links = links + "- [Gin](https://cardgames.io/ginrummy)\n";
10}
11
12async function weather(): string {
13 var weather = await blob.getJSON(Deno.env.get("WEATHER_BLOB"));
14 weather = weather.forecast;
17}
18
19async function wikitext(): string {
20 const randomArticle = await fetch(
21 "https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&exintro&explaintext&redirects=1&generator=random&formatversion=2&grnnamespace=0&grnlimit=3",
31}
32
33export default async function(interval: Interval) {
34 var emailText = "";
35 emailText = emailText + await weather();

LEDStrain-Discussion-To-PlainTextapp.tsx3 matches

@tyler71•Updated 23 hours ago
18const lruCache = new LRUCache(ttlOptions);
19
20export default async function(req: Request): Promise<Response> {
21 const searchParams = new URL(req.url).searchParams;
22 const discussionId = searchParams.get("discussion");
79}
80
81async function getDiscussionPosts(discussionId: string): Promise<PostT[]> {
82 // Used to get the list of post id's for the discussion.
83 const discussionRes = await fetch(`${server}/api/discussions/${discussionId}`);
117
118// This takes an array and chunks it.
119function chunkArray<T>(array: T[], chunkSize: number): T[][] {
120 const chunks: T[][] = [];
121 for (let i = 0; i < array.length; i += chunkSize) {

testOpenAIblah.tx1 match

@stevekrouse•Updated 23 hours ago
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}

TownieuseAuth.tsx1 match

@valdottown•Updated 1 day ago
5const ANTHROPIC_KEY = "anthropic_api_key";
6
7export function useAuth() {
8 const [token, setToken, removeToken] = useLocalStorage(TOKEN_KEY, "");
9 const [anthropicApiKey, setAnthropicApiKey, removeAnthropicApiKey] = useLocalStorage(ANTHROPIC_KEY, "");

getFileEmail4 file matches

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