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=1583&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 19844 results for "function"(3933ms)

aiTextEditormain.tsx3 matches

@sharanbabu•Updated 8 months ago
1/**
2 * This val creates a text editing tool using the Cerebras Llama 70B model.
3 * It includes a command input field with speech-to-text functionality, a collapsible additional context area,
4 * and a rich text editor. The user's command, additional context, and current text are sent to the Cerebras API,
5 * which returns the modified text to be displayed in the editor.
8
9// Server-side code
10async function server(request: Request): Promise<Response> {
11 if (request.method === "POST" && new URL(request.url).pathname === "/process") {
12 const { command, text, additionalContext } = await request.json();
70 import ReactQuill from "https://esm.sh/react-quill";
71
72 function App() {
73 const [command, setCommand] = useState("");
74 const [editorContent, setEditorContent] = useState("<p></p>");

htmlkitREADME.md1 match

@yawnxyz•Updated 8 months ago
1This module provides functions to convert HTML to various formats such as Markdown, Pug, and Turndown.
2It also includes utilities to fetch HTML from a URL, extract metadata, and clean HTML by removing unwanted selectors.
3Dependencies include Cheerio for HTML parsing, JSDOM for DOM manipulation, and Turndown for converting HTML to Markdown.

agenta_webhook_evalmain.tsx1 match

@mmabrouk•Updated 8 months ago
1
2export default async function server(request: Request): Promise<Response> {
3
4 // Parse the request body

slackScoutmain.tsx10 matches

@ewinney•Updated 8 months ago
15}
16
17export default async function(interval: Interval): Promise<void> {
18 try {
19 await createTable();
38
39// Create an SQLite table
40async function createTable(): Promise<void> {
41 await sqlite.execute(`
42 CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
50
51// Fetch Hacker news, Twitter, and Reddit results
52async function fetchHackerNewsResults(topic: string): Promise<Website[]> {
53 return hackerNewsSearch({
54 query: topic,
58}
59
60async function fetchTwitterResults(topic: string): Promise<Website[]> {
61 return twitterSearch({
62 query: topic,
67}
68
69async function fetchRedditResults(topic: string): Promise<Website[]> {
70 return redditSearch({ query: topic });
71}
72
73function formatSlackMessage(website: Website): string {
74 const displayTitle = website.title || website.url;
75 return `*<${website.url}|${displayTitle}>*
78}
79
80async function sendSlackMessage(message: string): Promise<Response> {
81 const slackWebhookUrl = Deno.env.get("SLACK_WEBHOOK_URL");
82 if (!slackWebhookUrl) {
104}
105
106async function isURLInTable(url: string): Promise<boolean> {
107 const result = await sqlite.execute({
108 sql: `SELECT 1 FROM ${TABLE_NAME} WHERE url = :url LIMIT 1`,
112}
113
114async function addWebsiteToTable(website: Website): Promise<void> {
115 await sqlite.execute({
116 sql: `INSERT INTO ${TABLE_NAME} (source, url, title, date_published)
120}
121
122async function processResults(results: Website[]): Promise<void> {
123 for (const website of results) {
124 if (!(await isURLInTable(website.url))) {

rssNotifymain.tsx1 match

@squidarth2•Updated 8 months ago
4import RssParser from "npm:rss-parser";
5
6export async function rssNotify() {
7 const lastRunAt = await blob.getJSON(getLegacyImportUrl(import.meta.url));
8 console.log(`Last run: ${lastRunAt || "Never"}`);

smsjournalertextrelaymain.tsx10 matches

@cephalization•Updated 8 months ago
34// this is either broken or textbelt is not sending me the right stuff
35// this is implemented per the textbelt docs but i cant verify the sig...
36function validateTextbeltRequestSignature(
37 apiKey: string,
38 timestamp: string,
52}
53
54// Helper function to send SMS using TextBelt API
55async function sendSMS(phone: string, message: string) {
56 const response = await fetch("https://textbelt.com/text", {
57 method: "POST",
68}
69
70// Helper function to get conversation history
71async function getConversationHistory(phone: string): Promise<Message[]> {
72 const key = makeBlobKey(phone);
73 const history = await blob.getJSON(key) as Message[] | null;
75}
76
77// Helper function to update conversation history
78async function updateConversationHistory(phone: string, message: Message) {
79 const key = makeBlobKey(phone);
80 const history = await getConversationHistory(phone);
83}
84
85// Helper function to generate AI response
86async function generateAIResponse(history: Message[]): Promise<string> {
87 const openai = new OpenAI();
88 const messages: { role: "user" | "assistant" | "system"; content: string }[] = history.map(msg => ({
106}
107
108export default async function server(request: Request): Promise<Response> {
109 const quotaResponse = await fetch(
110 `https://textbelt.com/quota/${textbeltKey}`,

svgEmojimain.tsx1 match

@pomdtr•Updated 8 months ago
1export function svgEmoji(req: Request) {
2 const url = new URL(req.url);
3 const emoji = decodeURIComponent(url.pathname.slice(1));

linkInBioTemplatemain.tsx6 matches

@rasputinkaiser•Updated 8 months ago
5// ... (previous AuthContext, AuthProvider, and useAuth remain the same)
6
7function App() {
8 // ... (App component remains the same)
9}
10
11function Home({ theme }) {
12 const { user } = useAuth();
13 const isDark = theme === 'dark';
51}
52
53function PromptGenerator() {
54 const [prompt, setPrompt] = useState('');
55
80}
81
82function Tools({ theme }) {
83 const isDark = theme === 'dark';
84 const tools = [
102}
103
104function Gallery({ theme }) {
105 const isDark = theme === 'dark';
106 const [filter, setFilter] = useState('all');
209};
210
211// ... (client and server functions remain the same)

finalScrapermain.tsx3 matches

@rochambeau314•Updated 8 months ago
7import { createRoot } from "https://esm.sh/react-dom/client";
8
9function App() {
10 const [link, setLink] = useState("");
11 const [results, setResults] = useState(null);
81}
82
83function client() {
84 createRoot(document.getElementById("root")).render(<App />);
85}
89}
90
91async function server(request: Request): Promise<Response> {
92 if (request.method === "POST" && new URL(request.url).pathname === "/scrape") {
93 const { link } = await request.json();

hasWebsiteChangedmain.tsx1 match

@browserbase•Updated 8 months ago
7import slugify from "npm:slugify";
8
9export async function hasWebsiteChanged(url: string, threshold = 0.5) {
10 const slug = slugify(url);
11

getFileEmail4 file matches

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

tuna8 file matches

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