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=886&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 17277 results for "function"(1375ms)

hnValTownmain.tsx1 match

@BrustUpdated 2 months ago
4import process from "node:process";
5
6export async function hnValTown({ lastRunAt }: Interval) {
7 // Edit to update time frame
8 const twoMonthsAgo = new Date();

emojisearchindex4 matches

@maxmUpdated 2 months ago
1import emojis from "npm:emojilib" with { type: "json" };
2
3function emojiToString([k, v]: [string, string[]]) {
4 return `${k} ${v.join(", ")}`;
5}
18const openai = new OpenAI();
19
20async function getEmbedding(emoji: string): Promise<number[]> {
21 const result = await openai.embeddings.create({
22 input: emoji,
34
35// Calculate cosine similarity between two vectors
36function cosineSimilarity(vecA: number[], vecB: number[]): number {
37 const dotProduct = vecA.reduce((sum, a, i) => sum + a * vecB[i], 0);
38 const magnitudeA = Math.sqrt(vecA.reduce((sum, a) => sum + a * a, 0));
46
47// Find nearest neighbors for a given emoji
48function findNearestNeighbors(
49 targetEmbedding: number[],
50 allEmbeddings: EmojiEmbedding[],

jobBoardChatAppmain.tsx3 matches

@mary1010Updated 2 months ago
3import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
4
5function App() {
6 const [jobs, setJobs] = useState([]);
7 const [messages, setMessages] = useState([]);
220}
221
222function client() {
223 createRoot(document.getElementById("root")).render(<App />);
224}
225if (typeof document !== "undefined") { client(); }
226
227export default async function server(request: Request): Promise<Response> {
228 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
229 const KEY = "jobBoardChatApp";

valentinemain.tsx3 matches

@DarshapageUpdated 2 months ago
13];
14
15function App() {
16 const [noClicks, setNoClicks] = useState(0);
17 const [isValentine, setIsValentine] = useState(false);
98}
99
100function client() {
101 createRoot(document.getElementById("root")).render(<App />);
102}
103if (typeof document !== "undefined") { client(); }
104
105export default async function server(request: Request): Promise<Response> {
106 return new Response(
107 `

blob_adminapp.tsx7 matches

@stevekrouseUpdated 2 months ago
10}
11
12function Tooltip({ children, content }: TooltipProps) {
13 const [isVisible, setIsVisible] = useState(false);
14 const tooltipRef = useRef<HTMLDivElement>(null);
49}
50
51function formatBytes(bytes: number, decimals = 2) {
52 if (bytes === 0) return "0 Bytes";
53 const k = 1024;
58}
59
60function copyToClipboard(text: string) {
61 navigator.clipboard.writeText(text).then(() => {
62 console.log("Text copied to clipboard");
66}
67
68function ActionMenu({ blob, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
69 const [isOpen, setIsOpen] = useState(false);
70 const menuRef = useRef(null);
73
74 useEffect(() => {
75 function handleClickOutside(event) {
76 if (menuRef.current && !menuRef.current.contains(event.target)) {
77 event.stopPropagation();
155}
156
157function BlobItem({ blob, onSelect, isSelected, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
158 const [isLoading, setIsLoading] = useState(false);
159 const decodedKey = decodeURIComponent(blob.key);
216}
217
218function App({ initialEmail, initialProfile, sourceURL }) {
219 const encodeKey = (key: string) => encodeURIComponent(key);
220 const decodeKey = (key: string) => decodeURIComponent(key);

ptcWebsiteDemomain.tsx2 matches

@SherazjaffriUpdated 2 months ago
6// Existing code remains the same...
7
8export default async function server(request: Request): Promise<Response> {
9 try {
10 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
199
200// Rest of the client-side code remains unchanged
201function Dashboard({ user }) {
202 // Existing dashboard code...
203

weatherDashboardHttpValmain.tsx6 matches

@mdalam7294Updated 2 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);
9
10 useEffect(() => {
11 async function fetchWeather() {
12 try {
13 const response = await fetch(
26 }, [location]);
27
28 function getWeatherDescription(code) {
29 const descriptions = {
30 0: "Clear sky ☀️",
56 }
57
58 function handleLocationChange(e) {
59 const [lat, lon] = e.target.value.split(',').map(parseFloat);
60 setLocation({ latitude: lat, longitude: lon });
140};
141
142function client() {
143 createRoot(document.getElementById("root")).render(<WeatherDashboard />);
144}
145if (typeof document !== "undefined") { client(); }
146
147export default async function server(request: Request): Promise<Response> {
148 return new Response(`
149 <html>

websitesSeoAnalyzermain.tsx3 matches

@mdalam7294Updated 2 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function SeoAnalyzer() {
6 const [url, setUrl] = useState('');
7 const [seoResults, setSeoResults] = useState(null);
61}
62
63function client() {
64 createRoot(document.getElementById("root")).render(<SeoAnalyzer />);
65}
66if (typeof document !== "undefined") { client(); }
67
68export default async function server(request: Request): Promise<Response> {
69 if (request.method === 'POST' && new URL(request.url).pathname === '/analyze') {
70 const { url } = await request.json();

succinctCyanLungfishmain.tsx3 matches

@mdalam7294Updated 2 months ago
3import React, { useState } from "https://esm.sh/react@18.2.0";
4
5function WebsiteRanker() {
6 const [url, setUrl] = useState("");
7 const [ranking, setRanking] = useState(null);
97}
98
99function client() {
100 createRoot(document.getElementById("root")).render(<WebsiteRanker />);
101}
102if (typeof document !== "undefined") { client(); }
103
104export default async function server(request: Request): Promise<Response> {
105 if (request.method === "POST" && new URL(request.url).pathname === "/rank") {
106 try {

statusstatus3 matches

@safoneUpdated 2 months ago
9const thisURL = parseProject(import.meta.url).links.self.project;
10
11function StatusRow({ rows }) {
12 return (
13 <div className="w-full flex flex-col space-y-2">
31}
32
33function StatusSection({ url, rows }) {
34 const sectionRows = rows.filter(row => row[0] === url);
35 const percentUp = Math.round((sectionRows.filter(row => row[1]).length / sectionRows.length) * 100);
47}
48
49export default async function(req: Request): Promise<Response> {
50 const { rows } = await sqlite.execute(
51 "select url, ok, duration, timestamp from uptime order by timestamp desc limit 200",

getFileEmail4 file matches

@shouserUpdated 1 week ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblkUpdated 1 week 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": "*",