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/?q=function&page=1481&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 18400 results for "function"(3344ms)

featureflagsmain.tsx1 match

@samwho•Updated 9 months ago
67};
68
69function getUserId(c: Context): string {
70 return c.req.query("userId")
71 || c.req.header("x-forwarded-for")

generateGuestbookSnippetmain.tsx2 matches

@tedlee•Updated 9 months ago
11 const msg = document.querySelector('#valtown-message');
12 const submitBtn = document.querySelector('#valtown-submit');
13 async function getMessages() {
14 const r = await fetch('https://${valUser}-${valName}.express.val.run');
15 msgList.innerHTML = '<ul>';
19 msgList.innerHTML += '</ul>';
20 }
21 async function sendMessage() {
22 submitBtn.disabled = true
23 const r = await fetch('https://${valUser}-${valName}.express.val.run', {

fuchsiaTapirmain.tsx1 match

@tempguy•Updated 9 months ago
1export default async function(req: Request): Promise<Response> {
2 const resp = await fetch("https://streamtape.com/v/", { "method": "GET", redirect: "manual" });
3 console.log(resp.headers.get("location"));

grimPinkLimpetmain.tsx2 matches

@jdan•Updated 9 months ago
1// This approach will use the Notion API to update a block's color.
2// We'll create a simple HTML page with a button, and use JavaScript to handle
3// the click event and make a request to our Val Town function.
4// The function will then make a request to the Notion API to update the block.
5
6import { Hono } from "npm:hono";

authmain.tsx3 matches

@brianleroux•Updated 9 months ago
1import { getSignedCookie, setSignedCookie } from "npm:hono/cookie";
2
3export async function login(c) {
4 const body = await c.req.formData();
5 const loggedIn = body.get("password") === Deno.env.get("PASSWORD");
7}
8
9export async function logout(c) {
10 await setSignedCookie(c, "loggedIn", "false", Deno.env.get("SECRET"));
11}
12
13export async function isLoggedIn(c) {
14 const { loggedIn } = await getSignedCookie(c, Deno.env.get("SECRET"));
15 console.log("loggedIn", loggedIn);

valleBlogV0main.tsx4 matches

@janpaul123•Updated 9 months ago
8import _ from "npm:lodash@4";
9
10async function main(req: Request): Promise<Response> {
11 const { readable, writable } = new TransformStream();
12 const writer = writable.getWriter();
20 <script>
21 // Scroll to the bottom of the page when the page changes.
22 (new MutationObserver(function (mutationsList, observer) {
23 window.scrollTo({ left: 0, top: document.body.scrollHeight, behavior: "instant" });
24 })).observe(document, { childList: true, characterData: true, subtree: true });
47 Your response should start with \`\`\`ts and end with \`\`\`, so full code fences.
48 There should be no comments like "more content here", it should be complete and directly runnable.
49 The val should have an "export default async function main". The val should return a valid HTML website.
50 Prefer using Tailwind. Put frontend functions in a <script> tag, using dangerouslySetInnerHTML. Don't use Hono. Don't use Response.redirect.
51 `.replace("\n", " "),
52 },

linearStandupmain.tsx3 matches

@schpet•Updated 9 months ago
45`;
46
47function getYesterdayDateRange(): { startDate: string; endDate: string } {
48 const now = new Date();
49 const yesterday = new Date(now.setDate(now.getDate() - 1));
56}
57
58export async function exec(interval: Interval) {
59 const apiKey = Deno.env.get("LINEAR_API_KEY");
60 if (!apiKey) {
132 });
133
134 function determineMatchedContext(
135 history: any[],
136 startDate: string,

orangeSolemain.tsx2 matches

@tempguy•Updated 9 months ago
51 },
52);
53export async function decodeHunter(encoded: string, mask: string, charCodeOffset: number, delimiterOffset: number) {
54 const delimiter = mask[delimiterOffset];
55 const chunks = encoded.split(delimiter).filter((chunk) => chunk);
69console.log(url);
70const player = await fetch(url[1]);
71const regex = /eval\(function\(h,u,n,t,e,r\).*?\("(.*?)",\d*?,"(.*?)",(\d*?),(\d*?),\d*?\)\)/;
72const linkRegex = /file:"(.*?)"/;
73const hunter_match = (await player.text()).match(regex);

lucia_adapter_basemain.tsx3 matches

@stevekrouse•Updated 9 months ago
127}
128
129function transformIntoDatabaseSession(raw: SessionSchema): DatabaseSession {
130 const { id, user_id: userId, expires_at: expiresAtUnix, ...attributes } = raw;
131 return {
137}
138
139function transformIntoDatabaseUser(raw: UserSchema): DatabaseUser {
140 const { id, ...attributes } = raw;
141 return {
145}
146
147function escapeName(val: string): string {
148 return "`" + val + "`";
149}

staleGithubPRsEmailmain.tsx2 matches

@jmandel•Updated 9 months ago
5// Sends an email with all the open PRs that have not had any activity
6// for specified period of days
7// Set up this function to run every day (or any interval)
8export async function staleGithubPRsEmail() {
9 // Set up a secret named githubRepos with all the repos you want to analyze (comma separated)
10 let repos = Deno.env.get("githubRepos")?.split(",").filter((r) => r.trim()) ?? [];

getFileEmail4 file matches

@shouser•Updated 1 week 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
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.