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/$%7Burl%7D?q=function&page=1904&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 24260 results for "function"(1589ms)

rollADicemain.tsx7 matches

@liyi•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5/** Utility functions */
6function generateValidRoll(): number {
7 return Math.floor(Math.random() * 6) + 1;
8}
9
10function getDiceEmoji(roll: number): string {
11 const diceEmojis = [
12 '⚀', // 1
20}
21
22function formatTime(timestamp: number): string {
23 const date = new Date(timestamp);
24 return date.toLocaleTimeString(undefined, {
36}
37
38function App() {
39 const [roll, setRoll] = useState(generateValidRoll());
40 const [isRolling, setIsRolling] = useState(false);
234}
235
236function client() {
237 createRoot(document.getElementById("root")).render(<App />);
238}
239if (typeof document !== "undefined") { client(); }
240
241export default async function server(request: Request): Promise<Response> {
242 const roll = generateValidRoll();
243

valuableLavenderOpossummain.tsx1 match

@ayaanpatel1790•Updated 6 months ago
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",

getWeatherREADME.md1 match

@lazynerdlab•Updated 6 months ago
1## Get Weather
2
3Simple function to get weather data from the free [wttr.in](https://wttr.in/:help) service.
4
5```ts

getWeathermain.tsx1 match

@lazynerdlab•Updated 6 months ago
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export async function getWeather(location: string): Promise<WeatherResponse> {
4 return fetchJSON(`https://wttr.in/${location}?format=j1`);
5}

cerebras_codermain.tsx5 matches

@joyboy•Updated 6 months ago
6import { tomorrow } from "https://esm.sh/react-syntax-highlighter/dist/esm/styles/prism";
7
8function App() {
9 const [prompt, setPrompt] = useState("hello llamapalooza");
10 const [code, setCode] = useState("");
18 >(null);
19
20 async function handleSubmit(e: React.FormEvent) {
21 e.preventDefault();
22 setLoading(true);
97}
98
99function client() {
100 createRoot(document.getElementById("root")!).render(<App />);
101}
105}
106
107function extractCodeFromFence(text: string): string {
108 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
109 return htmlMatch ? htmlMatch[1].trim() : text;
110}
111
112export default async function server(req: Request): Promise<Response> {
113 if (req.method === "POST") {
114 const client = new Cerebras();

exceptionalBlueMockingbirdmain.tsx1 match

@elise_if•Updated 6 months ago
2
3// Fetches a random joke:
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",

generateQuizmain.tsx1 match

@rayyan•Updated 6 months ago
14};
15
16export default async function(req: Request): Promise<Response> {
17 const topic = new URL(req.url).searchParams.get("topic") ?? "JavaScript";
18 const level = levelParser.safeParse(new URL(req.url).searchParams.get("level") ?? "beginner");

deepLTranslatorAppmain.tsx3 matches

@sky_porie_fire443•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function TranslationApp() {
6 const [sourceText, setSourceText] = useState("");
7 const [translatedText, setTranslatedText] = useState("");
195};
196
197function client() {
198 createRoot(document.getElementById("root")).render(<TranslationApp />);
199}
200if (typeof document !== "undefined") { client(); }
201
202export default async function server(request: Request): Promise<Response> {
203 if (request.method === "POST" && new URL(request.url).pathname === "/translate") {
204 try {

captivatingLimeGuanmain.tsx6 matches

@mahtabtattur•Updated 6 months ago
73
74// Plant Identification Service (Simulated with more sophisticated matching)
75async function identifyPlant(imageFile) {
76 return new Promise((resolve, reject) => {
77 // Simulate API call with image processing
106
107// Simulated image similarity calculation
108function calculateImageSimilarity(imageData, plantType) {
109 // In a real scenario, this would use machine learning techniques
110 const randomFactor = Math.random() * 0.4 + 0.3; // Base randomness
119}
120
121function PlantDetailCard({ plant, confidence }) {
122 return (
123 <div className="bg-white shadow-lg rounded-2xl p-6 animate-slide-up">
159}
160
161function PlantIdentifierApp() {
162 const [selectedImage, setSelectedImage] = useState(null);
163 const [plantInfo, setPlantInfo] = useState(null);
336}
337
338function client() {
339 createRoot(document.getElementById("root")).render(<PlantIdentifierApp />);
340}
341if (typeof document !== "undefined") { client(); }
342
343export default async function server(request: Request): Promise<Response> {
344 return new Response(`
345 <html>

yc_findermain.tsx5 matches

@stevekrouse•Updated 6 months ago
23`;
24
25function Hero() {
26 return (
27 <div className="hero">
32}
33
34function HowItWorks() {
35 return (
36 <div className="how-it-works">
53}
54
55function App() {
56 const [ycCompanies, setYcCompanies] = useState<YCCompany[]>([]);
57 const [mergedData, setMergedData] = useState<any[]>([]);
217}
218
219function client() {
220 createRoot(document.getElementById("root")!).render(<App />);
221}
225}
226
227export default async function server(request: Request): Promise<Response> {
228 const companies = await fetch("https://stevekrouse-yc_database.web.val.run").then(res => res.json());
229 const url = new URL(request.url);

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.