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=2517&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 29307 results for "function"(8448ms)

Splinemain.tsx3 matches

@muhammad_owais_warsi•Updated 8 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [SplineComponent, setSplineComponent] = useState(null);
7 const [error, setError] = useState(null);
50}
51
52function client() {
53 createRoot(document.getElementById("root")).render(<App />);
54}
56if (typeof document !== "undefined") { client(); }
57
58async function server(request: Request): Promise<Response> {
59 return new Response(
60 `

knownExploitedVulnsEndpointmain.tsx1 match

@hrbrmstr•Updated 8 months ago
1export default async function server(request: Request): Promise<Response> {
2 try {
3 const response = await fetch("https://www.cisa.gov/sites/default/files/feeds/known_exploited_vulnerabilities.json");

cisaKEVToRSSmain.tsx4 matches

@hrbrmstr•Updated 8 months ago
3const RSS_FEED_URL = "https://hrbrmstr-cisakevtorss.web.val.run"; // Update this to your actual RSS feed URL
4
5function escapeXML(str: string): string {
6 return str.replace(/&/g, "&amp;")
7 .replace(/</g, "&lt;")
11}
12
13function removeInvalidXMLChars(str: string): string {
14 return str
15 .replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, "") // Control characters
19}
20
21function generateRSS(data: any): string {
22 const { title, catalogVersion, dateReleased, vulnerabilities } = data;
23
68}
69
70export async function handler(req: Request): Promise<Response> {
71 try {
72 const response = await fetch(CISA_JSON_URL);

eagerIndigoPigmain.tsx10 matches

@nickaggarwal•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))) {

slackScoutmain.tsx10 matches

@nickaggarwal•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))) {

ForexDataHubmain.tsx3 matches

@samweist•Updated 8 months ago
1import { addMonths, format, subMonths } from "https://esm.sh/date-fns";
2
3function generateFutureEvents(months = 6) {
4 const events = [];
5 const startDate = new Date();
41}
42
43async function server(request: Request): Promise<Response> {
44 const url = new URL(request.url);
45
177}
178
179function getStyles() {
180 return `
181 <style>

linkInBioTemplatemain.tsx1 match

@grubdragon•Updated 8 months ago
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(

numbergamemain.tsx4 matches

@moe•Updated 8 months ago
9const HUE_DIFF = 25
10
11function getColor(value: number): string {
12 const power = Math.log2(value / 2)
13 const hue = (power * HUE_DIFF) % 360
15}
16
17function App() {
18 const [board, setBoard] = useState<number[][]>([])
19 const [selectedCells, setSelectedCells] = useState<[number, number][]>([])
227}
228
229function client() {
230 createRoot(document.getElementById("root")).render(<App />)
231}
233if (typeof document !== "undefined") { client() }
234
235async function server(request: Request): Promise<Response> {
236 return new Response(
237 `

FanficSearcherWebsitemain.tsx5 matches

@willthereader•Updated 8 months ago
2import { configure, hits, pagination, searchBox } from "https://esm.sh/instantsearch.js@4.49.1/es/widgets";
3// first stable version is 9 and the link is https://www.val.town/v/willthereader/FanficSearcherWebsite?v=9
4function validateConfig(): { appId: string; apiKey: string } {
5 const appId = Deno.env.get("ALGOLIA_APP_ID_fanficSearcher");
6 const apiKey = Deno.env.get("ALGOLIA_SEARCH_API_KEY_fanficSearcher");
13}
14
15function generateHtml(appId: string, apiKey: string): string {
16 console.log("Generating HTML with App ID:", appId, "and API Key:", apiKey ? "exists" : "missing");
17 return `
91 container: '#hits',
92 templates: {
93 item: function(hit) {
94 console.log('Hit:', hit); // Add this line
95 return '<div class="hit">' +
115}
116
117function handleError(error: Error): Response {
118 console.error("Server error:", error);
119 return new Response(`Error: ${error.message}`, { status: 500 });
120}
121
122async function handleRequest(request: Request): Promise<Response> {
123 console.log("Received request:", request.url);
124 try {

recordWebsitePreparermain.tsx8 matches

@willthereader•Updated 8 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [input, setInput] = useState({
7 storyTitle: "",
63}
64
65function client() {
66 createRoot(document.getElementById("root")).render(<App />);
67}
68if (typeof document !== "undefined") { client(); }
69
70function preparestoryForAlgolia(storyTitle, storyText) {
71 const generateUniqueID = (() => {
72 let counter = 1000000000; // Start from 1 billion
77 })();
78
79 function isWordBoundary(text, index) {
80 if (index === 0 || index === text.length) return true;
81 const prevChar = text[index - 1];
89 }
90
91 function createAlgoliaRecord(storyContent, startIndex, endIndex, storyTitle, chapterTitle, chunkIndex) {
92 return {
93 storyTitle: storyTitle,
102 }
103
104 function processstory(storyTitle, storyText) {
105 let algoliaRecords = [];
106 let currentChunk = "";
224}
225
226async function server(request: Request): Promise<Response> {
227 if (request.method === "POST") {
228 const { storyTitle, storyText } = await request.json();
314`;
315
316function extractContent(inputText) {
317 // Split the input text by newlines
318 const lines = inputText.split("\n");
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.