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/$%7Bart_info.art.src%7D?q=function&page=1645&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 18949 results for "function"(3580ms)

passkeys_demomain.tsx3 matches

@hlobil•Updated 1 year ago
23
24// UTILS
25function generateJWT(userId: string) {
26 return new SignJWT({ userId }).setProtectedHeader({ alg: "HS256" }).sign(SECRET);
27}
28function verifyJWT(token: string) {
29 return jwtVerify(token, SECRET);
30}
31function generateRandomString() {
32 return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
33}

moccasinRabbitmain.tsx1 match

@flxa•Updated 1 year ago
1// View at https://andreterron-htmlExample.web.val.run?name=Andre
2export default async function(req: Request): Promise<Response> {
3 const query = new URL(req.url).searchParams;
4

chatREADME.md1 match

@mxis•Updated 1 year ago
1# OpenAI ChatGPT helper function
2
3This val uses your OpenAI token if you have one, and the @std/openai if not, so it provides limited OpenAI usage for free.

chatmain.tsx3 matches

@mxis•Updated 1 year ago
1import type { ChatCompletion, ChatCompletionCreateParamsNonStreaming, Message } from "npm:@types/openai";
2
3async function getOpenAI() {
4 // if you don't have a key, use our std library version
5 if (Deno.env.get("OPENAI_API_KEY") === undefined) {
14/**
15 * Initiates a chat conversation with OpenAI's GPT model and retrieves the content of the first response.
16 * This function can handle both single string inputs and arrays of message objects.
17 * It supports various GPT models, allowing for flexibility in choosing the model based on the application's needs.
18 *
21 * @returns {Promise<string>} A promise that resolves to the content of the first response from the completion.
22 */
23export async function chat(
24 input: string | Message[],
25 options?: Omit<ChatCompletionCreateParamsNonStreaming, "messages">,

letterboxdmain.tsx1 match

@javier•Updated 1 year ago
22 });
23 };
24 async function getFilms() {
25 const totalPages = await getTotalPages();
26 const films = [];

htmlExamplemain.tsx1 match

@flxa•Updated 1 year ago
1// View at https://andreterron-htmlExample.web.val.run?name=Andre
2export default async function(req: Request): Promise<Response> {
3 const query = new URL(req.url).searchParams;
4

libsqlstudio_scriptmain.tsx1 match

@pomdtr•Updated 1 year ago
6import ValtownDriver from "https://esm.town/v/pomdtr/libsqlstudio_driver";
7
8function App() {
9 const driver = useMemo(() => {
10 return new ValtownDriver();

libsqlstudio_drivermain.tsx1 match

@pomdtr•Updated 1 year ago
8} from "https://esm.sh/@libsqlstudio/gui/driver";
9
10export function transformRawResult(raw: ResultSet): DatabaseResultSet {
11 const headerSet = new Set();
12

salmonMonkeymain.tsx1 match

@platoff•Updated 1 year ago
1import { capturePostHogEvent } from "https://esm.town/v/ianvph/capturePostHogEvent";
2
3export default async function(req: Request): Promise<Response> {
4 if (req.method !== "POST") {
5 return Response.json({ ok: "only post request" });

sapphireManateemain.tsx5 matches

@thecurryman•Updated 1 year ago
7 const body = await response.text();
8 const $ = cheerio.load(body);
9 const boeingElements = $("h5").filter(function() {
10 return $(this).text().includes("Boeing");
11 });
12 let aircraft = [];
13 boeingElements.each(function() {
14 aircraft.push($(this).text());
15 });
17};
18
19async function getFormData(req: Request) {
20 const data = await req.formData();
21 const aircraft = ("" + data.get("aircraft")).replace(" ", "");
34}
35
36function displayPlaneName(formData) {
37 if (formData && formData.boeingAircraft && formData.boeingAircraft.length > 0) {
38 return "💀 " + formData.boeingAircraft[0] + " 📉";
41}
42
43export default async function(req: Request) {
44 return new Response(
45 render(

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": "*",