34}
35
36async function detectTechnologies(email_address: string): Promise<ShovelResponse> {
37 const domain = email_address.split("@")[1];
38
57}
58
59export async function newUserWelcomeEmail(req: Request): Promise<Response> {
60 if (req.method === "GET") return html(welcomeEmail);
61 if (req.headers.get("clerkNonSensitive") !== Deno.env.get("clerkNonSensitive"))
1import cheerio from "https://esm.sh/cheerio@1.0.0-rc.12";
2
3async function fetchJobCount(url: string): Promise<{ count: number; month: string; year: string } | null> {
4 try {
5 const response = await fetch(url);
25}
26
27function* generateUrls(startDate: Date): Generator<string, void, unknown> {
28 const months = [
29 "january",
50}
51
52export default async function scrapeHNHiring() {
53 const startDate = new Date(2025, 0); // January 2025
54 const urls = generateUrls(startDate);
4import ReactMarkdown from "https://esm.sh/react-markdown@8.0.7?deps=react@18.2.0";
5
6function MarkdownPreview({ content }) {
7 return (
8 <div className="preview">
12}
13
14function EditView({ content, setContent, error }) {
15 return (
16 <div className="edit-view">
30}
31
32function ViewDocument({ content, documentId }) {
33 return (
34 <div className="view-document">
39}
40
41function App() {
42 const [content, setContent] = useState("");
43 const [documentId, setDocumentId] = useState(null);
122}
123
124function client() {
125 createRoot(document.getElementById("root")).render(<App />);
126}
130}
131
132export default async function server(request: Request): Promise<Response> {
133 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
134 const { v4: uuidv4 } = await import("https://esm.sh/uuid@9.0.0");
3export default httpClient(handler);
4
5async function handler(request: Request) {
6 try {
7 if (request.method !== "POST") {
62}
63
64function isLikelyArticle(url: string) {
65 const excludePatterns = [
66 "youtube.com",
79}
80
81async function getWallabagToken(config: any) {
82 const response = await fetch(`${config.WALLABAG_URL}/oauth/v2/token`, {
83 method: "POST",
98}
99
100async function saveToWallabag(url: string, token: string, config: any) {
101 const response = await fetch(`${config.WALLABAG_URL}/api/entries.json`, {
102 method: "POST",
1export default async function(req: Request): Promise<Response> {
2 return Response.json({ ok: true });
3}
4 title: "Todo App",
5 code:
6 "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>Task Master</title>\n <link href=\"https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css\" rel=\"stylesheet\">\n</head>\n<body class=\"bg-gray-100\">\n <div class=\"max-w-md mx-auto mt-12 p-6 rounded-lg shadow-md bg-white\">\n <div class=\"flex justify-between items-center mb-6\">\n <h2 class=\"text-2xl font-bold\">Task Master</h2>\n <span class=\"text-gray-600\">Manage your tasks efficiently</span>\n </div>\n <ul class=\"todo-list\" id=\"todo-list\"></ul>\n <div class=\"add-todo mt-6 flex justify-between items-center\">\n <input type=\"text\" id=\"todo-input\" placeholder=\"Add new task\" class=\"w-full py-2 pl-10 text-sm text-gray-800 border border-gray-400 rounded-lg focus:outline-none focus:ring-2 focus:ring-gray-600 bg-gray-50\">\n <button type=\"button\" id=\"add-todo-btn\" class=\"ml-4 px-4 py-2 bg-green-500 text-white font-medium text-xs leading-tight uppercase rounded shadow-md hover:bg-green-700 hover:shadow-lg focus:bg-green-700 focus:shadow-lg focus:outline-none focus:ring-0 active:bg-green-800 active:shadow-lg transition duration-150 ease-in-out\">Add Task</button>\n </div>\n <div class=\"mt-6 text-center text-gray-600\">\n Built on <a href=\"https://cerebrascoder.com\" target=\"_blank\" class=\"text-gray-900 underline\">Cerebras Coder</a>\n </div>\n </div>\n\n <script>\n // Get the todo list and add todo button elements\n const todoList = document.getElementById('todo-list');\n const addTodoBtn = document.getElementById('add-todo-btn');\n const todoInput = document.getElementById('todo-input');\n\n // Load todos from local storage\n let todos = JSON.parse(localStorage.getItem('todos')) || [];\n\n // Function to render the todo list\n function renderTodoList() {\n todoList.innerHTML = '';\n todos.forEach((todo, index) => {\n const todoItem = document.createElement('li');\n todoItem.innerHTML = `\n <div class=\"flex justify-between items-center py-4 border-b border-gray-300\">\n <div class=\"flex items-center\">\n <input type=\"checkbox\" id=\"todo-${index}\" class=\"mr-4\" ${todo.completed ? 'checked' : ''}>\n <span class=\"todo-text ${todo.completed ? 'text-gray-400 line-through' : 'text-gray-600'}\">${todo.text}</span>\n </div>\n <button type=\"button\" class=\"px-4 py-2 bg-red-500 text-white font-medium text-xs leading-tight uppercase rounded shadow-md hover:bg-red-700 hover:shadow-lg focus:bg-red-700 focus:shadow-lg focus:outline-none focus:ring-0 active:bg-red-800 active:shadow-lg transition duration-150 ease-in-out delete-todo\" data-index=\"${index}\">Delete</button>\n </div>\n `;\n todoList.appendChild(todoItem);\n });\n }\n\n // Render the initial todo list\n renderTodoList();\n\n // Add event listener to the add todo button\n addTodoBtn.addEventListener('click', () => {\n const todoText = todoInput.value.trim();\n if (todoText) {\n todos.push({ text: todoText, completed: false });\n localStorage.setItem('todos', JSON.stringify(todos));\n todoInput.value = '';\n renderTodoList();\n }\n });\n\n // Add event listener to the todo list\n todoList.addEventListener('change', (e) => {\n if (e.target.type === 'checkbox') {\n const index = parseInt(e.target.id.split('-')[1]);\n todos[index].completed = e.target.checked;\n localStorage.setItem('todos', JSON.stringify(todos));\n renderTodoList();\n }\n });\n\n // Add event listener to the delete todo buttons\n todoList.addEventListener('click', (e) => {\n if (e.target.classList.contains('delete-todo')) {\n const index = parseInt(e.target.dataset.index);\n todos.splice(index, 1);\n localStorage.setItem('todos', JSON.stringify(todos));\n renderTodoList();\n }\n });\n </script>\n</body>\n</html>",
7 performance: {
8 tokensPerSecond: 2298.56,
26 title: "Markdown Editor",
27 code:
28 "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>Markdown Editor</title>\n <link href=\"https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css\" rel=\"stylesheet\">\n</head>\n<body class=\"bg-white\">\n <div class=\"max-w-full mx-auto p-4 pt-6 md:p-6 lg:p-8\">\n <h1 class=\"text-3xl text-center mb-4\">Markdown Editor</h1>\n <div class=\"flex flex-row\">\n <div class=\"editor p-4 rounded-lg border border-gray-200 w-full md:w-1/2\">\n <textarea id=\"editor\" class=\"w-full h-screen p-2 border border-gray-200 rounded-lg\" placeholder=\"Type your Markdown here...\"></textarea>\n </div>\n <div class=\"preview p-4 rounded-lg border border-gray-200 w-full md:w-1/2 ml-2 md:ml-4 lg:ml-8\">\n <div id=\"preview\"></div>\n </div>\n </div>\n <p class=\"text-center mt-4\">Built on <a href=\"https://cerebrascoder.com\">Cerebras Coder</a></p>\n </div>\n\n <script>\n const editor = document.getElementById('editor');\n const preview = document.getElementById('preview');\n\n // Initialize textarea with default markdown\n const defaultMarkdown = `\n# Introduction to Markdown\nMarkdown is a lightweight markup language that is easy to read and write. It is often used for formatting text in plain text editors, chat applications, and even web pages.\n\n## Headers\nHeaders are denoted by the # symbol followed by a space. The number of # symbols determines the level of the header:\n# Heading 1\n## Heading 2\n### Heading 3\n\n## Emphasis\nYou can use emphasis to make your text **bold** or *italic*:\n*Italics*\n**Bold**\n\n## Lists\nYou can use lists to organize your text:\n* Item 1\n* Item 2\n* Item 3\nOr\n1. Item 1\n2. Item 2\n3. Item 3\n\n## Links\nYou can use links to reference external resources:\n[Google](https://www.google.com)\n\n## Images\nYou can use images to add visual content:\n\n`;\n editor.value = defaultMarkdown;\n\n // Update preview on input\n editor.addEventListener('input', () => {\n const markdown = editor.value;\n const html = markdownToHtml(markdown);\n preview.innerHTML = html;\n });\n\n // Initialize preview with default markdown\n const defaultHtml = markdownToHtml(defaultMarkdown);\n preview.innerHTML = defaultHtml;\n\n // Function to convert Markdown to HTML\n function markdownToHtml(markdown) {\n // Bold\n markdown = markdown.replace(/\\*\\*(.*?)\\*\\*/g, '<b>$1</b>');\n\n // Italic\n markdown = markdown.replace(/\\*(.*?)\\*/g, '<i>$1</i>');\n\n // Links\n markdown = markdown.replace(/\\[(.*?)\\]\\((.*?)\\)/g, '<a href=\"$2\">$1</a>');\n\n // Images\n markdown = markdown.replace(/!\\[(.*?)\\]\\((.*?)\\)/g, '<img src=\"$2\" alt=\"$1\">');\n\n // Headings\n markdown = markdown.replace(/(^#{1,6} )(.*)/gm, (match, level, text) => {\n return `<h${level.length}>${text}</h${level.length}>`;\n });\n\n // Lists\n markdown = markdown.replace(/^(\\*|\\d+\\.) (.*)/gm, (match, marker, text) => {\n if (marker.startsWith('*')) {\n return `<li>${text}</li>`;\n } else {\n return `<li>${text}</li>`;\n }\n });\n\n // Line breaks\n markdown = markdown.replace(/\\n/g, '<br>');\n\n // Fix for nested lists\n markdown = markdown.replace(/<li><li>/g, '<li>');\n markdown = markdown.replace(/<\\/li><\\/li>/g, '</li>');\n\n // Wrap lists in ul\n markdown = markdown.replace(/(<li>.*<\\/li>)/g, '<ul>$1</ul>');\n\n return markdown;\n }\n </script>\n</body>\n</html>",
29 performance: {
30 tokensPerSecond: 4092.96,
24);
25
26function Hero({
27 prompt,
28 setPrompt,
45
46 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
47 Turn your ideas into fully functional apps in{" "}
48 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
49 less than a second
116}
117
118function App() {
119 const previewRef = React.useRef<HTMLDivElement>(null);
120 const [prompt, setPrompt] = useState("");
170 });
171
172 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
173 setLoading(true);
174 setTimeout(() => handleSubmit(promptItem.prompt), 0);
175 }
176
177 async function handleSubmit(e: React.FormEvent | string) {
178 if (typeof e !== "string") {
179 e.preventDefault();
226 }
227
228 function handleVersionChange(direction: "back" | "forward") {
229 const { currentVersionIndex, versions } = versionHistory;
230 if (direction === "back" && currentVersionIndex > 0) {
974);
975
976function client() {
977 const path = window.location.pathname;
978 const root = createRoot(document.getElementById("root")!);
1010}
1011
1012function extractCodeFromFence(text: string): string {
1013 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1014 return htmlMatch ? htmlMatch[1].trim() : text;
1015}
1016
1017async function generateCode(prompt: string, currentCode: string) {
1018 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1019 if (starterPrompt) {
1059}
1060
1061export default async function server(req: Request): Promise<Response> {
1062 // Dynamic import for SQLite to avoid client-side import
1063 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
12type PromptItem = typeof prompts[number];
13
14function Hero({
15 prompt,
16 setPrompt,
50
51 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
52 Turn your ideas into fully functional apps in{" "}
53 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
54 less than a second
121}
122
123function App() {
124 const previewRef = React.useRef<HTMLDivElement>(null);
125 const [prompt, setPrompt] = useState("");
174 });
175
176 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
177 setLoading(true);
178 setTimeout(() => handleSubmit(promptItem.prompt), 0);
179 }
180
181 async function handleSubmit(e: React.FormEvent | string) {
182 if (typeof e !== "string") {
183 e.preventDefault();
230 }
231
232 function handleVersionChange(direction: "back" | "forward") {
233 const { currentVersionIndex, versions } = versionHistory;
234 if (direction === "back" && currentVersionIndex > 0) {
993);
994
995function client() {
996 const path = window.location.pathname;
997 const root = createRoot(document.getElementById("root")!);
1029}
1030
1031function extractCodeFromFence(text: string): string {
1032 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1033 return htmlMatch ? htmlMatch[1].trim() : text;
1034}
1035
1036async function generateCode(prompt: string, currentCode: string) {
1037 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1038 if (starterPrompt) {
1075}
1076
1077export default async function server(req: Request): Promise<Response> {
1078 // Dynamic import for SQLite to avoid client-side import
1079 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");
74}
75
76export default async function(req: Request): Promise<Response> {
77 // Use your Val Town API Token to create a session
78 const wide = new Wide(await ValSession.new(Deno.env.get("valtown")));