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=45&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 7802 results for "function"(428ms)

stevensDemoREADME.md2 matches

@sajtosm•Updated 5 days ago
4
5* `migrations.ts` - code to set up the database tables the app needs
6* `queries.ts` - functions to run queries against those tables, which are imported and used in the main Hono server in `/backend/index.ts`
7
8## Migrations
18The queries file is where running the migrations happen in this app. It'd also be reasonable for that to happen in index.ts, or as is said above, for that line to be commented out, and only run when actual changes are made to your database schema.
19
20The queries file exports functions to get and write data. It relies on shared types and data imported from the `/shared` directory.

stevensDemoqueries.ts4 matches

@sajtosm•Updated 5 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}

stevensDemopopulateMemoryIds.ts1 match

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

stevensDemopopulateDemo.ts5 matches

@sajtosm•Updated 5 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

stevensDemopopulateCreatedBy.ts1 match

@sajtosm•Updated 5 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

stevensDemoNotebookView.tsx1 match

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

stevensDemomigrateMemoriesDb.ts1 match

@sajtosm•Updated 5 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

stevensDemomemoryUtils.ts3 matches

@sajtosm•Updated 5 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.";

stevensDemohandleUSPSEmail.ts3 matches

@sajtosm•Updated 5 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);

stevensDemohandleTelegramMessage.ts5 matches

@sajtosm•Updated 5 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) {

getFileEmail4 file matches

@shouser•Updated 6 days ago
A helper function to build a file's email

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago