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=2&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 18181 results for "function"(635ms)

cerebras_coderqueries.ts5 matches

@Webmaker•Updated 3 hours 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

@Webmaker•Updated 3 hours 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

@Webmaker•Updated 3 hours 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

@Webmaker•Updated 3 hours 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

@Webmaker•Updated 3 hours 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

@Webmaker•Updated 3 hours 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) {

steamforumscannerREADME.md1 match

@luoyuchu•Updated 6 hours ago
10import scanSteamForums from "https://esm.town/v/dreww/steamforumscanner";
11
12export default async function(interval: Interval) {
13 const dota2Threads = await scanSteamForums({
14 gameName: "Dota 2",

steamforumscannermain.tsx15 matches

@luoyuchu•Updated 6 hours ago
29}
30
31async function sendErrorEmail(gameName: string, error: Error, context: string) {
32 const subject = `Error in Steam Forum Scanner for ${gameName}`;
33 const text = `An error occurred while ${context} for ${gameName}:\n\n${error.message}\n\n${error.stack}`;
41}
42
43function constructSteamUrl(steamId: string): string {
44 return `https://steamcommunity.com/app/${steamId}/discussions/`;
45}
46
47export default async function scanSteamForums({
48 gameName,
49 steamId,
98}
99
100async function cleanupDebugHtmlBlobs(gameName: string) {
101 try {
102 const debugBlobs = await blob.list(`steam_html_debug_${gameName}_`);
115}
116
117async function fetchSteamDiscussionsPage(url: string): Promise<string> {
118 const response = await fetch(url, {
119 headers: {
132}
133
134async function saveDebugHtml(gameName: string, html: string) {
135 const key = `steam_html_debug_${gameName}_${Date.now()}`;
136 await blob.set(key, html);
138}
139
140async function getStoredThreads(gameName: string): Promise<SteamThread[]> {
141 const storageKey = `steam_threads_${gameName}`;
142 return await blob.getJSON(storageKey) ?? [];
143}
144
145function identifyThreadsToNotify(currentThreads: SteamThread[], storedThreads: SteamThread[]): SteamThread[] {
146 return currentThreads.filter(currentThread => {
147 const storedThread = storedThreads.find(st => st.id === currentThread.id);
150}
151
152async function sendDiscordNotifications(
153 gameName: string,
154 threads: SteamThread[],
174}
175
176async function updateStoredThreads(gameName: string, storedThreads: SteamThread[], currentThreads: SteamThread[]) {
177 const currentThreadMap = new Map(currentThreads.map(thread => [thread.id, thread]));
178
200}
201
202function parseThreads(html: string): SteamThread[] {
203 const $ = cheerio.load(html);
204
251}
252
253function cleanTitle(title: string): string {
254 return title.replace(/\t/g, '').trim();
255}
256
257function parseForumTopic($: cheerio.Root, el: cheerio.Element): SteamThread {
258 const threadNameEl = $(el).find(".forum_topic_name");
259 const link = $(el).find(".forum_topic_overlay");
275}
276
277function parseForumTopicName($: cheerio.Root, el: cheerio.Element): SteamThread {
278 const link = $(el).find("a");
279 const url = link.attr("href") ?? "";
295}
296
297async function sendDiscordWebhook(
298 gameName: string,
299 threads: SteamThread[],

synced_reducermain.tsx1 match

@jeffreyyoung•Updated 7 hours ago
1export default async function(req: Request): Promise<Response> {
2 const url = new URL(req.url);
3 if (url.pathname === "/v1") {

templateTwitterAlertREADME.md2 matches

@divya88•Updated 7 hours ago
46- Key: `mentionsDiscord`
47- Value: Your Discord webhook URL.
48Notifications will be sent using this function:
49
50```ts
63
64- **Proxies via Val Town's [SocialDataProxy](https://www.val.town/v/stevekrouse/socialDataProxy)**: Limited to 10 cents per day for [**Val Town Pro users**](https://www.val.town/pricing). This API is *only* for Pro users.
65- **Need more calls?** Sign up for your own [SocialData API token](https://socialdata.tools) and configure the [`socialDataSearch`](https://www.val.town/v/stevekrouse/socialDataSearch) function.

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": "*",