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%22Image%20title%22?q=function&page=68&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 24329 results for "function"(3113ms)

cerebras_coderqueries.ts5 matches

@Catspindev•Updated 2 days ago
2import { ITERATIONS_TABLE, KEY, PROJECTS_TABLE, SCHEMA_VERSION } from "./migrations.ts";
3
4export async function createProject(prompt: string) {
5 const projectResult = await sqlite.execute(
6 `INSERT INTO ${PROJECTS_TABLE} (initial_prompt) VALUES (?)`,
11}
12
13export async function getNextVersionNumber(projectId: number) {
14 const data = await sqlite.execute(
15 `SELECT version_number FROM ${ITERATIONS_TABLE}
21}
22
23export async function insertVersion(projectId: number, versionNumber: number, prompt: string, code: string) {
24 await sqlite.execute(
25 `INSERT INTO ${ITERATIONS_TABLE}
29}
30
31export async function getCodeInner(table: string, project: string, version?: string) {
32 let data;
33 if (version === undefined) {
50}
51
52export async function getCode(project: string, version?: string) {
53 // try to get code in the new table partition first
54 const code = await getCodeInner(ITERATIONS_TABLE, project, version);

cerebras_codermigrations.ts1 match

@Catspindev•Updated 2 days ago
7export const ITERATIONS_TABLE = "cerebras_coder_iterations";
8
9export async function createTables() {
10 await sqlite.execute(`
11 CREATE TABLE IF NOT EXISTS ${PROJECTS_TABLE} (

cerebras_codermain.tsx1 match

@Catspindev•Updated 2 days ago
6await createTables();
7
8export default async function cerebras_coder(req: Request): Promise<Response> {
9 if (req.method === "POST") {
10 let { prompt, currentCode, versionHistory, projectId } = await req.json();

cerebras_coderindex.ts7 matches

@Catspindev•Updated 2 days 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_coderindex.html1 match

@Catspindev•Updated 2 days 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_codergenerate-code.ts2 matches

@Catspindev•Updated 2 days 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) {

Websitequeries.ts4 matches

@w_ache•Updated 2 days ago
3import type { Product, Transaction } from "../../shared/types.ts";
4
5export async function getAllProducts(): Promise<Product[]> {
6 const result = await sqlite.execute(`SELECT * FROM ${PRODUCTS_TABLE} ORDER BY id`);
7 return result.rows?.map(row => ({
14}
15
16export async function getProductById(id: number): Promise<Product | null> {
17 const result = await sqlite.execute(`SELECT * FROM ${PRODUCTS_TABLE} WHERE id = ?`, [id]);
18 if (result.rows && result.rows.length > 0) {
29}
30
31export async function createTransaction(productId: number, productName: string, price: number): Promise<Transaction> {
32 const timestamp = new Date().toISOString();
33
58}
59
60export async function getAllTransactions(): Promise<Transaction[]> {
61 const result = await sqlite.execute(`SELECT * FROM ${TRANSACTIONS_TABLE} ORDER BY timestamp DESC`);
62 return result as Transaction[];

Websitemigrations.ts2 matches

@w_ache•Updated 2 days ago
4const TRANSACTIONS_TABLE = 'ecommerce_transactions_1';
5
6export async function runMigrations() {
7 // Create products table
8 await sqlite.execute(`CREATE TABLE IF NOT EXISTS ${PRODUCTS_TABLE} (
31}
32
33async function insertSampleProducts() {
34 const sampleProducts = [
35 {

untitled-3477dailyFactTweet.ts5 matches

@w_ache•Updated 2 days ago
49 * Generate OAuth 1.0a signature for Twitter API
50 */
51async function generateTwitterSignature(
52 method: string,
53 url: string,
102 * Post a tweet to Twitter using the v1.1 API
103 */
104async function postTweet(text: string, credentials: TwitterCredentials): Promise<boolean> {
105 const url = 'https://api.twitter.com/1.1/statuses/update.json';
106 const method = 'POST';
147 * Get a random fact from our collection
148 */
149function getRandomFact(): RandomFact {
150 const randomIndex = Math.floor(Math.random() * RANDOM_FACTS.length);
151 return RANDOM_FACTS[randomIndex];
153
154/**
155 * Main function - posts a random fact to Twitter
156 */
157export default async function(): Promise<void> {
158 console.log('🤖 Daily Fact Bot starting...');
159

cqueries.ts15 matches

@Sujal5•Updated 2 days ago
3
4// User queries
5export async function getUserByEmail(email: string): Promise<User | null> {
6 const result = await sqlite.execute("SELECT * FROM users WHERE email = ?", [email]);
7 return result.rows[0] as User || null;
8}
9
10export async function createUser(userData: Omit<User, 'id' | 'created_at'>): Promise<number> {
11 const result = await sqlite.execute(`
12 INSERT INTO users (email, password, name, phone, role)
17
18// Customer queries
19export async function getAllCustomers(): Promise<Customer[]> {
20 const result = await sqlite.execute("SELECT * FROM customers ORDER BY name");
21 return result as Customer[];
22}
23
24export async function getCustomerById(id: number): Promise<Customer | null> {
25 const result = await sqlite.execute("SELECT * FROM customers WHERE id = ?", [id]);
26 return result[0] as Customer || null;
27}
28
29export async function createCustomer(customerData: Omit<Customer, 'id' | 'created_at'>): Promise<number> {
30 const result = await sqlite.execute(`
31 INSERT INTO customers (name, email, phone, address)
35}
36
37export async function updateCustomer(id: number, customerData: Partial<Customer>): Promise<void> {
38 const fields = [];
39 const values = [];
63
64// Bill queries
65export async function getAllBills(): Promise<Bill[]> {
66 const result = await sqlite.execute(`
67 SELECT b.*, c.name as customer_name, c.phone as customer_phone, c.email as customer_email
77}
78
79export async function getBillsByCustomerId(customerId: number): Promise<Bill[]> {
80 const result = await sqlite.execute(`
81 SELECT b.*, c.name as customer_name, c.phone as customer_phone, c.email as customer_email
92}
93
94export async function getBillById(id: number): Promise<Bill | null> {
95 const result = await sqlite.execute(`
96 SELECT b.*, c.name as customer_name, c.phone as customer_phone, c.email as customer_email
109}
110
111export async function createBill(billData: {
112 customer_id: number;
113 bill_number: string;
142}
143
144export async function updateBill(id: number, billData: Partial<Bill>): Promise<void> {
145 const fields = [];
146 const values = [];
194}
195
196export async function deleteBill(id: number): Promise<void> {
197 await sqlite.execute("DELETE FROM payments WHERE bill_id = ?", [id]);
198 await sqlite.execute("DELETE FROM bills WHERE id = ?", [id]);
200
201// Payment queries
202export async function getPaymentsByBillId(billId: number): Promise<Payment[]> {
203 const result = await sqlite.execute(
204 "SELECT * FROM payments WHERE bill_id = ? ORDER BY payment_date DESC",
208}
209
210export async function createPayment(paymentData: {
211 bill_id: number;
212 amount: number;
228}
229
230export async function generateBillNumber(): Promise<string> {
231 const result = await sqlite.execute("SELECT COUNT(*) as count FROM bills");
232 const count = result[0].count as number;

getFileEmail4 file matches

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

tuna8 file matches

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