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=64&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 18558 results for "function"(1231ms)

eink-framecomponents.tsx7 matches

@pcar•Updated 3 days ago
4
5// Display components can be used to change the look and feel of each frame.
6export function Header({ title = "Eink" }) {
7 return (
8 <head>
39}
40
41export function Footer() {
42 const currentDate = new Date().toLocaleDateString("en-US", {
43 timeZone: "America/Los_Angeles",
62}
63
64export function Headline({ text = "Headline missing" }: { text: string }) {
65 return (
66 <div className="flex justify-between items-center p-5">
70}
71
72export function Content(props: any) {
73 return <div className="relative p-5 overflow-none">{props.children}</div>;
74}
75
76export function BodyWrapper(props: any) {
77 return (
78 <body className="bg-black p-0 m-0">
84}
85
86export function App() {
87 return (
88 <html>
99}
100
101export default async function(): Promise<Response> {
102 const html = renderToString(<App />);
103

eink-frameapod.tsx2 matches

@pcar•Updated 3 days ago
6
7// Displays NASA's astronomy photo of the day
8function Render({ data }: { data: APOD }) {
9 return (
10 <html>
25}
26
27export default async function(req: Request): Promise<Response> {
28 const data: APOD = await GetAPOD(req).then((res: any) => res.json());
29 const html = renderToString(<Render data={data} />);

eink-frameapod.ts1 match

@pcar•Updated 3 days ago
13const NASA_API_KEY = Deno.env.get("NASA_API_KEY");
14
15export default async function GetAPOD(req: Request): Promise<Response> {
16 const url = `https://api.nasa.gov/planetary/apod?api_key=${NASA_API_KEY}&thumbs=true`;
17 const cacheKey = "nasa_apod";

snippetshtml_with_hono.tsx1 match

@chadparker•Updated 3 days ago
55});
56
57export default async function(req: Request): Promise<Response> {
58 return app.fetch(req);
59}

snippetsrandomNumber.tsx1 match

@chadparker•Updated 3 days ago
1export default function server(request: Request): Response {
2 const randomNumber = Math.floor(Math.random() * 100) + 1;
3 const responseData = { randomNumber: randomNumber };

mod-interview-apiapi.js1 match

@twschiller•Updated 3 days ago
1// export default async function (req: Request): Promise<Response> {
2
3// if (req.url)

a4595dc5b24_handleTelegramMessage.ts5 matches

@vtTestLocal•Updated 3 days ago
36 * Store a chat message in the database
37 */
38export async function storeChatMessage(
39 chatId,
40 senderId,
69 * Retrieve chat history for a specific chat
70 */
71export async function getChatHistory(chatId, limit = 50) {
72 try {
73 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
94 * Format chat history for Anthropic API
95 */
96function formatChatHistoryForAI(history) {
97 const messages = [];
98
118 * Analyze a Telegram message and extract memories from it
119 */
120async function analyzeMessageContent(
121 anthropic,
122 username,
499
500// Handle webhook requests
501export default async function (req: Request): Promise<Response> {
502 // Set webhook if it is not set yet
503 if (!isEndpointSet) {

a4595dc5b24_getWeather.ts5 matches

@vtTestLocal•Updated 3 days ago
8const TABLE_NAME = `memories`;
9
10function summarizeWeather(weather: WeatherResponse) {
11 const summarizeDay = (day: WeatherResponse["weather"][number]) => ({
12 date: day.date,
25}
26
27async function generateConciseWeatherSummary(weatherDay) {
28 try {
29 // Get API key from environment
83}
84
85async function deleteExistingForecast(date: string) {
86 await sqlite.execute(
87 `
93}
94
95async function insertForecast(date: string, forecast: string) {
96 const { nanoid } = await import("https://esm.sh/nanoid@5.0.5");
97
112}
113
114export default async function getWeatherForecast(interval: number) {
115 const weather = await getWeather("Washington, DC");
116 console.log({ weather });

a4595dc5b24_generateFunFacts.ts8 matches

@vtTestLocal•Updated 3 days ago
11 * @returns Array of previous fun facts
12 */
13async function getPreviousFunFacts() {
14 try {
15 const result = await sqlite.execute(
32 * @param dates Array of date strings in ISO format
33 */
34async function deleteExistingFunFacts(dates) {
35 try {
36 for (const date of dates) {
51 * @param factText The fun fact text
52 */
53async function insertFunFact(date, factText) {
54 try {
55 await sqlite.execute(
75 * @returns Array of generated fun facts
76 */
77async function generateFunFacts(previousFacts) {
78 try {
79 // Get API key from environment
197 * @returns Array of parsed facts
198 */
199function parseFallbackFacts(responseText, expectedDates) {
200 // Try to extract facts using regex
201 const factPattern = /(\d{4}-\d{2}-\d{2})["']?[,:]?\s*["']?(.*?)["']?[,}]/gs;
260
261/**
262 * Main function to generate and store fun facts for the next 7 days
263 */
264export async function generateAndStoreFunFacts() {
265 try {
266 // Get previous fun facts
301 * Intended to be used as a Val Town cron job
302 */
303export default async function() {
304 console.log("Running fun facts generation cron job...");
305 return await generateAndStoreFunFacts();

a4595dc5b24_handleUSPSEmail.ts3 matches

@vtTestLocal•Updated 3 days ago
4const RECIPIENTS = ["Geoffrey", "Maggie"] as const;
5
6function parseDateFromSubject(subject: string): string | null {
7 const match = subject.match(/(\w{3}), (\d{1,2}\/\d{1,2})/);
8 if (match) {
19};
20
21async function analyzeHtmlContent(
22 anthropic: Anthropic,
23 htmlContent: string,
80}
81
82export default async function (e: Email) {
83 console.log("email content");
84 console.log(e.html);

getFileEmail4 file matches

@shouser•Updated 2 weeks 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
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.