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/?q=function&page=589&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 18726 results for "function"(2725ms)

stevensDemogetCalendarEvents.ts6 matches

@vasusenโ€ขUpdated 3 weeks ago
6const LOCAL_TIMEZONE = "America/New_York";
7
8async function deleteExistingCalendarEvents() {
9 await sqlite.execute(
10 `
15}
16
17// Helper function to extract time from ISO string without timezone conversion
18function extractTimeFromISO(isoString) {
19 // Match the time portion of the ISO string
20 const timeMatch = isoString.match(/T(\d{2}):(\d{2}):/);
31}
32
33function formatEventToNaturalLanguage(event) {
34 const summary = event.summary || "Untitled event";
35
83}
84
85async function insertCalendarEvent(date, eventText) {
86 const { nanoid } = await import("https://esm.sh/nanoid@5.0.5");
87
97}
98
99export default async function getCalendarEvents() {
100 try {
101 const events = await getEvents(

stevensDemogenerateFunFacts.ts8 matches

@vasusenโ€ขUpdated 3 weeks 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();

stevensDemo.cursorrules15 matches

@vasusenโ€ขUpdated 3 weeks ago
8### 1. Script Vals
9
10- Basic JavaScript/TypeScript functions
11- Can be imported by other vals
12- Example structure:
13
14```typescript
15export function myFunction() {
16 // Your code here
17}
25
26```typescript
27export default async function (req: Request) {
28 return new Response("Hello World");
29}
37
38```typescript
39export default async function () {
40 // Scheduled task code
41}
49
50```typescript
51export default async function (email: Email) {
52 // Process email
53}
57
58- Ask clarifying questions when requirements are ambiguous
59- Provide complete, functional solutions rather than skeleton implementations
60- Test your logic against edge cases before presenting the final solution
61- Ensure all code follows Val Town's specific platform requirements
70- **Never bake in secrets into the code** - always use environment variables
71- Include comments explaining complex logic (avoid commenting obvious operations)
72- Follow modern ES6+ conventions and functional programming practices if possible
73
74## Val Town Standard Libraries
75
76Val Town provides several hosted services and utility functions.
77
78### Blob Storage
124```
125
126## Val Town Utility Functions
127
128Val Town provides several utility functions to help with common project tasks.
129
130### Importing Utilities
176 {
177 name: "should add numbers correctly",
178 function: () => {
179 expect(1 + 1).toBe(2);
180 },
210โ”‚ โ”œโ”€โ”€ database/
211โ”‚ โ”‚ โ”œโ”€โ”€ migrations.ts # Schema definitions
212โ”‚ โ”‚ โ”œโ”€โ”€ queries.ts # DB query functions
213โ”‚ โ”‚ โ””โ”€โ”€ README.md
214โ”‚ โ”œโ”€โ”€ index.ts # Main entry point
226โ””โ”€โ”€ shared/
227 โ”œโ”€โ”€ README.md
228 โ””โ”€โ”€ utils.ts # Shared types and functions
229```
230
232- Hono is the recommended API framework (similar to Express, Flask, or Sinatra)
233- Main entry point should be `backend/index.ts`
234- **Static asset serving:** Use the utility functions to read and serve project files:
235 ```ts
236 // Use the serveFile utility to handle content types automatically
273- Run migrations on startup or comment out for performance
274- Change table names when modifying schemas rather than altering
275- Export clear query functions with proper TypeScript typing
276- Follow the queries and migrations pattern from the example
277

stevensDemocronDailyBrief.ts1 match

@vasusenโ€ขUpdated 3 weeks ago
1import { sendDailyBriefing } from "./sendDailyBrief.ts";
2
3export async function cronDailyBrief() {
4 try {
5 const chatId = Deno.env.get("TELEGRAM_CHAT_ID");

stevensDemoApp.tsx2 matches

@vasusenโ€ขUpdated 3 weeks ago
62};
63
64export function App() {
65 const [memories, setMemories] = useState<Memory[]>([]);
66 const [loading, setLoading] = useState(true);
139 const data = await response.json();
140
141 // Change the sorting function to show memories in chronological order
142 const sortedMemories = [...data].sort((a, b) => {
143 const dateA = a.createdDate || 0;

iMessageSnowglobeGroupAvatarmain.tsx3 matches

@vawogbemiโ€ขUpdated 3 weeks ago
116};
117
118function App() {
119 const [avatarCount, setAvatarCount] = useState(7);
120 const [sizeMultiplier, setSizeMultiplier] = useState(1);
171}
172
173function client() {
174 createRoot(document.getElementById("root")).render(<App />);
175}
176if (typeof document !== "undefined") { client(); }
177
178export default async function server(request: Request): Promise<Response> {
179 return new Response(
180 `

iMessagePlanetGroupAvatarmain.tsx3 matches

@vawogbemiโ€ขUpdated 3 weeks ago
160};
161
162function App() {
163 const [avatarCount, setAvatarCount] = useState(10);
164 const [scale, setScale] = useState(1);
214}
215
216function client() {
217 createRoot(document.getElementById("root")).render(<App />);
218}
219if (typeof document !== "undefined") { client(); }
220
221export default async function server(request: Request): Promise<Response> {
222 return new Response(
223 `

iMessagePlanetAdHocGroupAvatarmain.tsx3 matches

@vawogbemiโ€ขUpdated 3 weeks ago
160};
161
162function App() {
163 const [avatarCount, setAvatarCount] = useState(10);
164 const [sizeMultiplier, setSizeMultiplier] = useState(1);
215}
216
217function client() {
218 createRoot(document.getElementById("root")).render(<App />);
219}
220if (typeof document !== "undefined") { client(); }
221
222export default async function server(request: Request): Promise<Response> {
223 return new Response(
224 `

fullStackTaskProjectmain.tsx3 matches

@Minkemโ€ขUpdated 3 weeks ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function App() {
6 const [tasks, setTasks] = useState([]);
7 const [newTask, setNewTask] = useState("");
103}
104
105function client() {
106 createRoot(document.getElementById("root")).render(<App />);
107}
108if (typeof document !== "undefined") { client(); }
109
110export default async function server(request: Request): Promise<Response> {
111 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
112 const KEY = "fullStackTaskProject";

landing-pageHome.jsx4 matches

@juecdโ€ขUpdated 3 weeks ago
4
5// Main App
6function App() {
7 https:
8 // juecd-scintillatingrosegoose.web.val.run/
70}
71
72function client() {
73 createRoot(document.getElementById("root")).render(<App />);
74}
75if (typeof document !== "undefined") { client(); }
76
77export default async function server(request: Request): Promise<Response> {
78 return new Response(
79 `
120.text-lg { font-size: 1.125rem; }
121.rounded-lg { border-radius: 0.5rem; }
122.transition-colors { transition-property: color; transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); transition-duration: 150ms; }
123.relative { position: relative; }
124.absolute { position: absolute; }

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