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/image-url.jpg%20%22Image%20title%22?q=function&page=2139&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 23749 results for "function"(1776ms)

isTripleWhaleDownHourlymain.tsx1 match

@weaverwhale•Updated 1 year ago
1import isMyWebsiteDown from "https://esm.town/v/weaverwhale/isMyWebsiteDown";
2
3export default async function(interval: Interval) {
4 const data = await isMyWebsiteDown("https://app.triplewhale.com");
5 console.log(data);

cron2main.tsx2 matches

@stevekrouse•Updated 1 year ago
63
64// convert a timezone string like America/New_York to "EST"
65function shortenTimezoneString(timeZone: string) {
66 const string = new Date().toLocaleString("en-US", { timeZone, timeZoneName: "short" });
67 return string.split(" ").at(-1);
76};
77
78export async function compile(description: string, timezone: string) {
79 const { content } = await chat([
80 {

chatmain.tsx3 matches

@weaverwhale•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">,

chatREADME.md1 match

@weaverwhale•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.

apimain.tsx1 match

@weaverwhale•Updated 1 year ago
1import { API_URL } from "https://esm.town/v/std/API_URL";
2
3export async function api<T = any>(
4 path: string,
5 options?: RequestInit & {

roastCastmain.tsx5 matches

@jamiedubs•Updated 1 year ago
4import process from "node:process";
5
6async function fetchCast({ fid, hash }: { fid: string; hash: string }) {
7 console.log("fetchCast", { fid, hash });
8 const res = await fetch(
27}
28
29async function runGlif({ inputs }: { inputs: string[] }): Promise<RunGlifResponse> {
30 const id = "cluu91eda000cv8jd675qsrby" as const;
31 const body = { id, inputs };
50}
51
52async function postCast({ text, replyToFid, replyToHash }: { text: string; replyToFid: string; replyToHash: string }) {
53 if (!process.env.FARCASTER_SIGNER_ID || !process.env.PINATA_JWT) {
54 throw new Error("missing required ENV vars");
90}
91
92async function runGlifAndPost({ inputs, cast }: { inputs: string[]; cast: { fid: string; hash: string } }) {
93 const glifRes = await runGlif({ inputs });
94 console.log({ glifRes });
98}
99
100export default async function(req: Request): Promise<Response> {
101 // console.log("req", req);
102 if (!process.env.GLIF_API_TOKEN) {

indie_authmain.tsx1 match

@pomdtr•Updated 1 year ago
5type HandlerFunc = (req?: Request) => Response | Promise<Response>;
6
7export function indieauth(handler: HandlerFunc, params: {
8 clientID: string;
9}): HandlerFunc {

reactEmailTemplatemain.tsx1 match

@tomas_padrieza•Updated 1 year ago
6import { sendMail } from "https://esm.town/v/tomas_padrieza/sendEmail";
7
8export function Email(props) {
9 const { url } = props;
10

sendEmailmain.tsx1 match

@tomas_padrieza•Updated 1 year ago
14};
15
16export function sendMail(to, subject, html) {
17 transport.sendMail({ ...options, to, subject, html });
18

sendEmailREADME.md1 match

@tomas_padrieza•Updated 1 year ago
1Simple function to provide the Email sending capability. The internal is limited to the `Pro` version only.

getFileEmail4 file matches

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

tuna8 file matches

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