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=849&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 17289 results for "function"(2001ms)

cerebras_coderindex.html1 match

@brevmana•Updated 2 months ago
19 <meta property="og:site_name" content="Cerebras Coder">
20 <meta property="og:url" content="https://cerebrascoder.com"/>
21 <meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
22 <meta property="og:type" content="website">
23 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">

cerebras_coderindex2 matches

@brevmana•Updated 2 months 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

@brevmana•Updated 2 months 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

@brevmana•Updated 2 months 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) {

sqliteDumpHtmlmain.tsx5 matches

@netux•Updated 2 months ago
10const coerceArray = <T extends unknown>(v: T | T[]): T[] => Array.isArray(v) ? v : [v];
11
12function findClosingParen(str: string, openParenIdx: number) {
13 let parenDepth = 1;
14 for (let i = openParenIdx + 1; i < str.length; i++) {
27}
28
29function prettifyCreateSqlStatement(sql: string) {
30 let beforeParens: string;
31 let insideParens: string;
67}
68
69async function getAllDumpableTables() {
70 const { rows } = await sqlite.execute(
71 "SELECT name FROM sqlite_schema WHERE type = 'table' AND name NOT LIKE 'sqlite_%'",
74}
75
76function generateInsertStatement(
77 tableName: string,
78 columns: string[],
92}
93
94export async function sqliteDump(tables?: string[]) {
95 const dumpTables = tables !== undefined
96 ? tables

hardballcityfront7 matches

@flymaster•Updated 2 months ago
6
7const authDomain = Deno.env.get("CLERK_DOMAIN");
8export default async function(req: Request): Promise<Response> {
9 const app = await getApp();
10
12}
13
14export async function getApp(): Promise<Hono> {
15 var app = new Hono();
16 app.use(clerkMiddleware());
19}
20
21async function isAdmin(id: string): Promise<boolean> {
22 const rows = await sqlite.execute("select * from hbc_admins where id = :id;", { id: id });
23 return rows.rows.length > 0;
24}
25
26async function getLoginLine(c): Promise<string> {
27 const auth = getAuth(c);
28 var login =
45}
46
47async function mainPage(c): Promise<string> {
48 const login = await getLoginLine(c);
49 const body = await getStories();
51}
52
53async function getStories(): Promise<string> {
54 var rows = await sqlite.execute(
55 `select
93}
94
95async function updateUser(id: string, username: string) {
96 await sqlite.execute({
97 sql: "INSERT INTO hbc_users (id, name) VALUES(:id, :username) ON CONFLICT(id) DO UPDATE SET name = :username;",
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function App() {
6 const [originalNumber, setOriginalNumber] = useState('');
7 const [percentageToSubtract, setPercentageToSubtract] = useState('');
85}
86
87function client() {
88 createRoot(document.getElementById("root")).render(<App />);
89}
90if (typeof document !== "undefined") { client(); }
91
92export default async function server(request: Request): Promise<Response> {
93 return new Response(`
94 <html>

sqliteDumpHtmlREADME.md1 match

@netux•Updated 2 months ago
5Fork of [nbbaier/sqliteDump](https://val.town/v/nbbaier/sqliteDump) with a web interface.
6
7> A utility function that generates SQL statements to dump the data and schema of tables in a SQLite database.
8
9## Usage

invitingBlackSawfishmain.tsx4 matches

@Rishu0516•Updated 2 months ago
3import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
4
5function WeatherDashboard() {
6 const [weather, setWeather] = useState(null);
7 const [location, setLocation] = useState({ latitude: 40.7128, longitude: -74.0060 }); // Default NYC
8
9 useEffect(() => {
10 async function fetchWeather() {
11 try {
12 const response = await fetch(
83};
84
85function client() {
86 createRoot(document.getElementById("root")).render(<WeatherDashboard />);
87}
88if (typeof document !== "undefined") { client(); }
89
90export default async function server(request: Request): Promise<Response> {
91 return new Response(
92 `

heroicTomatoSailfishmain.tsx4 matches

@Rishu0516•Updated 2 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function WeatherDashboard() {
6 const [weather, setWeather] = useState(null);
7 const [location, setLocation] = useState({ latitude: 40.7128, longitude: -74.0060 }); // Default NYC
8
9 useEffect(() => {
10 async function fetchWeather() {
11 try {
12 const response = await fetch(
83};
84
85function client() {
86 createRoot(document.getElementById("root")).render(<WeatherDashboard />);
87}
88if (typeof document !== "undefined") { client(); }
89
90export default async function server(request: Request): Promise<Response> {
91 return new Response(`
92 <html>

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 1 week 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.