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=1451&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 19019 results for "function"(2530ms)

sqliteExplorerAppREADME.md1 match

@braedennorris•Updated 6 months ago
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
35- [x] add export to CSV, and JSON (CSV and JSON helper functions written in [this val](https://www.val.town/v/nbbaier/sqliteExportHelpers). Thanks to @pomdtr for merging the initial version!)
36- [x] add listener for cmd+enter to submit query

ZineFairsmain.tsx4 matches

@sylvea•Updated 6 months ago
12
13// Scrapes the stencil fairs website and gets the upcoming events
14async function scrapeWebsiteAndGetEvents(url: string): Promise<Array<Event>> {
15 const response = await fetch(url);
16 if (!response.ok) {
44
45// Checks whether a given event already exists in the database
46async function doesEventExist(eventName: string): Promise<boolean> {
47 const result = await sqlite.execute({
48 sql: `select * from stencil_fairs where name = :eventName`,
52}
53
54// This is the function that is called via the Cron job
55// It gets all the upcoming events from the website
56// Then it checks if there are any new ones by checking whether all the upcoming events are already in our db
57// If there are any new ones, it saves them to the db and sends a notification email
58export default async function(interval: Interval) {
59 try {
60 const upcomingEvents = await scrapeWebsiteAndGetEvents(WEBSITE_URL);

flutteringVioletBirdmain.tsx4 matches

@stevekrouse•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [description, setDescription] = useState("Thu, Sep 26, 2024 2:25 PM EDT");
7 const [dateString, setDateString] = useState("2024-09-26T14:25:00-04:00");
77}
78
79function DateComponent({ dateString }) {
80 if (!dateString) {
81 return <div>Invalid date string provided</div>;
107);
108
109function client() {
110 createRoot(document.getElementById("root")).render(<App />);
111}
115}
116
117export default async function server(request: Request): Promise<Response> {
118 return new Response(`
119 <!DOCTYPE html>

newUserWelcomeEmailmain.tsx2 matches

@charmaine•Updated 6 months ago
4import { html } from "https://esm.town/v/stevekrouse/html";
5
6async function sendTownieEmail() {
7 try {
8 await email({
19}
20
21export async function newUserWelcomeEmail(req: Request): Promise<Response> {
22 if (req.method === "GET") return html(welcomeEmail);
23 if (req.headers.get("clerkNonSensitive") !== Deno.env.get("clerkNonSensitive"))

upstashmain.tsx2 matches

@kora•Updated 6 months ago
14// console.log(await redis.get("json-ex-1"));
15
16// Export a function that returns the redis client
17export function get_redis() {
18 return redis;
19}

upstash_incmain.tsx2 matches

@kora•Updated 6 months ago
3const redis = get_redis();
4
5// Function to increment and get the count
6export async function incrementCount() {
7 return await redis.incr("count");
8}

timeCalculatormain.tsx9 matches

@mikaello•Updated 6 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function TimeInput({ value, onChange, placeholder }) {
6 const handleChange = (e) => {
7 let newValue = e.target.value.replace(/\D/g, '').slice(0, 4);
30}
31
32function TimeRow({ index, startTime, endTime, subtractFullDay, onChange, fullDayHours }) {
33 const duration = calculateTimeDifference(startTime, endTime, subtractFullDay, fullDayHours);
34 const isNegative = duration.startsWith('-');
56}
57
58function calculateTimeDifference(start, end, subtractFullDay, fullDayHours) {
59 if (start.length !== 4 || end.length !== 4) return "";
60
82}
83
84function calculateTotalDuration(rows, fullDayHours) {
85 let totalMinutes = 0;
86 rows.forEach(row => {
99}
100
101function saveToQueryParams(rows, fullDayHours) {
102 const params = new URLSearchParams();
103 params.append('fullDayHours', fullDayHours);
110}
111
112function loadFromQueryParams() {
113 const params = new URLSearchParams(window.location.search);
114 const rows = [];
128}
129
130function App() {
131 const [rows, setRows] = useState([{ start: "", end: "", subtractFullDay: false }]);
132 const [fullDayHours, setFullDayHours] = useState(8);
201}
202
203function client() {
204 createRoot(document.getElementById("root")).render(<App />);
205}
209}
210
211export default async function server(request: Request): Promise<Response> {
212 return new Response(`
213 <!DOCTYPE html>

whackaghostmain.tsx12 matches

@Ttt•Updated 6 months ago
44 * HomeButton component - Renders a button to return to the home screen
45 * @param {Object} props - Component props
46 * @param {Function} props.onClick - Function to handle button click
47 */
48function HomeButton({ onClick }) {
49 return (
50 <button className="home-button" onClick={onClick}>
57 * SpookyMessage component - Displays a game over message with a ghost animation
58 * @param {Object} props - Component props
59 * @param {Function} props.onHomeClick - Function to handle home button click
60 * @param {boolean} props.isTimeOut - Whether the game ended due to timeout
61 * @param {number} props.score - The player's final score
63 * @param {boolean} props.isWin - Whether the player has won the game
64 */
65function SpookyMessage({ onHomeClick, isTimeOut, score, isTooManyWrongClicks, isWin }) {
66 console.log("SpookyMessage rendered. isWin:", isWin, "score:", score);
67 return (
83 * GameDescription component - Displays game instructions and rules
84 */
85function GameDescription() {
86 return (
87 <div className="game-description">
109 * Main App component for the Whack-a-Ghost game
110 */
111function App() {
112 const [score, setScore] = useState(0);
113 const [activeGhost, setActiveGhost] = useState(-1);
314
315/**
316 * Client-side rendering function
317 */
318export function client() {
319 const rootElement = document.getElementById("root");
320 if (rootElement) {
328
329/**
330 * Server-side rendering function
331 * @param {Request} request - The incoming request object
332 * @returns {Promise<Response>} The response object with the HTML content
333 */
334export default async function server(request: Request): Promise<Response> {
335 return new Response(
336 `
350 import { client } from "${import.meta.url}";
351 window.addEventListener("load", () => {
352 if (typeof client === "function") {
353 client();
354 } else {
355 console.error("Client function not found");
356 }
357 });

dateme_react_hydratedmain.tsx1 match

@jacobhthomas•Updated 6 months ago
10import { html } from "https://esm.town/v/stevekrouse/html";
11
12export default async function(req: Request) {
13 let handler = createStaticHandler(routes);
14 let context = await handler.query(req);

runescapeWoodCuttingmain.tsx4 matches

@charmaine•Updated 6 months ago
9};
10
11function LoginScreen({ onLogin }) {
12 const [name, setName] = useState("");
13
36}
37
38function App() {
39 const [playerName, setPlayerName] = useState("");
40 const [skill, setSkill] = useState("woodcutting");
107}
108
109function client() {
110 createRoot(document.getElementById("root")).render(<App />);
111}
115}
116
117export default async function server(request: Request): Promise<Response> {
118 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
119 const SCHEMA_VERSION = 2;

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 2 weeks 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": "*",