instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a service distribution system that efficiently updates and rebuilds the distribution whenever a profile is updated. The system should be able to reuse existing services from the prior state to minimize resource usage.
You are given a list of services and their corresponding profiles. ... | codefeedback |
You are tasked with creating a function to visualize persons detected in an image using OpenCV in Python. The function should take an input image and a list of dictionaries, where each dictionary represents a person's bounding box and label. The function should draw bounding boxes around each person and label them with... | codefeedback |
You are tasked with creating a password validation function for a user registration system. The function should take in two passwords, a name, a list of modes, a homepage URL, an API URL, a MIPTA URL, a phone number, and an email address. The function should perform the following validations:
1. Check if the two passwo... | codefeedback |
You are tasked with implementing a class `ArbitraryIntervals` that supports the following operations on a set of arbitrary intervals:
1. `add_interval(start, end)`: Add a new interval `[start, end]` to the set. If the new interval overlaps with existing intervals, merge them into a single interval.
2. `remove_interval... | codefeedback |
You are tasked with implementing a custom exception class in C++. Your exception class should inherit from the standard `std::exception` class and provide a custom error message. Additionally, you need to create a function that throws an instance of your custom exception class and handle the exception in the main progr... | codefeedback |
You are tasked with implementing a generic dependency injection framework in Swift. The framework should allow the user to define providers for different types and then use these providers to create instances of elements. The providers are responsible for providing the necessary dependencies to the element factories.
... | codefeedback |
You are tasked with creating a leaderboard system for a coding competition. The competition is hosted by GNOME, and the leaderboard will display the top contributors based on their points earned through project contributions. Each contributor has a name and a point total associated with their contributions.
You need t... | codefeedback |
You are given an array `a` of length `n`. Your task is to find the maximum element to the left of each element in the array. You need to store these maximum values in an array `lmax` such that `lmax[i]` contains the maximum element in the subarray `a[0:i]` (inclusive).
For example, if the input array `a` is `[3, 1, 5,... | codefeedback |
You are tasked with creating a program that processes SQL template strings to extract specific information. The SQL template string follows a specific format and contains placeholders for variables. Your task is to write a function that takes the SQL template string as input and returns a dictionary containing the extr... | codefeedback |
You are tasked with designing a Python class that manages contract event loggers for Ethereum smart contracts. The class should handle the retrieval of new entries from logs for transfer and approval events. You are provided with a code snippet that initializes an empty list called `approval_tasks` and iterates through... | codefeedback |
You are tasked with implementing a Python class for a color sensor device. The class should include a method to calculate the color currently being viewed based on the sensor readings. The color is determined by comparing the sensor readings to baseline values obtained during initialization.
Your task is to complete t... | codefeedback |
You are working on a quantum chemistry software project and are tasked with implementing a function to calculate the kernel of a many-body perturbation (MP) theory. The kernel function takes several arguments, including the molecular orbitals (mo_coeff), orbital energies (mo_energy), and electron repulsion integrals (e... | codefeedback |
You are tasked with implementing a simple module system in a JavaScript application. The module system should allow for the export and import of modules between different files. The code snippet provided is an example of an export statement in JavaScript, which exports the `Dock` module from a file called "Dock.js".
Y... | codefeedback |
You are tasked with creating a Python function that utilizes the TensorFlow library to build a custom neural network model for image classification. Your function should take in the number of classes for the classification task and return a compiled neural network model with specific architecture and configurations.
W... | codefeedback |
You are tasked with implementing a search function for a custom search engine using C#. The function should take in a search text, a boolean flag indicating whether to use wildcards, a LuceneSearcher provider, and an index type. The function should return a XPathNodeIterator containing the search results.
Your task is... | codefeedback |
You are tasked with simulating the behavior of a cellular automaton known as Conway's Game of Life. In this game, a grid of cells evolves through discrete time steps based on a set of rules. Each cell can be in one of two states: alive or dead. The rules for the evolution of the grid are as follows:
1. Any live cell wi... | codefeedback |
You are tasked with simulating a simple thread management system for a multi-threaded application. The system is responsible for creating, executing, and tracking the elapsed time of threads. Each thread is associated with a specific task and is executed sequentially.
You are provided with a code snippet that demonstr... | codefeedback |
You are tasked with implementing a DNS tracing tool that follows the chain of authority to resolve a domain name. The tool will perform DNS queries starting at the root Internet name servers and continue following the specified authorities until it finds an answer.
Your task is to implement the `trace` function that t... | codefeedback |
You are tasked with creating a program to assist in the process of merging and editing datasets. The program should take an existing "silver" dataset with binary accept/reject annotations and merge the annotations to find the best possible analysis given the constraints defined in the annotations. After merging, the pr... | codefeedback |
You are tasked with implementing a custom data structure to represent a directed graph. The graph will consist of nodes and edges, where each node can have multiple outgoing edges to other nodes. Your task is to create a class `DirectedGraph` that supports the following operations:
1. `addNode(nodeId)`: Adds a new node... | codefeedback |
You are tasked with creating a program that simulates a simple banking system. The system should be able to create and manage bank accounts, allowing users to deposit, withdraw, and check their balance. Additionally, the program should support transferring funds between accounts.
Your task is to implement the `Bank` s... | codefeedback |
You are tasked with creating a role-based access control system for a web application. The application has two user roles: "Admin" and "Employee". You need to implement a method that checks whether a given user has the necessary role to access a specific feature.
You are provided with a class `CustomRole` that contain... | codefeedback |
You are tasked with implementing a Python class that handles the serialization of synthetic enzyme data. The class should provide methods for both standard and long-form serialization, as well as the ability to log the serialization process to a JSON file.
Your task is to create a class `SynthaseSerializer` with the f... | codefeedback |
You are tasked with creating a class decorator in TypeScript that validates the length and non-empty nature of a property. The decorator should ensure that the property is a string, not empty, and does not exceed a specified maximum length. Your task is to implement the class decorator `ValidateStringProperty` that can... | codefeedback |
You are tasked with creating a Java class that represents a product with various attributes. The class should be designed to be serialized to JSON using the Jackson library. Below is a partial code snippet for the product class:
```java
import com.fasterxml.jackson.annotation.JsonProperty;
public class Product {
... | codefeedback |
You are tasked with creating a Python program that simulates a simplified web page fetching and processing system using asyncio. The program will fetch multiple web pages concurrently, wait for their completion, and then process the responses. Your goal is to implement the necessary functions and logic to achieve this.... | codefeedback |
You are tasked with implementing a simplified version of a mail system in Python. Your goal is to create a class that represents an email message and a mail system that can send and receive these messages. The `Mail` class should have the following functionalities:
- A method `send_mail` that takes a `Message` object a... | codefeedback |
You are working on a neuroimaging data analysis pipeline using the AFNI software suite. As part of the pipeline, you need to write a script to apply cluster results to each output file and then perform the same operation on NIfTI files with a liberal threshold.
You have a code snippet that uses various AFNI commands a... | codefeedback |
You are tasked with implementing a custom logging system for a Python application. The logging system should support different log levels and be able to write log messages to a file. You are provided with a basic logger module called `easy_logger`, which contains the following functions:
1. `set_log_level(level)`: Thi... | codefeedback |
You are tasked with creating a Python script that automates the process of setting up a new Anaconda environment on a Linux system. The script should install Anaconda, create a new conda environment, and activate it. Your script should take the following inputs:
- `install_dir`: The directory where Anaconda will be ins... | codefeedback |
You are tasked with implementing a program to extract linguistic constructions from a given UCCA corpus. The UCCA (Uniform CoNstructional Annotation) corpus is a linguistic resource that annotates text with a graph-based representation of its grammatical structure. The program should take as input the corpus in the for... | codefeedback |
You are tasked with implementing a method to set the positions of objects in a 2D space. The method should take a list of objects and arrange them in a grid-like pattern, ensuring that no two objects occupy the same position. The objects should be positioned in a way that minimizes the total distance between them.
You... | codefeedback |
You are tasked with implementing a photo editing feature that allows users to crop images within a specified rectangular overlay. The provided code snippet is part of a larger photo editing application and contains methods related to image cropping and manipulation.
Your task is to implement the `crop()` method and th... | codefeedback |
You are tasked with implementing a simple buffered output system in Rust. The system should allow for writing to a buffer and then flushing the buffer to the standard output. You are provided with a code snippet that sets up the initial infrastructure for the buffered output system using Rust's standard library.
Your ... | codefeedback |
You are tasked with creating a Python class that simulates a simple banking system. The class should have methods for depositing funds, withdrawing funds, checking the balance, and displaying the account information. Additionally, the class should incorporate basic security features to prevent unauthorized access.
You... | codefeedback |
You are tasked with implementing a GUI-based encryption tool using Python's tkinter library. The provided code snippet is a part of the GUI setup for the encryption tool. The snippet includes event bindings for the "Return" key, configuration settings for disabled elements, and window position adjustment.
Your task is... | codefeedback |
You are tasked with creating a Python function that processes and splits a dataset into training and testing sets. The dataset consists of features and corresponding classes, and the function should perform the following steps:
1. Concatenate three sets of features (DatasetFeatures1, DatasetFeatures2, DatasetFeatures3... | codefeedback |
You are tasked with creating a program that simulates a simple network client-server interaction. The server is listening on localhost at port 9090, and upon receiving a specific message, it performs an operation and sends back a response. The client program needs to send the message to the server and display the hexad... | codefeedback |
You are tasked with implementing a function that extracts the class names from a given HTML code snippet. The function should take the HTML code as input and return a list of unique class names found within the code.
Write a function `extract_class_names(html_code: str) -> List[str]` that takes a string `html_code` re... | codefeedback |
You are tasked with implementing a Python function to perform image augmentation using the imgaug library. Image augmentation is a common technique used in machine learning and computer vision to artificially expand the size of a training dataset by applying various transformations to the original images. The imgaug li... | codefeedback |
You are tasked with implementing a custom adapter class for a list of accounts in an Android application. The adapter will be used to display the accounts in a RecyclerView and allow for drag-and-drop functionality. The provided code snippet is the constructor of the adapter class, which takes an instance of a ToolbarA... | codefeedback |
You are tasked with implementing a simple game where a player navigates through a grid-based maze. The maze is represented as a 2D grid, where each cell can be either empty (denoted by '0') or blocked (denoted by '1'). The player can move up, down, left, or right, but cannot move into blocked cells. The player starts a... | codefeedback |
You are tasked with implementing a simple virtual machine that can perform arithmetic operations on integers of various sizes. The virtual machine operates on a stack-based architecture and supports four basic arithmetic operations: addition, subtraction, multiplication, and division. Additionally, the virtual machine ... | codefeedback |
You are tasked with implementing a custom validation system for a MongoDB database using the Java MongoDB driver. The `ValidationOptions` class provides a way to configure validation rules for a collection in MongoDB. Your goal is to create a program that sets up validation options for a collection and then retrieves t... | codefeedback |
You are tasked with optimizing the execution of a Java application running on a cloud server. The provided code snippet is a Bash script used to start the Java application in a detached screen session. The script specifies various JVM options to optimize the application's performance and memory usage. Your goal is to a... | codefeedback |
You are tasked with implementing a function that validates and parses a given input to produce a specific output. The input consists of a sequence ID and a dot-bracket structure. The sequence ID is a string representing an identifier, and the dot-bracket structure is a string containing a sequence of characters, where ... | codefeedback |
You are tasked with implementing a parser for a specific file format that contains account numbers. Each account number is represented as a series of lines, where each line contains a sequence of characters that form a digit. Your goal is to write a parser that takes the raw lines as input and returns an array of accou... | codefeedback |
You are tasked with creating a Python function that merges batches of data from a specified folder using multiprocessing. Your task is to implement the `mergeBatches` function, which takes in several parameters to perform the merging operation efficiently.
The function signature is as follows:
```python
def mergeBatch... | codefeedback |
You are tasked with creating a database migration for an event booking system using Laravel's Eloquent ORM. The database schema should include fields for event booking entries, such as event code, membership type, contact person, registration type, member number, names, ID number, and registration number.
Your task i... | codefeedback |
You are tasked with implementing a function to reverse a singly linked list. You are given the definition of a ListNode class as follows:
```cpp
template <typename T>
class ListNode
{
public:
T value;
ListNode<T>* next = nullptr;
~ListNode() { delete next; }
};
```
You need to implement the following func... | codefeedback |
You are tasked with creating a script to validate the existence and executability of a list of executables. The script should iterate through the list of executables and check if each one exists and is executable. If an executable is not found or is not executable, an error message should be printed to the standard err... | codefeedback |
You are tasked with implementing a throttle controller for an autonomous vehicle. The vehicle's throttle, brake, and steering commands are determined based on the cross-track error (cte), sample time, linear velocity, current velocity, deceleration limit, vehicle mass, and wheel radius. The throttle controller is respo... | codefeedback |
You are tasked with implementing a user management system for a web application. The system has three types of users: regular users, admins, and super-admins. Each user has the ability to delete other users based on their role. The following rules apply:
- Regular users can only delete themselves.
- Admins can delete o... | codefeedback |
You are tasked with creating a JavaScript function that processes date ranges and retrieves case numbers from local storage. The function should perform the following tasks:
1. Check the current month and format it with a leading zero if it is less than 10.
2. Set the `date_range` object with a start date of January 1s... | codefeedback |
You are tasked with creating a Swift function that interacts with a web service to retrieve and process JSON data. The function should handle the response from the web service and decode the JSON data into a specific Swift struct. Your task is to implement the function that accomplishes this.
You are provided with the... | codefeedback |
You are tasked with creating a shell script that automates the process of initializing a new Git repository and setting up a remote origin. The script should take the following steps:
1. Determine the absolute path of the directory containing the script and navigate to its parent directory.
2. Extract the base name of... | codefeedback |
You are tasked with implementing a custom hook for form handling in a React application. The hook should provide functions for handling changes, blur events, and form submissions. Additionally, the hook should integrate with a custom components hook to access specific components for a sign-up form.
Your task is to cre... | codefeedback |
You are tasked with creating a Swift package that simulates a mock URLSession for testing network requests in iOS applications. Your goal is to implement a `MockURLSession` class that mimics the behavior of URLSession, allowing developers to define and verify expected network requests and responses in their unit tests.... | codefeedback |
You are tasked with creating a Bash script to automate the process of capturing webcam photos using the `fswebcam` command-line tool. The script should check if the `fswebcam` tool is installed, create a directory to store the photos if it does not exist, and then capture a photo using the webcam.
Your script should p... | codefeedback |
You are tasked with implementing a Python class for executing star operations on a query. The class `Star` inherits from `QueryCommand` and has an `execute` method that sends a PATCH request to star a specific query. The `execute` method catches any `RequestError` and raises a `BusinessError` with a custom error messag... | codefeedback |
You are given an array of integers `a` of size `n`. You need to perform `q` queries on this array. Each query consists of an integer `x`. For each query, you have to find the number of elements in the array `a` that are less than `x`.
Write a function or method that takes in the array `a`, its size `n`, an array of qu... | codefeedback |
You are given a Python code snippet that involves manipulating quantum states using Pauli operators. Your task is to create a function that simulates the action of a Pauli operator on a quantum state and returns the resulting state and the corresponding coefficient.
You need to implement the `compute_action` function,... | codefeedback |
You are tasked with implementing a database client factory function in Python. The function should dynamically load and instantiate the appropriate database client based on the provided database provider and connection configuration. Additionally, the function should validate the availability of the specified database ... | codefeedback |
You are tasked with creating a PHP script that reads environment variables from a `.env` file using the `vlucas/phpdotenv` library and establishes a database connection using the configuration details from the `.env` file.
Your task is to complete the PHP script by implementing the following steps:
1. Load the environ... | codefeedback |
You are tasked with creating a function that processes a given string to extract specific information based on a predefined pattern. The pattern consists of a series of commands enclosed in curly braces, each command representing a specific action to be performed on the input string. Your task is to implement the funct... | codefeedback |
You are tasked with creating a Python program to manage a queue of tasks using multithreading and serial communication. The program should utilize the `serial` library to communicate with an external device and manage a queue of tasks using multithreading.
Your program should have the following functionalities:
1. Ini... | codefeedback |
You are tasked with creating a custom tab bar controller for a mobile application. The tab bar controller should consist of two tabs: "Balance" and "Transactions". Each tab should be associated with a navigation controller and a corresponding view controller. The "Balance" tab should display the `BalanceController` and... | codefeedback |
You are tasked with creating a custom exception handler for a Python web application framework. Your goal is to implement a function that raises a specific exception when a template file is not found during the rendering process.
You are provided with a basic code snippet that uses the `pytest` library to test the exc... | codefeedback |
You are tasked with implementing a Java method that scales a list of Android `View` objects using the `ExpectAnim` library. The `ExpectAnim` library provides a way to create smooth and flexible animations for Android views. Your task is to complete the implementation of the `scale` method in the `Scale` class within th... | codefeedback |
You are given a code snippet that manipulates vectors in a 3D space using a custom `Vector3` class. The code snippet is part of an orthonormal basis (ONB) construction process, where three mutually perpendicular unit vectors `onb.u`, `onb.v`, and `onb.w` are being computed.
The `onb` object represents the orthonormal ... | codefeedback |
You are tasked with implementing a custom Polynomial class in C++. The Polynomial class should support addition, subtraction, and output operations. The class should be able to handle polynomials of any degree and should provide appropriate operator overloading for the operations.
Your task is to complete the implemen... | codefeedback |
You are tasked with creating a Python function that processes the response from a REST API and extracts specific information based on the response status code and other conditions. The function should handle scenarios where a project does not exist, the response status code is 200, and certain conditions related to App... | codefeedback |
You are tasked with creating a JavaScript function that interacts with the Ethereum blockchain using the Web3 library. Your function should send a specified amount of Ether from one Ethereum account to another. You will need to handle any potential errors and ensure that the transaction is successfully executed.
Your ... | codefeedback |
You are tasked with implementing a class for generating SQL statements based on specified parameters. The class, `Items`, takes in arguments for date range, type group, order by, and number of items to retrieve. The `write_statement` method of the class should construct and return an SQL statement based on the provided... | codefeedback |
You are tasked with implementing a function that extracts class-balanced patches from full images. The function should take in full images and return class-balanced patches with a specified shape and number of channels.
You are given the following function signature and documentation:
```python
def extract_class_bala... | codefeedback |
You are tasked with implementing a function to calculate the virial radius of a dark matter halo in a cosmological simulation. The virial radius is defined as the radius within which the average density is a certain multiple (denoted by `odelta`) of the critical density of the universe at the redshift of the halo. The ... | codefeedback |
You are working on an image processing project and need to implement a specific set of operations on an input image using the OpenCV library in Python. Your task is to write a function that takes an input image and performs the following operations in sequence:
1. Apply a thresholding operation to the input image usin... | codefeedback |
You are tasked with simulating a multi-agent system to navigate through a grid-based environment with obstacles. Each agent must find the shortest path from a start point to a goal point while avoiding the obstacles. The agents can move in four directions: up, down, left, and right. The goal is to determine the average... | codefeedback |
You are tasked with implementing a function that processes a list of strings and returns a boolean value based on certain conditions. The function should iterate through the list and return True if any string contains the word 'No', and False otherwise. However, the function should also handle exceptions gracefully and... | codefeedback |
You are tasked with implementing a class `Tester` that has a method `test` which takes a function as an argument and returns the result of executing that function. Additionally, you need to create a program that utilizes the `Tester` class to test various functions.
Your task is to implement the `Tester` class and wri... | codefeedback |
You are tasked with implementing a feature flag system for a software library. The library has various features that can be enabled or disabled using feature flags. The code snippet provided is a simplified representation of the feature flag system using the Rust programming language.
The `has_xcb_xinerama_query_scree... | codefeedback |
You are tasked with implementing a simple panic handler for a bare-metal Rust application. The provided code snippet is a part of the panic handler function, which is called when the application encounters a panic. The `panic` function takes a reference to `PanicInfo` and returns a never type (`!`), indicating that it ... | codefeedback |
You are tasked with implementing a class that represents a running session. The class should have a method to calculate the total number of run cycles completed during the session. A run cycle is defined as the combination of alternating periods of running and walking. The class should also have methods to record the d... | codefeedback |
You are tasked with implementing a Python class method that returns a string representation of an object. The method should return a string that, when evaluated by Python, would produce an equivalent object. Your task is to complete the implementation of the `test_repr` method in the given Python class.
```python
clas... | codefeedback |
You are tasked with implementing a custom logging system for a software application. The logging system should support different log levels (e.g., DEBUG, INFO, WARNING, ERROR) and be able to output log messages to various destinations such as the console, a file, or a network socket.
Your task is to design and impleme... | codefeedback |
You are tasked with creating a function to analyze ice hockey player pairings and line combinations. The function will take in the season, game, and homeroad parameters, and then perform various manipulations on the data to extract relevant information. Specifically, the function will retrieve line combinations, player... | codefeedback |
You are tasked with developing a program to analyze a given signal and identify the peaks in the signal using Python's scientific computing libraries. The signal processing involves using various functions from libraries such as `cv2`, `imalgo`, `sys`, `plotting`, `matplotlib.pylab`, and `scipy`. Your task is to implem... | codefeedback |
You are tasked with creating a script to automate the installation and usage of a code coverage tool for a Rust project. The code snippet provided is a part of the script and checks for the existence of the `grcov` command, installs it if it's not available, and then uses it to generate code coverage reports.
Your tas... | codefeedback |
You are tasked with creating a Python function that extracts the version information from a given module and returns it in a specific format. The module contains version-related variables and a tuple conversion function. Your task is to implement the function `extract_version_info` that takes the module as input and re... | codefeedback |
You are tasked with creating a program that reads and processes 3D model data from a Wavefront OBJ file. The Wavefront OBJ file format is a simple text-based format for representing 3D models, including vertices, normals, texture coordinates, and faces. Your program should read the OBJ file, extract relevant data, and ... | codefeedback |
You are tasked with creating a Python function that generates a scatter plot with a line plot overlay. The scatter plot should display real data points, while the line plot should represent predictions made by a neural network (NN). Your function should take in the real data points (`x` and `y`), the predicted data poi... | codefeedback |
You are tasked with implementing a program to process and analyze location data. The input consists of a 2D array `loc` containing location coordinates. Each row of the array represents a location, and each column represents a coordinate (e.g., latitude, longitude, altitude, etc.). The code snippet provided is a part o... | codefeedback |
You are given a code snippet that appears to be a partial and corrupted implementation of a generic function in an unknown programming language. Your task is to analyze the code and reconstruct the missing parts to complete the function.
The code snippet is as follows:
```
({})
}
f
e)
func f<g>() -> (g, g -> g) -> g {... | codefeedback |
You are tasked with creating a RESTful API endpoint for a code judging platform using Flask. The API endpoint should accept a POST request with a JSON payload containing code, language, and problem ID. The code snippet provided is a partial schema for the JSON payload that the API endpoint expects.
Your task is to com... | codefeedback |
You are tasked with implementing a file encryption and decryption program using the Advanced Encryption Standard (AES) in Python. The program should allow users to encrypt a file using a given key and initialization vector (IV), and subsequently decrypt the encrypted file using the same key and IV.
Your task is to com... | codefeedback |
You are tasked with creating a Python program to process and split dataframes for training and validation. The program should calculate the time taken to load the dataframes and then split them into training and validation sets. The time taken to load the dataframes is given in minutes and seconds, and the program shou... | codefeedback |
You are tasked with implementing a shopping cart feature for an online music store. The code snippet provided is a function that populates a view with album information. Your task is to extend this functionality by creating a ShoppingCart class that allows users to add albums to their cart, calculate the total price, a... | codefeedback |
You are tasked with implementing a memo tracking system for a company. The system should allow users to create memos, update their status, and track the history of memo activities. The code snippet provided is a part of the memo system and is responsible for marking a memo as obsolete, recording the activity, and savin... | codefeedback |
You are working on a command-line interface (CLI) application that manages commands and their permissions. The application has a function `get_command` that retrieves a command by name and a function `set_command_permission` that updates the permission for a given command. The `get_command` function attempts to retriev... | codefeedback |
You are tasked with implementing a Python function that processes a JSON object and sorts its keys in a specific manner. The function should take a JSON object as input and return a string representation of the sorted JSON object with indentation.
The function signature should be:
```python
def custom_json_sort(json_o... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.