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=921&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 18182 results for "function"(2911ms)

cerebras_coderindex2 matches

@admariner•Updated 1 month ago
3import { createProject, getCode, getNextVersionNumber, insertVersion } from "./database/queries";
4
5async function servePublicFile(path: string): Promise<Response> {
6 const url = new URL("./public/" + path, import.meta.url);
7 const text = await (await fetch(url, {
20await createTables();
21
22export default async function cerebras_coder(req: Request): Promise<Response> {
23 if (req.method === "POST") {
24 let { prompt, currentCode, versionHistory, projectId } = await req.json();

cerebras_coderindex7 matches

@admariner•Updated 1 month ago
23);
24
25function Hero({
26 prompt,
27 setPrompt,
44
45 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
46 Turn your ideas into fully functional apps in{" "}
47 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
48 less than a second
115}
116
117function App() {
118 const previewRef = React.useRef<HTMLDivElement>(null);
119 const [prompt, setPrompt] = useState("");
169 });
170
171 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
172 setLoading(true);
173 setTimeout(() => handleSubmit(promptItem.prompt), 0);
174 }
175
176 async function handleSubmit(e: React.FormEvent | string) {
177 if (typeof e !== "string") {
178 e.preventDefault();
225 }
226
227 function handleVersionChange(direction: "back" | "forward") {
228 const { currentVersionIndex, versions } = versionHistory;
229 if (direction === "back" && currentVersionIndex > 0) {
973);
974
975function client() {
976 const path = window.location.pathname;
977 const root = createRoot(document.getElementById("root")!);

cerebras_codergenerate-code2 matches

@admariner•Updated 1 month ago
2import STARTER_PROMPTS from "../public/starter-prompts.js";
3
4function extractCodeFromFence(text: string): string {
5 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
6 return htmlMatch ? htmlMatch[1].trim() : text;
7}
8
9export async function generateCode(prompt: string, currentCode: string) {
10 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
11 if (starterPrompt) {

email_summarizermain.tsx2 matches

@patrickgdl•Updated 1 month ago
4import { OpenAI } from "npm:openai";
5
6function stripHtmlBackticks(html: string): string {
7 return html.replace(/^```html\n?/, "").replace(/\n?```$/, "");
8}
9
10export default async function(e: Email) {
11 const openai = new OpenAI();
12 console.log(`from: ${e.from} to: ${e.to} subject: ${e.subject}, cc: ${e.cc}, bcc: ${e.bcc}`);

backupSQLiteDB_cronmain.tsx6 matches

@AIWB•Updated 1 month ago
1# Database Backup Cron Script
2
3This cron script is designed to automatically backup specific database tables using the `backupSQLiteDB` function. It groups tables and stores them as blobs for easy retrieval and management.
4
5## Overview
6
7The script imports a `backupDatabase` function from an external module and uses it to perform regular backups of specified database tables. It's set up as a cron job to run at scheduled intervals, ensuring your database is consistently backed up.
8
9## Main Function: handleBackup
10
11The `handleBackup` function is the core of this script. It takes the following parameters:
12
13- `DATABASE_PREFIX` (string): The prefix used for the database tables.
15- `DATABASE_SUFFIX` (string, optional): A suffix to be added to the database names.
16
17## Imported Function
18
19The script relies on the `backupDatabase` function imported from:
20
21```typescript

libsqlstudio_scriptmain.tsx3 matches

@AIWB•Updated 1 month ago
3import React, { useMemo } from "https://esm.sh/react@18.2.0";
4
5function App({ Studio, ValtownDriver }) {
6 const driver = useMemo(() => {
7 return new ValtownDriver();
23}
24
25async function client() {
26 const [
27 { createRoot },
44}
45
46export default function server(request: Request): Response {
47 return new Response(
48 `

backupSQLiteDB_cronREADME.md6 matches

@AIWB•Updated 1 month ago
1# Database Backup Cron Script
2
3This cron script is designed to automatically backup specific database tables using the `backupSQLiteDB` function. It groups tables and stores them as blobs for easy retrieval and management.
4
5## Overview
6
7The script imports a `backupDatabase` function from an external module and uses it to perform regular backups of specified database tables. It's set up as a cron job to run at scheduled intervals, ensuring your database is consistently backed up.
8
9## Main Function: handleBackup
10
11The `handleBackup` function is the core of this script. It takes the following parameters:
12
13- `DATABASE_PREFIX` (string): The prefix used for the database tables.
15- `DATABASE_SUFFIX` (string, optional): A suffix to be added to the database names.
16
17## Imported Function
18
19The script relies on the `backupDatabase` function imported from:
20
21```typescript

unbeatableCopperTunamain.tsx1 match

@charmaine•Updated 1 month ago
12});
13
14async function main() {
15 let session;
16 let browser;

steel_puppeteer_startermain.tsx1 match

@steel•Updated 1 month ago
12});
13
14async function main() {
15 let session;
16 let browser;

zakatCalculatormain.tsx3 matches

@Mujib786•Updated 1 month ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function ZakatCalculator() {
6 const [formData, setFormData] = useState({
7 cash: 0,
190};
191
192function client() {
193 createRoot(document.getElementById("root")).render(<ZakatCalculator />);
194}
195if (typeof document !== "undefined") { client(); }
196
197export default async function server(request: Request): Promise<Response> {
198 return new Response(`
199 <html>

getFileEmail4 file matches

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

tuna8 file matches

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