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/$%7BsvgDataUrl%7D?q=function&page=75&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 31568 results for "function"(3321ms)

Cardsmain.tsx8 matches

@svc•Updated 4 days ago
5const LOCAL_STORAGE_KEY = "aiCardGradingResults_v2";
6
7function generateTimestamp() {
8 try {
9 return new Date().toLocaleString("en-US", { timeZone: "America/Phoenix" });
13}
14
15function getGradeColorClass(grade) {
16 const gradeLetter = (grade || "").charAt(0).toUpperCase();
17 switch (gradeLetter) {
37}
38
39function formatNumber(num) {
40 return Math.round(num).toString();
41}
42
43function ScoreRevealAnimation({ startSignal, gradeData, onComplete }) {
44 const [phase, setPhase] = useState("idle");
45 const [score, setScore] = useState(0);
157}
158
159function ImageUploader({ side, imageFile, onFileChange, disabled }) {
160 const [preview, setPreview] = useState(null);
161 const fileInputRef = useRef(null);
196}
197
198function CardGraderApp() {
199 const [frontImageFile, setFrontImageFile] = useState(null);
200 const [backImageFile, setBackImageFile] = useState(null);
482}
483
484function client() {
485 const root = document.getElementById("root");
486 if (root) createRoot(root).render(<CardGraderApp />);
490}
491
492export default async function server(request) {
493 const { OpenAI } = await import("https://esm.town/v/std/openai");
494 const corsHeaders = {

markdownBlogStarterLayout.tsx1 match

@roramigator•Updated 4 days ago
2import type { ReactNode } from "npm:react@18.2.0";
3
4export function Layout({ children }: { children: ReactNode }) {
5 return (
6 <html lang="en">

markdownBlogStarterindex.tsx3 matches

@roramigator•Updated 4 days ago
5import { Layout } from "./Layout.tsx";
6
7function PostComponent({ markdown, link }: { markdown: string; link?: string }) {
8 return (
9 <div style={{ border: "1px solid gray", padding: "10px", marginBottom: "20px", borderRadius: "5px" }}>
14}
15
16export default async function(req: Request): Promise<Response> {
17 const url = new URL(req.url);
18 if (url.pathname === "/") {
44}
45
46function html(children: React.ReactNode) {
47 return new Response(
48 renderToString(

reactHonoStarterApp.tsx1 match

@roramigator•Updated 4 days ago
2import { useState } from "https://esm.sh/react@18.2.0";
3
4export function App() {
5 const [clicked, setClicked] = useState(0);
6 return (

MsgBoardREADME.md2 matches

@roramigator•Updated 4 days ago
16In a normal server environment, you would likely use a middleware [like this one](https://hono.dev/docs/getting-started/nodejs#serve-static-files) to serve static files. Some frameworks or deployment platforms automatically make any content inside a `public/` folder public.
17
18However in Val Town you need to handle this yourself, and it can be suprisingly difficult to read and serve files in a Val Town Project. This template uses helper functions from [stevekrouse/utils/serve-public](https://www.val.town/x/stevekrouse/utils/branch/main/code/serve-public/README.md), which handle reading project files in a way that will work across branches and forks, automatically transpiles typescript to javascript, and assigns content-types based on the file's extension.
19
20### `index.html`
26## CRUD API Routes
27
28This app has two CRUD API routes: for reading and inserting into the messages table. They both speak JSON, which is standard. They import their functions from `/backend/database/queries.ts`. These routes are called from the React app to refresh and update data.
29
30## Errors

MsgBoardREADME.md2 matches

@roramigator•Updated 4 days ago
4
5* `migrations.ts` - code to set up the database tables the app needs
6* `queries.ts` - functions to run queries against those tables, which are imported and used in the main Hono server in `/backend/index.ts`
7
8## Migrations
18The queries file is where running the migrations happen in this app. It'd also be reasonable for that to happen in index.ts, or as is said above, for that line to be commented out, and only run when actual changes are made to your database schema.
19
20The queries file exports functions to get and write data. It relies on shared types and data imported from the `/shared` directory.

MsgBoardqueries.ts2 matches

@roramigator•Updated 4 days ago
10await createTables();
11
12export async function getMessages(limit = MESSAGE_LIMIT): Promise<Message[]> {
13 const messages = await sqlite.execute(
14 `SELECT * FROM ${tableName}
20}
21
22export async function insertMessage(content: string) {
23 await sqlite.execute(
24 `INSERT INTO ${tableName} (content)

MsgBoardmigrations.ts1 match

@roramigator•Updated 4 days ago
3export const tableName = "reactHonoStarter_messages";
4
5export async function createTables() {
6 await sqlite.batch([
7 `CREATE TABLE IF NOT EXISTS ${tableName} (

MsgBoardMessageInput.tsx1 match

@roramigator•Updated 4 days ago
3import type { Message } from "../shared/types.ts";
4
5export function MessageInput({ onSubmit }: { onSubmit: () => void }) {
6 const [message, setMessage] = React.useState("");
7

MsgBoardApp.tsx3 matches

@roramigator•Updated 4 days ago
4import { MessageInput } from "./MessageInput.tsx";
5
6export function App(
7 { initialMessages = [], thisProjectURL }: { initialMessages?: Message[]; thisProjectURL?: string },
8) {
41}
42
43function MessageList({ messages }: { messages: Message[] }) {
44 const displayedMessages = messages.slice(0, MESSAGE_LIMIT);
45 return (
50}
51
52function MessageItem({ message }) {
53 const formattedDate = new Date(message.timestamp).toLocaleString();
54
tuna

tuna9 file matches

@jxnblk•Updated 2 weeks ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouser•Updated 2 months ago
A helper function to build a file's email
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.