linearRegressionmain.tsx4 matches
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
45function linearRegression(x: number[], y: number[]) {
6const n = x.length;
7
22}
2324function App() {
25const [inputData, setInputData] = useState('');
26const [result, setResult] = useState<{ slope?: number; intercept?: number }>({});
107}
108109function client() {
110createRoot(document.getElementById("root")).render(<App />);
111}
112if (typeof document !== "undefined") { client(); }
113114export default async function server(request: Request): Promise<Response> {
115return new Response(`
116<html>
blob_adminmain.tsx8 matches
13}
1415function Tooltip({ children, content }: TooltipProps) {
16const [isVisible, setIsVisible] = useState(false);
17const tooltipRef = useRef<HTMLDivElement>(null);
52}
5354function formatBytes(bytes: number, decimals = 2) {
55if (bytes === 0) return "0 Bytes";
56const k = 1024;
61}
6263function copyToClipboard(text: string) {
64navigator.clipboard.writeText(text).then(() => {
65console.log("Text copied to clipboard");
69}
7071function ActionMenu({ blob, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
72const [isOpen, setIsOpen] = useState(false);
73const menuRef = useRef(null);
7677useEffect(() => {
78function handleClickOutside(event) {
79if (menuRef.current && !menuRef.current.contains(event.target)) {
80event.stopPropagation();
158}
159160function BlobItem({ blob, onSelect, isSelected, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
161const [isLoading, setIsLoading] = useState(false);
162const decodedKey = decodeURIComponent(blob.key);
219}
220221function App({ initialEmail, initialProfile }) {
222const encodeKey = (key: string) => encodeURIComponent(key);
223const decodeKey = (key: string) => decodeURIComponent(key);
645}
646647function client() {
648const initialEmail = document.getElementById("root").getAttribute("data-email");
649const initialProfile = JSON.parse(document.getElementById("root").getAttribute("data-profile"));
dailyThoughtPromptmain.tsx1 match
4import { email } from "https://esm.town/v/std/email";
56export default async function(interval: Interval) {
7const TOPICS = [
8"Productivity",
6console.log(AnimatePresence);
78function ErrorMessage({ message }) {
9return (
10<div className="min-h-screen bg-gray-100 flex items-center justify-center p-4">
17}
1819function Loader() {
20return (
21<div className="flex flex-col items-center justify-center min-h-screen bg-gray-100">
57}
5859function shuffleArray(array) {
60const shuffledArray = [...array];
61for (let i = shuffledArray.length - 1; i > 0; i--) {
66}
6768function RecordCard() {
69const [records, setRecords] = useState([]);
70const [currentRecordIndex, setCurrentRecordIndex] = useState(0);
7778useEffect(() => {
79async function fetchReleases() {
80try {
81const response = await fetch("https://ashryanio-getallreleasesfromdiscogs.web.val.run");
130131useEffect(() => {
132function handleKeydown(event) {
133if (
134event.target.tagName.toLowerCase() !== "input"
340}
341342function client() {
343const rootElement = document.getElementById("root");
344if (!rootElement) {
359}
360361export default async function server(request: Request): Promise<Response> {
362const url = new URL(request.url);
363
1import { OpenAI } from "https://esm.town/v/std/openai";
23export default async function(req: Request): Promise<Response> {
4if (req.method === "OPTIONS") {
5return new Response(null, {
sendSassyEmailmain.tsx1 match
31};
3233export default async function() {
34const openai = new OpenAI();
35
Ms_Spanglermain.tsx11 matches
153const typingIndicator = document.querySelector('.typing-indicator');
154155function addMessage(content, type) {
156const messageElement = document.createElement('div');
157messageElement.classList.add('message', type);
161}
162163function loadChatHistories() {
164try {
165const savedChatsRaw = localStorage.getItem('chatHistories');
167
168chatHistorySelect.innerHTML = '';
169savedChats.forEach(function(chat, index) {
170const option = document.createElement('option');
171option.value = index;
178}
179180function saveChat() {
181try {
182const chatName = prompt('Enter a name for this chat history:') || ('Chat ' + Date.now());
183const messages = Array.from(chatMessages.children).map(function(msg) {
184return {
185content: msg.textContent,
200}
201202function loadSelectedChat() {
203try {
204const selectedIndex = chatHistorySelect.value;
211if (selectedChat) {
212chatMessages.innerHTML = '';
213selectedChat.messages.forEach(function(msg) {
214addMessage(msg.content, msg.type === 'user' ? 'user-message' : 'ai-message');
215});
221}
222223function deleteSelectedChat() {
224try {
225const selectedIndex = chatHistorySelect.value;
239}
240241async function sendMessage() {
242const message = messageInput.value.trim();
243if (!message) return;
270loadButton.addEventListener('click', loadSelectedChat);
271deleteButton.addEventListener('click', deleteSelectedChat);
272messageInput.addEventListener('keypress', function(e) {
273if (e.key === 'Enter') sendMessage();
274});
308} catch (error) {
309console.error("OpenAI error:", error);
310return c.json({ response: "Neural networks malfunctioning. Try again, human." });
311}
312});
gameplay_agentmain.tsx5 matches
83/** The name of the agent. */
84agentname: string;
85/** The agent function. */
86agent: Connect4Agent<T> | Connect4AsyncAgent<T>;
87}
99/** The name of the agent. */
100agentname: string;
101/** The agent function. */
102agent: PokerAgent<T> | PokerAsyncAgent<T>;
103}
121* a variety of different http server libraries.
122*
123* To see how to write the agent functions,
124* see the {@link Connect4Agent} and {@link PokerAgent}
125*
134* used with an http server that supports the fetch interface.
135*/
136export function agentHandler<
137T extends Json = Json,
138>(
139agents: AgentSpec<T>[],
140): (req: Request) => Promise<Response> {
141return async function(request: Request): Promise<Response> {
142if (request.method === "GET") {
143return Response.json({
whoIsHiringmain.tsx3 matches
7import About from "https://esm.town/v/vawogbemi/whoIsHiringAbout";
89function App() {
10const tabs = { "/": "Home", "/about": "About" };
11const [activeTab, setActiveTab] = useState("/");
335}
336337function ServerApp() {
338return (
339<html>
358}
359360export default async function(req: Request): Promise<Response> {
361const url = new URL(req.url);
362if (url.pathname === "/api/stories") {
3import { createRoot } from "https://esm.sh/react-dom/client";
45function App() {
6const [numPeople, setNumPeople] = useState(4);
7const [numRecipes, setNumRecipes] = useState(1);
229}
230231function client() {
232createRoot(document.getElementById("root")).render(<App />);
233}
234if (typeof document !== "undefined") { client(); }
235236function extractJSONFromMarkdown(markdown: string): string {
237const jsonMatch = markdown.match(/```json\n([\s\S]*?)\n```/);
238return jsonMatch ? jsonMatch[1] : "";
239}
240241export default async function server(request: Request): Promise<Response> {
242if (request.method === "POST" && new URL(request.url).pathname === "/recipes") {
243const { OpenAI } = await import("https://esm.town/v/std/openai");
338}
339340async function generateImage(recipeName: string): Promise<string> {
341const response = await fetch(`https://maxm-imggenurl.web.val.run/${encodeURIComponent(recipeName)}`);
342if (!response.ok) {