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/$%7Bsuccess?q=function&page=1999&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 28692 results for "function"(3506ms)

cerebras_coderqueries5 matches

@Time•Updated 3 months ago
2import { ITERATIONS_TABLE, KEY, PROJECTS_TABLE, SCHEMA_VERSION } from "./migrations";
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_codermigrations1 match

@Time•Updated 3 months 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_coderindex.html1 match

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

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

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

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

OpenTelemetryCollectortransformExport.ts10 matches

@fiberplane•Updated 3 months ago
24 * By convention, we only use string and number values. Complex values are serialized.
25 */
26export async function transformExport(
27 tracesData: IExportTraceServiceRequest,
28): Promise<Array<OtelSpan>> {
107 | Record<string, AttributeValuePrimitive>;
108
109async function mapAttributeValue(value: IAnyValue): Promise<AttributeValue> {
110 if (!value) {
111 return null;
137}
138
139async function mapAttributes(
140 attributes: IKeyValue[],
141): Promise<Record<string, AttributeValue>> {
158}
159
160async function mapEvent(event: IEvent) {
161 return {
162 name: event.name,
166}
167
168async function mapLink(link: ILink) {
169 return {
170 trace_id: stringOrUintToString(link.traceId),
175}
176
177function stringOrUintToString(id: string | Uint8Array) {
178 return id instanceof Uint8Array
179 ? Buffer.from(id).toString("hex")
181}
182
183function mapStatus(status: IStatus) {
184 return {
185 code: status.code,
188}
189
190function statusCodeToString(statusCode: EStatusCode) {
191 switch (statusCode) {
192 case 0:
201}
202
203// Function to convert ESpanKind to SpanKind
204function convertToSpanKind(spanKind: ESpanKind): string {
205 switch (spanKind) {
206 case 1:

videoVisionAnalysismain.tsx3 matches

@RuthvikBandari•Updated 3 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function App() {
6 const [videoFile, setVideoFile] = useState<File | null>(null);
7 const [analysis, setAnalysis] = useState<string | null>(null);
136};
137
138function client() {
139 createRoot(document.getElementById("root")).render(<App />);
140}
141if (typeof document !== "undefined") { client(); }
142
143export default async function server(request: Request): Promise<Response> {
144 if (request.method === 'POST') {
145 try {

reactWeatherDashboardmain.tsx4 matches

@nik•Updated 3 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function WeatherDashboard() {
6 const [location, setLocation] = useState({ latitude: 40.7128, longitude: -74.0060 }); // Default to NYC
7 const [weather, setWeather] = useState(null);
28
29 useEffect(() => {
30 async function fetchWeather() {
31 try {
32 const response = await fetch(
152};
153
154function client() {
155 createRoot(document.getElementById("root")).render(<WeatherDashboard />);
156}
157if (typeof document !== "undefined") { client(); }
158
159export default async function server(request: Request): Promise<Response> {
160 return new Response(`
161 <html>

OpenTelemetryCollectorindex.ts2 matches

@fiberplane•Updated 3 months ago
47
48/**
49 * Export a function that wraps the incoming request,
50 * then injects the Deno env vars into the Hono app befoe
51 * executing the api entrypoint (`app.fetch`)
52 */
53export default async function(req: Request): Promise<Response> {
54 const env = Deno.env.toObject();
55 // NOTE - Adding the entire env object will also expose the following values to your api handlers:

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.