money_countermain.tsx7 matches
3SINGLE-FILE VAL CODE
41) Imports React, once.
52) Declares CSS + server() function
63) Declares the <App/> React component
74) Declares client() to mount <App/>
298299/* ------------------------------------------------
3002) server() function: returns the HTML skeleton
301------------------------------------------------ */
302export default async function server(request: Request): Promise<Response> {
303return new Response(
304`
3283) The React App
329------------------------------------------------ */
330function App() {
331// States for inputs
332const [entryName, setEntryName] = useState("#");
365366// Helpers
367function formatNumber(num) {
368return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
369}
370function formatCurrency(num) {
371return `$${num.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, "$&,")}`;
372}
8974) Mount the React <App/> client-side
898------------------------------------------------ */
899function client() {
900createRoot(document.getElementById("root")).render(<App />);
901}
tastefulIvoryWormmain.tsx1 match
4console.log("after 1s");
5});
6export default async function() {
7console.log("from within export");
8}
bedtimeStoryMakermain.tsx1 match
36// );
3738function parseStory(text) {
39// Split the text into lines and remove empty lines
40const lines = text.split("\n").filter(line => line.trim() !== "")
hopefulGoldChinchillamain.tsx11 matches
73const PoweredByInfo = "";
7475function Hero({
76prompt,
77setPrompt,
9495<p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
96Turn your ideas into fully functional apps in{" "}
97<span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
98less than a second
168}
169170function App() {
171const previewRef = React.useRef<HTMLDivElement>(null);
172const [prompt, setPrompt] = useState("");
222});
223224function handleStarterPromptClick(promptItem: typeof prompts[number]) {
225setLoading(true);
226setTimeout(() => handleSubmit(promptItem.prompt), 0);
227}
228229async function handleSubmit(e: React.FormEvent | string) {
230if (typeof e !== "string") {
231e.preventDefault();
278}
279280function handleVersionChange(direction: "back" | "forward") {
281const { currentVersionIndex, versions } = versionHistory;
282if (direction === "back" && currentVersionIndex > 0) {
994);
995996function client() {
997const path = window.location.pathname;
998const root = createRoot(document.getElementById("root")!);
1030}
10311032function extractCodeFromFence(text: string): string {
1033const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1034return htmlMatch ? htmlMatch[1].trim() : text;
1035}
10361037async function generateCode(prompt: string, currentCode: string) {
1038const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1039if (starterPrompt) {
1080}
10811082export default async function cerebras_coder(req: Request): Promise<Response> {
1083// Dynamic import for SQLite to avoid client-side import
1084const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1183<meta property="og:site_name" content="Cerebras Coder">
1184<meta property="og:url" content="https://cerebrascoder.com"/>
1185<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1186<meta property="og:type" content="website">
1187<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
bluesky_bot_templatemain.tsx5 matches
6});
78// Helper function to convert data URI to Uint8Array
9function convertDataURIToUint8Array(dataURI: string): Uint8Array {
10const base64Data = dataURI.split(",")[1];
11const binaryString = atob(base64Data);
17}
1819// Helper function to fetch SVG and convert to base64
20async function fetchSVGAsBase64(url: string): Promise<string> {
21const response = await fetch(url);
22if (!response.ok) {
27}
2829export default async function(interval: Interval) {
30// Don't forget to set these environment variables in the val's settings.
31const username = process.env.BLUESKY_USERNAME;
kanbanTodoListmain.tsx16 matches
8import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
910function TaskBoard() {
11const [taskLists, setTaskLists] = useState({
12todo: [],
44}, []);
4546function loadUserPreferences() {
47const savedDarkMode = localStorage.getItem("app-theme") === "true";
48setIsDarkMode(savedDarkMode);
59}
6061function updateAppStyle(font, size) {
62document.body.style.setProperty("--app-font", font);
63document.body.style.setProperty("--app-font-size", `${size}px`);
64}
6566function saveUserPreferences() {
67localStorage.setItem("app-font", chosenFont);
68localStorage.setItem("app-font-size", fontSize.toString());
72}
7374async function fetchTasks() {
75try {
76const response = await fetch("/get-tasks");
82}
8384async function addNewTask() {
85if (!newTaskText.trim()) return;
86102}
103104async function handleTaskMove(result) {
105const { destination, source, draggableId } = result;
106if (!destination) return;
123}
124125async function removeTask(taskId, column) {
126try {
127const response = await fetch("/delete-task", {
137}
138139async function moveTaskForward(task, currentColumn) {
140const currentIndex = listProgression.indexOf(currentColumn);
141const nextColumn = listProgression[currentIndex + 1];
158}
159160function toggleDarkMode() {
161const newDarkMode = !isDarkMode;
162setIsDarkMode(newDarkMode);
165}
166167function openEditModal(task) {
168setTaskBeingEdited(task);
169setEditedTaskText(task.title);
171}
172173async function saveEditedTask() {
174if (!editedTaskText.trim() || !taskBeingEdited) return;
175try {
191}
192193function handleTaskInteraction(e, task, column) {
194if (e.button === 1) {
195e.preventDefault();
432}
433434function client() {
435createRoot(document.getElementById("root")).render(<TaskBoard />);
436}
439}
440441export default async function server(request: Request): Promise<Response> {
442const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
443const KEY = "kanbanTodoList";
517}
518519async function getAllTasks(sqlite, KEY, SCHEMA_VERSION) {
520const todo = await sqlite.execute(
521`SELECT * FROM ${KEY}_tasks_${SCHEMA_VERSION} WHERE column = 'todo'`,
townieIllustratorPromptmain.tsx4 matches
3First ask a user what app they would like you to illustrate. Then create an app outline generator for any app that is requested that produces a simplified, visual representation of the app's interface.
45Core Functionality
67- Accept an app name as input (e.g., "Zoom", "Slack", "Discord")
8- Generate a single val that renders a minimal, branded mockup of the app's main interface
9- Allow the user to export a png screenshot with transparent background with rounded corners (8px radius)
10- Move the `html2canvas` import inside the `client()` function.
11- Wrap the `exportAsPNG` function in a `useEffect` hook to ensure it's only defined on the client-side.
12- Use dynamic import for `html2canvas` inside the `exportAsPNG` function.
13- Make sure html2canvas is only loaded and used on the client-side
14
townieIllustratorPromptREADME.md4 matches
6First ask a user what app they would like you to illustrate. Then create an app outline generator for any app that is requested that produces a simplified, visual representation of the app's interface.
78Core Functionality
910- Accept an app name as input (e.g., "Zoom", "Slack", "Discord")
11- Generate a single val that renders a minimal, branded mockup of the app's main interface
12- Allow the user to export a png screenshot with transparent background with rounded corners (8px radius)
13- Move the `html2canvas` import inside the `client()` function.
14- Wrap the `exportAsPNG` function in a `useEffect` hook to ensure it's only defined on the client-side.
15- Use dynamic import for `html2canvas` inside the `exportAsPNG` function.
16- Make sure html2canvas is only loaded and used on the client-side
17
blissfulBrownSmeltmain.tsx2 matches
34}
3536async function detectTechnologies(email_address: string): Promise<ShovelResponse> {
37const domain = email_address.split("@")[1];
3857}
5859export async function newUserWelcomeEmail(req: Request): Promise<Response> {
60// if (req.method === "GET") return html(welcomeEmail);
61if (req.headers.get("clerkNonSensitive") !== Deno.env.get("clerkNonSensitive"))
emailValHandlermain.tsx10 matches
3import { pdfText } from "jsr:@pdf/pdftext";
45// main controller function
6export async function emailValHandler(receivedEmail) {
7const openaiUrl = "https://api.openai.com/v1/chat/completions";
8const apiKey = Deno.env.get("OPENAI_API_KEY"); // replace this entire line with your OpenAI API key as a string, e.g., "sk-123..." or use environment variable: https://docs.val.town/reference/environment-variables/
4849// extract attachments (if any)
50async function extractAttachments(email) {
51if (!email.attachments || email.attachments.length === 0) {
52return [];
64}
6566async function extractPdfText(attachments) {
67const pdfTexts = [];
6897}
9899// helper function to generate a prompt for openai
100function generatePrompt(email, pdfTexts, emailText) {
101// extract the first name from the 'from' field if it exists
102const senderName = email.from.split("<")[0].trim().split(" ")[0] || "";
121}
122123// helper function to send a request to openai
124async function sendRequestToOpenAI(prompt, openaiUrl, apiKey, model) {
125try {
126// prepare the openai messages payload
161}
162163// helper function to send a response back via email
164async function sendResponseByEmail(toEmail, responseContent) {
165const subject = "AI Response to Your Email";
166const text = `${responseContent}`;