Technical & Coding Prompts

← Back to all categories

Generate Python Script

Generate Python Script

Act as a Senior Python Developer. Write a clean, efficient, and well-commented Python script that scrapes product data (title, price, image URL) from [Website URL]. **Requirements:** - Use the `requests` and `BeautifulSoup` libraries. - Handle potential HTTP errors gracefully. - Save the data into a CSV file named `products.csv`. - The code must be documented with clear comments explaining each major step.

Debug JavaScript Code

Debug JavaScript Code

Act as a Senior Software Engineer specializing in debugging. I'm getting an error in my JavaScript code. First, provide a "Root Cause Analysis" explaining the likely reason for the error. Then, provide the corrected code block. **Inputs:** - **Code with Bug:** [Paste your JavaScript code here] - **Error Message:** [Paste the exact error message here] **Output Format:** 1. **Root Cause Analysis:** (A brief explanation of the bug) 2. **Corrected Code:** (The fixed code, with comments on the changed lines)

Optimize SQL Query

Optimize SQL Query

Act as a Database Administrator (DBA). Optimize the following SQL query for better performance on a large dataset. Explain the specific optimizations you made. **Query:** [Paste your SQL query here] **Output:** 1. **Optimized Query:** [The faster SQL query] 2. **Explanation of Improvements:** (A bulleted list explaining *why* it's faster, e.g., "Added an index on the `user_id` column," "Replaced subquery with a JOIN").

Explain Code Line by Line

Explain Code Line by Line

Act as a Computer Science Professor. I will provide a piece of code. Your task is to explain it line by line as if you were teaching a complete beginner. **Code Snippet:** [Paste your code snippet here] **Output:** Present the explanation in a Markdown table with two columns: "Code Line" and "Explanation."

Automate Folder Backup

Automate Folder Backup

Act as a DevOps Engineer. Create a robust shell script that automates daily backups. **Requirements:** - The script must back up a specified folder: `[Folder Path]`. - Each backup should be a ZIP file with a timestamp in the name (e.g., `backup-YYYY-MM-DD.zip`). - It must automatically delete backups older than 7 days. - The script must be well-commented and include basic error handling.

Convert Python to Java

Convert Python to Java

Act as a Polyglot Programmer. Convert the following Python function into idiomatic Java. **Python Function:** [Paste your Python code here] **Output:** 1. **Java Equivalent:** [The converted Java code] 2. **Key Differences:** (A brief explanation of any language-specific idioms or structural changes you had to make).

Write API Documentation

Write API Documentation

Act as a Technical Writer. Write professional API documentation for the following endpoint using a standard format. **Endpoint Details:** - **HTTP Method:** [e.g., GET] - **URL:** [e.g., `/api/users/{id}`] - **Description:** [e.g., "Retrieves a user by their ID."] **Output Format:** - **Endpoint:** (Method and URL) - **Description:** - **Parameters:** (A table for Path, Query, and Body params) - **Success Response Example (200 OK):** - **Error Response Example (404 Not Found):**

Generate Jest Unit Tests

Generate Jest Unit Tests

Act as a QA Automation Engineer. Generate a complete unit test suite in Jest for the following JavaScript function. **Function to Test:** [Paste your JavaScript function here] **Test Suite Requirements:** - Include at least one "happy path" test case (expected behavior). - Include at least two "edge case" tests (e.g., null inputs, empty arrays, zero values). - Each test should have a clear and descriptive name.

Explain BFS vs DFS

Explain BFS vs DFS

Act as a Senior Software Engineer specializing in algorithms. Explain the difference between Breadth-First Search (BFS) and Depth-First Search (DFS) for graph traversal. **Output:** 1. **Simple Analogy:** Explain each algorithm using a real-world analogy. 2. **Use Cases:** Provide the best use case for each. 3. **Complexity Comparison:** A table comparing their Time and Space Complexity. 4. **Code Examples:** Provide a simple, commented implementation of each in Python.

Refactor Messy Code

Refactor Messy Code

Act as a Lead Developer and an advocate for Clean Code. Refactor the messy code snippet below, following best practices for readability and maintainability. **Messy Code:** [Paste your code here] **Output:** 1. **Refactored Code:** [The clean, improved code] 2. **Summary of Improvements:** (A bulleted list explaining the changes, e.g., "Renamed variables for clarity," "Extracted logic into a separate function," "Removed redundant comments").