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=1762&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 20293 results for "function"(2455ms)

greenLobstermain.tsx1 match

@generatecoll•Updated 11 months ago
1// View at https://andreterron-htmlExample.web.val.run?name=Andre
2export default async function(req: Request): Promise<Response> {
3 const query = new URL(req.url).searchParams;
4

valwritermain.tsx2 matches

@stevekrouse•Updated 11 months ago
11 user: "website that shows the current time",
12 content: `/** @jsxImportSource npm:react */
13export default function() {
14 return <h1>{new Date().toLocaleTimeString()}</h1>;
15}`,
91 );
92});
93export async function compile(description: string) {
94 const messages = [
95 {

sudoku_solver_exact_covermain.tsx4 matches

@saolsen•Updated 11 months ago
86};
87
88function slotToConstraints(slot: Slot): Constraint[] {
89 console.assert(slot.row >= 0 && slot.row <= 8);
90 console.assert(slot.col >= 0 && slot.col <= 8);
100}
101
102function constraintsToSlot(constraints: Constraint[]): Slot {
103 console.assert(constraints.length === 4);
104 let row = null;
136}
137
138function cIndex(constraint: Constraint): number {
139 switch (constraint.kind) {
140 case "slot":
347}
348
349export function solve(sudoku: Sudoku): Sudoku | null {
350 sudoku = Sudoku.parse(sudoku);
351 const matrix = new Matrix();

falImageHandlermain.tsx1 match

@isidentical•Updated 11 months ago
6});
7
8export default async function(req: Request): Promise<Response> {
9 const { prompt } = await req.json();
10

imgGenUrlmain.tsx1 match

@maxm•Updated 11 months ago
6};
7
8export default async function(req: Request): Promise<Response> {
9 let key = new URL(req.url).pathname;
10 let url = await blob.getJSON(genKey(key));

falImageGenmain.tsx1 match

@isidentical•Updated 11 months ago
5 * @returns {Promise<string>} A promise that resolves to the URL of the image.
6 */
7export async function generateImage(
8 input: string,
9): Promise<{ url: string }> {

Queriesmain.tsx10 matches

@iamseeley•Updated 11 months ago
3
4// Fetch user by username
5export async function getUserByUsername(username: string) {
6 const userResult = await sqlite.execute({
7 sql: `SELECT id, name, bio, username, email, location, currently_listening, currently_reading_title,
29
30// Update user profile
31export async function updateUser(userId, name, bio, location, currentlyListening, currentlyReading, currentlyWatching, profile_theme, profile_img) {
32 if (typeof userId !== "number") {
33 throw new Error("userId must be a number.");
46}
47
48export async function insertUserLink(userId: number, label: string, url: string) {
49 await sqlite.execute({
50 sql: `INSERT INTO user_links (user_id, label, url) VALUES (?, ?, ?)`,
53}
54
55export async function getLinkById(linkId: number) {
56 const result = await sqlite.execute({
57 sql: `SELECT id, label, url, user_id FROM user_links WHERE id = ?`,
68}
69
70export async function updateUserLink(linkId: number, label: string, url: string) {
71 await sqlite.execute({
72 sql: `UPDATE user_links SET label = ?, url = ? WHERE id = ?`,
75}
76
77export async function deleteUserLink(linkId: number, userId: number) {
78 await sqlite.execute({
79 sql: `DELETE FROM user_links WHERE id = ? AND user_id = ?`,
82}
83
84export async function getUserLinks(userId) {
85 if (typeof userId !== "number") {
86 throw new Error("userId must be a number.");
101}
102
103export async function isUsernameTaken(username) {
104 const result = await sqlite.execute({
105 sql: `SELECT COUNT(*) FROM users WHERE username = ?`,
110}
111
112export async function isEmailTaken(email) {
113 const result = await sqlite.execute({
114 sql: `SELECT COUNT(*) FROM users WHERE email = ?`,
140
141
142export async function getProfileImageUrl(username) {
143 const key = `profile_img/${username}`;
144 const imageUrl = await blob.get(key);

incremementCloudLabCountAntiSpammain.tsx1 match

@todepond•Updated 11 months ago
4// Make SQLite table to store the count increments (with timestamps)
5
6export default async function(req: Request): Promise<Response> {
7 const result = await sqlite.batch([
8 "CREATE TABLE IF NOT EXISTS counter_2_baby (timestamp DATETIME DEFAULT CURRENT_TIMESTAMP)",

getCloudLabCountmain.tsx1 match

@todepond•Updated 11 months ago
4// TODO: Convert to sqlite
5
6export default async function(req: Request): Promise<Response> {
7 const result = await sqlite.execute(
8 "SELECT COUNT(*) FROM counter_2_baby",

createValmain.tsx1 match

@stevekrouse•Updated 11 months ago
29}
30
31export function createVal({ token, ...data }: { token?: string } & CreateValArgs): Promise<ValResponse> {
32 return fetchJSON("https://api.val.town/v1/vals", {
33 bearer: token || Deno.env.get("valtown"),

getFileEmail4 file matches

@shouser•Updated 3 weeks ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 3 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.