instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a method to clear a specific property in a builder class. The builder class is used to construct instances of a data structure, and the method should reset the property to its default value and update the builder's internal state accordingly.
You are given a code snippet that partially... | codefeedback |
You are tasked with implementing a configuration management system for a web application. The system should allow registering configuration parameters with various flags to control their behavior. Each parameter can have different flags, such as `FLAG_REQUIRED`, `FLAG_NOSTORE`, `FLAG_ALLOW_EMPTY`, and `FLAG_PRIORITIZE_... | codefeedback |
You are tasked with implementing a custom serialization and deserialization algorithm for a specific data structure. The data structure consists of a list of brawlers, each represented by a unique identifier and a name. The serialization algorithm should encode the data structure into a compact binary format, while the... | codefeedback |
You are tasked with creating a PHP class that manages the publishing of configuration files for a Laravel application. The class should include a method to publish a specific configuration file when the application is running in the console.
Your task is to implement the `publishConfigFile` method within the given `Co... | codefeedback |
You are tasked with implementing a function to retrieve comments from a YouTube video using the YouTube Data API. The function should handle pagination by retrieving subsequent pages of comments using a page token.
You are given a code snippet that partially implements the comment retrieval function. The function take... | codefeedback |
You are tasked with implementing a custom directive in reStructuredText using the `docutils` library in Python. The custom directive will create a new admonition type called "helloworld" that can be used in reStructuredText documents.
Your task is to create a class `helloworld` that inherits from `nodes.Admonition` an... | codefeedback |
You are tasked with creating a web-based system for managing drawing files and certificates for Amadeus Marine Ltd. The system should provide a solution to the risk of lost or misplaced drawing files and should have the capability to manage certificates, completed and work-in-progress drawings. Your task is to design a... | codefeedback |
You are tasked with creating a Python script to manage the start and stop operations of an OpenResty server. The script should utilize the `subprocess` module to execute commands and handle any errors that may occur during the process. Additionally, the script should replace specific placeholders in configuration files... | codefeedback |
You are tasked with implementing a function to find the smallest amicable pair of numbers. Amicable numbers are two different numbers so related that the sum of the proper divisors of each is equal to the other number. The proper divisors of a number are all positive divisors excluding the number itself.
You need to i... | codefeedback |
You are tasked with creating a program to simulate a simple messaging system using RabbitMQ. Your program should establish a connection to a RabbitMQ server, create a queue for receiving messages, and then publish a message to the queue.
Your program should use the RabbitMQ .NET client library. The code snippet provid... | codefeedback |
You are tasked with implementing a class for loading spatial data for a machine learning model. The class, `SpatialDataLoader`, is responsible for loading training and testing data for a computer vision model. The provided code snippet initializes an instance of `SpatialDataLoader` and prints the length of the training... | codefeedback |
You are given a string `input_str` containing a series of words separated by spaces. Your task is to write a Python function `capitalize_vowels(input_str)` that capitalizes all the vowels in the string. The function should return the modified string with capitalized vowels.
For example, if the input string is "hello w... | codefeedback |
You are tasked with implementing a class that represents a collection of variable-sized square matrices. The class should provide methods for adding matrices to the collection, retrieving the count of matrices in the collection, and performing a specific operation on the matrices.
You are given a code snippet from a u... | codefeedback |
You are tasked with implementing a game of life simulation using Rust. The game of life is a cellular automaton devised by the British mathematician John Horton Conway. The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, alive ... | codefeedback |
You are tasked with implementing a function that compresses an image using the JPEG format. The function should take an input image and a quality parameter, and return the compressed image data as a byte array.
The JPEG compression process involves converting the input image into a compressed format by reducing the fi... | codefeedback |
You are tasked with implementing a Minimum Latency Constrained Minimum Spanning Tree (MLCMST) algorithm for a communication network. The MLCMST problem involves finding a spanning tree in a weighted graph that minimizes the sum of edge latencies, subject to the constraint that the maximum latency of any path in the tre... | codefeedback |
You are tasked with implementing a matrix multiplication function for 4x4 matrices. The matrix is represented as a 1D array of 16 elements, where the elements are stored in row-major order. The multiplication should be performed according to the standard matrix multiplication rules. You need to write a function that ta... | codefeedback |
You are tasked with implementing a class for a game environment that features a lava floor. The provided code snippet outlines a part of the implementation for the `LavaFloor` class. Your goal is to complete the class by adding necessary member functions and variables to simulate the behavior of a lava floor in a game.... | codefeedback |
You are tasked with implementing a generic cache class in C#. The cache should have the ability to store and retrieve items of any type, and it should support a maximum capacity, evicting the least recently used item when the capacity is exceeded. You need to implement the `Cache<TItem>` class with the following method... | codefeedback |
You are tasked with creating a Python function that parses a given software license text and extracts the conditions specified in the license. The license text is provided as a string, and the conditions are listed as numbered points followed by a period and space. Your function should return a list of the extracted co... | codefeedback |
You are tasked with creating a program that parses a given URL and extracts specific components from it. Your program should take a URL as input and then parse it to extract the protocol, domain, port (if specified), path, and query parameters. The URL will be in the format: `protocol://domain:port/path?query`, where t... | codefeedback |
You are tasked with implementing a network traffic monitoring system. The system should track the start times of connections between network ports and capture snapshots of the traffic for different services. You are given a code snippet that connects network ports and records the event of a connection being built.
You... | codefeedback |
You are working on a multilingual chat application that supports different languages. The application uses a file named `localized.chat.php` to store language-specific phrases and messages. The file contains multiple "define" rows, each representing a different phrase in different languages. Your task is to write a scr... | codefeedback |
You are tasked with implementing a loot modifier system for a game entity that triggers only when the entity is killed by a player using a specific weapon. The loot modifier should have the option to consider the damage dealt by the weapon and its NBT data. Your task is to create a method that adds this loot modifier t... | codefeedback |
You are tasked with implementing a Python class that interacts with an API endpoint to retrieve information about a shop. The provided code snippet is a part of a Python SDK for the Pokepay partner API. The `GetShop` class is responsible for making a GET request to the `/shops/{shop_id}` endpoint to fetch details about... | codefeedback |
You are tasked with creating a function to find the nth digit of a given number. The function should take two parameters: the number and the index of the digit to be found. The index is 0-based, meaning the least significant digit is at index 0, the next digit is at index 1, and so on. If the index is out of range for ... | codefeedback |
You are tasked with implementing a function to find the top N most frequently occurring words in a given string. The function should take two parameters: a string `s` containing space-separated words and an integer `n` representing the number of top words to return. The function should return a list of tuples, each con... | codefeedback |
You are tasked with implementing a function that processes a given string to extract specific information. The string contains a question related to evaluating suspected non-conformity in the context of Health IT Module certification. Your task is to write a function that extracts and returns the key information from t... | codefeedback |
You are tasked with implementing a data structure to manage a stack of boolean expressions. Each boolean expression is associated with a set of variables. Additionally, you need to implement a method to retrieve a failure case based on a given name.
You are given a partial code snippet for the data structure and the m... | codefeedback |
You are tasked with implementing an asynchronous caching system for user data in a web application. The system involves managing user data, user sockets, socks, and a cache. Additionally, it requires handling WebSocket users and a PostgreSQL connection pool. The provided code snippet initializes the necessary asynchron... | codefeedback |
You are tasked with implementing a Python function for segmenting ECG (electrocardiogram) signals to detect R peaks using the Pekkanen algorithm. The algorithm is based on the work of Kathirvel et al. (2001) with some modifications, primarily involving the robust estimation of the rectified signal cutoff threshold.
Yo... | codefeedback |
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 ... | codefeedback |
You are given a list of integers. Write a function `find_max_number` to find and return the maximum number in the list. You are not allowed to use any built-in functions or methods that directly provide the maximum value.
Function Signature: `def find_max_number(arr: List[int]) -> int`
Example:
Input: [5, 8, 3, 12, 9... | codefeedback |
You are working on a project that involves using the Opticks library for geometric modeling and ray tracing. The Opticks library provides functionalities for Constructive Solid Geometry (CSG) operations and analysis. You are tasked with creating a Python script that utilizes the Opticks library to define CSG objects an... | codefeedback |
You are tasked with implementing a class that simulates a virtual user making multiple requests and storing the results. The class should have the following functionalities:
1. Initialize a virtual user and an array to store request results.
2. Provide a method to make a request and store the result.
3. Calculate the ... | codefeedback |
You are tasked with creating a Python function that validates and processes connection information for a relational database management system (RDBMS). The function should take a dictionary containing connection details as input and return a modified dictionary with the connection information formatted according to spe... | codefeedback |
You are tasked with creating a Django REST framework API for managing messages and provinces. The given code snippet is a part of the URL configuration for the API. The `v1_api` is being used to register resources for handling sent messages, trashed messages, and provinces. The `urlpatterns` variable is used to include... | codefeedback |
You are tasked with implementing a generic view builder in Swift. The provided code snippet is a part of a generic view builder framework. The `buildEither` function is intended to create an instance of `EirtherView` which can hold either a `TrueView` or a `FalseView`. The `TrueView` and `FalseView` are both subclasses... | codefeedback |
You are tasked with implementing a Python class to manage email messages. The class should have the following functionalities:
- Store the sender's email address, subject, and message body.
- Provide a method to return a string representation of the email message in the format "From: sender_address\nSubject: subject\nM... | codefeedback |
You are tasked with creating a program to determine the travel restrictions for different Australian states and territories based on the given rules. The rules are provided in the form of HTML snippets, each containing the travel restrictions for a specific region. The restrictions include being open to all, closed to ... | codefeedback |
You are tasked with creating a Python function that organizes a dataset by moving files from multiple directories into a single directory based on specific criteria. Your task is to complete the implementation of the `organize_dataset` function.
You are given the following code snippet as a starting point:
```python
... | codefeedback |
You are tasked with implementing a method to retrieve a list of epics that a subscriber is subscribed to. The code snippet provided is a part of a method that aims to achieve this functionality. The method `GetEpicsSubscribedTo` takes a `subscriberID` as a parameter and is expected to return a collection of `Domain.Mod... | codefeedback |
You are tasked with implementing a class for handling binary data storage and retrieval. The class should support writing and reading binary data to and from a file. The provided code snippet is a part of the class, showcasing the `write` and `read` methods. The `write` method is responsible for writing binary data to ... | codefeedback |
You are tasked with creating a Swift extension for a custom AWS API plugin that facilitates querying GraphQL requests. The extension should be able to handle requests of various types and provide a listener for the results. Your task is to implement the `query` method within the `AWSAPIPlugin` extension to support this... | codefeedback |
You are given a list of intervals, where each interval is represented as a pair of integers `[start, end]`. Your task is to write a function that merges overlapping intervals and returns a new list of non-overlapping intervals.
For example, given the input list of intervals:
```
intervals = [[1, 3], [2, 6], [8, 10], [... | codefeedback |
You are tasked with creating a Python program that processes a dataset using a pre-trained TensorFlow model. The program should accept command-line arguments for batch size and the path to the pre-trained model. The model should then be loaded using TensorFlow's `tf.saved_model.load` function, and the dataset should be... | codefeedback |
You are tasked with creating a program that processes the output of an Optical Character Recognition (OCR) system to identify and handle empty text elements. The OCR system has already extracted text from an image and stored it in a JSON file. Your program needs to read this JSON file, identify any empty text elements,... | codefeedback |
You are tasked with implementing a class for managing academic subjects in a database. The class has a method for saving subject information to the database. Your task is to complete the implementation of the `save` method by adding the necessary code to insert subject information into the database table. You will also... | codefeedback |
You are tasked with implementing a function that checks the validity of HTML tags in a given string. The function should return `true` if all the opening and closing tags in the string are properly nested and balanced, and `false` otherwise.
The function should consider only the following tags: `<div>`, `</div>`, `<s... | codefeedback |
You are tasked with creating a custom transformer class in Python for data preprocessing. The transformer should implement a fit method that calculates the mean and standard deviation of each feature in the input data and a transform method that standardizes the input data based on the calculated mean and standard devi... | codefeedback |
You are tasked with implementing a gradient descent algorithm for a function with one variable. Gradient descent is an iterative optimization algorithm used to find the minimum of a function. The goal is to minimize a given function by adjusting its input parameter iteratively. Your task is to implement the gradient de... | codefeedback |
You are tasked with implementing a custom vector class, `EuclideanVector`, which represents a mathematical vector in n-dimensional space. The class should support type conversion to and from `std::vector<double>`. Your task is to implement the conversion operator from `EuclideanVector` to `std::vector<double>`.
The `E... | codefeedback |
You are tasked with creating a Rust function that generates code for validating floating-point numbers based on certain options. The function should take in three parameters: `range` of type `ValidatorRangeOption`, `nan` of type `ValidatorOption`, and `f` of type `f64`. The `ValidatorRangeOption` enum has two variants:... | codefeedback |
You are tasked with implementing a class for multidimensional arrays and overloading mathematical operations for it. Specifically, you need to implement the `log` function for the NDArray class, which computes the natural logarithm of each element in the array.
You are given a code snippet that tests the `log` functio... | codefeedback |
You are working on a project that involves downloading and clipping raster files. Your task is to implement a function that downloads a file from a given URI, then clips it based on a specified bounding box. If the bounding box covers the entire file, the function should create a hardlink instead of clipping the file. ... | codefeedback |
You are tasked with implementing a Python class method that processes media requests and returns a DeferredList object. The method takes in two parameters: `item` and `info`. The `get_media_requests` method retrieves media requests for the given item and info, and `arg_to_iter` converts the result into an iterable. The... | codefeedback |
You are tasked with creating a function that will parse and extract the button text from a given HTML code snippet. The button text is enclosed within the `<button>` tag and may contain additional attributes. Your function should be able to handle different variations of the `<button>` tag and extract the text content ... | codefeedback |
You are tasked with implementing a class hierarchy for vectors in a 2D space. The code snippet provided is a part of a program that uses this class hierarchy to read input from a file, create vector objects using different factories, and then perform a parallel test on the vectors.
Your task is to complete the impleme... | codefeedback |
You are working on a project that involves building and deploying a Docker image using a specific set of commands. Your task is to write a script that automates this process by extracting a tar.gz file, building a Docker image, and then cleaning up the extracted files.
You are given the following commands as a startin... | codefeedback |
You are tasked with implementing a simplified version of an OAuth constructor in PHP. The OAuth constructor takes an object implementing the `RequestInterface` and initializes the OAuth client with the provided request object.
Your task is to create a PHP class `OAuth` with a constructor that accepts an object impleme... | codefeedback |
You are tasked with implementing a custom navigation drawer for a mobile application. The navigation drawer should have the ability to animate its opening and closing. You are provided with a code snippet from the constructor of a class responsible for creating the custom navigation drawer. Your task is to complete the... | codefeedback |
You are tasked with creating a Python function that interacts with the Binance Futures Testnet API to retrieve the current price of a specified cryptocurrency pair. The Binance Futures Testnet API is used for testing purposes and simulates the behavior of the actual Binance Futures API. The base URL for the testnet is ... | codefeedback |
You are working on a project to develop an image classification model using TensorFlow. As part of the data preprocessing pipeline, you need to implement a function to perform data augmentation on the test dataset. The code snippet provided below is a part of the data preprocessing pipeline for the test dataset.
```py... | codefeedback |
You are given a directory containing a large number of FASTA files, each representing genetic sequences. Your task is to write a script that efficiently compresses each file using gzip and then removes the original uncompressed file. Additionally, the script should print "Job is done." after completing the compression ... | codefeedback |
You are tasked with creating a program that reads a text file and counts the occurrences of each word in the file. For the purpose of this problem, a word is defined as a sequence of alphanumeric characters (letters and digits) separated by any non-alphanumeric character. The program should then output the list of uniq... | codefeedback |
You are tasked with implementing a command-line tool that processes batch data based on various options provided by the user. The code snippet provided is a part of the command-line tool's configuration, which uses the Swift Argument Parser library for parsing command-line arguments.
Your task is to create a Swift pro... | codefeedback |
You are tasked with implementing a priority queue data structure using a linked list in Python. The priority queue should support the following operations:
1. `insert(value, priority)`: Insert a new element with the given value and priority into the priority queue.
2. `pop()`: Remove and return the element with the hig... | codefeedback |
You are given a list of edges representing a graph and their corresponding weights. Your task is to implement a function that finds the shortest path from a given source node to all other nodes in the graph using Dijkstra's algorithm.
The graph is represented as a list of edges, where each edge is a tuple in the forma... | codefeedback |
You are tasked with creating a file upload validation system for a web application. The system should ensure that the uploaded files meet certain criteria before they are stored. Specifically, the system should validate that the uploaded files are images (in JPEG, PNG, JPG, GIF, or SVG format) and that they are require... | codefeedback |
You are tasked with implementing a Python program that simulates a simple banking system. The program should allow users to create accounts, deposit and withdraw funds, and check their balance. The program should also ensure that account balances are not allowed to go negative.
Your task is to implement the `BankAccou... | codefeedback |
You are tasked with implementing a simplified version of an authentication handler for a tunneling system. The provided code snippet is a partial implementation of an authentication handler trait for a simple acknowledgment-based authentication mechanism.
The `SimpleAckAuthenticationHandler` struct implements the `Aut... | codefeedback |
You are tasked with implementing a resource locking mechanism in a multi-threaded environment. The resource locking mechanism should prevent multiple threads from accessing the same resource simultaneously. You are given a code snippet that attempts to lock a resource using a `Lock` object and handles errors using a ca... | codefeedback |
You are tasked with implementing a function that checks the validity of a given JavaScript code snippet. The code snippet will consist of a series of lines, each containing a JavaScript statement or comment. Your function should determine if the code snippet follows a specific pattern, and return true if it does, and f... | codefeedback |
You are given the definition of a binary tree node and a Python class `Solution` that will be used to solve a specific problem related to binary trees.
Your task is to implement a method within the `Solution` class that checks whether a given binary tree is symmetric. A binary tree is symmetric if it mirrors around it... | codefeedback |
You are tasked with creating a function that generates a form for selecting interactions within a course management system. The interactions include options such as "view," "edit," and "delete" for various course elements. The function `print_interactions_selector_form` takes a `course` object as a parameter and should... | codefeedback |
You are given the definition of a ListNode class and a function addTwoNumbers that takes in two linked lists representing non-negative integers. The function should return a new linked list representing the sum of the two input lists.
Definition of ListNode class:
```python
class ListNode:
def __init__(self, val=0... | codefeedback |
You are tasked with implementing a Python function that simulates a command execution environment with retry functionality. The function will take in a list of commands, a retry interval, and a choice of shell, and execute the commands in the specified shell environment. If a command fails, the function should retry th... | codefeedback |
You are tasked with designing a file download manager in Android that utilizes OkHttp for downloading files. Your goal is to implement a solution that ensures the file downloads occur in a background thread to prevent blocking the main UI thread.
Your task is to create a class that manages file downloads using OkHttp ... | codefeedback |
You are tasked with implementing a game state management system using the Memento design pattern. The Memento pattern allows an object's state to be captured and restored at a later time without violating encapsulation. Your goal is to create a Java program that utilizes the Memento pattern to save and restore the stat... | codefeedback |
You are tasked with creating a Python function that simulates the behavior of a simple text-based game. The game involves a player navigating through a grid-based world, collecting treasures, and avoiding obstacles. The player's position and the layout of the world are represented by a 2D grid. The player can move up, ... | codefeedback |
You are tasked with implementing a data aggregation system for a distributed computing environment. The system consists of an aggregator and multiple worker nodes. The aggregator is responsible for collecting and processing data from the worker nodes. Each worker node runs a specific task and sends its results to the a... | codefeedback |
You are tasked with implementing a custom operator pipeline system for a data processing framework. The framework provides a base class `OperatorBase` for creating custom operators, and it supports multiprocessing for parallel execution. The code snippet provided initializes some shared resources and data structures fo... | codefeedback |
You are tasked with implementing a class for information retrieval evaluation metrics. The class should include methods for calculating precision at k (p@k) and average precision (AP) for a given set of retrieved items and relevant items.
You are provided with a code snippet representing the attributes of the class:
... | codefeedback |
You are given a sequence of integers representing the operations performed on a tape. The operations include pushing and popping elements from the tape. Your task is to implement a function that simulates the operations and returns the final state of the tape after all the operations have been applied.
The tape is ini... | codefeedback |
You are tasked with creating a custom admin interface for managing different types of financial transactions in a web application. The provided code snippet registers various models with the admin interface in Django, a popular web framework for Python. Each registered model is associated with a specific ModelAdmin cla... | codefeedback |
You are tasked with creating a Python function that processes form data submitted via a POST request in a web application. The function should handle the form data and perform specific actions based on the input.
Write a Python function `process_application_form` that takes in a `request` object representing the HTTP... | codefeedback |
You are tasked with implementing a program that can efficiently count the occurrences of a given word in a large text file. The program should be able to handle files of any size and provide the count of occurrences for the specified word.
Your task is to write a function `countWordOccurrences` that takes two paramete... | codefeedback |
You are tasked with implementing a simplified version of a page store management system. The system is responsible for storing and deleting pages identified by unique page IDs. The provided code snippet is a part of the existing implementation and contains the `delete` method, which removes a page from the page store.
... | codefeedback |
You are tasked with creating a Python class that simulates a simple catalog system. The catalog should be able to update its count and calculate the relative count based on the previous count. Your task is to implement the `Catalog` class with the following methods:
1. `update_count(count)`: A method that takes an int... | codefeedback |
You are tasked with implementing a social media app's navigation system. The app has a tab bar controller with three tabs: Home, Mentions, and Profile. Each tab corresponds to a navigation controller with a view controller for displaying tweets. The provided code snippet initializes the view controllers for the Home an... | codefeedback |
You are tasked with creating a Bash script that handles errors and displays error messages in Japanese. Your script should define three functions: `error_message`, `error_handler`, and `main`. The `error_message` function takes an error message as an argument and prints it in red, along with the command name. The `erro... | codefeedback |
You are tasked with implementing a Python function that visualizes data using a line plot with two distinct collections of points. The function should take in two sets of data points, a title for the plot, and the x-axis limits. The function should then create a line plot with two distinct collections of points, set th... | codefeedback |
You are tasked with implementing a simple adapter pattern in Rust. The adapter pattern is a structural design pattern that allows the interface of an existing class to be used as another interface. It is often used to make existing classes work with others without modifying their source code. In this problem, you are r... | codefeedback |
You are tasked with implementing a tax registry system for different types of documents. The tax registry system will allow the registration of tax rules for specific document types and conditions. Your goal is to create a class that can build a tax registry and register tax rules for a given document type.
You are pr... | codefeedback |
You are tasked with implementing a function to determine whether a user has access to a specific feature based on their roles. The function takes in the user's information and a set of roles, and it should return true if the user has access to the feature, and false otherwise. The user's roles are stored as an array of... | codefeedback |
You are tasked with creating a web application that manages a database of products. The application should have an admin interface with specific functionality and security measures. To achieve this, you need to implement a ModelView class and its associated methods.
You are provided with a code snippet that includes a... | codefeedback |
You are given a string `s` consisting of lowercase letters. Your task is to write a function to find the minimum number of cuts needed to partition the string into substrings such that each substring is a palindrome. A palindrome is a string that reads the same forwards and backwards.
For example, given the string "ab... | codefeedback |
You are tasked with implementing a logging system for a software application. The system should be able to log messages at different levels of severity and support logging to multiple destinations, such as the console, files, and network services. Your goal is to design and implement a flexible and extensible logging s... | codefeedback |
You are tasked with implementing a Python module that handles user authentication and authorization for a web application. The module should include the following functionalities:
1. User Registration: Implement a function `register_user(username: str, password: str) -> bool` that registers a new user with the given u... | codefeedback |
You are tasked with implementing a custom annotation parser for a PHP application. Annotations are a form of metadata that can be added to classes, methods, or properties in PHP code. These annotations are enclosed in special comment blocks and can be used to provide additional information or instructions to the applic... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.