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=2468&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 28783 results for "function"(3665ms)

tidbytCirclemain.tsx1 match

@andreterron•Updated 8 months ago
1export async function tidbytCircle({ size = 7, fill, border }: {
2 size?: number;
3 fill?: number;

createTidbytWorkoutsImagemain.tsx2 matches

@andreterron•Updated 8 months ago
8import Jimp from "npm:jimp@0";
9
10export async function createTidbytWorkoutsImage(icons: WorkoutIcon[]) {
11 const headerUrl = "https://art.pixilart.com/sr2c714c74a22aws3.png";
12 const weekdaysUrl = "https://art.pixilart.com/sr22f1df42b42aws3.png";
54 });
55
56 function selectIcon(icon: WorkoutIcon) {
57 switch (icon) {
58 case "done":

rabbitstreamUtilsmain.tsx5 matches

@tempdev•Updated 8 months ago
1import CryptoJS from "npm:crypto-js";
2const cryptoJs = CryptoJS;
3function _kv(a) {
4 return [(a & 4278190080) >> 24, (a & 16711680) >> 16, (a & 65280) >> 8, a & 255];
5}
13 }
14};
15export async function decryptURL(a, X) {
16 try {
17 var r0 = CryptoJS.AES.decrypt(a, X);
23}
24
25export async function decryptSource(keys, kversion, response) {
26 let encrypted = response.sources;
27 console.log(kversion);
38 return response;
39}
40export async function getMeta(id) {
41 const req = await fetch(`https://rabbitstream.net/v2/embed-4/${id}?z=`, {
42 headers: {
54 return metaMatch[1];
55}
56export async function getWasm() {
57 const req = await fetch("https://rabbitstream.net/images/loading.png?v=0.6", {
58 "headers": {

WundergroundStationDisplayV2main.tsx4 matches

@Croniac•Updated 8 months ago
7import { createRoot } from "https://esm.sh/react-dom/client";
8
9function calculateDensityAltitude(elevation, temperature, pressure) {
10 // Convert temperature to Celsius
11 const tempC = (temperature - 32) * 5 / 9;
20}
21
22function App() {
23 const [weatherData, setWeatherData] = useState(null);
24 const [error, setError] = useState(null);
134}
135
136function client() {
137 createRoot(document.getElementById("root")).render(<App />);
138}
140if (typeof document !== "undefined") { client(); }
141
142async function server(request: Request): Promise<Response> {
143 const url = new URL(request.url);
144 const stationId = url.searchParams.get("stationId");

jsonToDalleFormmain.tsx4 matches

@weaverwhale•Updated 8 months ago
6import { systemPrompt } from "https://esm.town/v/weaverwhale/jtdPrompt";
7
8// Move OpenAI initialization to server function
9let openai;
10
11function App() {
12 const [json, setJson] = useState("");
13 const [imageUrl, setImageUrl] = useState("");
128`;
129
130function client() {
131 createRoot(document.getElementById("root")).render(<App />);
132}
136}
137
138async function server(request: Request): Promise<Response> {
139 const url = new URL(request.url);
140

leaderboardAppmain.tsx3 matches

@guillermodoghel•Updated 8 months ago
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [page, setPage] = useState("home");
7 const [showModal, setShowModal] = useState(false);
153}
154
155function client() {
156 createRoot(document.getElementById("root")).render(<App />);
157}
159if (typeof document !== "undefined") { client(); }
160
161async function server(request: Request): Promise<Response> {
162 return new Response(
163 `

hackerNewsDigestmain.tsx4 matches

@yasarcelep•Updated 8 months ago
3import { email } from "https://esm.town/v/std/email";
4
5async function fetchStories(type: string, count: number) {
6 const response = await fetch(`https://hacker-news.firebaseio.com/v0/${type}stories.json`);
7 const storyIds = await response.json();
15}
16
17function createStoryHTML(story: any) {
18 return `
19 <li>
28}
29
30function createEmailContent(
31 topStories: any[],
32 newStories: any[],
118}
119
120export default async function server(req: Request) {
121 try {
122 const topStories = await fetchStories("top", 10);

quotableApiProxymain.tsx1 match

@johndturn•Updated 8 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export default async function proxy(req: Request) {
4 const resp = await fetch(
5 "http://api.quotable.io/quotes/random?limit=1",

telegrambotmain.tsx6 matches

@begoon•Updated 8 months ago
14const openai = new OpenAI();
15
16async function POST(cmd: string, data: { [key: string]: string }) {
17 const url = BOT + "/" + cmd;
18 return await (await fetch(
26}
27
28async function GET(cmd: string) {
29 return await (await fetch(BOT + "/" + cmd)).json();
30}
31
32async function sendMessage(chat_id: string, text: string) {
33 return await POST("sendMessage", { chat_id, text });
34}
35
36async function setWebhook(url: string) {
37 return await POST("setWebhook", { url });
38}
39
40async function getWebhookInfo() {
41 return await GET("getWebhookInfo");
42}
43
44export default async function(req: Request): Promise<Response> {
45 const url = new URL(req.url);
46 const path = url.pathname;

upsetSilverLimpetmain.tsx10 matches

@danielchalef•Updated 8 months ago
15}
16
17export default async function(interval: Interval): Promise<void> {
18 try {
19 await createTable();
38
39// Create an SQLite table
40async function createTable(): Promise<void> {
41 await sqlite.execute(`
42 CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
50
51// Fetch Hacker news, Twitter, and Reddit results
52async function fetchHackerNewsResults(topic: string): Promise<Website[]> {
53 return hackerNewsSearch({
54 query: topic,
58}
59
60async function fetchTwitterResults(topic: string): Promise<Website[]> {
61 return twitterSearch({
62 query: topic,
67}
68
69async function fetchRedditResults(topic: string): Promise<Website[]> {
70 return redditSearch({ query: topic });
71}
72
73function formatSlackMessage(website: Website): string {
74 const displayTitle = website.title || website.url;
75 return `*<${website.url}|${displayTitle}>*
78}
79
80async function sendSlackMessage(message: string): Promise<Response> {
81 const slackWebhookUrl = Deno.env.get("SLACK_WEBHOOK_URL");
82 if (!slackWebhookUrl) {
104}
105
106async function isURLInTable(url: string): Promise<boolean> {
107 const result = await sqlite.execute({
108 sql: `SELECT 1 FROM ${TABLE_NAME} WHERE url = :url LIMIT 1`,
112}
113
114async function addWebsiteToTable(website: Website): Promise<void> {
115 await sqlite.execute({
116 sql: `INSERT INTO ${TABLE_NAME} (source, url, title, date_published)
120}
121
122async function processResults(results: Website[]): Promise<void> {
123 for (const website of results) {
124 if (!(await isURLInTable(website.url))) {

getFileEmail4 file matches

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

tuna8 file matches

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