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=34&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 18895 results for "function"(586ms)

luciaMagicLinkStarter

luciaMagicLinkStarterschema.ts1 match

@stevekrouse•Updated 2 days ago
5export const MAGIC_LINKS_TABLE = "lucia_demo_magic_links_v2";
6
7async function createTables() {
8 await sqlite.execute(`
9 CREATE TABLE IF NOT EXISTS ${USER_TABLE} (
luciaMagicLinkStarter

luciaMagicLinkStarterLoginForm.tsx1 match

@stevekrouse•Updated 2 days ago
6}
7
8export function LoginForm({ onError }: LoginFormProps) {
9 const [email, setEmail] = useState("");
10 const [isSubmitting, setIsSubmitting] = useState(false);

EEPMOnitoringmediaMonitoring.tsx5 matches

@solomonferede•Updated 2 days ago
10};
11
12function MediaMonitoringTab({ user }) {
13 const [entries, setEntries] = useState([]);
14 const [platform, setPlatform] = useState("");
167 };
168
169 // Function to open the edit modal
170 const handleEditClick = (entry) => {
171 setEditingEntry(entry);
187 };
188
189 // Function to close the edit modal
190 const handleCloseEditModal = () => {
191 setIsEditModalOpen(false);
204 };
205
206 // Function to handle changes in the edit modal form
207 const handleEditFormChange = (e) => {
208 const { name, value } = e.target;
213 };
214
215 // Function to save the edited entry
216 const handleSaveEdit = async () => {
217 // Validate required fields from editFormData

my-first-val04_email.tsx1 match

@Slade_Corp•Updated 2 days ago
2// Click "Run", copy and paste the email address and send an email to it.
3// This example will log the email details received.
4export default async function emailHandler(email: Email){
5 console.log("Email received!", email.from, email.subject, email.text);
6 for (const file of email.attachments) {

my-first-val03_cron.tsx1 match

@Slade_Corp•Updated 2 days ago
2// Configure the timer with the 🕒 icon in the top right.
3// This example just logs the current time.
4export function scheduledHandler() {
5 const timestamp = new Date().toISOString();
6 console.log(`Cron val executed at: ${timestamp}`);

my-first-val02_http.tsx1 match

@Slade_Corp•Updated 2 days ago
2// Access it via its public URL (you can also pick a nicer subdomain).
3// Try adding ?name=YourName to the URL!
4export default function httpHandler(req: Request): Response {
5 const url = new URL(req.url);
6 const name = url.searchParams.get("name") || "Friend";

my-first-val01_script.tsx1 match

@Slade_Corp•Updated 2 days ago
1// This script returns a random fun fact
2// You can run scripts manually in this view or call it from other vals.
3export default function getRandomFact() {
4 const funFacts = [
5 "Honey never spoils.",

HHGtoMyDaygetTodoist.ts4 matches

@lm3m•Updated 2 days ago
30}
31
32async function deleteExistingTodoistEvents() {
33 await sqlite.execute(
34 `
43 * @returns Array of Todoist tasks due today or overdue
44 */
45async function fetchTodoistTasks(): Promise<TodoistTask[]> {
46 const apiToken = Deno.env.get("TODOIST_API_TOKEN");
47
87 * @returns Memory object
88 */
89function convertTodoistTaskToMemory(task: TodoistTask): Memory {
90 return {
91 id: task.id.toString(),
101 * Stores Todoist tasks in SQLite database
102 */
103export default async function storeTodoistTasksToMemories() {
104 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
105

HHGtoMyDaysendDailyBrief.ts6 matches

@lm3m•Updated 2 days ago
8import { formatMemoriesForPrompt, getRelevantMemories } from "../memoryUtils.ts";
9
10async function generateBriefingContent(anthropic, memories, today, isSunday) {
11 try {
12 const weekdaysHelp = generateWeekDays(today);
92}
93
94export async function sendDailyBriefing(today?: DateTime) {
95 // Get API keys from environment
96 const apiKey = Deno.env.get("ANTHROPIC_API_KEY");
131 const lastSunday = today.startOf("week").minus({ days: 1 });
132
133 // Fetch relevant memories using the utility function
134 const memories = await getRelevantMemories();
135
222}
223
224function generateWeekDays(today) {
225 let output = [];
226
245// console.log(weekDays);
246
247// Export a function that calls sendDailyBriefing with no parameters
248// This maintains backward compatibility with existing cron jobs
249export default async function(overrideToday?: DateTime) {
250 return await sendDailyBriefing(undefined, overrideToday);
251}

telegramBotStartertestBot.tsx2 matches

@asdfg•Updated 2 days ago
5import { sendTelegramMessage } from "https://esm.town/v/asdfg/telegramBotStarter/sendTelegramMessage.tsx";
6
7async function testBot() {
8 const ownerChatId = process.env.OWNER_CHAT_ID;
9
26}
27
28// console log testBot function
29// console.log(await testBot);
30

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
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": "*",