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/$2?q=function&page=2462&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 28557 results for "function"(6868ms)

stormyCyanLeoponREADME.md3 matches

@stevekrouseUpdated 9 months ago
1# Send Chunked Discord Message
2This function is used to send a message to a Discord webhook. If the message exceeds the maximum character limit (2000 characters), it will be divided into chunks and sent as multiple messages.
3
4### Parameters
5message (string): The message to be sent to the Discord webhook.
6### Return Value
7This function does not return any value.
8
9## Example Usage:
13await @ktodaz.sendDiscordMessage(message);
14```
15In the above example, the sendDiscordMessage function is used to send the message to the Discord webhook. If the message exceeds 2000 characters, it will be split into smaller chunks and sent as separate messages.
16
17## Required Secrets:

sendDiscordMessageREADME.md3 matches

@stevekrouseUpdated 9 months ago
1# Send Chunked Discord Message
2This function is used to send a message to a Discord webhook. If the message exceeds the maximum character limit (2000 characters), it will be divided into chunks and sent as multiple messages.
3
4### Parameters
5message (string): The message to be sent to the Discord webhook.
6### Return Value
7This function does not return any value.
8
9## Example Usage:
13await @ktodaz.sendDiscordMessage(message);
14```
15In the above example, the sendDiscordMessage function is used to send the message to the Discord webhook. If the message exceeds 2000 characters, it will be split into smaller chunks and sent as separate messages.
16
17## Required Secrets:

sendDiscordMessagemain.tsx1 match

@stevekrouseUpdated 9 months ago
6 webhook_url: string = process.env.discord_webhook,
7) => {
8 function chunkString(str) {
9 const chunks = [];
10 let startIndex = 0;

aloneBronzeCattlemain.tsx3 matches

@jamisonlUpdated 9 months ago
22const rest = new REST({ version: "9" }).setToken(process.env.DISCORD_BOT_TOKEN);
23
24async function findUserVoiceChannel(guildId, userId) {
25 try {
26 const channels = await rest.get(Routes.guildChannels(guildId));
39}
40
41async function sayMessage(guildId, channelId, message) {
42 const url = googleTTS.getAudioUrl(message, {
43 lang: "en",
68}
69
70function createDiscordJSAdapter(channelId, guildId) {
71 return {
72 sendPayload: (payload) => {

aloneBronzeCattleREADME.md1 match

@jamisonlUpdated 9 months ago
1Bot for Cama discord server. To initialize new slash commands, you have to run a separate bit of code. This is for modifying their functionality

darkMagentaFlamingoREADME.md1 match

@jamisonlUpdated 9 months ago
1Bot for Cama discord server. To initialize new slash commands, you have to run a separate bit of code. This is for modifying their functionality

convenientAzureSparrowmain.tsx2 matches

@gioUpdated 9 months ago
4const apiKey = "your_api_key";
5
6// Function to send SMS
7async function sendSMS(to, from) {
8 try {
9 const response = await axios.post(

numbergamemain.tsx4 matches

@tnorthcuttUpdated 9 months ago
27const HUE_DIFF = 25;
28
29function getColor(value: number): string {
30 const power = Math.log2(value / 2);
31 const hue = (power * HUE_DIFF) % 360;
33}
34
35function App() {
36 const [board, setBoard] = useState<number[][]>([]);
37 const [selectedCells, setSelectedCells] = useState<[number, number][]>([]);
281}
282
283function client() {
284 createRoot(document.getElementById("root")).render(<App />);
285}
289}
290
291async function server(request: Request): Promise<Response> {
292 return new Response(
293 `

easingbattlegroundmain.tsx23 matches

@ejfoxUpdated 9 months ago
4import { BrowserRouter as Router, Route, Link, Routes } from "https://esm.sh/react-router-dom";
5
6function EasingVisualizer({ easing }) {
7 const canvasRef = React.useRef(null);
8
13 const height = canvas.height;
14
15 function drawCurve() {
16 ctx.clearRect(0, 0, width, height);
17
18 const [x1, y1, x2, y2] = easing.params;
19
20 const bezierFunction = cubicBezier(x1, y1, x2, y2);
21
22 ctx.beginPath();
23 ctx.moveTo(0, height);
24 for (let t = 0; t <= 1; t += 0.01) {
25 const point = bezierFunction(t);
26 const x = point.x * width;
27 const y = height - point.y * height;
34 // Animate the dot
35 const time = (Date.now() % 3000) / 3000;
36 const point = bezierFunction(time);
37 const x = point.x * width;
38 const y = height - point.y * height;
44 }
45
46 const animationFrame = requestAnimationFrame(function animate() {
47 drawCurve();
48 requestAnimationFrame(animate);
55}
56
57function cubicBezier(x1, y1, x2, y2) {
58 return function(t) {
59 const cx = 3 * x1;
60 const bx = 3 * (x2 - x1) - cx;
72}
73
74function EasingGuide() {
75 return (
76 <div className="bg-gray-100 p-6 rounded-lg mb-8">
92 <h3 className="text-xl font-semibold mb-2">🧙‍♂️ Cubic-Bezier Magic:</h3>
93 <p className="mb-4">
94 Input your easing as a cubic-bezier function, like this:
95 <code className="bg-gray-200 px-2 py-1 rounded">cubic-bezier(0.05, 0.00, 0.16, 0.13)</code>
96 </p>
104}
105
106function EasingForm({ onSubmit }) {
107 const [newEasing, setNewEasing] = useState({ name: '', author: '', params: [0.05, 0.00, 0.16, 0.13] });
108
109 function handleSubmit(e) {
110 e.preventDefault();
111 onSubmit(newEasing);
113 }
114
115 function handleCubicBezierInput(e) {
116 const value = e.target.value;
117 const match = value.match(/cubic-bezier\(([\d.]+),\s*([\d.]+),\s*([\d.]+),\s*([\d.]+)\)/);
125 <form onSubmit={handleSubmit} className="mb-8">
126 <div className="mb-4">
127 <label htmlFor="easingInput" className="block mb-2 font-semibold">Easing Function (cubic-bezier format):</label>
128 <input
129 id="easingInput"
163}
164
165function Leaderboard({ easings, onVote, votedEasings }) {
166 return (
167 <div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6">
184}
185
186function Home({ easings, onSubmit, onVote, votedEasings }) {
187 return (
188 <div>
200}
201
202function FullLeaderboard({ easings, onVote, votedEasings }) {
203 return (
204 <div>
214}
215
216function App() {
217 const [easings, setEasings] = useState([]);
218 const [votedEasings, setVotedEasings] = useState([]);
222 }, []);
223
224 async function fetchEasings() {
225 const response = await fetch('/easings');
226 const data = await response.json();
228 }
229
230 async function submitEasing(newEasing) {
231 await fetch('/easings', {
232 method: 'POST',
237 }
238
239 async function vote(id, direction) {
240 await fetch(`/vote/${id}/${direction}`, { method: 'POST' });
241 setVotedEasings([...votedEasings, id]);
256}
257
258function client() {
259 createRoot(document.getElementById("root")).render(<App />);
260}
264}
265
266async function server(request: Request): Promise<Response> {
267 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
268 const SCHEMA_VERSION = 1

ChatGPTTextDefinitionUserscriptmain.tsx13 matches

@xsecUpdated 9 months ago
11// ==/UserScript==
12
13(function() {
14 "use strict";
15
71 };
72
73 // Run the function when the page loads
74 window.addEventListener("load", () => {
75 console.log("Page loaded, running toggleStylesBasedOnWidth");
77 });
78
79 // Also run the function when the window is resized
80 window.addEventListener("resize", () => {
81 console.log("Window resized, running toggleStylesBasedOnWidth");
201
202 // Stream processing
203 async function* streamProcessor(reader) {
204 const decoder = new TextDecoder();
205 let buffer = "";
237
238 // API response handling
239 async function processApiResponse(response) {
240 const reader = response.body.getReader();
241
253
254 // Selection handling
255 async function handleSelection() {
256 console.time("handleSelection");
257 const selectedText = getSelectedText();
291 }
292
293 // Helper functions
294 function getSelectedText() {
295 return window.getSelection().toString().trim();
296 }
343 };
344
345 // Function to create a new section and append it properly
346 const showLoadingPopup = (selectedText) => {
347 const popup = createPopup();
362 };
363
364 function clearPreviousPopup() {
365 const previousPopup = document.getElementById("definition-popup");
366 if (previousPopup) {
427 };
428
429 function createCloseButton() {
430 console.log("Creating close button");
431
463 }
464
465 async function makeApiRequest(text) {
466 console.log(`Preparing to send fetch request for text: "${text}"`);
467 try {
482 }
483
484 // Pure functions to calculate dimensions and positioning
485 const calculateCharacterSize = () => {
486 const tempElement = document.createElement("span");

getFileEmail4 file matches

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

tuna8 file matches

@jxnblkUpdated 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.