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=1433&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 18633 results for "function"(4430ms)

placeholderKittenImagesmain.tsx2 matches

@ashryanio•Updated 7 months ago
2// It supports generating square images with a single dimension parameter or rectangular images with two dimension parameters.
3
4export default async function server(request: Request): Promise<Response> {
5 const url = new URL(request.url);
6 const parts = url.pathname.split('/').filter(Boolean);
95 <p>Start generating your own kitten images by using the form above or modifying the URL!</p>
96 <script>
97 document.getElementById('kittenForm').addEventListener('submit', function(e) {
98 e.preventDefault();
99 const width = document.getElementById('width').value;

FanFicScrapermain.tsx5 matches

@willthereader•Updated 7 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4// last stable version is v138
5function App() {
6 const [url, setUrl] = useState("");
7 const [result, setResult] = useState(null);
68}
69
70function client() {
71 console.log("Initializing client-side React application");
72 createRoot(document.getElementById("root")).render(<App />);
77}
78
79async function scrapePage(url) {
80 console.log(`Starting to scrape page: ${url}`);
81 const apiKey = Deno.env.get("ScrapingBeeAPIkey");
163}
164
165async function getApiKey() {
166 const apiKey = Deno.env.get("ScrapingBeeAPIkey");
167 if (!apiKey) {
172}
173
174async function server(request) {
175 console.log(`Received ${request.method} request for path: ${new URL(request.url).pathname}`);
176 if (request.method === "POST" && new URL(request.url).pathname === "/scrape") {

getBlobAndRenderAsImageREADME.md2 matches

@ashryanio•Updated 7 months ago
15
16 - The client-side React component makes a fetch request to "/image".
17 - This request is handled by our server function.
18
19
202. Server-side handling:
21
22 - The server function calls `blob.get("test.png")`.
23 - This `blob.get()` method makes an HTTP request to the Val Town API.
24 - The API returns a Response object containing the image data.

zygomorphicPurpleStoatmain.tsx1 match

@seanodotcom•Updated 7 months ago
2import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
3
4export async function aqi(interval: Interval) {
5 const location = "Philadelphia"; // <-- change to place, city, or zip code
6 const data = await easyAQI({ location });

jsonVisualizerAppmain.tsx3 matches

@tmcw•Updated 7 months ago
8SyntaxHighlighter.registerLanguage('json', json);
9
10function App() {
11 const [jsonInput, setJsonInput] = useState('');
12 const [parsedJson, setParsedJson] = useState('');
57}
58
59function client() {
60 createRoot(document.getElementById("root")).render(<App />);
61}
63if (typeof document !== "undefined") { client(); }
64
65export default async function server(request: Request): Promise<Response> {
66 return new Response(`
67 <html>

count_visitsmain.tsx4 matches

@nicosql•Updated 7 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [websiteUrl, setWebsiteUrl] = useState("");
7 const [embedCode, setEmbedCode] = useState("");
61}
62
63function client() {
64 createRoot(document.getElementById("root")).render(<App />);
65}
69}
70
71async function server(request: Request): Promise<Response> {
72 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
73 const SCHEMA_VERSION = 1;
92import { useState, useEffect } from 'react';
93
94function VisitorCounter() {
95 const [count, setCount] = useState(0);
96

redditSearchmain.tsx4 matches

@nicosql•Updated 7 months ago
15
16// Use Browserbase (with proxy) to search and scrape Reddit results
17export async function redditSearch({
18 query,
19 apiKey = Deno.env.get("BROWSERBASE_API_KEY"),
46}
47
48function constructSearchUrl(query: string): string {
49 const encodedQuery = encodeURIComponent(query).replace(/%20/g, "+");
50 return `https://www.reddit.com/search/?q=${encodedQuery}&type=link&t=week`;
51}
52
53async function extractPostData(page: any): Promise<Partial<ThreadResult>[]> {
54 return page.evaluate(() => {
55 const posts = document.querySelectorAll("div[data-testid=\"search-post-unit\"]");
67}
68
69async function processPostData(postData: Partial<ThreadResult>[]): Promise<ThreadResult[]> {
70 const processedData: ThreadResult[] = [];
71

ablePinkDogmain.tsx5 matches

@nicosql•Updated 7 months ago
11};
12
13async function createSessionTable(tableName: string) {
14 await sqlite.execute(`CREATE TABLE ${tableName} (
15 id TEXT NOT NULL PRIMARY KEY,
19}
20
21async function createSession(tableName: string, valSlug: string): Promise<Session> {
22 try {
23 const expires_at = new Date();
39}
40
41async function getSession(tableName: string, sessionID: string, valSlug: string): Promise<Session> {
42 try {
43 const { rows, columns } = await sqlite.execute({
80</html>`;
81
82export function redirect(location: string): Response {
83 return new Response(null, {
84 headers: {
98const cookieName = "auth_session";
99
100export function passwordAuth(next, options?: PasswordAuthOptions) {
101 const sessionTable = options?.sessionTable || "password_auth_session";
102 return async (req: Request) => {

renderFormAndSaveDataREADME.md1 match

@nicosql•Updated 7 months ago
1# Render form and save data
2
3This val provides a web-based interface for collecting email addresses. It features a dual-functionality approach: when accessed via a web browser using a GET request, it serves an HTML form where users can submit their email address. If the script receives a POST request, it implies that the form has been submitted, and it proceeds to handle the incoming data.
4
5Fork this val to customize it and use it on your account.

harshAquamarineRoostermain.tsx7 matches

@nicosql•Updated 7 months ago
31
32// ------------
33// Functions
34// ------------
35
36async function execute(statement: InStatement, args?: InArgs): Promise<ResultSet> {
37 const res = await fetch(`${API_URL}/v1/sqlite/execute`, {
38 method: "POST",
49}
50
51async function batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
52 const res = await fetch(`${API_URL}/v1/sqlite/batch`, {
53 method: "POST",
64}
65
66function createResError(body: string) {
67 try {
68 const e = zLibsqlError.parse(JSON.parse(body));
85}
86
87function normalizeStatement(statement: InStatement, args?: InArgs) {
88 if (Array.isArray(statement)) {
89 // for the case of an array of arrays
107}
108
109function upgradeResultSet(results: ImpoverishedResultSet): ResultSet {
110 return {
111 ...results,
116// adapted from
117// https://github.com/tursodatabase/libsql-client-ts/blob/17dd996b840c950dd22b871adfe4ba0eb4a5ead3/packages/libsql-client/src/sqlite3.ts#L314C1-L337C2
118function rowFromSql(
119 sqlRow: Array<unknown>,
120 columns: Array<string>,

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