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/$%7Burl%7D?q=function&page=3&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 31478 results for "function"(3074ms)

currentDateAndTimetime.ts1 match

@jamiedubs•Updated 10 hours ago
4 * Accepts both IANA names (America/New_York) and common abbreviations (ET, EDT, EST, PT, etc.)
5 */
6export default async function(req: Request): Promise<Response> {
7 const url = new URL(req.url);
8 const tz = url.searchParams.get('tz') || 'UTC';

image-sliderscript.js7 matches

@ivobg•Updated 11 hours ago
5showSlides(SLIDEINDEX);
6
7function showSlides(index) {
8 // get slides html and dots
9 let slides = document.querySelectorAll(".slide"),
26
27// event on prev arrow
28document.querySelector("#arrow-prev").addEventListener("click", function() {
29 showSlides(--SLIDEINDEX);
30});
31
32// event on next arrow
33document.querySelector("#arrow-next").addEventListener("click", function() {
34 showSlides(++SLIDEINDEX);
35});
36
37// event on dots
38document.querySelectorAll(".dot-navigation").forEach(function(elem) {
39 elem.addEventListener("click", function() {
40 // get index of the dot
41 let nodes = Array.prototype.slice.call(this.parentElement.children),
42 dotIndex = nodes.indexOf(elem);
43
44 // call the function for the index of clicked dot
45 showSlides(SLIDEINDEX = dotIndex);
46 });
48
49// automatic slideshow
50setInterval(function() {
51 showSlides(++SLIDEINDEX);
52}, 10000);

Townietext-editor.ts1 match

@valdottown•Updated 11 hours ago
4import fileWithLinesNumbers from "../utils/fileWithLinesNumbers.ts";
5
6function printFileType(file: any) {
7 if (file.type === "interval")
8 return " (cron)";

TowniefileWithLinesNumbers.ts1 match

@valdottown•Updated 11 hours ago
1export default function fileWithLineNumbers(text: string, view_range) {
2 const lines = text.split("\n")
3 .map((line, index) => (index + 1) + ": " + line)

TownieMessages.tsx9 matches

@valdottown•Updated 11 hours ago
23});
24
25export function Messages ({
26 messages,
27 messageEndTimes,
58}
59
60function Message ({
61 message,
62 messageEndTimes,
86}
87
88function AssistantMessage ({ message, messageEndTimes, running }: {
89 message: Message;
90 messageEndTimes: Record<string, number>;
107}
108
109function Part ({ part }) {
110 switch (part.type) {
111 case "text":
122}
123
124function TextPart ({ part }) {
125 return (
126 <ReactMarkdown>
130}
131
132function Details ({ open, onClick, children, summary }) {
133 return (
134 <details
148}
149
150function ToolPart ({ part }) {
151 const { openSummaries, setOpenSummaries } = useContext(MessageContext);
152 const {
312}
313
314function EditorToolPart ({ part }) {
315 const { openSummaries, setOpenSummaries } = useContext(MessageContext);
316 const {
383}
384
385function UserMessage ({ message }: {
386 message: Message;
387}) {

Architmain.tsx1 match

@hackthehackerman•Updated 12 hours ago
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}

statustest-notify.tsx1 match

@helge•Updated 12 hours ago
2import { pushover } from "./pushover";
3
4export async function testNotify() {
5 notify("hello world2");
6 pushover({ message: "message", title: "title" });

statusnotify1 match

@helge•Updated 12 hours ago
5const EMAIL = Deno.env.get("EMAIL");
6
7export async function notify(message: string) {
8 // cant set to on FREE accounts....
9 // await email({ to: EMAIL, subject: message, text: `Email sent from ${thisURL}` });

statusmonitor1 match

@helge•Updated 12 hours ago
10const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
11
12export async function uptimeCheck(url: string, attempt = 1) {
13 let reason: string = "";
14 let status: number | null = null;

statusstatus3 matches

@helge•Updated 12 hours ago
9const thisURL = parseProject(import.meta.url).links.self.project;
10
11function StatusRow({ rows }) {
12 return (
13 <div className="w-full flex flex-col space-y-2">
31}
32
33function StatusSection({ url, rows }) {
34 const sectionRows = rows.filter(row => row[0] === url);
35 const percentUp = Math.round((sectionRows.filter(row => row[1]).length / sectionRows.length) * 100);
47}
48
49export default async function(req: Request): Promise<Response> {
50 const { rows } = await sqlite.execute(
51 "select url, ok, duration, timestamp from uptime order by timestamp asc limit 200",
tuna

tuna9 file matches

@jxnblk•Updated 2 weeks ago
Simple functional CSS library for Val Town

getFileEmail4 file matches

@shouser•Updated 1 month ago
A helper function to build a file's email
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.