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=62&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 19678 results for "function"(1057ms)

MiniAppStarterFarcasterMiniApp.tsx1 match

@kashi•Updated 3 days ago
4import { formatAddress, formatJSON, MonoButtonWithStatus, Section } from "./ui.tsx";
5
6export function FarcasterMiniApp() {
7 const [context, setContext] = useState<any>();
8 const [walletAddresses, setWalletAddresses] = useState<any>();

MiniAppStarterExample.tsx1 match

@kashi•Updated 3 days ago
5import { ShareButton } from "./ui.tsx";
6
7export function Example() {
8 const [context, setContext] = useState<any>();
9 useEffect(() => {

MiniAppStarterdb.ts2 matches

@kashi•Updated 3 days ago
3const projectPrefix = "miniapp-starter";
4
5export async function get(key: string) {
6 return await blob.getJSON(`${projectPrefix}::${key}`);
7}
8export async function set(key: string, value: any) {
9 return await blob.setJSON(`${projectPrefix}::${key}`, value);
10}

MiniAppStarterdaily-notification.ts1 match

@kashi•Updated 3 days ago
3const baseUrl = "https://miniapp-starter.val.run";
4
5export default async function(interval: Interval) {
6 // await sendNotificationToAllUsers({
7 // title: "Example daily notification",

MiniAppStarterApp.tsx4 matches

@kashi•Updated 3 days ago
10import { fetchNeynarGet } from "./util/neynar.ts";
11
12export function App() {
13 const navLinks = [
14 { name: "Farcaster SDK", path: "/" },
43}
44
45function About() {
46 return (
47 <Section className="flex flex-col items-start gap-3 m-5">
66}
67
68function Database() {
69 const queryFn = () => fetch("/api/counter/get").then((r) => r.json());
70 const { data, refetch } = useQuery({ queryKey: ["counter"], queryFn });
80}
81
82function Neynar() {
83 useEffect(() => {
84 fetchNeynarGet("user/by_username?username=moe").then(console.log).catch(console.error);

pollinaterpbldemo.tsx5 matches

@quartex•Updated 3 days ago
3import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
4
5function BeehiveMonitor() {
6 const [temperature, setTemperature] = useState(null);
7 const [humidity, setHumidity] = useState(null);
9
10 useEffect(() => {
11 async function fetchSensorData() {
12 try {
13 // Simulated sensor data with realistic bee habitat conditions
70}
71
72function App() {
73 return <BeehiveMonitor />;
74}
75
76function client() {
77 createRoot(document.getElementById("root")).render(<App />);
78}
79if (typeof document !== "undefined") { client(); }
80
81export default async function server(request: Request): Promise<Response> {
82 return new Response(
83 `

roseytestDailyBrief.ts1 match

@avni•Updated 3 days ago
4import { DateTime } from "https://esm.sh/luxon@3.4.4";
5
6export async function testDailyBrief() {
7 try {
8 const testChatId = Deno.env.get("TEST_TELEGRAM_CHAT_ID");

roseysetupTelegramChatDb.ts1 match

@avni•Updated 3 days ago
2// Run this script manually to create the database table
3
4export default async function setupTelegramChatDb() {
5 try {
6 // Import SQLite module

roseysendDailyBrief.ts6 matches

@avni•Updated 3 days ago
13} from "../memoryUtils.ts";
14
15async function generateBriefingContent(anthropic, memories, today, isSunday) {
16 try {
17 const weekdaysHelp = generateWeekDays(today);
96}
97
98export async function sendDailyBriefing(chatId?: string, today?: DateTime) {
99 // Get API keys from environment
100 const apiKey = Deno.env.get("ANTHROPIC_API_KEY");
135 const lastSunday = today.startOf("week").minus({ days: 1 });
136
137 // Fetch relevant memories using the utility function
138 const memories = await getRelevantMemories();
139
216}
217
218function generateWeekDays(today) {
219 let output = [];
220
239// console.log(weekDays);
240
241// Export a function that calls sendDailyBriefing with no parameters
242// This maintains backward compatibility with existing cron jobs
243export default async function (overrideToday?: DateTime) {
244 return await sendDailyBriefing(undefined, overrideToday);
245}

roseyREADME.md2 matches

@avni•Updated 3 days ago
16In a normal server environment, you would likely use a middleware [like this one](https://hono.dev/docs/getting-started/nodejs#serve-static-files) to serve static files. Some frameworks or deployment platforms automatically make any content inside a `public/` folder public.
17
18However in Val Town you need to handle this yourself, and it can be suprisingly difficult to read and serve files in a Val Town Project. This template uses helper functions from [stevekrouse/utils/serve-public](https://www.val.town/x/stevekrouse/utils/branch/main/code/serve-public/README.md), which handle reading project files in a way that will work across branches and forks, automatically transpiles typescript to javascript, and assigns content-types based on the file's extension.
19
20### `index.html`
26## CRUD API Routes
27
28This app has two CRUD API routes: for reading and inserting into the messages table. They both speak JSON, which is standard. They import their functions from `/backend/database/queries.ts`. These routes are called from the React app to refresh and update data.
29
30## Errors

getFileEmail4 file matches

@shouser•Updated 3 weeks ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 3 weeks ago
Simple functional CSS library for Val Town
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": "*",
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.