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/$2?q=function&page=58&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 29395 results for "function"(967ms)

9}
10
11export default function ShareModal({ onSave, onCancel, isUploading }: ShareModalProps) {
12 const [expirationType, setExpirationType] = useState<'none' | 'date' | 'listens'>('none');
13 const [expirationDate, setExpirationDate] = useState('');

voicemessagesqueries.ts6 matches

@michaelwschultzUpdated 2 days ago
3import type { VoiceNote } from "../../shared/types.ts";
4
5export async function createVoiceNote(voiceNote: Omit<VoiceNote, 'isExpired'>): Promise<void> {
6 try {
7 await sqlite.execute(
29}
30
31export async function getVoiceNote(id: string): Promise<VoiceNote | null> {
32 try {
33 const result = await sqlite.execute(
68}
69
70export async function incrementListenCount(id: string): Promise<void> {
71 await sqlite.execute(
72 `UPDATE ${TABLE_NAME} SET current_listens = current_listens + 1 WHERE id = ?`,
75}
76
77export async function updateTranscription(id: string, transcription: string): Promise<void> {
78 await sqlite.execute(
79 `UPDATE ${TABLE_NAME} SET transcription = ? WHERE id = ?`,
82}
83
84export async function deleteVoiceNote(id: string): Promise<void> {
85 await sqlite.execute(
86 `DELETE FROM ${TABLE_NAME} WHERE id = ?`,
89}
90
91export async function getAllVoiceNotes(): Promise<VoiceNote[]> {
92 try {
93 const result = await sqlite.execute(`SELECT * FROM ${TABLE_NAME} ORDER BY created_at DESC`);

voicemessagesmigrations.ts1 match

@michaelwschultzUpdated 2 days ago
3const TABLE_NAME = 'voice_notes_v1';
4
5export async function runMigrations() {
6 try {
7 // Create voice notes table

voicemessagesDashboard.tsx1 match

@michaelwschultzUpdated 2 days ago
3import type { VoiceNote } from "../../shared/types.ts";
4
5export default function Dashboard() {
6 const [voiceNotes, setVoiceNotes] = useState<VoiceNote[]>([]);
7 const [loading, setLoading] = useState(true);

voicemessagesApp.tsx1 match

@michaelwschultzUpdated 2 days ago
11}
12
13export default function App() {
14 const [currentView, setCurrentView] = useState<"recorder" | "player" | "dashboard">("recorder");
15 const voiceNoteId = window.__VOICE_NOTE_ID__;

wakatime-readme-chartmain.tsx7 matches

@loadingUpdated 2 days ago
40}
41
42function App() {
43 const [chartUrl, setChartUrl] = useState<string | null>(null);
44
57}
58
59function client() {
60 createRoot(document.getElementById("root")!).render(<App />);
61}
65}
66
67async function fetchWakaTimeData(): Promise<DataPoint[]> {
68 const response = await fetch("https://wakatime.com/share/@load1n9/899abefd-d814-4e99-b603-e94af0305d4a.json");
69 const data = await response.json();
82};
83
84async function generateChart(data: DataPoint[]): Promise<string> {
85 const width = 1000;
86 const height = 600;
164}
165
166function roundRect(
167 ctx: CanvasRenderingContext2D,
168 x: number,
190}
191
192function roundRectTop(
193 ctx: CanvasRenderingContext2D,
194 x: number,
219}
220
221export default async function server(request: Request): Promise<Response> {
222 const url = new URL(request.url);
223

base2getNewsBatches.js1 match

@tehaUpdated 2 days ago
3import { sqlite } from "https://esm.town/v/YOUR_USERNAME/database"; // ⚠️ CHANGE YOUR_USERNAME
4
5export default async function(req: Request) {
6 const results = await sqlite.execute(`
7 SELECT batch_id, MIN(fetched_at) as fetch_time, COUNT(*) as article_count

base2getNewsByBatch.js1 match

@tehaUpdated 2 days ago
4import { sqlite } from "https://esm.town/v/YOUR_USERNAME/database"; // ⚠️ CHANGE YOUR_USERNAME
5
6export default async function(req: Request) {
7 const url = new URL(req.url);
8 const batchId = url.pathname.split("/").pop(); // Get batchId from path

base2getLatestNews.js1 match

@tehaUpdated 2 days ago
3import { sqlite } from "https://esm.town/v/YOUR_USERNAME/database"; // ⚠️ CHANGE YOUR_USERNAME
4
5export default async function(req: Request) {
6 const latestBatch = await sqlite.execute(`SELECT batch_id FROM news ORDER BY fetched_at DESC LIMIT 1`);
7 if (latestBatch.rows.length === 0) {

base2fetchAndStoreNews.js5 matches

@tehaUpdated 2 days ago
1// Val Name: fetchAndStoreNews.js
2// Type: Scheduled Function (e.g., every 3 hours)
3
4import { blob } from "https://esm.town/v/std/blob";
9const GNEWS_API_KEY = "973de7360b49225b484c14a98fcc0a7f"; // It's better to store this as an environment variable in Val Town
10
11// Function to generate TTS and save it to blob storage
12async function generateTtsAudio(text, newsId) {
13 // Check if audio already exists
14 const existing = await sqlite.execute({
46}
47
48// Main function to be scheduled
49export default async function fetchAndStoreNews() {
50 console.log("Fetching fresh news...");
51 const response = await fetch(
tuna

tuna9 file matches

@jxnblkUpdated 2 days ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouserUpdated 1 month ago
A helper function to build a file's email
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.