PromptsVault AI is thinking...
Searching the best prompts from our community
Searching the best prompts from our community
Top-rated prompts for Coding
Analyze and optimize PostgreSQL query performance. Steps: 1. Identify slow queries with pg_stat_statements. 2. Analyze Execution plans (EXPLAIN ANALYZE). 3. Create covering indexes for frequent queries. 4. Optimize JOIN operations. 5. Vacuum and analyze strategy. 6. Partition large tables. 7. Tune configuration parameters (work_mem, shared_buffers). 8. Connection pooling setup (PgBouncer). Include index maintenance plan.
Optimize Unity game physics for mobile performance. Techniques: 1. Adjust fixed timestep settings. 2. Use primitive colliders over mesh colliders. 3. Implement object pooling for projectiles. 4. Configure collision matrix to reduce checks. 5. Use raycast layers for efficiency. 6. Bake static physics objects. 7. Profile with Unity Profiler and Frame Debugger. 8. Limit rigidbodies on active scenes. Include multi-threading setup for physics calculations.
Design scalable URL shortening service (like TinyURL). Components: 1. API design (REST/GraphQL). 2. Hashing algorithm (Base62). 3. Database schema (NoSQL vs SQL) and partitioning. 4. Cache layer (Redis) for redirect performance. 5. Unique ID generation (KGS - Key Generation Service). 6. Analytics service (async processing). 7. Rate limiting and abuse prevention. 8. High availability and georedundancy strategy.
Design reusable Cypress E2E testing framework. components: 1. Page Object Model (POM) pattern. 2. Custom commands for common actions. 3. API interception for mocking backend. 4. Visual regression testing (percy/applitools). 5. Dynamic data generation (faker.js). 6. Environment configuration (staging/prod). 7. CI/CD integration using GitHub Actions. 8. Flaky test retry logic. Include HTML report generation.
Implement robust MQTT communication for IoT sensor network. Architecture: 1. Broker selection (HiveMQ, Mosquitto). 2. Topic hierarchy design. 3. QoS level configuration (0, 1, 2). 4. Retained messages and Last Will and Testament (LWT). 5. TLS encryption for data in transit. 6. Device authentication (X.509 certs). 7. Data compression (Protobuf vs JSON). 8. Scalability testing with JMeter. Include offline message queuing strategy.
I'm getting the following error message in my browser console: "Uncaught TypeError: Cannot read properties of undefined (reading 'map')". Explain what this error means in simple terms, what are the common causes for it, and how I can go about debugging it in my JavaScript code.
Generate a SQL schema for a simple e-commerce website. It should include tables for Products, Customers, Orders, and Order_Items. Define the columns for each table, specify data types, and set up primary and foreign key relationships.
Explain the difference between `std::unique_ptr`, `std::shared_ptr`, and `std::weak_ptr` in modern C++. When should each one be used? Provide a code example demonstrating a common use case for `std::shared_ptr` to manage a shared resource.
Design a GraphQL schema for a blog application. The schema should define types for Author, Post, and Comment. Include queries to fetch all posts, a single post by ID, and all posts by a specific author. Also, include mutations for creating a new comment.
Explain the "Single Responsibility Principle" (SRP) from the SOLID principles of object-oriented design. Provide a simple "before" code example in C# or Java that violates SRP, and then show an "after" example that refactors the code to adhere to the principle.
Explain how `async` and `await` work in JavaScript for handling asynchronous operations. How do they differ from using `.then()` with Promises? Provide a code example that fetches data from an API, first using Promises with `.then()` and then refactored to use `async/await`.
I need to store a collection of items where I will frequently be adding new items and searching for existing items. The order of items does not matter. What is the most appropriate data structure to use (e.g., Array, Linked List, Hash Table, Tree)? Explain the trade-offs and why your choice is the best for this scenario.
What is the best practice for managing environment variables (e.g., API keys, database passwords) in a Node.js project? Explain the use of `.env` files and the `dotenv` package. Provide an example of how to load and access variables from a `.env` file.
Analyze the time complexity (Big O notation) of the following Python function, which checks if an array contains duplicate values. Explain your reasoning step-by-step. `def has_duplicates(arr): for i in range(len(arr)): for j in range(i + 1, len(arr)): if arr[i] == arr[j]: return True; return False`
Rewrite the following imperative JavaScript code, which uses a for-loop to double every number in an array, into a functional style. Use higher-order functions like `map`. Explain the benefits of the functional approach, such as immutability and readability.
Let's do a system design interview. Your task is to design a URL shortening service like TinyURL. Discuss the requirements, API design, data model, and how you would handle scaling the service to millions of users. Draw a high-level architecture diagram.
I am a Python developer learning Go. Explain the concept of "goroutines" and "channels". How do they compare to Python's threading or asyncio? Provide a simple code example in Go that demonstrates concurrent execution using goroutines and channels.
Design a basic CI/CD pipeline using GitHub Actions for a Python web application. The pipeline should be triggered on a push to the main branch. It should include steps for installing dependencies, running linters, executing unit tests, and deploying the application to a staging environment.
Compare and contrast the microservices architecture with the monolithic architecture. Discuss the pros and cons of each in terms of development, deployment, scalability, and complexity. For a new, small-scale e-commerce startup, which architecture would you recommend and why?
Explain the concept of Protocol-Oriented Programming (POP) in Swift. How does it differ from traditional Object-Oriented Programming (OOP)? Provide an example of how you can use protocol extensions to provide default implementations for methods.
I need to design a RESTful API for a social media application. The resources are Users, Posts, Comments, and Likes. Design the endpoints, including HTTP methods, URL structure, and request/response payloads. Provide examples for creating a new post and fetching comments for a post.
Create a regular expression to validate a strong password. The password must be at least 8 characters long, contain at least one uppercase letter, one lowercase letter, one number, and one special character (e.g., !, @, #, $). Explain the different parts of the regex.
Explain what a decorator is in Python. Write a simple decorator called `@timer` that measures the execution time of any function it decorates and prints the duration to the console. Show how to apply this decorator to a sample function.
I need to add charts and graphs to my web application. What are some popular JavaScript libraries for data visualization? Compare libraries like D3.js, Chart.js, and Highcharts based on ease of use, customization options, and performance.
Explain the concept of "ownership" in Rust. What are the three main rules of ownership? How does it help Rust achieve memory safety without a garbage collector? Provide a simple code example that would cause a compile-time ownership error and explain why it fails.
I have an old JavaScript codebase that uses ES5 syntax (var, function declarations). Help me modernize it to ES6+ syntax (let/const, arrow functions, classes). Take the following ES5 code and rewrite it using modern JavaScript features.
I have a bug in my Python code. The function is supposed to calculate the factorial of a number, but it's returning an incorrect result for inputs greater than 5. Here is the code: [paste code here]. Help me find and fix the bug.
I have a Node.js application with a package.json file. Create a Dockerfile to containerize this application. The Dockerfile should install dependencies, copy the application code, and specify the command to run the application. Optimize the Dockerfile for smaller image size and faster builds.
Take the following poorly formatted C# code and format it according to standard C# coding conventions. Ensure consistent indentation, spacing, and brace style. Point out the specific changes you made.
Act as a senior software engineer. Take the following code snippet and refactor it for better readability, performance, and maintainability. Explain the changes you made and why.
Simulate a technical interview for a junior front-end developer position. Ask me questions about HTML, CSS, JavaScript, and a framework like React. Start with a simple coding challenge, like reversing a string.
I am starting a new web project. It will be a highly interactive single-page application (SPA) with real-time data updates. Compare and contrast React, Vue, and Angular for this project. Recommend one and justify your choice based on performance, learning curve, ecosystem, and scalability.
Explain the "Quicksort" algorithm. Describe how it works step-by-step, its time and space complexity (best, average, and worst-case), and its main advantages and disadvantages compared to other sorting algorithms like Mergesort.
I accidentally committed sensitive data to my last commit and pushed it to the remote repository. What are the Git commands I need to use to completely remove the sensitive file from the repository's history? Explain each step of the process.
Write a basic Terraform configuration (`main.tf`) to provision an AWS S3 bucket. The configuration should specify the AWS provider, a resource for the S3 bucket, and a unique bucket name. Include a variable for the AWS region.
Act as a peer reviewer for my code. I will provide a pull request link or a code snippet. Please review it for potential bugs, style inconsistencies, performance issues, and security vulnerabilities. Provide constructive feedback and suggest specific improvements.
I have a slow-running SQL query. Here is the query: [paste query here]. And here is the table schema: [paste schema here]. Analyze the query and suggest ways to optimize it. Consider adding indexes, rewriting the query, or denormalizing the data.
I want to create a responsive three-column layout. The middle column should be fluid, and the side columns should have a fixed width. Show me how to achieve this using both CSS Flexbox and CSS Grid. Explain the pros and cons of each approach for this specific layout.
Explain the problem of state management in large frontend applications. What is "prop drilling"? How do libraries like Redux or Zustand solve this problem? Describe the basic concepts of a global store, actions, and reducers (or their equivalents).
Debate the pros and cons of using an Object-Relational Mapper (ORM) like SQLAlchemy or TypeORM versus writing raw SQL queries. Discuss aspects like developer productivity, performance, security, and database abstraction. In what scenarios would you strongly prefer one over the other?
Explain the structure of a JSON Web Token (JWT). What are the three parts (Header, Payload, Signature)? What information is typically stored in the payload? How is the signature used to verify the token's authenticity? Provide an example of a decoded JWT payload.
I have a function that accepts a parameter which can be a `string` or a `number`. Write a custom type guard in TypeScript to check if the variable is a `string`. Then, show how to use this type guard within an `if` statement to safely access string-specific properties.
Generate the YAML for a basic Kubernetes Deployment and Service. The Deployment should run 3 replicas of the `nginx:alpine` image. The Service should expose the Nginx deployment on port 80 using a `ClusterIP`.
Take the following C-style for-loop in Python and rewrite it in a more "Pythonic" way. Explain why the Pythonic version is preferred. Original code: `for i in range(len(my_list)): print(my_list[i])`
What is Dependency Injection (DI)? How does it help in creating loosely coupled and more testable code? Provide a simple "before" and "after" code example in Java or C# that demonstrates the concept of constructor injection.
Generate documentation for the following TypeScript function in JSDoc format. The function accepts a user object and returns a formatted greeting string. Make sure to document the parameters, their types, and the return value.
Explain the "Singleton" design pattern. What problem does it solve? Provide a code example of how to implement it in Java or Python. Discuss its pros and cons, and when it is appropriate to use.
Write a set of unit tests for the following JavaScript function, which takes an array of numbers and returns the sum. Use a testing framework like Jest. Cover edge cases like an empty array, an array with non-numeric values, and a very large array.
Analyze the following PHP code snippet for common security vulnerabilities like SQL Injection, Cross-Site Scripting (XSS), or Insecure Direct Object References. Explain where the vulnerabilities are and how to fix them.
Let's code together. I want to build a simple command-line to-do list application in Node.js. Let's start by outlining the features. Then, you can help me write the code for adding a new task. I will ask questions as we go.