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/$%7Bsuccess?q=function&page=2513&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 29109 results for "function"(1794ms)

multipleBronzeCaterpillarmain.tsx1 match

@tbsvttrβ€’Updated 9 months ago
1import { email } from "https://esm.town/v/std/email";
2
3export default async function handler(request: Request) {
4 if (request.method !== "POST") {
5 return Response.json({ message: "This val responds to POST requests." }, {

add_to_notion_w_aimain.tsx9 matches

@junhocaβ€’Updated 9 months ago
35});
36
37function createPrompt(title, description, properties) {
38 let prompt =
39 "You are processing content into a database. Based on the title of the database, its properties, their types and options, and any existing descriptions, infer appropriate values for the fields:\n";
80}
81
82function processProperties(jsonObject) {
83 const properties = jsonObject.properties;
84 const filteredProps = {};
111}
112
113async function get_and_save_notion_db_processed_properties(databaseId)
114{
115 const response = await notion.databases.retrieve({ database_id: databaseId });
122}
123
124async function get_notion_db_info(databaseId) {
125 databaseId = databaseId.replaceAll("-", "");
126 let db_info = null;
137}
138
139async function get_and_save_notion_db_info(databaseId) {
140 databaseId = databaseId.replaceAll("-", "");
141 let db_info = await get_and_save_notion_db_processed_properties(databaseId);
144}
145
146function createZodSchema(filteredProps) {
147 const schemaObject = {};
148
193}
194
195function convertToNotionProperties(responseValues, filteredProps) {
196 const notionProperties = {};
197
268}
269
270async function process_text(dbid, text) {
271 const db_info = await get_notion_db_info(dbid);
272 const processed_message = await client.chat.completions.create({
283}
284
285async function addToNotion(databaseId, text) {
286 databaseId = databaseId.replaceAll("-", "");
287 const properties = await process_text(databaseId, text);

chatWithCerebrasmain.tsx3 matches

@lazyplatypusβ€’Updated 9 months ago
5
6const MODELS = ["llama3.1-8b", "llama3.1-70b"];
7function App() {
8 const [messages, setMessages] = useState<Array<{ role: string; content: string }>>([]);
9 const [edits, setEdits] = useState<Array<{ id: number; content: string }>>(
128}
129
130function client() {
131 createRoot(document.getElementById("root")).render(<App />);
132}
136}
137
138async function server(request: Request): Promise<Response> {
139 if (request.method === "POST" && new URL(request.url).pathname === "/api/chat") {
140 const { messages, model } = await request.json();

printedWhiteToadmain.tsx3 matches

@lazyplatypusβ€’Updated 9 months ago
5
6const MODELS = ["llama3.1-8b", "llama3.1-70b"];
7function App() {
8 const [messages, setMessages] = useState<Array<{ role: string; content: string }>>([]);
9 const [edits, setEdits] = useState<Array<{ id: number; content: string }>>(
125}
126
127function client() {
128 createRoot(document.getElementById("root")).render(<App />);
129}
133}
134
135async function server(request: Request): Promise<Response> {
136 if (request.method === "POST" && new URL(request.url).pathname === "/api/chat") {
137 const { messages, model } = await request.json();

honEmeraldSnailmain.tsx6 matches

@stevekrouseβ€’Updated 9 months ago
5const MODEL = "claude-3-sonnet-20240229";
6
7function applyDiffs(html, diffs) {
8 console.log("Applying diffs. Initial HTML:", html);
9 console.log("Diffs to apply:", diffs);
54}
55
56function parseHTMLFromResponse(content) {
57 const htmlMatch = content.match(/```html\s*([\s\S]*?)\s*```/);
58 console.log("Parsed HTML from response:", htmlMatch && htmlMatch[1] ? htmlMatch[1].trim() : null);
60}
61
62function parseDiffsFromResponse(content) {
63 try {
64 const jsonMatch = content.match(/\{[\s\S]*\}/);
72
73
74function App() {
75 const [messages, setMessages] = useState<Array<{ role: string; content: string }>>([]);
76 const [edits, setEdits] = useState<Array<{ id: number; content: string }>>([]);
200}
201
202function client() {
203 createRoot(document.getElementById("root")).render(<App />);
204}
208}
209
210async function server(request: Request): Promise<Response> {
211 if (request.method === "POST" && new URL(request.url).pathname === "/api/chat") {
212 const { Anthropic } = await import("https://esm.sh/@anthropic-ai/sdk@0.17.1");

selectHtmlmain.tsx7 matches

@yawnxyzβ€’Updated 9 months ago
6import { JSDOM } from 'npm:jsdom';
7
8// Function to fetch HTML from a URL and remove <style> and <script> tags
9export async function fetchHtml(url, removeSelectors = "style, script, link, noscript, frame, iframe, comment") {
10 try {
11 const response = await fetch(url);
22}
23
24// Function to use Cheerio to select text from the html, and attempts to clean it a bit
25export function selectHtml(html, selector = "h1", removeSelectors = "style, script, link, noscript, frame, iframe, comment") {
26 const $ = cheerio.load(html); // Load the cleaned HTML into Cheerio
27 $(removeSelectors).remove(); // Remove unwanted tags
37}
38
39// Function to convert HTML to Pug using html2pug
40export function convertHtmlToPug(html, options = { tabs: true }) {
41 const pug = html2pug(html, options);
42 return pug;
59}
60
61export function convertHtmlToMarkdown(htmlStr: string, options?: ConversionOptions): string {
62 const dom = new JSDOM(htmlStr);
63 const markdown = semanticMarkdown(htmlStr, { ...options, overrideDOMParser: new dom.window.DOMParser() });

dailyDadJokemain.tsx1 match

@rahulgβ€’Updated 9 months ago
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({

aqimain.tsx1 match

@unicornβ€’Updated 9 months ago
2import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
3
4export async function aqi(interval: Interval) {
5 const location = "ZΓΌrich, Schweiz"; // <-- change to place, city, or zip code
6 const data = await easyAQI({ location });

virtualPetSimmain.tsx5 matches

@muhammad_owais_warsiβ€’Updated 9 months ago
16const FOODS = ["🍎", "🍌", "πŸ₯•", "πŸ–", "🍣"];
17
18function App() {
19 const [pet, setPet] = useState(null);
20 const [loading, setLoading] = useState(true);
77}
78
79function client() {
80 createRoot(document.getElementById("root")).render(<App />);
81}
85}
86
87async function server(request: Request): Promise<Response> {
88 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
89 const SCHEMA_VERSION = 1;
138}
139
140async function getPet() {
141 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
142 const SCHEMA_VERSION = 1;
164}
165
166async function updatePet(action) {
167 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
168 const SCHEMA_VERSION = 1;

migrationsmain.tsx1 match

@saolsenβ€’Updated 9 months ago
1import { sqlite as valtown_sqlite } from "https://esm.town/v/std/sqlite";
2
3export async function migrate(
4 sqlite: typeof valtown_sqlite,
5 key: string,
tuna

tuna9 file matches

@jxnblkβ€’Updated 1 day ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouserβ€’Updated 1 month ago
A helper function to build a file's email
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.