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=18&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 7215 results for "function"(319ms)

stevensDemoqueries.ts4 matches

@lixP•Updated 3 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

@lixP•Updated 3 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

@lixP•Updated 3 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

@lixP•Updated 3 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

@lixP•Updated 3 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

@lixP•Updated 3 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

@lixP•Updated 3 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

@lixP•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);

stevensDemohandleTelegramMessage.ts5 matches

@lixP•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) {

stevensDemogetWeather.ts5 matches

@lixP•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 });

getFileEmail4 file matches

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

TwilioHelperFunctions

@vawogbemi•Updated 2 months ago