15 "recipe ingredient converter and scaler",
16 "morse code translator with audio output",
17 "random quote generator with tweet functionality",
18 "personal finance tracker with basic charts",
19 "multiplayer rock-paper-scissors game",
20];
21
22function Dashboard() {
23 const [stats, setStats] = useState<{
24 totalGenerations: number;
36
37 useEffect(() => {
38 async function fetchStats() {
39 const response = await fetch("/dashboard-stats");
40 const data = await response.json();
115}
116
117function App() {
118 const [prompt, setPrompt] = useState(
119 STARTER_PROMPTS[Math.floor(Math.random() * STARTER_PROMPTS.length)],
141 });
142
143 async function handleSubmit(e: React.FormEvent) {
144 e.preventDefault();
145 setLoading(true);
174 }
175
176 function handleVersionChange(direction: "back" | "forward") {
177 const { currentVersionIndex, versions } = versionHistory;
178
305}
306
307function client() {
308 const path = window.location.pathname;
309 const root = createRoot(document.getElementById("root")!);
320}
321
322function extractCodeFromFence(text: string): string {
323 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
324 return htmlMatch ? htmlMatch[1].trim() : text;
325}
326
327export default async function server(req: Request): Promise<Response> {
328 // Dynamic import for SQLite to avoid client-side import
329 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
15 "recipe ingredient converter and scaler",
16 "morse code translator with audio output",
17 "random quote generator with tweet functionality",
18 "personal finance tracker with basic charts",
19 "multiplayer rock-paper-scissors game",
20];
21
22function Dashboard() {
23 const [stats, setStats] = useState<{
24 totalGenerations: number;
36
37 useEffect(() => {
38 async function fetchStats() {
39 const response = await fetch("/dashboard-stats");
40 const data = await response.json();
115}
116
117function App() {
118 const [prompt, setPrompt] = useState(
119 STARTER_PROMPTS[Math.floor(Math.random() * STARTER_PROMPTS.length)],
141 });
142
143 async function handleSubmit(e: React.FormEvent) {
144 e.preventDefault();
145 setLoading(true);
174 }
175
176 function handleVersionChange(direction: "back" | "forward") {
177 const { currentVersionIndex, versions } = versionHistory;
178
305}
306
307function client() {
308 const path = window.location.pathname;
309 const root = createRoot(document.getElementById("root")!);
320}
321
322function extractCodeFromFence(text: string): string {
323 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
324 return htmlMatch ? htmlMatch[1].trim() : text;
325}
326
327export default async function server(req: Request): Promise<Response> {
328 // Dynamic import for SQLite to avoid client-side import
329 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
8 .join(" OR ") + " " + excludes;
9
10function relevant(t: Tweet) {
11 if (keywords.some(k => t.full_text?.includes(k))) return true;
12 return t.entities.urls?.some(u => keywords.some(k => u.expanded_url?.includes(k)));
17const isProd = true;
18
19export async function twitterAlert({ lastRunAt }: Interval) {
20 // search
21 const since = isProd
4import React, { useRef, useState, useEffect } from "https://esm.sh/react@18.2.0";
5
6function App() {
7 const [username, setUsername] = useState("");
8 const [valName, setValName] = useState("");
158}
159
160function client() {
161 createRoot(document.getElementById("root")).render(<App />);
162}
163if (typeof document !== "undefined") { client(); }
164
165export default async function server(request: Request): Promise<Response> {
166 const url = new URL(request.url);
167 const parts = url.pathname.split('/').filter(Boolean);
248 });
249 } catch (error) {
250 console.error('Error in server function:', error);
251 return new Response(`Error: ${error.message}`, { status: 500 });
252 }
15]);
16// Get embedding for a single emoji
17async function getEmbedding(emoji: string): Promise<number[]> {
18 const result = await openai.embeddings.create({
19 input: emoji,
23}
24
25async function loadEmoji(e: string) {
26 const result = await sqlite.execute("SELECT 1 FROM emojis WHERE emoji = ?", [e]);
27 if (result.rows.length !== 0) {
43}
44
45async function loadAllEmojis() {
46 const batchSize = 20;
47 for (let i = 0; i < emojis.length; i += batchSize) {
54// await loadAllEmojis();
55
56export async function searchEmojis(query: string): Promise<string[]> {
57 return (await sqlite.execute(
58 `SELECT emoji
70// };
71
72// // Function to get all emojis (this is a subset for demonstration)
73
74// // Calculate cosine similarity between two vectors
75// function cosineSimilarity(vecA: number[], vecB: number[]): number {
76// const dotProduct = vecA.reduce((sum, a, i) => sum + a * vecB[i], 0);
77// const magnitudeA = Math.sqrt(vecA.reduce((sum, a) => sum + a * a, 0));
81
82// // Get embedding for a single emoji
83// async function getEmbedding(emoji: string): Promise<number[]> {
84// const result = await openai.embeddings.create({
85// input: emoji,
90
91// // Get embeddings for all emojis
92// async function getAllEmbeddings(): Promise<EmojiEmbedding[]> {
93// const emojis = getAllEmojis();
94// const embeddings: EmojiEmbedding[] = [];
116
117// // Find nearest neighbors for a given emoji
118// function findNearestNeighbors(
119// targetEmbedding: number[],
120// allEmbeddings: EmojiEmbedding[],
130// }
131
132// // Main function to demonstrate usage
133// async function main() {
134// try {
135// console.log("Getting embeddings for all emojis...");
6console.log(AnimatePresence);
7
8function ErrorMessage({ message }) {
9 return (
10 <div className="min-h-screen bg-gray-100 flex items-center justify-center p-4">
17}
18
19function Loader() {
20 return (
21 <div className="flex flex-col items-center justify-center min-h-screen bg-gray-100">
57}
58
59function shuffleArray(array) {
60 const shuffledArray = [...array];
61 for (let i = shuffledArray.length - 1; i > 0; i--) {
66}
67
68function RecordCard() {
69 const [records, setRecords] = useState([]);
70 const [currentRecordIndex, setCurrentRecordIndex] = useState(0);
77
78 useEffect(() => {
79 async function fetchReleases() {
80 try {
81 const response = await fetch("https://ashryanio-getallreleasesfromdiscogs.web.val.run");
130
131 useEffect(() => {
132 function handleKeydown(event) {
133 if (
134 event.target.tagName.toLowerCase() !== "input"
340}
341
342function client() {
343 const rootElement = document.getElementById("root");
344 if (!rootElement) {
359}
360
361export default async function server(request: Request): Promise<Response> {
362 const url = new URL(request.url);
363
1export default async function(req: Request): Promise<Response> {
2 return new Response(
3 `
14]
15
16function esc(string) {
17 return replacements.reduce(function(string, replacement) {
18 return string.replace(replacement[0], replacement[1])
19 }, string)
71 )
72
73 function c(tag, style) {
74 const elem = document.createElement(tag)
75 if (style) elem.style = style
10const SOLUTION_WORDS = ["WILLY", "YOUTH", "MARRY", "METER"];
11
12function Modal({ isOpen, onClose, children }) {
13 if (!isOpen) return null;
14
22}
23
24function WinModal({ isOpen, onPlay }) {
25 return (
26 <Modal isOpen={isOpen}>
36}
37
38function ProposalModal({ isOpen }) {
39 return (
40 <Modal isOpen={isOpen}>
47}
48
49function App() {
50 const [games, setGames] = useState(SOLUTION_WORDS.map(word => ({
51 word,
188}
189
190function GameBoard(
191 {
192 word,
272}
273
274function Keyboard({ usedLetters, onKeyPress, disabled }) {
275 const rows = [
276 ["Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P"],
339}
340
341function client() {
342 createRoot(document.getElementById("root")).render(<App />);
343}
345if (typeof document !== "undefined") { client(); }
346
347export default async function server(request: Request): Promise<Response> {
348 const { blob } = await import("https://esm.town/v/std/blob");
349 const wordList = await (await blob.get("quordle")).text();
393 }
394 @keyframes bounce {
395 0%, 100% { transform: translateY(-25%); animation-timing-function: cubic-bezier(0.8, 0, 1, 1); }
396 50% { transform: translateY(0); animation-timing-function: cubic-bezier(0, 0, 0.2, 1); }
397 }
398 .animate-bounce { animation: bounce 1s infinite; }
8type User = { id: string; username: string; tier: string };
9
10function SimpleLineChart({ data, width = 800, height = 400, margin = { top: 20, right: 20, bottom: 30, left: 40 } }) {
11 const chartWidth = width - margin.left - margin.right;
12 const chartHeight = height - margin.top - margin.bottom;
69}
70
71function Dashboard({ data }) {
72 const chartData = Object.keys(data[0].users).map(username => ({
73 name: username,
106}
107
108function App({ initialData }) {
109 const [data] = useState(initialData);
110
112}
113
114function client() {
115 const initialData = (window as any).INITIAL_DATA;
116 createRoot(document.getElementById("root")).render(<App initialData={initialData} />);
121}
122
123async function getUsageData() {
124 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
125 const result = await sqlite.execute(`
141}
142
143export default async function server(req: Request): Promise<Response> {
144 const url = new URL(req.url);
145