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%22Optional%20title%22?q=function&page=12&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 18580 results for "function"(738ms)

hn-remote-ts-genai-jobsapi.ts4 matches

@prashamtrivedi•Updated 18 hours ago
9 * Main HTTP handler
10 */
11export default async function(req: Request): Promise<Response> {
12 // Get the URL pathname
13 const url = new URL(req.url);
30 * Handle the main jobs page
31 */
32async function handleJobsPage(req: Request): Promise<Response> {
33 // Get the latest results
34 const results = await getLatestResults();
104 * Handle the JSON API endpoint
105 */
106async function handleJobsAPI(req: Request): Promise<Response> {
107 // Get the format parameter
108 const url = new URL(req.url);
146 * Handle the refresh endpoint
147 */
148async function handleRefresh(req: Request): Promise<Response> {
149 try {
150 // Run the job finder

hn-remote-ts-genai-jobsindex.ts9 matches

@prashamtrivedi•Updated 18 hours ago
26
27/**
28 * Main function to fetch and process job listings
29 */
30export async function findRemoteTSGenAIJobs(): Promise<{
31 threadId: number;
32 jobs: JobListing[];
73 * Store job results in blob storage
74 */
75async function storeResults(results: {
76 threadId: number;
77 jobs: JobListing[];
91 * Get the latest stored results
92 */
93export async function getLatestResults(): Promise<{
94 threadId: number;
95 jobs: JobListing[];
107 * Format job listings into a readable HTML format
108 */
109export function formatJobListingsHTML(jobs: JobListing[]): string {
110 if (jobs.length === 0) {
111 return "<p>No matching jobs found.</p>";
220 * Format job listings into a readable text format
221 */
222export function formatJobListingsText(jobs: JobListing[]): string {
223 if (jobs.length === 0) {
224 return "No matching jobs found.";
247
248/**
249 * Helper function to escape HTML special characters
250 */
251function escapeHtml(str: string): string {
252 return str
253 .replace(/&/g, "&amp;")
276}
277
278// Make the main function available for import
279export default findRemoteTSGenAIJobs;
280

hn-remote-ts-genai-jobscommentParser.ts11 matches

@prashamtrivedi•Updated 18 hours ago
1/**
2 * Comment Parser
3 * Functions to parse Hacker News comments and filter for job listings
4 */
5
22 * @param text The comment text to check
23 */
24export function hasTypeScriptAndGenAI(text: string): boolean {
25 const lowerText = text.toLowerCase();
26
56 * @param text The comment text to check
57 */
58export function isRemoteJob(text: string): boolean {
59 const lowerText = text.toLowerCase();
60
84 * @param text The comment text
85 */
86export function extractCompany(text: string): string {
87 const companyMatch = text.match(/^([^|]*?)(?=\s*\||\n|$)/);
88 if (companyMatch && companyMatch[1].trim()) {
111 * @param text The comment text
112 */
113export function extractPosition(text: string): string {
114 // Common patterns for job titles in HN threads
115 const positionPatterns = [
135 * @param text The comment text
136 */
137export function extractSkills(text: string): string[] {
138 const lowerText = text.toLowerCase();
139 const skills: string[] = [];
174 * @param text The comment text
175 */
176export function extractLocation(text: string): string {
177 if (isRemoteJob(text)) {
178 // Check for remote with specific regions
216 * @param text The comment text
217 */
218export function extractUrl(text: string): string | undefined {
219 // Look for URLs in the text
220 const urlMatch = text.match(/(https?:\/\/[^\s]+)/);
226 * @param text The comment text
227 */
228export function extractDescription(text: string): string {
229 // Remove HTML tags for clean text
230 const cleanText = text.replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ').trim();
257 * @returns A parsed job listing or null if not a valid job listing
258 */
259export function parseJobListing(comment: HNItem): JobListing | null {
260 if (!comment.text) {
261 return null;
288 * @returns Array of parsed job listings
289 */
290export function filterJobListings(comments: HNItem[]): JobListing[] {
291 const jobListings: JobListing[] = [];
292

hn-remote-ts-genai-jobshackerNewsApi.ts5 matches

@prashamtrivedi•Updated 18 hours ago
1/**
2 * Hacker News API helper functions
3 * Provides utilities to interact with the official Hacker News API
4 */
28 * @returns The item data or null if not found
29 */
30export async function fetchItem(id: number): Promise<HNItem | null> {
31 try {
32 const response = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`);
46 * @returns An array of comment items
47 */
48export async function fetchComments(storyId: number): Promise<HNItem[]> {
49 const story = await fetchItem(storyId);
50 if (!story || !story.kids || story.kids.length === 0) {
69 * @returns The thread ID or null if not found
70 */
71export async function findLatestWhoIsHiringThread(): Promise<number | null> {
72 try {
73 // First get the user information for "whoishiring" account
105 * This is useful because the thread is typically posted on the first of each month
106 */
107export function getFallbackThreadId(): number {
108 // May 2023 "Who is hiring?" thread ID as a fallback
109 // In a real implementation, you might want to update this periodically

hn-remote-ts-genai-jobsREADME.md2 matches

@prashamtrivedi•Updated 18 hours ago
17
18- `backend/index.ts` - Main script that orchestrates the entire process
19- `backend/hackerNewsApi.ts` - Functions to interact with the Hacker News API
20- `backend/commentParser.ts` - Functions to parse and filter job listings
21
22## View Results

slacktransform.tsx16 matches

@dinavinter•Updated 18 hours ago
1import { DefineFunction, Schema, SlackFunction, type SlackFunctionArgs } from "deno-slack-sdk/mod.ts";
2import SampleObjectDatastore from "./datastore.ts";
3
4/**
5 * Functions are reusable building blocks of automation that accept
6 * inputs, perform calculations, and provide outputs. Functions can
7 * be used independently or as steps in workflows.
8 * https://api.slack.com/automation/functions/custom
9 */
10export const SampleFunctionDefinition = DefineFunction({
11 callback_id: "sample_function",
12 title: "Sample function",
13 description: "A sample function",
14 source_file: "functions/sample_function.ts",
15 input_parameters: {
16 properties: {
38
39/**
40 * SlackFunction takes in two arguments: the CustomFunction
41 * definition (see above), as well as a function that contains
42 * handler logic that's run when the function is executed.
43 * https://api.slack.com/automation/functions/custom
44 */
45export default SlackFunction(
46 SampleFunctionDefinition,
47 async ({ inputs, client }: SlackFunctionArgs) => {
48 const uuid = crypto.randomUUID();
49

Discord_Bot_Servicesmap-vote-setup-config.tsx10 matches

@ktodaz•Updated 19 hours ago
4import { getCurrentConfig } from "https://www.val.town/x/ktodaz/Discord_Bot_Services/code/map_vote/map-vote-getCurrentConfig.tsx";
5
6// Main configuration function
7export async function setupMapVoteSystem() {
8 console.log("🔧 Setting up Map Vote Channel Creator System");
9
17 return {
18 success: true,
19 message: "Setup completed successfully. You can now use the map-vote-channel-creator function.",
20 };
21 } catch (error) {
29
30// Initialize SQLite database for vote tallying
31async function initializeDatabase() {
32 console.log("🔧 Setting up SQLite database...");
33
71
72// Check if environment variables exist and suggest default values
73async function initializeEnvironmentVariables() {
74 console.log("🔧 Checking environment variables...");
75
132
133// Update Discord configuration
134export async function updateDiscordConfig(config: {
135 guildId?: string;
136 categoryId?: string;
179
180// Update voting requirements
181export async function updateVotingRequirements(config: {
182 maxVotesPerVoter?: number;
183 numberOfWinners?: number;
215
216// Update map variant options
217export async function updateMapVariantOptions(options: {
218 enableDawn?: boolean;
219 enableDay?: boolean;
286
287// Get a single map for testing/development purposes
288export function getTestMapData() {
289 return {
290 Maps: [
311
312// Run a test creation of a channel - this would be a dry run without actually creating the channel
313export async function testChannelSetup() {
314 try {
315 // Validate Discord settings by checking environment variables

telegramBotStarterbotFunctions.js19 matches

@asdfg•Updated 19 hours ago
1// ============================================================
2// CORE FUNCTIONALITY
3// ============================================================
4import storage from "./storage.js";
7 * Expose this as an HTTP endpoint in Val.town
8 */
9async function handleTelegramWebhook(req) {
10 try {
11 const update = await req.json();
50 * Process commands from the owner
51 */
52async function processOwnerCommand(message) {
53 const text = message.text || "";
54
175 * Get information about a user
176 */
177async function getUserInfo(userId) {
178 return await storage.get(`userInfo:${userId}`);
179}
182 * Get list of all active users who have messaged the bot
183 */
184async function getActiveUsers() {
185 // Fetch raw user data from the blob storage
186 const rawUserKeys = await storage.list({ prefix: "userInfo:" });
210 * Get list of blocked user IDs
211 */
212async function getBlockedUsers() {
213 return await storage.get("blockedUsers") || [];
214}
217 * Block a user
218 */
219async function blockUser(userId) {
220 const blockedUsers = await getBlockedUsers();
221 userId = userId.toString();
232 * Unblock a user
233 */
234async function unblockUser(userId) {
235 const blockedUsers = await getBlockedUsers();
236 userId = userId.toString();
252 * Store a message in the database
253 */
254async function storeMessage(userId, userName, text, direction) {
255 const messages = await getMessages(userId) || [];
256
279 * Get message history for a specific user
280 */
281async function getMessages(userId) {
282 return await storage.get(`messages:${userId}`) || [];
283}
286 * Notify the owner about new incoming messages
287 */
288async function notifyOwner(userId, userName, messageText) {
289 const ownerChatId = process.env.OWNER_CHAT_ID;
290
299 * Reply to a specific user
300 */
301async function replyToUser(userId, text) {
302 // Send the message to the user
303 const success = await sendTelegramMessage(userId, text);
333 * Send a message using the Telegram API
334 */
335async function sendTelegramMessage(chatId, text) {
336 try {
337 const botToken = process.env.TELEGRAM_BOT_TOKEN;
356
357// ============================================================
358// SETUP FUNCTIONS
359// ============================================================
360
363 * Use this once during initial setup
364 */
365async function setupWebhook(webhookUrl) {
366 try {
367 const botToken = process.env.TELEGRAM_BOT_TOKEN;
387 * Get information about the webhook status
388 */
389async function getWebhookInfo() {
390 try {
391 const botToken = process.env.TELEGRAM_BOT_TOKEN;
403 * Send a welcome message to yourself to verify the bot is working
404 */
405async function testBot() {
406 const ownerChatId = process.env.OWNER_CHAT_ID;
407
424}
425
426// Export the functions
427export default {
428 // Main webhook handler
429 telegram: handleTelegramWebhook,
430
431 // Setup and utility functions
432 setupWebhook,
433 getWebhookInfo,

nameSeeingServermain.tsx3 matches

@thesilentdefender•Updated 19 hours ago
5let mostRecentName: string | null = null;
6
7function handleGet(req: ExpressRequest, res: ExpressResponse) {
8 res.send({ namesPreviouslySeen: namesPreviouslySeen.size, mostRecentName });
9}
10
11const zPostBody = z.any();
12function handlePost(req: ExpressRequest, res: ExpressResponse) {
13 const body = zPostBody.safeParse(req.body);
14 if (!body.success) {
52 send: (json: any) => void;
53}
54export default async function(req: Request): Promise<Response> {
55 let resStatus = 200;
56

nameSeeingServerjmain.tsx3 matches

@razahtet•Updated 19 hours ago
5let mostRecentName: string | null = null;
6
7function handleGet(req: ExpressRequest, res: ExpressResponse) {
8 res.send({ namesPreviouslySeen: namesPreviouslySeen.size, mostRecentName });
9}
10
11const zPostBody = z.any();
12function handlePost(req: ExpressRequest, res: ExpressResponse) {
13 const body = zPostBody.safeParse(req.body);
14 if (!body.success) {
52 send: (json: any) => void;
53}
54export default async function(req: Request): Promise<Response> {
55 let resStatus = 200;
56

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