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=24&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 18846 results for "function"(960ms)

Townieusage-dashboard.ts4 matches

@valdottown•Updated 18 hours ago
4
5// Basic Auth middleware
6async function basicAuthMiddleware(req: Request): Promise<Response | null> {
7 const realm = "Usage Dashboard";
8 const unauthorizedResponse = new Response("Unauthorized", {
50}
51
52export default async function(req: Request) {
53 // Check authentication first
54 const authResponse = await basicAuthMiddleware(req);
288
289 <script>
290 document.addEventListener('DOMContentLoaded', function() {
291 // Add click event listeners to all tabs
292 document.querySelectorAll('.tab').forEach(tab => {
293 tab.addEventListener('click', function() {
294 const tabId = this.getAttribute('data-tab');
295

glastonewsindex.ts5 matches

@bensomething•Updated 19 hours ago
9
10// ======= Fetch HTML with Improved Retry =======
11async function fetchHtmlWithRetry(url, options = {}, retries = 5, delay = 1000) {
12 for (let i = 0; i < retries; i++) {
13 try {
71
72// ======= Fetch News =======
73async function fetchNews() {
74 const url = "https://glastonburyfestivals.co.uk/news/";
75 try {
94
95// ======= Fetch Your Own Recent Bluesky Post Titles =======
96async function fetchOwnRecentPostTitles(agent, handle, limit = 100) {
97 const feed = await agent.getAuthorFeed({ actor: handle, limit });
98 return feed.data.feed.map(item => item.post.record.text);
100
101// ======= Fetch Embed Data =======
102async function fetchEmbedData(url) {
103 try {
104 const html = await fetchHtmlWithRetry(url);
168
169// ======= Main Bot =======
170async function main() {
171 try {
172 await agent.login({

untitled-5581lambdaCalculus.ts11 matches

@FireCrystalScribe•Updated 20 hours ago
19// c: cutoff - indices >= c are shifted, < c are bound locally and untouched
20// term: the term to process
21function shift(d: number, c: number, term: Term): Term {
22 switch (term.type) {
23 case "var":
39// s: the replacement term
40// term: the term in which substitution occurs
41function substitute(j: number, s: Term, term: Term): Term {
42 switch (term.type) {
43 case "var":
63// 2. substitute(0, <shifted_t2>, t1): Replace Var(0) in t1 with the shifted t2.
64// 3. shift(-1, 0, <result>): Decrement free variables in the result as the outer lambda binder is removed.
65function betaReduce(absBody: Term, arg: Term): Term {
66 const shiftedArg = shift(1, 0, arg);
67 const substitutedBody = substitute(0, shiftedArg, absBody);
72// Single Step Reducer (Normal Order)
73// --------------------------
74function reduceStep(term: Term): Term | null {
75 switch (term.type) {
76 case "app":
79 return betaReduce(term.func.body, term.arg);
80 }
81 // Rule 2: t1 t2 ---> t1' t2 (Reduce function part)
82 const reducedFunc = reduceStep(term.func);
83 if (reducedFunc) {
107// Full Reducer
108// --------------------------
109function reduce(term: Term, maxSteps: number = 100, verbose: boolean = false): Term {
110 let currentTerm = term;
111 if (verbose) console.log(`Reducing: ${termToString(currentTerm)}`);
124
125// --------------------------
126// toString Function
127// --------------------------
128const baseVarNames = "xyzabcdefghijklmnopqrstuvw";
129
130function generateVarName(depth: number, usedNames: string[]): string {
131 let name: string;
132 let tempDepth = depth;
149}
150
151function termToStringInternal(term: Term, boundNames: string[]): string {
152 switch (term.type) {
153 case "var":
183}
184
185function termToString(term: Term): string {
186 return termToStringInternal(term, []);
187}
256const Y = Abs(App(Y_inner, Y_inner));
257
258// A sample function F (e.g. identity I)
259const F_for_Y_test = I;
260const test_Y_F = App(Y, F_for_Y_test);

templateTwitterAlertREADME.md2 matches

@noumanshakeel82•Updated 20 hours ago
46- Key: `mentionsDiscord`
47- Value: Your Discord webhook URL.
48Notifications will be sent using this function:
49
50```ts
63
64- **Proxies via Val Town's [SocialDataProxy](https://www.val.town/v/stevekrouse/socialDataProxy)**: Limited to 10 cents per day for [**Val Town Pro users**](https://www.val.town/pricing). This API is *only* for Pro users.
65- **Need more calls?** Sign up for your own [SocialData API token](https://socialdata.tools) and configure the [`socialDataSearch`](https://www.val.town/v/stevekrouse/socialDataSearch) function.

templateTwitterAlertmain.tsx1 match

@noumanshakeel82•Updated 20 hours ago
12const isProd = false;
13
14export async function twitterAlert({ lastRunAt }: Interval) {
15 // If isProd, search for tweets since that last time this interval ran
16 // if not, search for tweets since 48 hours ago for testing

testtowniePostView.tsx2 matches

@charmaine•Updated 20 hours ago
13}
14
15export function PostView({ post }: PostViewProps) {
16 // Format date
17 const formatDate = (timestamp: number) => {
27 if (typeof marked !== 'undefined' && typeof hljs !== 'undefined') {
28 marked.setOptions({
29 highlight: function(code: string, language: string) {
30 if (language && hljs.getLanguage(language)) {
31 return hljs.highlight(code, { language }).value;

testtowniePostList.tsx2 matches

@charmaine•Updated 20 hours ago
8}
9
10export function PostList({ posts }: PostListProps) {
11 if (posts.length === 0) {
12 return (
18 }
19
20 // Format date function
21 const formatDate = (timestamp: number) => {
22 return new Date(timestamp).toLocaleDateString('en-US', {

testtownieFooter.tsx1 match

@charmaine•Updated 20 hours ago
3import { parseProject } from "https://esm.town/v/std/utils@85-main/index.ts";
4
5export function Footer() {
6 const currentYear = new Date().getFullYear();
7 const projectInfo = React.useMemo(() => {

testtownieHeader.tsx1 match

@charmaine•Updated 20 hours ago
3import { Link } from "https://esm.sh/react-router-dom@6.20.1?deps=react@18.2.0";
4
5export function Header() {
6 return (
7 <header className="bg-white shadow-sm">

testtownieindex.tsx6 matches

@charmaine•Updated 20 hours ago
10
11// Main App component
12function App() {
13 return (
14 <BrowserRouter>
29
30// Home page component
31function Home() {
32 const [posts, setPosts] = React.useState<PostWithTags[]>([]);
33 const [loading, setLoading] = React.useState(true);
35
36 React.useEffect(() => {
37 async function fetchPosts() {
38 try {
39 const response = await fetch('/api/posts');
74
75// Single post page component
76function Post() {
77 const { slug } = useParams<{ slug: string }>();
78 const [post, setPost] = React.useState<PostWithTags | null>(null);
82
83 React.useEffect(() => {
84 async function fetchPost() {
85 if (!slug) return;
86
139
140// 404 Not Found component
141function NotFound() {
142 return (
143 <div className="text-center py-12">

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