instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with creating a Python class for managing data from a Fourfront server and writing test cases for its methods. The class, `FFWfrUtils`, is initialized with the server name and provides methods for accessing and manipulating metadata and keys associated with the server. Your task is to complete the implem...
codefeedback
You are tasked with implementing a Python module for colored console output. The module should provide functions for printing text in different colors and for creating rainbow-colored text. Your task is to create a Python module called `rainbow_console` that contains the following functionalities: 1. `paint(text, col...
codefeedback
You are tasked with creating a web form for a blog application using Django. The form should include a field for users to input the content of their blog post. You have been provided with a code snippet from the Django forms module that creates a textarea widget for the content field. Your task is to extend the form b...
codefeedback
You are tasked with creating a Python class that simulates a simple online store. The store should have the ability to add products, remove products, and calculate the total cost of all products in the store. Additionally, the store should be able to apply a discount to the total cost. Your task is to implement the `On...
codefeedback
You are tasked with implementing a simple logging system in Python. The system should support creating loggers with different names and logging messages with different levels of severity. The log messages should be stored in a centralized location and should be retrievable by logger name and severity level. Your task ...
codefeedback
You are tasked with creating a Python script to simulate a simple file cleanup process. The script should recursively remove all files and directories within specified paths, except for those with specific file extensions. The script should also log the details of the deleted files and directories to a separate log fil...
codefeedback
You are tasked with implementing a custom tree traversal algorithm using the provided `TreeWalker` class. The `TreeWalker` class has a method `traverse` which takes a tree structure and a callback function as parameters. The tree structure is represented as a nested list of integers, where each integer represents a nod...
codefeedback
You are tasked with implementing a custom output format class for a Hadoop-based system. The class should extend the `HiveOutputFormatImpl` and implement the `HiveOutputFormat` interface. Your task is to complete the implementation of the `TrevniOutputFormat` class by providing the missing method and ensuring that it a...
codefeedback
You are tasked with creating a function to translate account group IDs based on a given role object. The role object contains information about account group IDs, and your task is to extract these IDs and translate them into a new format. You are given a code snippet that checks if the role object contains account gro...
codefeedback
You are tasked with implementing a REST API endpoint rate limiter. The goal is to limit the number of requests a client can make to a specific endpoint within a given time window. You are provided with a code snippet from a REST API server that handles requests and responses. Your task is to design and implement a rate...
codefeedback
You are tasked with implementing a cache system that stores content and ensures that duplicate content is not added to the cache. The cache should be able to determine whether new content is the same as existing content, and if so, it should not be added as a replacement. The cache implementation should handle the inte...
codefeedback
You are given a Python code snippet that attempts to find the minimum distance between a point `X` and a set of points `X_0` in a multi-dimensional space. However, there is a bug in the code that causes it to always assign the class `0` to the minimum distance, regardless of the actual closest point. Your task is to id...
codefeedback
You are tasked with creating a Python program to manage a database of software projects using SQLAlchemy. Your program should include a class `Project` with attributes `learning`, `tech`, and `tools`, representing the technologies and tools used in the project. Additionally, you need to implement a function to add a ne...
codefeedback
You are tasked with creating a script that sets up port forwarding for SSH tunnels. The script should take a list of ports as input and construct an SSH command that forwards each port to the localhost on the same port. Your task is to write a Bash script that accomplishes this. Your script should take a list of ports...
codefeedback
You are tasked with creating a Python script that automates the process of identifying genomic variations at scale using the Espresso-Caller tool. The script should be able to take input files, execute the Espresso-Caller tool, and produce the desired output. Your script should perform the following steps: 1. Accept ...
codefeedback
You are tasked with creating a Python script that analyzes a given directory and its subdirectories to identify all Python files and count the occurrences of imported modules in each file. Your script should output a dictionary where the keys are the imported module names and the values are the total occurrences of eac...
codefeedback
You are tasked with creating a function that generates a table of contents (TOC) for a given Markdown text. The TOC should include all the headings (lines starting with one or more `#` symbols) along with their corresponding levels and line numbers. The function should return an array of objects, where each object repr...
codefeedback
You are working on a project that involves interfacing with a C++ library using Python's SWIG (Simplified Wrapper and Interface Generator). As part of this project, you need to create a Python class that acts as a proxy for a C++ `std::vector` of match objects. The C++ library provides a class `Matcher` with a method `...
codefeedback
You are tasked with implementing a simplified version of a shopping cart system using Python. The `GoCardlessShop` class represents a shop that uses the GoCardless payment system. Your goal is to implement the `GoCardlessShop` class with the ability to add items to the cart, calculate the total cost, and process the pa...
codefeedback
You are tasked with creating a program that simulates a version control system's behavior when skipping the changelog for specific libraries. The program should be able to identify and skip the changelog generation for configured libraries based on certain criteria. You are given a code snippet from a test case in a J...
codefeedback
You are tasked with creating a Python class to manage a list of tasks in a run file. The class should be able to extract task names from the run file, create task objects, and calculate the real start time for each task based on timer information. Your task is to implement the methods for extracting task names, creatin...
codefeedback
You are tasked with implementing a function to determine if a given string containing just the characters '(', ')', '{', '}', '[' and ']' is valid. The function should return true if the input string is valid, and false if it is not. A string is considered valid if: 1. Open brackets must be closed by the same type of ...
codefeedback
You are tasked with creating a program that simulates the process of parsing and extracting specific headers from an HTTP request. The HTTP request headers are represented as a string in the following format: ``` "Accept": "application/json, text/plain, */*", "recaptcha": "<KEY>", "X-CSRF-TOKEN": "<KEY>", "X-Requested...
codefeedback
You are working on a project to build a content management system (CMS) and need to implement a function to create nodes and relationships for the CMS client. The CMS is built using a graph database, and you are using a Python-based library to interact with the database. Your task is to write a Python function `create...
codefeedback
You are given two arrays, red and blue, each containing integers. Your task is to find the maximum absolute difference between the sum of elements in the red array and the sum of elements in the blue array. You need to implement the function `red_and_blue(red, blue)` that takes in two arrays of integers and returns the...
codefeedback
You are tasked with implementing a change calculator for a vending machine. The vending machine accepts coins of various denominations and needs to return the optimal combination of coins as change for a given amount. The existing coins in the machine are represented as an associative array, where the keys are the coin...
codefeedback
You are tasked with implementing a function that converts a given list of menu items into a specific format. The menu items are represented as a list of strings, where each string contains the name of the menu item. The goal is to transform this list into a nested structure that represents a menu hierarchy. The output ...
codefeedback
You are tasked with creating a program that checks whether a given Rust source code contains non-ASCII characters in byte constants. Byte constants are sequences of bytes enclosed in single quotes, such as `b'x'` or `b"abc"`. Your program should identify and report any non-ASCII characters found within these byte const...
codefeedback
You are tasked with implementing a password cracker that uses a hash function to generate potential passwords. The hash function produces a string of characters, and the password cracker must extract specific characters from the hash to form a valid password. The password is 8 characters long and can contain any alphan...
codefeedback
You are tasked with implementing a Python generator function that manages the lifecycle of a development network (devnet) for a blockchain application. The function should start the devnet, yield the URL for accessing the devnet, and then terminate the devnet process. The `start_devnet()` function is already provided ...
codefeedback
You are tasked with implementing a data structure to manage information about lost items and their finders. The data structure should support adding new items, recording the details of the person who found the item, and retrieving information about the items and their finders. You are given a list of fields that should...
codefeedback
You are tasked with implementing a custom data structure called `CustomObject` in Swift. This data structure should have the following properties and functionalities: Properties: - `initial`: A property of type `Any` to store the initial value. - `status`: A property of type `String` to store the status of the object....
codefeedback
You are tasked with implementing a restaurant repository interface for a .NET application. The interface, `IRestaurantRepository`, extends the `IBaseRepository` interface and includes two additional methods: `GetTopRestaurants` and `GetRestaurantWithMenuAsync`. Your task is to create a concrete implementation of the `...
codefeedback
You are tasked with implementing a Python class for a simple neural network layer using the PyTorch library. The provided code snippet is a partial implementation of the `LayerBiVanilla` class, which is intended to be a bidirectional vanilla RNN layer. Your task is to complete the implementation of the `LayerBiVanilla`...
codefeedback
You are tasked with implementing a fixed property module in Rust. The module should provide a way to define and manage fixed properties for objects in a system. A fixed property is a property that cannot be changed once it is set. Your task is to create a Rust module that allows users to define fixed properties for obj...
codefeedback
You are tasked with creating a Python function that retrieves a list of private keys from a plugin using given connection parameters. The `plugin.get_private_key_list` function takes keyword arguments for server username and server IP. However, the code snippet provided contains a mistake in the server username argumen...
codefeedback
You are tasked with implementing a function to calculate the Levenshtein distance between two strings. The Levenshtein distance is a measure of the similarity between two strings, which is defined as the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one string int...
codefeedback
You are tasked with implementing a Python class that manages statistics for a set of data. The class should have a method to calculate the mean of the data and another method to generate a unique ID for each instance of the class. The ID should be generated using a combination of a prefix and a unique number. Your tas...
codefeedback
You are tasked with implementing a function to convert an image into a cross-stitch pattern. The function should take an image as input and return a cross-stitch pattern based on the image's colors and dimensions. The provided code snippet is a part of the function and contains some initial calculations for determining...
codefeedback
You are tasked with creating a program that generates an image based on a given string representation of a tree structure. The tree structure consists of nodes representing color values and operations to combine them. Each node can be a color value or a combination of colors using horizontal (H) or vertical (V) operati...
codefeedback
You are tasked with implementing a Python module that manages various hooks for monitoring and profiling code execution. The given code snippet shows an excerpt from the module's `__init__.py` file, which lists the available hooks as part of the module's public interface. Your task is to create a class `HookManager` t...
codefeedback
You are tasked with creating a program that reads a file and processes its content based on specific requirements. Your program should read the content of a file and perform a series of operations on the data. The file contains a list of transactions, each represented by a string in the format "timestamp,amount,descrip...
codefeedback
You are tasked with implementing a Python function that calculates the modular inverse of a number using the extended Euclidean algorithm. The extended Euclidean algorithm is used to find the greatest common divisor (GCD) of two numbers and their coefficients that satisfy Bézout's identity. The modular inverse of a num...
codefeedback
You are tasked with implementing a neural network autoencoder for image compression using the given Python code snippet as a reference. An autoencoder is a type of artificial neural network used to learn efficient representations of data, typically for the purpose of dimensionality reduction. Your goal is to create a P...
codefeedback
You are tasked with implementing a method to convert an identifier from a byte array to a hexadecimal string representation and vice versa. The identifier is represented by a sequence of bytes, and the conversion should handle endianness properly. You are given a class `Identifier` with the following methods: 1. `Ide...
codefeedback
You are tasked with implementing a Python class method that decodes an indirect solution using the given parameters. The method should take two arguments: `solution`, which represents the solution to be decoded, and `sf`, which is a scaling factor. The method should return the decoded solution. The provided code snipp...
codefeedback
You are tasked with implementing a method to retrieve the build date as a `LocalDate` from a `BuildVersion` class. The `BuildVersion` class has a method `getBuildDateAsLocalDate()` that should return the build date as a `LocalDate` object. The build date is initially stored as a string in the format specified by `Build...
codefeedback
You are tasked with implementing a simplified GPIO (General Purpose Input/Output) class in C++. The class should support different types of GPIO operations, including digital input/output, PWM (Pulse Width Modulation), and servo control. Your goal is to complete the implementation of the `write` method, which sets the ...
codefeedback
You are given the definition of a binary tree node and a class `Solution` with a method `diameterOfBinaryTree`. The method takes a binary tree's root node as input and is expected to return the diameter of the binary tree. The diameter of a binary tree is defined as the number of nodes along the longest path between an...
codefeedback
You are tasked with creating a Python function that converts a given integer into its Roman numeral representation. Roman numerals are represented by seven different symbols: I, V, X, L, C, D, and M, which correspond to the decimal values 1, 5, 10, 50, 100, 500, and 1000 respectively. The conversion should follow the s...
codefeedback
You are tasked with implementing a parallelized matrix multiplication using OpenMP in C++. Given two square matrices A and B of size N x N, your goal is to create a parallelized kernel function that computes the product of these matrices. The kernel function should be defined within the RedMF::Kernel namespace and shou...
codefeedback
You are working for a web hosting company that needs to automate the process of cleaning up the root directory of a web server. The company wants to remove a specific file, `index.html`, from the directory `/var/www/html`. Your task is to write a Python script that accomplishes this. Write a Python function `remove_in...
codefeedback
You are tasked with creating a React component that displays a list of items fetched from an API and allows the user to filter the items based on a specific criterion. The component should also include a search functionality to filter items based on a search query. You are provided with a basic structure of the compone...
codefeedback
You are tasked with creating a Python script to automate the process of cleaning and building a Python package. The script should perform the following tasks: 1. Remove the `build`, `cryptoString.egg-info`, and `dist` folders if they exist. 2. Print "clean dist folder!" after removing the folders. 3. Run the command `p...
codefeedback
You are tasked with implementing a function to parse a configuration file and retrieve specific configuration items based on a given identifier. The configuration file contains various configuration items in the form of key-value pairs. The function should be able to read the configuration file, locate the specified it...
codefeedback
You are given a list of tuples, where each tuple contains a sentence and its corresponding label. Your task is to write a function that sorts the list of tuples based on the labels in descending order. If two or more sentences have the same label, they should be sorted in lexicographical order. Write a function `sort_...
codefeedback
You are tasked with implementing a function to extract the name of a network interface from a given `IfrIfrn` union in Rust. The `IfrIfrn` union is defined with the `repr(C)` attribute and contains a single field `ifrn_name` which is an array of `libc::c_char` representing the name of the network interface. Your task i...
codefeedback
You are tasked with implementing a circular buffer data structure in Rust. A circular buffer is a fixed-size buffer that overwrites old data when the buffer is full. It has a read pointer and a write pointer, and it supports operations for reading from and writing to the buffer. The buffer should be implemented as a ge...
codefeedback
You are tasked with creating a program that processes a vocabulary file and provides various statistics about the words in the file. The vocabulary file contains a list of words, with each word on a separate line. Your program should read the vocabulary file and perform the following tasks: 1. Count the total number o...
codefeedback
You are tasked with implementing a function that handles the rendering of an Alert component based on the result of a bitrate test. The function should take in the result of the test and return the appropriate Alert message to be displayed. The Alert should be rendered when the bitrate test returns an "expired" error. ...
codefeedback
You are working on a complaint management system that interacts with a RESTful API. The provided code snippet is part of a Java class that handles HTTP requests for deleting and updating complaints. Your task is to implement a method to update a complaint by sending a PUT request to the API. You are given the followin...
codefeedback
You are tasked with creating a Bash script that configures a user with non-root privileges, but only if a user is specified. If no user is specified, the script should not change the user. Your task is to complete the Bash script by implementing the logic to achieve this configuration. The provided code snippet initia...
codefeedback
You are tasked with implementing a simple URL routing system for a web application. The system should be able to handle requests for controllers and actions, and if a requested controller is not found, it should fall back to an "EmptyController" to handle the request. You are given a code snippet for an "EmptyControll...
codefeedback
You are tasked with implementing a stretching factor calculation function for a numerical computation library. The stretching factor is used to adjust the grid spacing in a numerical method to ensure accuracy and efficiency. The function should take into account the minimum width of the domain and the number of grid po...
codefeedback
You are tasked with creating a Python function that approximates the equilibrium point of a given system using the EMIS (Energy Minimization via Iterative Surrogate) method. The EMIS method is a numerical optimization technique used to find the equilibrium point of a system by minimizing its energy. You are provided w...
codefeedback
You are tasked with creating a Python class that manages channel aliases for different user types in a messaging system. The system has a predefined key, help category, and user controller. Your task is to create a class that inherits from the `AbstractChannelAdminCommand` and implements the necessary functionality for...
codefeedback
You are tasked with implementing a custom iterator in Rust that generates a sequence of numbers based on a given closure. Your iterator should yield the numbers produced by the closure when iterated over. Additionally, you need to write a test to ensure that the iterator behaves as expected. Your task is to complete t...
codefeedback
You are tasked with implementing a function that converts a given string from a specified base to a decimal number. The input string may include a prefix indicating the base (e.g., "0x" for hexadecimal, "0b" for binary, "0c" for octal). If no prefix is provided, the base is assumed to be 10. The input string may also i...
codefeedback
You are given a snippet of code that appears to be incomplete. Your task is to complete the code by implementing a function that calculates the average of an array of numbers. The function should take an array of numbers as input and return the average value. You need to write the missing function and ensure that it ha...
codefeedback
You are tasked with creating a Python function that takes a list of strings as input and returns a new list containing only the strings that have a length greater than 5 characters and start with the letter 'A'. If no strings meet these criteria, the function should return an empty list. Create a function called `filt...
codefeedback
You are tasked with implementing a generic resource plugin factory in C++ for the iRODS (Integrated Rule-Oriented Data System) data management software. The factory should be able to return a pointer through the generic interface of an `irods::resource` pointer. Your task is to complete the implementation of the `plug...
codefeedback
You are working on a flood monitoring system that collects water level data from various monitoring stations. Your task is to implement a function that identifies the stations with water levels over a certain threshold and plots the water levels for those stations. You are given the following code snippet as a startin...
codefeedback
You are tasked with creating a program that manipulates comment formatting within a given body of text. The program should take a body of text, a list of comment formats, and the content in which the body of text will be inserted. The goal is to modify the body of text according to the comment format and then check if ...
codefeedback
You are tasked with implementing a custom class for setting up Parallel-Split Shadow Mapping (PSSM) in a Gazebo simulation environment. The provided code snippet is the beginning of the header file for this custom class. Your task is to complete the implementation of the class `CustomPSSMShadowCameraSetup` by adding ne...
codefeedback
You are tasked with creating a Python function that resolves a relative file path to its absolute path. The function should take two parameters: `relative_path` (a string representing the relative path) and `file_path` (a string representing the absolute path of the file in which the relative path is specified). The fu...
codefeedback
You are tasked with implementing a class that simulates the behavior of a vehicle's control system. The class, named `VehicleControl`, has the following attributes and methods: Attributes: - `on`: a boolean indicating whether the vehicle's control system is on or off - `mode`: a string representing the current mode of...
codefeedback
You are working on a security application that involves analyzing and manipulating cipher blocks. Your task is to implement a function that simulates a specific cryptographic operation based on the given code snippet. You are given a Python code snippet that performs operations on cipher blocks. The code snippet inclu...
codefeedback
You are tasked with creating a Python decorator that logs the execution time of a function and prints the result to the console. The decorator should be able to handle functions with any number of arguments and keyword arguments. You should also ensure that the decorator can handle functions that return values of any t...
codefeedback
You are tasked with implementing a Python package management system that can handle the installation and removal of packages. The system should support adding, removing, and listing packages, as well as checking for package dependencies. You are given a code snippet representing the structure of the package system: `...
codefeedback
You are tasked with implementing a service for managing bus routes in a transportation management system. The system uses Angular for the front-end and TypeScript for the back-end. The code snippet provided is from the front-end component responsible for creating a new bus route. The `CreateBusRouteComponent` class ha...
codefeedback
You are tasked with implementing a function that builds a widget within a web page using the provided HTML and JavaScript code. The function should replace the content of an HTML element with the specified ID with a new HTML structure representing a widget. The provided code snippet includes an incomplete JavaScript f...
codefeedback
You are tasked with creating a Python function to implement the SubBytes operation of the Advanced Encryption Standard (AES) algorithm. The SubBytes operation is a non-linear byte substitution that operates on each byte of the input independently. The operation involves replacing each byte of the input with a correspon...
codefeedback
You are tasked with implementing a Python class that simulates a simple bank account system. The class should support basic operations such as depositing funds, withdrawing funds, and checking the current balance. Additionally, the class should keep track of the total number of transactions performed on the account. Y...
codefeedback
You are tasked with implementing a custom managed buffer pointer in Swift. A managed buffer pointer is a low-level construct used to manage the memory of a buffer that holds a specific type of data. Your goal is to create a class that provides a specialized constructor for initializing the managed buffer pointer with a...
codefeedback
You are tasked with implementing a custom equality comparison for a `Program` data type in Swift. The `Program` type represents a program and has a property `code` which is an array of objects conforming to the `ProtobufConvertible` protocol. The `ProtobufConvertible` protocol provides a method `asProtobuf()` that retu...
codefeedback
You are working on a software tool for generating circuit diagrams based on input signals. The code snippet provided is a part of a function that appends information to a global variable `payload` in order to create a circuit diagram. The function takes in three parameters: `out`, `in1`, and `in2`. If `out` is `None`, ...
codefeedback
You are tasked with creating a Python program to slice a 3D model in STL format based on specified parameters. The program should take an input STL file, apply bottom and top clipping planes, and create multiple rings within the model. The program should be able to handle command-line arguments for input file, output f...
codefeedback
You are tasked with implementing a function to calculate the values of a 2D grid using the given code snippet as a reference. The grid represents a physical system, and the function should use the provided iterative method to update the grid values based on the initial conditions and system parameters. You are given t...
codefeedback
You are tasked with implementing a function to parse a string representing a JSON array and return the parsed array. The function should handle both empty and non-empty arrays. The input string will be in the format of a JSON array, with elements separated by commas and enclosed in square brackets. The elements can be ...
codefeedback
You are tasked with implementing a custom collection class in C# that represents a collection of DOMSheet objects. The DOMSheet class represents a sheet in a workbook and provides functionality to work with the data in the sheet. Your task is to implement the custom collection class, including the IEnumerable interface...
codefeedback
You are tasked with implementing a custom PyTorch dataset class for the Vidor dataset, which is used for training a machine learning model for action recognition in videos. The Vidor dataset contains annotated video data for various action recognition tasks. Your goal is to create the `VidorPytorchTrain` class, which w...
codefeedback
You are tasked with implementing a function that searches a data structure description for fields that need to be split up based on a given direction. The data structure description is represented as a string, and the direction is specified as an integer. The function should return a list of all fields that need splitt...
codefeedback
You are tasked with implementing a class for a deck of playing cards in C++. The class should have the following functionalities: 1. A constructor that takes a file name as a parameter and initializes the deck with the cards listed in the file. 2. A destructor to clean up any resources used by the deck. 3. A method to...
codefeedback
You are working on a data visualization project and need to create a web application that displays gender-based boxplots. You have a function `update(xmax, xcon)` that takes in two parameters: `xmax` (maximum value for x-axis) and `xcon` (gender-based data to be plotted). The function `update` calls another function `p...
codefeedback
You are tasked with implementing a function that extracts the text content from a given HTML string. The HTML string may contain various tags and attributes, but the function should only return the plain text content without any HTML tags or attributes. You are given the following code snippet as an example of the HTM...
codefeedback
You are tasked with implementing a contact management system using Python. The system should allow users to create and manage contacts, including their email addresses, phone numbers, and group memberships. The code snippet provided imports the necessary modules for managing contacts, including the `Person` model and t...
codefeedback
You are tasked with creating a Python program to draw a spiral pattern using the turtle graphics library. The program should take input parameters for the number of sides, the turning angle, the color of the spiral, and the width of the lines. The turtle should start drawing the spiral from the center and gradually inc...
codefeedback
You are tasked with testing a Python function that handles token refresh requests in an authentication system. The function makes an HTTP POST request to a Keycloak server to refresh an access token using a refresh token. Your goal is to write a unit test for this function to ensure that it correctly handles the token ...
codefeedback
You are given a SHA-256 hash and its corresponding size in bytes. Your task is to write a program to find the original input data that produced this hash. The input data is a string of alphanumeric characters and symbols. You need to find the shortest possible input data that produces the given hash. Write a function ...
codefeedback
You are tasked with implementing a data validation framework in Swift. The provided code snippet includes an enum `ValidationResult` with cases for passing and failing validation, and a generic class `DataValidator` that will be used to validate different types of data. Your task is to extend the `DataValidator` class...
codefeedback