14let colorIndex: number
15
16export function setup() {
17 console.log("setup")
18 // variables
77}
78
79function hexagon(x, y, r, c) {
80 let hx = (i) => x + sin((i * 2 * PI) / 6) * (i < 0 ? 0 : r)
81 let hy = (i) => y + cos((i * 2 * PI) / 6) * (i < 0 ? 0 : r)
201}
202
203function drawBorder(border, strokeW = 0) {
204 strokeWeight(0)
205 rect(0, 0, border, height)
216}
217
218export function draw() {}
219
220export function keyPressed() {
221 if (key == "i") {
222 saveCanvas("p5js-" + new Date().getTime(), "png")
226 }
227}
228// export function touchEnded() {
229// saveCanvas("p5js-" + new Date().getTime(), "png");
230// }
7export class Blobby {
8 // by default we have no prefixes or scope, whicm neans these will need to be managed by
9 // the setters / calling function. These are used as shortcuts, but they can cause a lot of confusion
10 // if you forget they were set (oops)
11
66 return bloblist.map((blob) => blob.slice(prefix.length + scope.length));
67 }
68 // prefer using the static version to strip instead, on the calling function
69 static strip(bloblist, prefix?, scope?) {
70 return bloblist.map((blob) => blob.slice(prefix.length + scope.length));
216}
217
218function getContentType(key: string): string {
219 const extension = key.split(".").pop()?.toLowerCase();
220 switch (extension) {
19import { email } from "https://esm.town/v/std/email";
20
21export default async function(emailData: Email) {
22 // Extract email content
23 const htmlContent = emailData.text;
35};
36
37function App() {
38 const [currentLetter, setCurrentLetter] = useState('');
39 const [options, setOptions] = useState([]);
124}
125
126function client() {
127 createRoot(document.getElementById("root")).render(<App />);
128}
130if (typeof document !== "undefined") { client(); }
131
132export default async function server(request: Request): Promise<Response> {
133 return new Response(`
134 <html>
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>
12]
13
14function shuffleArray(arr) {
15 return arr.toSorted(() => {
16 return Math.random() > 0.5 ? 1 : -1
26];
27
28function reducer(state) {
29 return state + 1;
30}
31
32function App() {
33 let [count, dispatch] = useReducer(reducer, 0);
34
43}
44
45export function renderApp() {
46 let root = createRoot(document.getElementById("root")!);
47
2
3/**
4 * You can supply these options as a second argument to the `proxy` function.
5 * These options are used to configure the frontend.
6 */
135
136export const proxy = (url: string, options?: FrontendOptions) => {
137 return async function(req: Request): Promise<Response> {
138 if (req.method === "GET") {
139 return renderFrontend(url, options);
4const TIMEOUT = 30000; // 30 seconds timeout
5
6export default async function server(request: Request): Promise<Response> {
7 // Array of URLs to scrape
8 const urls = [
128
129export const service = (boardUrl: string, options?: ServiceOptions) => {
130 return async function(req: Request): Promise<Response> {
131 const url = new URL(req.url);
132 const path = url.pathname;
18
19type User = { id: string; username: string; tier: string };
20export default async function(req: Request): Promise<Response> {
21 // Ensure only allowed pathnames are used
22 const { pathname, search } = new URL(req.url);
82
83// Free users are limited to gpt-4o-mini. Limit pro users to 10 expensive model requests.
84async function limitFreeModel(req: Request, user: User) {
85 const input = await req.json();
86 let model = "gpt-4o-mini";
Simple functional CSS library for Val Town
A helper function to build a file's email
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": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.