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/?q=function&page=558&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 19844 results for "function"(2390ms)

eink-framefontsTest.tsx2 matches

@seigel•Updated 4 weeks ago
4import { BodyWrapper, Content, Footer, Header, Headline } from "../components.tsx";
5
6function Render() {
7 const line = "To be taught if fortunate";
8 return (
36}
37
38export default async function(): Promise<Response> {
39 const html = renderToString(<Render />);
40

eink-framefetchWithCache.ts1 match

@seigel•Updated 4 weeks ago
6};
7
8export default async function fetchWithCache(
9 apiUrl: string,
10 cacheKey: string,

eink-framecomponents.tsx7 matches

@seigel•Updated 4 weeks ago
4
5// Display components can be used to change the look and feel of each frame.
6export function Header({ title = "Eink" }) {
7 return (
8 <head>
39}
40
41export function Footer() {
42 const currentDate = new Date().toLocaleDateString("en-US", {
43 timeZone: "America/Los_Angeles",
62}
63
64export function Headline({ text = "Headline missing" }: { text: string }) {
65 return (
66 <div className="flex justify-between items-center p-5">
70}
71
72export function Content(props: any) {
73 return <div className="relative p-5 overflow-none">{props.children}</div>;
74}
75
76export function BodyWrapper(props: any) {
77 return (
78 <body className="bg-black p-0 m-0">
84}
85
86export function App() {
87 return (
88 <html>
99}
100
101export default async function(): Promise<Response> {
102 const html = renderToString(<App />);
103

eink-frameapod.tsx2 matches

@seigel•Updated 4 weeks ago
6
7// Displays NASA's astronomy photo of the day
8function Render({ data }: { data: APOD }) {
9 return (
10 <html>
25}
26
27export default async function(req: Request): Promise<Response> {
28 const data: APOD = await GetAPOD(req).then((res: any) => res.json());
29 const html = renderToString(<Render data={data} />);

eink-frameapod.ts1 match

@seigel•Updated 4 weeks ago
13const NASA_API_KEY = Deno.env.get("NASA_API_KEY");
14
15export default async function GetAPOD(req: Request): Promise<Response> {
16 const url = `https://api.nasa.gov/planetary/apod?api_key=${NASA_API_KEY}&thumbs=true`;
17 const cacheKey = "nasa_apod";

colorBarsmain.tsx5 matches

@dcm31•Updated 4 weeks ago
35
36
37// Function to safely calculate tan, clamping output
38float safeTan(float x) {
39 // Clamp output to avoid extreme values that break rendering.
85
86// --- React Component ---
87function App() {
88 const canvasRef = useRef<HTMLCanvasElement>(null);
89
170 console.log("Position buffer created.");
171
172 // --- Resize Function ---
173 const resizeCanvasToDisplaySize = () => {
174 if (!canvas) return false;
261
262// --- Client Entry ---
263function client() {
264 const rootElement = document.getElementById("root");
265 if (!rootElement) {
280 canvas { display: block; width: 100%; height: 100%; }
281`;
282export default async function server(request: Request): Promise<Response> {
283 const valUrl = import.meta.url;
284 return new Response(

lavamain.tsx10 matches

@dcm31•Updated 4 weeks ago
21const float EPS = 1e-5; // Epsilon for safe division etc.
22
23// Helper functions must be defined before they are called in GLSL 1.0
24
25// Smooth minimum function
26float opSmoothUnion( float d1, float d2, float k )
27{
31}
32
33// Signed distance function for a sphere
34float sdSphere( vec3 p, float s )
35{
37}
38
39// Main distance function for the scene (map)
40// Uses a loop to combine multiple moving spheres smoothly
41float map(vec3 p)
66 const float h = 1e-5;
67 const vec2 k = vec2(1.0,-1.0); // Helper vectors for offsets
68 // Sample map function at points slightly offset from p in different directions
69 return normalize( k.xyy*map( p + k.xyy*h ) +
70 k.yyx*map( p + k.yyx*h ) +
73}
74
75// Main function
76void main()
77{
108
109// --- React Component ---
110function App() {
111 const canvasRef = useRef<HTMLCanvasElement>(null);
112
193 console.log("Position buffer created.");
194
195 // --- Resize Function ---
196 const resizeCanvasToDisplaySize = () => {
197 if (!canvas) return false;
259
260// --- Client Entry ---
261function client() {
262 const rootElement = document.getElementById("root");
263 if (!rootElement) {
278 canvas { display: block; width: 100%; height: 100%; }
279`;
280export default async function server(request: Request): Promise<Response> {
281 const valUrl = import.meta.url;
282 return new Response(

clouds2main.tsx4 matches

@dcm31•Updated 4 weeks ago
141
142// --- React Component ---
143function App() {
144 const canvasRef = useRef<HTMLCanvasElement>(null);
145 // No mouse input needed
227 console.log("Position buffer created.");
228
229 // --- Resize Function ---
230 const resizeCanvasToDisplaySize = () => {
231 if (!canvas) return false;
313
314// --- Client Entry ---
315function client() {
316 const rootElement = document.getElementById("root");
317 if (!rootElement) {
332 canvas { display: block; width: 100%; height: 100%; }
333`;
334export default async function server(request: Request): Promise<Response> {
335 const valUrl = import.meta.url;
336 return new Response(

reactHonoStarterApp.tsx1 match

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

cloudsmain.tsx6 matches

@dcm31•Updated 4 weeks ago
34const mat2 m = mat2( 1.6, 1.2, -1.2, 1.6 );
35
36// Hash function generates pseudo-random 2D vector
37vec2 hash( vec2 p ) {
38 p = vec2(dot(p,vec2(127.1,311.7)), dot(p,vec2(269.5,183.3)));
41}
42
43// Simplex noise function (gradient noise)
44float noise( vec2 p ) { // Removed 'in' qualifier for GLSL 1.0
45 const float K1 = 0.366025404; // (sqrt(3)-1)/2;
171
172// --- React Component ---
173function App() {
174 const canvasRef = useRef<HTMLCanvasElement>(null);
175 // No mouse input needed for this shader
260 console.log("Position buffer created.");
261
262 // --- Resize Function ---
263 const resizeCanvasToDisplaySize = () => {
264 if (!canvas) return false;
346
347// --- Client Entry ---
348function client() {
349 const rootElement = document.getElementById("root");
350 if (!rootElement) {
365 canvas { display: block; width: 100%; height: 100%; }
366`;
367export default async function server(request: Request): Promise<Response> {
368 const valUrl = import.meta.url;
369 return new Response(

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 3 weeks 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.