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=33&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 7325 results for "function"(1134ms)

stevens-openaiqueries.ts4 matches

@yash_ingโ€ขUpdated 4 days ago
6const tableName = "memories_demo";
7
8export async function getAllMemories(): Promise<Memory[]> {
9 const result = await sqlite.execute(
10 `SELECT id, date, text, createdBy, createdDate, tags FROM ${tableName}
23}
24
25export async function createMemory(
26 memory: Omit<Memory, "id">
27): Promise<Memory> {
51}
52
53export async function updateMemory(
54 id: string,
55 memory: Partial<Omit<Memory, "id">>
70}
71
72export async function deleteMemory(id: string): Promise<void> {
73 await sqlite.execute(`DELETE FROM ${tableName} WHERE id = ?`, [id]);
74}

stevens-openaipopulateMemoryIds.ts1 match

@yash_ingโ€ขUpdated 4 days ago
4import { nanoid } from "https://esm.sh/nanoid@5.0.5";
5
6export default async function populateMemoryIds() {
7 try {
8 // Import SQLite module

stevens-openaipopulateDemo.ts5 matches

@yash_ingโ€ขUpdated 4 days ago
5
6// Create the memories_demo table
7async function createMemoriesDemoTable() {
8 try {
9 await sqlite.execute(`
25
26// Create a fake memory with proper ID and timestamps
27function createMemory(date, text, createdBy, tags, createdDateOffset = 0) {
28 const id = nanoid(10);
29 // Base date is April 5, 2025
375
376// Insert memories into the database
377async function insertDemoMemories() {
378 try {
379 // Clear existing data if any
406}
407
408// Main function to populate demo data
409export default async function populateDemo() {
410 try {
411 // Create the table

stevens-openaipopulateCreatedBy.ts1 match

@yash_ingโ€ขUpdated 4 days ago
2// Run this script manually to set createdBy based on memory content
3
4export default async function populateCreatedBy() {
5 try {
6 // Import SQLite module

stevens-openaiNotebookView.tsx1 match

@yash_ingโ€ขUpdated 4 days ago
54}
55
56export function NotebookView({ onClose, avatarUrl }: NotebookViewProps) {
57 const [memories, setMemories] = useState<Memory[]>([]);
58 const [loading, setLoading] = useState(true);

stevens-openaimigrateMemoriesDb.ts1 match

@yash_ingโ€ขUpdated 4 days ago
2// Run this script manually to add new columns to the memories table
3
4export default async function migrateMemoriesDb() {
5 try {
6 // Import SQLite module

stevens-openaimemoryUtils.ts3 matches

@yash_ingโ€ขUpdated 4 days ago
7 * @returns Array of memory objects
8 */
9export async function getAllMemories(includeDate = true, startDate = null) {
10 try {
11 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
41 * @returns Array of memory objects
42 */
43export async function getRelevantMemories() {
44 try {
45 // Get today's date in US Eastern Time
59 * @returns Formatted string of memories
60 */
61export function formatMemoriesForPrompt(memories) {
62 if (!memories || memories.length === 0) {
63 return "No stored memories are available.";

stevens-openaihandleUSPSEmail.ts3 matches

@yash_ingโ€ขUpdated 4 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);

stevens-openaigetCalendarEvents.ts6 matches

@yash_ingโ€ขUpdated 4 days 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(

stevens-openai.cursorrules15 matches

@yash_ingโ€ขUpdated 4 days 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

getFileEmail4 file matches

@shouserโ€ขUpdated 5 days ago
A helper function to build a file's email

TwilioHelperFunctions

@vawogbemiโ€ขUpdated 2 months ago