instruction_seed stringlengths 29 40.5k | source stringclasses 6
values |
|---|---|
You are tasked with creating a program that retrieves the top GitHub repositories based on the number of stars within a specified range. Your program should utilize the GitHub API to fetch repository data and then display the repository names and their corresponding star counts. Additionally, the program should allow t... | magicoder |
You are tasked with creating a Laravel controller method that handles the process of resetting the password for an admin user. The controller contains several methods, including `resetarSenhaAdmin()` and `AllresetarSenhaAdmin()`, which are responsible for rendering the views for resetting the admin password. Your task ... | magicoder |
You are tasked with implementing a custom string-to-localdatetime converter in Java. Your task is to create a class that implements the `Converter` interface to convert a string representation of a date and time to a `LocalDateTime` object using the `LocalDateTime.parse()` method.
Your implementation should adhere to ... | magicoder |
You are tasked with creating a Python function that validates the existence of a specified output directory and raises a custom exception if the directory does not exist. Your function should take the output directory path as an argument and should raise a custom exception with a specific error message if the directory... | magicoder |
You are tasked with implementing a class for managing a grid hierarchy tree used in volume data processing. The class, `GridHierarchyTree`, is responsible for constructing and managing the hierarchy tree based on specified refinement levels and volume dimensions.
The constructor of the `GridHierarchyTree` class takes ... | magicoder |
You are tasked with implementing a class that manages and tests node results. The class should have methods for adding results to a list and for testing a specific node result. The results are associated with unique identifiers and public keys.
You need to implement the following class:
```python
class NodeManager:
... | magicoder |
You are tasked with implementing a simplified version of a duck simulation program. The program should include a base class `Duck` and a derived class `DecoyDuck`. The `DecoyDuck` class should inherit from the `Duck` class and override the default behavior of the `quack` method. The `quack` method of the `DecoyDuck` cl... | magicoder |
You are tasked with creating a function that determines whether a given JavaScript module is the default export or not. In JavaScript, the `export default` statement is used to export a single value or object from a module. Your function should take a string representing the code of a JavaScript module and return `true... | magicoder |
You are tasked with creating a Python function that processes a list of module names and returns a new list containing only the module names that can be successfully imported. If a module cannot be imported, it should be excluded from the resulting list. You should handle any potential import errors gracefully.
Your t... | magicoder |
You are tasked with implementing a function to determine whether a given point lies within a triangle in a 2D plane. The triangle is defined by three vertices, and the point is represented by its (x, y) coordinates. The function should return True if the point lies within the triangle, and False otherwise.
You are giv... | magicoder |
You are tasked with implementing a custom bitset data structure in Rust using the `bitset_const_macros` crate. The bitset should support setting, clearing, and checking individual bits, as well as performing bitwise operations such as AND, OR, XOR, and NOT.
Your task is to create a Rust module `CustomBitset` that prov... | magicoder |
You are tasked with creating a class that represents a person's profile in a database. The class should include attributes for the person's birth date and address. Additionally, the class should incorporate data annotations to enforce specific constraints and provide metadata for the attributes.
Create a C# class name... | magicoder |
You are tasked with creating a unit test for a utility class called `X509CertificateUtil`. This utility class likely contains methods for working with X.509 certificates, such as parsing, validating, or manipulating them. The unit test should verify the behavior of the methods in this utility class using the Mockito fr... | magicoder |
You are given a code snippet that defines a method `construct` within a class. The method takes two parameters `x` and `b`, and performs some operations using other methods `mul` and `tile` from the same class. Additionally, there are four tensors `_x`, `_w1`, `_w2`, and `_b` defined outside the class.
Your task is to... | magicoder |
You are tasked with creating a Python function that takes a string as input and returns a modified version of the string based on specific rules. The function should perform the following operations:
1. If the input string contains the substring "fabric", it should be replaced with "cotton".
2. If the input string end... | magicoder |
You are tasked with implementing a function that retrieves the coordinates of a specific point in a 2D action grid. The action grid is represented as a 2D array, and the function should return the index of the point in the grid.
The function `get_coords(action_grid, x, y)` takes in three parameters:
- `action_grid`: a... | magicoder |
You are given a list of integers representing the scores of participants in a competition. The task is to determine the minimum number of participants who scored at least the k-th highest score. Write a function `min_participants_scored_kth_highest` that takes in the number of participants `n`, the value of `k`, and th... | magicoder |
You are tasked with implementing a context manager in Python to manage the lifecycle of a database session within a web application. The context manager should handle the setup and teardown of the database session, ensuring proper resource management and cleanup.
Your task is to create a Python context manager class, ... | magicoder |
You are given a Python class `ListNode` representing a node in a linked list. The class has two methods: `__str__` and `__repr__`. The `__str__` method returns a string representation of the linked list starting from the current node, and the `__repr__` method returns a string representation of the `ListNode` object.
... | magicoder |
You are tasked with implementing a simple event logging system in Rust. The system should allow the creation of event fields with a name and a value, and provide a method to retrieve the formatted log message containing all the event fields.
You need to implement the following structure and methods:
```rust
struct Ev... | magicoder |
You are working on a program to analyze gene sets and their relationships. The program uses a set of rules to summarize the relationships between gene sets. One of the rules, `commonSupertermInListRepresentsSubtermsWithLessRepresentativePower`, is designed to identify superterms that represent subterms with less repres... | magicoder |
You are tasked with implementing a simple document management system. The system should support creating, updating, and retrieving documents. Each document has a unique identifier, a title, and content. You need to implement the `Document` class with the following requirements:
- The `Document` class should have priva... | magicoder |
You are tasked with creating a Python program that processes a given directory and its subdirectories to identify and list all files that have been modified within a specified time range. You will need to utilize the `os` module to traverse the directory structure and obtain file information, as well as the `time` modu... | magicoder |
You are tasked with creating a program that processes a list of integers and performs a specific operation on them. The program should take the following steps:
1. Read a list of integers from the standard input.
2. For each integer in the list, calculate its square and print the result to the standard output.
Your pr... | magicoder |
You are working on a data processing system that handles a JSON-like data structure. The system is designed to process and manipulate the data in various ways. One of the tasks involves modifying a nested dictionary within the data structure. The dictionary contains information about questions and subquestions, and you... | magicoder |
You are tasked with creating a React component that displays a custom 404 error page for a website. The component should render a layout with search engine optimization (SEO) metadata, a template section with specific styling, and a message indicating that the requested route was not found. Additionally, the component ... | magicoder |
You are tasked with creating a simple animation system for scaling a view in a mobile application. The animation system uses a value obtained from an animation object to set the scale of a view. Your task is to implement a function that calculates the scale factor based on the given animated value and the maximum scale... | magicoder |
You are tasked with implementing a generic method to find the maximum element in a list of comparable objects. You should create a Java method that takes a list of comparable objects and returns the maximum element in the list. The method should be able to handle any type of comparable objects, such as integers, string... | magicoder |
You are tasked with implementing a class in PHP to handle the system level data associated with SMPP (Short Message Peer-to-Peer) external interface. The class should be able to make a request to retrieve this data and handle the response accordingly.
Your task is to create a PHP class named `SystemSMPPGetRequest22` w... | magicoder |
You are working on a project that involves processing astronomical data stored in HDF5 format. The code snippet provided is part of a Python script that appends columns to an HDF5 file. The `append_column_to_hdf5` function takes four arguments: the input HDF5 file (`infile`), the data to be appended, the group within t... | magicoder |
You are working on a server-side Swift application using Kitura, a web framework for building web services and applications. In this scenario, you are tasked with implementing a WebSocket upgrade handler for handling incoming upgrade requests. The `ConnectionUpgrader` class provides a method `register` to register a fa... | magicoder |
You are tasked with creating a Python function that simulates a simple game environment. The game consists of episodes, each of which involves a certain number of timesteps. At the end of each episode, the function should print a message indicating the episode number and the number of timesteps it took to complete that... | magicoder |
You are tasked with creating a Python script to automate the generation of private keys and certificates for a test certificate authority and a cluster. The script should utilize the `openssl` command-line tool to perform the necessary operations. Your task is to write a Python function that generates the private keys ... | magicoder |
You are given a Java class `LinkChecker` with two methods: `isLink()` and `isNotLink()`. The `isLink()` method returns `true`, while the `isNotLink()` method returns `false`. Your task is to create a new class `LinkValidator` that utilizes the `LinkChecker` class to validate a given URL.
Your task is to implement the ... | magicoder |
You are tasked with implementing a class to manage a scheduled task. The class should have methods to view the configuration of the task and to set its running status. The task has attributes for the time it should run, including the on_time, on_hour, and on_minute, as well as a boolean attribute is_running to indicate... | magicoder |
You are working on a continuous integration (CI) pipeline for a web application hosted on Vercel. The CI pipeline is triggered whenever a new commit is made to the repository. You need to ensure that the pipeline only runs when the commit is made to a specific branch called "stream-data". To achieve this, you decide to... | magicoder |
You are tasked with creating a multithreaded Rust program that simulates a simple banking system. The program should utilize threads to handle multiple account transactions concurrently. Each account will have an initial balance, and the program should support deposit and withdrawal operations. To ensure thread safety,... | magicoder |
You are given a Python function that returns an array of neighbors for each cell in a grid. Each cell has a specific number of neighbors, and the function returns an array where each element represents the neighbors of a particular cell. Your task is to implement a Python function that takes the grid size and the numbe... | magicoder |
You are tasked with creating a program to manage course information for a university. The program should allow users to add, update, and display course details such as course days, available seats, and course times.
You are given a class `Course` with the following attributes:
- `courseDays`: a string representing th... | magicoder |
You are tasked with creating a service in an Angular application that interacts with a RESTful API to fetch and manipulate data. The service should be responsible for making HTTP requests and handling the responses. Your goal is to implement a method within the service that retrieves a list of items from a specific end... | magicoder |
You are tasked with implementing a generic method for paginating and returning a collection of data in a web API. The method should take a `PagedResult<T>` object as a parameter and return an `ActionResult` containing the paginated data.
The `PagedResult<T>` class represents a paginated result set, containing the data... | magicoder |
You are tasked with implementing a container management system that can retrieve containers based on their status. The system has a method `_get_containers_with_state` which takes in a list of container names, a boolean flag `select_random`, and variable number of container states. The method retrieves containers with ... | magicoder |
You are tasked with creating a Django migration for a new model called "Profile" in the "pictures" app. The "Profile" model should have the following fields:
- "user" field of type ForeignKey to the User model in the auth app.
- "bio" field of type TextField.
- "avatar" field of type ImageField.
Write the migration fi... | magicoder |
You are tasked with implementing a simple task management system using Java. Your task is to create a class `Task` with the following specifications:
- The class should have a method `done` with no parameters and a return type of `void`.
- The `done` method should be overridden to perform a specific action when a task... | magicoder |
You are tasked with creating a Rust function that interacts with ROS (Robot Operating System) services. The function should be able to handle a specific service call and return a result based on the input provided.
You are given a code snippet that demonstrates the usage of ROS service in Rust. The `rosrust::service` ... | magicoder |
You are tasked with creating a Bash script that automates the installation or upgrade of packages using a specified Personal Package Archive (PPA). Your script should prompt the user to input the package name to be installed or upgraded. If the user provides the package name as a command-line argument, it should be use... | magicoder |
You are tasked with creating a build system for a set of C programs that interact with a Redis database. The build system should compile multiple test programs with different flags and dependencies. The provided code snippet shows a part of the build commands used to compile the test programs.
Your task is to write a ... | magicoder |
You are working as a DevOps engineer for a company that uses Kubernetes for managing containerized applications. As part of your responsibilities, you need to create and manage various resources using `kubectl` commands. One common task is to create Kubernetes resources from YAML manifest files.
Your task is to creat... | magicoder |
You are tasked with implementing a function that processes a list of valid URLs and generates HTML code based on certain conditions. The function should take the following inputs:
- `validURL`: a list of strings representing valid URLs
- `includeQR`: a boolean indicating whether to include QR codes in the HTML output
-... | magicoder |
You are tasked with implementing a custom exception class in Java for handling situations where a resource is not processable. The custom exception class should be named `ResourceNotProcessable` and should accept a message as a parameter when it is instantiated. Your task is to create the `ResourceNotProcessable` class... | magicoder |
You are tasked with implementing a simple command-line calculator that can perform basic arithmetic operations. The calculator should take user input in the form of a mathematical expression and then evaluate and display the result. The supported operations are addition (+), subtraction (-), multiplication (*), and div... | magicoder |
You are tasked with implementing a Python function that retrieves the release version of a client's service. The function should handle potential errors and set a default version if necessary. You are provided with a code snippet that partially implements this functionality using the `subprocess` module and exception h... | magicoder |
You are given a list of one-letter words represented as strings. Each string contains a single letter surrounded by spaces. Your task is to write a function that takes this list as input and returns a dictionary where the keys are the letters and the values are the number of occurrences of each letter in the list.
Wri... | magicoder |
You are tasked with implementing a function that processes image boundaries. The function should validate the boundaries and raise an error if they do not meet certain criteria. The provided code snippet is a part of the function and contains a conditional check for the y-coordinates of the boundaries. If the differenc... | magicoder |
You are tasked with implementing a simplified version of a dependency injection container in C#. The container should be able to resolve and instantiate registered types based on their dependencies.
Your task is to create a class called `DependencyContainer` with the following requirements:
- The container should be a... | magicoder |
You are tasked with implementing a function that truncates a given string to ensure that it ends at a valid character boundary within a specified maximum byte length. The function should take a string `s` and a maximum byte length `max_bytes` as input and return a new string that is truncated to the nearest character b... | magicoder |
You are tasked with implementing a function to analyze and visualize the results of a simulation. The simulation generates a set of samples, and the goal is to plot the average of the last 20% of these samples. The code snippet provided gives a glimpse of the process, including saving the results to a file using cPickl... | magicoder |
You are given a Python function `get_next_number(numbers, last_number)` that takes in a list of numbers `numbers` and the last number `last_number` in the list. The function is designed to return the next number in the sequence based on the following rules:
- If the `last_number` is not present in the list `numbers` ex... | magicoder |
You are tasked with creating a Python program to handle MQTT messages from a broker and perform specific actions based on the received messages. The program should subscribe to a specified MQTT topic and define a callback function to process incoming messages.
Your task is to implement the `handleMessage` function, wh... | magicoder |
You are tasked with implementing a class to manage download preferences for a testing profile in a browser. The given code snippet is part of a unit test for this class. The `TestingProfile` and `DownloadPrefs` classes are part of a testing framework for a web browser.
The `TestingProfile` class represents a testing p... | magicoder |
You are tasked with implementing a simplified version of a social media application using the Clean Swift architecture. The application should allow users to create posts, view posts, and like posts. The core components of Clean Swift architecture include the View, Interactor, Presenter, Worker, and Router.
Your task ... | magicoder |
You are tasked with implementing a feature flag management system. A feature flag is a way to control the visibility of a feature in an application, allowing for gradual rollouts, A/B testing, and other deployment strategies. The system provides a `FeatureFlagClient` class with methods for creating and listing feature ... | magicoder |
You are tasked with creating a Python function that processes files within a specified directory and its subdirectories. The function should calculate the total size of all files with a specific file extension within the given directory and its subdirectories.
You are provided with a code snippet that sets the `HOST_D... | magicoder |
You are tasked with implementing a Python class that represents a simple bank account. The class should have methods for depositing funds, withdrawing funds, and checking the current balance. Additionally, the class should handle the scenario where the account holder attempts to withdraw more funds than are available i... | magicoder |
You are tasked with creating a Java program that validates system properties against expected values. Your program should implement a method `assertSystemProperty` that takes two parameters: `name` (the name of the system property) and `expectedValue` (the expected value of the system property). The method should compa... | magicoder |
You are working on an Angular application that manages user roles and permissions. The code snippet provided is a part of the Angular component for the admin interface. Your task is to implement a feature that restricts access to certain sections of the admin interface based on the user's role.
You have the following ... | magicoder |
You are tasked with analyzing the performance data of a CUDA application. The given code snippet loads timing data from a CSV file and performs some initial processing using the NumPy library. Your task is to complete the analysis by calculating the average execution time for each of the 16 CUDA kernels.
The CSV file ... | magicoder |
You are tasked with implementing a simple type aliasing system for a custom vector and matrix library. The library uses the following type definitions:
```cpp
typedef glm::vec2 vec2;
typedef glm::vec3 vec3;
typedef glm::vec4 vec4;
typedef glm::mat4 mat4;
```
Your goal is to create a C++ program that demonstrates the ... | magicoder |
You are tasked with creating a Python function that sets the root directory for a file system and creates a data directory within it. The function should take the root directory path as an argument and return the path of the data directory.
Function Signature: `def set_root_directory(root_path: str) -> str`
Example:
... | magicoder |
You are tasked with implementing a function to calculate the Generalized Intersection over Union (GIoU) loss on anchor boxes. The GIoU loss is a metric and a loss function used for bounding box regression in object detection tasks. The GIoU loss measures the dissimilarity between predicted bounding boxes and ground tru... | magicoder |
You are tasked with implementing a simple counter class in C++. The class should have the following functionalities:
1. Initialize the counter to a given value.
2. Increment the counter by a specified amount.
3. Decrement the counter by a specified amount.
4. Retrieve the current value of the counter.
You are provided... | magicoder |
You are tasked with creating a simple HTTP server using the Rust programming language. Your goal is to implement an endpoint that responds with a "Hello, World!" message when accessed. You will need to use the `gotham` and `hyper` crates to set up the server and handle the incoming requests.
Your task is to complete t... | magicoder |
You are tasked with creating a function that processes a list of user groups and their associated users to generate a queryset of task results. The function should take a list of users and their associated groups, and then filter the task results based on these users and their groups.
The function should perform the f... | magicoder |
You are tasked with creating a Bash script that extracts and processes information from a Git repository. Your script should accomplish the following tasks:
1. Extract the current branch name from the Git repository.
2. Count the number of commits on the current branch.
3. Display the last commit message on the current... | magicoder |
You are tasked with creating a program to process applications for a confidential invoice discount service. The service requires specific company data to be submitted for evaluation. Your task is to implement a function that takes an application object and extracts the necessary company data to submit for the confident... | magicoder |
You are tasked with creating a Python program to manage and monitor a network of IoT devices. The program should utilize asynchronous programming to handle multiple tasks concurrently. One of the devices in the network is a Sense HAT, which provides environmental data and user input capabilities. The program needs to c... | magicoder |
You are tasked with creating a Python class that simulates a simple device and an API handler for basic operations. The device class will have attributes to store its state and methods to manipulate that state, while the API handler class will provide methods to interact with the device.
Your task is to implement the ... | magicoder |
You are tasked with creating a Django model for a coding competition platform. The model should represent a user's Kattis handle, which is a unique identifier for their profile on the Kattis online judge platform. Additionally, the model should include a field to store the creation timestamp of the Kattis handle entry.... | magicoder |
You are tasked with creating a custom serializer for a new model in a Django REST framework application. The model, `Car`, represents various attributes of a car, such as make, model, year, and color. Your task is to create a custom serializer class, `CarSerializer`, that will handle the serialization and deserializati... | magicoder |
You are tasked with creating a function that calculates the average score of a student based on their test scores. The function should take an array of test scores as input and return the average score as a floating-point number. You need to ensure that the function handles edge cases such as an empty input array and n... | magicoder |
You are given a code snippet that includes the use of the `lazy_static` crate, file reading, and a data processing function. Your task is to create a program that reads a list of integers from a file, finds the first repeating sum of the integers, and returns the repeated sum.
Write a function `find_repeated_sum` that... | magicoder |
You are tasked with implementing a specialized stack that supports the following operations: push, pop, and getMin. The getMin operation should return the minimum value currently in the stack. The stack should have O(1) time complexity for all operations.
You are given a code snippet that partially implements the stac... | magicoder |
You are tasked with creating a logging system for an application. The system should be able to store log entries, each containing a date and time, event source, and a message. To achieve this, you need to implement a LogEntry class with the following properties:
- DateAndTime: a property of type DateTime, representing... | magicoder |
You are tasked with implementing a custom error type and its conversion traits in Rust. Your custom error type, `Error`, should be able to represent different error conditions and be convertible from other error types. You need to define the `Error` type and implement the `From` trait for converting from specific error... | magicoder |
You are tasked with implementing a middleware function for a webhooks list command in a codebase. The `ListWebhooksCommand` class is provided as a TypeScript declaration, and you need to create the `resolveMiddleware` function to handle the middleware logic. The `serialize` and `deserialize` functions are also required... | magicoder |
You are tasked with implementing a class that manages a bulk processing system for a database. The class should handle the configuration of the database connection and the bulk processing of data.
You are provided with a code snippet that contains some configuration settings and constants related to the database conne... | magicoder |
You are tasked with implementing a function to draw a series of rectangles on a screen using the Pygame library. The function `draw_next` takes in the following parameters:
- `screen`: the Pygame screen object to draw on
- `bot_left`: a tuple representing the bottom-left corner of the area to draw on
- `top_right`: a t... | magicoder |
You are tasked with creating a Python function that processes a given DataFrame and transforms it from wide to long format using the `melt` function from the `pandas` library. The function should take the DataFrame, the column to be used as the identifier variable, and the names for the variable and value columns as in... | magicoder |
You are tasked with creating a Python function that dynamically configures logging for a Flask application based on a JSON configuration file. The function should handle the scenario where the configuration file exists and where it does not exist. The function should also enable Cross-Origin Resource Sharing (CORS) for... | magicoder |
You are tasked with creating a unit test for a section of code that manages a user search feature in a social media application. The code snippet provided is a part of a unit test suite written in a behavior-driven development (BDD) style using a testing framework like Jasmine or Mocha. The test suite is for a user sea... | magicoder |
You are given a Python function that processes an image represented as a 2D list of pixels. The function takes the image as input and performs a specific operation on each pixel. However, the code snippet provided is incomplete and lacks the initial part of the function. Your task is to complete the function by writing... | magicoder |
You are tasked with implementing a data validation function for a clinical trial database. The function should validate the data types of various fields in a trial record based on a provided schema. The schema is represented as a dictionary where the keys are field names and the values are the expected data types for t... | magicoder |
You are tasked with implementing a simplified version of a stack data structure in a programming language of your choice. The stack should support the following operations: create, push, pop, and peek. Additionally, the stack should have the ability to specify its orientation as either "horizontal" or "vertical" during... | magicoder |
You are tasked with creating a script to automate the backup and restoration of configuration files for a specific application. The application in question is tmux, a terminal multiplexer that allows multiple terminal sessions to be accessed and controlled from a single window. The provided code snippet is a part of a ... | magicoder |
You are tasked with creating a Django form for blocking a user with a specific reason. The form should include a dropdown menu populated with reasons for blocking a user, which are retrieved from the `MotivoBloqueo` model. The `MotivoBloqueo` model has a field named `accion`, which represents the action associated with... | magicoder |
You are tasked with creating a program that analyzes the GitHub repository names of a user and identifies the repositories that contain a specific keyword. You will need to implement a function that takes a list of repository names and a keyword as input and returns a list of repository names that contain the given key... | magicoder |
You are tasked with creating a program that simulates a simple online shopping cart system. The program should allow users to add items to their cart, view the items in their cart, remove items from their cart, and calculate the total cost of the items in the cart.
You are provided with a partial implementation of the... | magicoder |
You are tasked with implementing a custom neural network layer for a natural language processing (NLP) model. The layer will include token and positional embeddings, as well as a series of stacked transformer layers. The token embeddings will be initialized with a normal distribution, and the positional embeddings will... | magicoder |
You are tasked with implementing a simple volume management system for a media player application. The provided code snippet is part of a Rust program that defines a `CVolume` struct and its associated methods. The `CVolume` struct represents a volume control, and the `volumes` method is used to retrieve a slice of `Vo... | magicoder |
You are tasked with implementing a simple IRC (Internet Relay Chat) client in Python. The provided code snippet contains a portion of the IRC client implementation, including a method for connecting to an IRC server and a method for receiving data from the server.
Your task is to complete the implementation of the IRC... | magicoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.