instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with creating a custom attribute class in C# to provide localizable descriptions for an enum type. The attribute should allow developers to specify localized descriptions for each enum value, making it easier to internationalize the application. Your task is to create a custom attribute class called `Lo...
codefeedback
You are tasked with implementing a data calibration algorithm for a 3D color space. The provided code snippet includes a class `Grads` and a class `polyCalibration`, which are used to store and calibrate polynomial tables from a data pack. Your task is to create a function that takes the data pack file path as input, c...
codefeedback
You are tasked with implementing a function to smooth the coordinates of the vertices of a polygon using a moving average algorithm. The function takes as input an instance of `shapely.geometry.Polygon`, the number of vertices in the smoothing half-window, the number of iterations, and a boolean flag for input argument...
codefeedback
You are given an array of integers `a`. Your task is to implement a function that converts the given array into a min-heap and returns the resulting min-heap array. A min-heap is a complete binary tree where the value of each node is less than or equal to the values of its children. The root is the minimum element in ...
codefeedback
You are tasked with creating a Python program that utilizes the `System.Management` and `System.Management.Instrumentation` namespaces to retrieve system information and perform management tasks. Your program should be able to retrieve the CPU usage, total physical memory, and list all running processes on a Windows sy...
codefeedback
You are tasked with creating a Java program that interacts with a database to retrieve and display a list of items. The program uses MyBatis, a persistence framework that maps Java methods to SQL statements. Your goal is to implement a method that retrieves a list of items from the database and returns it as a JSON res...
codefeedback
You are tasked with creating a program to perform bi-gram analysis on a given input phrase. A bi-gram is a pair of consecutive words within a string of text. Your program should take a phrase as input and output the frequency of each unique bi-gram in the phrase. For example, given the input phrase "the quick brown fo...
codefeedback
You are tasked with implementing a custom macro in Rust that emulates the behavior of a `select` statement in Go. The `select` statement in Go allows for concurrent communication among goroutines, enabling them to wait on multiple communication operations. Your task is to create a Rust macro, `loop_select!`, that mimic...
codefeedback
You are tasked with implementing a Python class for managing runs of a scientific experiment. The class, named `ExperimentManager`, should have the following functionalities: 1. `is_finished()`: A method that returns `True` if all runs are finished, and `False` otherwise. 2. `create_runs_upto(n)`: A method that create...
codefeedback
You are given a set of instructions represented as a list of strings. Each instruction can be one of the following: 1. "acc x": Increase the global variable `acc` by the value of `x`. 2. "jmp x": Jump to a new instruction relative to the current one. The value of `x` can be positive or negative, indicating the number ...
codefeedback
You are tasked with implementing a version bumping function in a shell script. The function should take two arguments: the bump type and the current version. The bump type can be one of the following: 0 (for no change), 1 (for a patch update), 2 (for a minor update), or 3 (for a major update). The current version is a ...
codefeedback
You are tasked with creating a versioning system for a software project. The versioning system should automatically generate a new version number based on the current date and the number of revisions made on that date. The version number should follow the format `YYYY.R.D.R`, where: - `YYYY` represents the current year...
codefeedback
You are tasked with implementing a notification system for a blogging platform. The platform uses Django, and the code snippet provided is a part of the URL configuration for the notifications feature. When a user visits the URL `/remainder/`, the `notification` view function in the `views` module is called to handle t...
codefeedback
You are working on a Laravel application that involves seeding a database with sample data. The code snippet provided is from a Laravel migration file that seeds the database using the `call` method to execute various seeder classes. Each seeder class populates a specific table in the database with sample data. Your ta...
codefeedback
You are tasked with implementing a function that processes an array of vouchers and returns a new array containing only the unique vouchers. A voucher is represented as a string and is considered unique if it does not appear more than once in the input array. You need to write a function `getUniqueVouchers` that takes ...
codefeedback
You are working on a project that involves interfacing with a shared library written in C using Python's ctypes module. The shared library, named librmath, contains functions for mathematical operations and manipulation of geometric points. You need to create a Python wrapper for the library to perform certain operatio...
codefeedback
You are tasked with creating a build automation tool that can execute a series of commands based on a given configuration file. The configuration file will contain a list of commands to be executed in sequential order. Each command may have dependencies on other commands, and the tool should ensure that these dependenc...
codefeedback
You are tasked with creating a Rust module that handles parsing and processing intermediate representation (IR) code for a compiler. The provided code snippet includes the declaration of two modules: `ir` and `parser`. Your task is to implement the functionality for these modules to handle the parsing and processing of...
codefeedback
You are given a Java method that is intended to check whether a given string is a palindrome. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward (ignoring spaces, punctuation, and capitalization). However, the given method contains some errors and is incompl...
codefeedback
You are tasked with creating a program to manage and execute various command codes in a Trusted Platform Module (TPM) system. The command codes are represented as constants of the `CommandCodeStructure` type. Your goal is to implement a function that takes a list of command codes and executes them in a specific order. ...
codefeedback
You are tasked with creating a function that generates CSS styles based on a given theme object. The theme object contains key-value pairs where the keys represent the CSS property names and the values represent the corresponding property values. Your task is to implement the `generate_style` function that takes the th...
codefeedback
You are given a Python function `sum_list_1` that takes a list of integers `dataset` as input. The function is intended to calculate the sum of numbers in the list `dataset` where the sum of their digits is divisible by 7. However, the given code snippet is incomplete and contains errors. Your task is to complete the f...
codefeedback
You are given a Python function `src_number` that takes in a list of integers as input. The function is intended to return the source number, which is defined as the number that appears only once in the input list, while all other numbers appear exactly twice. If the input list does not contain a source number, the fun...
codefeedback
You are tasked with creating a Python script to automate the selection of test scripts based on certain conditions. The script should determine the appropriate test script to call based on the given arguments and configuration. The script should take into account the following conditions: 1. If the command-line argume...
codefeedback
You are tasked with implementing a Python function to convert a given transfer function to a linear phase. The transfer function is represented as a NumPy array, and the conversion involves performing a Fourier transform on the transfer function. Write a function `tf2linphase(h, normalize=True)` that takes in the orig...
codefeedback
You are tasked with implementing a Python class to store and manipulate information about blockchain blocks. The class, `BlockInfo`, should have the following attributes: - `block_hash`: A string representing the hash of the block. - `short_ids`: A list of integers representing short IDs associated with the block. - `d...
codefeedback
You are tasked with implementing a module dependency resolution system for a software project. The system should allow different scheduling strategies for handling module dependencies. The provided code snippet is a part of a Rust project and shows the module structure and the public re-exports of different scheduling ...
codefeedback
You are given a Python class `Count` with the following attributes and method: ```python @attr.s class Count(object): """Count class with monochromatic and bichromatic counts""" n = attr.ib() monochromatic = attr.ib(default=0) bichromatic = attr.ib(default=0) def count_edge(self, u, v): pa...
codefeedback
You are working on a robotics project and need to implement a configuration manager for a robotic arm. The configuration manager is responsible for storing and managing different joint configurations for the robotic arm. Each joint configuration is represented as a 6-dimensional array of joint angles. Your task is to ...
codefeedback
You are tasked with creating a script to automate the cleanup of a specific file in a given directory. The script should remove a file named `server.pid` located in the `/myapp/tmp/pids/` directory. Additionally, the script should handle the case where the file does not exist and should not raise an error in that scena...
codefeedback
You are tasked with implementing a Python class that manages a dictionary with additional functionality for publishing and retrieving values. The class, named `PublisherDict`, has the following methods: 1. `__getitem__(self, key)`: This method should return the value associated with the given key. If the key is associ...
codefeedback
You are tasked with implementing a validation system for a web application that allows users to create posts. The system should check if the user is a bot before allowing the post creation. You are given a code snippet from the backend controller that handles the post creation process. The snippet includes a check for ...
codefeedback
You are tasked with simulating the energy production and storage of a power plant based on the given generation mapping and raw data. The raw data contains the energy values produced by different sources, and the generation mapping specifies how these values should be aggregated into the production data. Your task is t...
codefeedback
You are tasked with creating a Python script that processes a long description of a software package and extracts specific information from it. The long description is stored in a file and is formatted in Markdown. The script should extract the name, version, description, and URL of the software package and print them ...
codefeedback
You are tasked with implementing a Python class to manage and analyze time-series data. The class, named `Data`, should have a method `add_data` to add new data points to the time-series dataset. Each data point consists of a timestamp and multiple numerical values. The `add_data` method should take a timestamp and a v...
codefeedback
You are tasked with creating a gRPC web service for a merchant client application. The application needs to support invoice functionality, and you are required to define the protocol buffer message types and gRPC service methods for handling invoices. You have been provided with a code snippet that includes a command ...
codefeedback
You are given a Rust code snippet that implements a graph data structure using depth-first search (DFS) to compute the depth of nodes and their adjacent nodes. Your task is to implement a function that finds the maximum depth of the graph and returns the node with that depth. You need to implement a function `max_dept...
codefeedback
You are tasked with implementing a function that parses a given `slugReference` string and extracts the relevant information based on the provided conditions. The `slugReference` string contains a conditional statement that selects a specific slug based on the type of content and the language. Your task is to write a f...
codefeedback
You are tasked with implementing a password validation function for a user registration system. The function should validate the password based on a set of rules and return a boolean value indicating whether the password meets the criteria. You are given a code snippet representing the rules for password validation: ...
codefeedback
You are tasked with creating a web application that utilizes the EligereVS library to manage and display voting data. The EligereVS library provides functionality for handling voting processes and displaying voting results. Your task is to implement a feature that allows users to view and interact with voting data usin...
codefeedback
You are tasked with implementing a material mapping system for a 3D model loading library. The code snippet provided is a part of the material mapping process. The `MaterialMapper` class is responsible for mapping materials from various sources to a unified format. The `RegisteredMappers` property contains the names of...
codefeedback
You are tasked with implementing a simplified version of the `transform_reduce` function, which applies a transformation and reduction operation to two arrays of the same size. The transformation and reduction operations are provided as function objects. The goal is to calculate the result of applying the transformatio...
codefeedback
You are tasked with implementing a mnemonic seed generator for different types of wallets. Mnemonic seeds are used to generate deterministic wallets, allowing users to easily back up and restore their wallets using a series of words. Each type of wallet has a specific prefix that must be included in the hash of the mne...
codefeedback
You are tasked with implementing a data structure to efficiently store and retrieve snapshot values. The data structure should support the following operations: 1. `take_snapshot()`: Take a snapshot of the current state of the data structure and return a unique snapshot index. 2. `get_value(snapshot_index, value_node)...
codefeedback
You are tasked with implementing a thread-safe scheduler class in C++ that manages a schedule of tasks. The class should provide methods to set and clear tasks at specific indices in the schedule, as well as a method to check if all tasks are completed. You are given a code snippet that includes a `std::mutex` and a `...
codefeedback
You are given a Python function that takes a list of integers as input and is intended to return a new list containing only the unique elements from the input list, preserving their original order. However, the given code snippet is incomplete and contains a logical error. Your task is to identify the error in the code...
codefeedback
You are tasked with creating a TypeScript interface for managing effects in a functional programming environment. The interface, `Effect<R, E, A>`, is defined with a method `runMain` that is annotated with a rewrite method directive. Your goal is to implement the `runMain` method in a way that adheres to the provided a...
codefeedback
You are tasked with implementing a Serial Number Diagnostic system for a manufacturing company. The system should be able to validate the serial numbers of the products being produced. The serial numbers are expected to follow a specific format and should be checked for validity based on certain criteria. The format o...
codefeedback
You are given a Python function `d` that takes eight arguments representing the coordinates of four points in a 2D plane. The function is intended to calculate the perimeter of the quadrilateral formed by these points. However, the function has some issues that need to be fixed. The function `d` has the following sign...
codefeedback
You are tasked with implementing a Python function that takes a list of integers as input and returns the frequency of each unique integer in the list as a dictionary. You are also required to handle the scenario where the input list is empty. The frequency of each integer should be calculated using the Counter class f...
codefeedback
You are tasked with creating a TypeScript function that generates CSS styles for responsive border radii in a web application. The function should take in an object of properties and return an array of CSS objects representing the responsive border radius styles. The function signature is as follows: ```typescript exp...
codefeedback
You are tasked with creating a Python script to automate the migration of collections from a MongoDB database to a PostgreSQL database. The script should utilize the `mongo_to_sql` library, which provides functionality for interacting with both MongoDB and PostgreSQL databases. The script should be able to handle the m...
codefeedback
You are tasked with creating a Python function that simulates a rocket takeoff sequence. The function should handle potential errors that may occur during the takeoff process. Your task is to implement the `rocket_takeoff` function, which takes two parameters: 1. `countdown` (integer): The countdown value in seconds ...
codefeedback
You are tasked with creating a Python class that represents a task in a to-do list application. The task should have a title, a description, a due date, and a priority level. Additionally, you need to implement a method that allows for the comparison of two tasks based on their priority levels. Create a Python class `...
codefeedback
You are tasked with implementing a Swift class for managing cryptocurrency data. The class should have properties for storing various attributes of a cryptocurrency, and a designated initializer to populate these properties from a given database row. Your task is to complete the implementation of the `CryptoCurrency` ...
codefeedback
You are tasked with implementing a simple blockchain system using Python. A blockchain is a distributed ledger that records transactions across multiple computers in a secure and tamper-proof manner. The provided code snippet is a function to initialize the blockchain by setting up the necessary database table and ensu...
codefeedback
You are given a 2D grid representing a map with cells containing either 0 or 9. The map is represented as a list of lists, where each inner list represents a row of the map. The value 0 represents an empty cell, and 9 represents an obstacle. You need to find the largest product of the sizes of three connected regions o...
codefeedback
You are tasked with implementing a Queue data structure using a linked list. The Queue class has a destructor and a method to make the queue empty. The linked list is implemented using a separate List class, which has a method to make the list empty. Your task is to complete the implementation of the Queue class by pro...
codefeedback
You are working on a project that involves image processing and machine learning. Your task is to create a program that uses the K-Nearest Neighbors (KNN) algorithm to classify colors in images based on their HSV (Hue, Saturation, Value) values. You will need to load a pre-trained KNN model, process an input image, and...
codefeedback
You are tasked with creating a Python function that simulates a database management system's command execution. The function should take in a database name, port number, and a SQL command as input, and then construct and log the corresponding command to be executed. The SQL command should include dropping existing tabl...
codefeedback
You are tasked with implementing a function that calculates the total number of unique paths from the top-left corner to the bottom-right corner of a grid. You can only move either down or to the right at any point in time. The grid is represented as a 2D array of integers, where each element represents the cost of mov...
codefeedback
You are tasked with implementing a simplified version of a command-line interface (CLI) navigation system. The CLI supports two commands: "cd" to change the current directory and "exit" to terminate the program. The "cd" command takes a single argument representing the directory to change to. Directories are represente...
codefeedback
You are tasked with implementing a caching system using Python. The provided code snippet imports a module named `caches`, which contains various caching implementations. Your goal is to create a new caching class that utilizes a specific caching strategy and implements the necessary methods to interact with the cache....
codefeedback
You are tasked with implementing a particle simulation system that includes the behavior of particles interacting with boundaries. The system should support both rectangular and circular boundaries, with specific interactions defined for each type of boundary. For rectangular boundaries, newly generated particles are ...
codefeedback
You are tasked with implementing a bytecode emitter for a custom programming language. The emitter takes floating-point numbers and converts them into a series of opcodes to be executed by a virtual machine. Your task is to complete the implementation of the `emit_value` method, which takes a `value` of type `f64` and ...
codefeedback
You are tasked with creating a script to automate the setup of a Venafi-PKI backend in HashiCorp Vault. The script should include the necessary environment variable configurations and Vault commands to enable the secrets engine, create a PKI role, and configure specific settings for the Venafi-PKI backend. Given the c...
codefeedback
You are tasked with implementing a class that manages the rendering of shadow maps in a 3D graphics application. The class contains a method `onReceiveShadowMap` that is called after activating a shader and before validation. The method takes three parameters: an OpenGL interface `g`, a texture unit context `tc`, and a...
codefeedback
You are tasked with creating a script to automate the generation of PDF files from LaTeX (.tex) documents. Your script should handle the compilation of the LaTeX document using pdflatex and optionally display the resulting PDF file using the evince viewer. Additionally, the script should reset a configuration using the...
codefeedback
You are tasked with implementing a data serialization and deserialization process for a messaging system. The provided code snippet is a part of the serialization process, using a binary writer (`bw`) to write specific data types to a stream. Your task is to complete the serialization process and then implement the cor...
codefeedback
You are tasked with creating a Python function that interacts with a network management system to retrieve information about networks to be added. The network management system is accessed through an API, and the function needs to make a request to the system to fetch the required data. You are provided with a code sn...
codefeedback
You are given a dataset containing information about passengers on the Titanic. The dataset includes a column "Name" which contains the names of the passengers. You are required to write a Python function that assigns a numerical "Title" to each passenger based on their name. The titles are assigned according to the fo...
codefeedback
You are tasked with implementing a function to process audio data and extract mel spectrogram features. The function should take in audio data, along with various parameters for spectrogram computation, and return the mel spectrogram features. You are given a code snippet that partially implements the feature extracti...
codefeedback
You are tasked with implementing a support vector machine (SVM) classifier using Python's scikit-learn library. Your goal is to build a program that performs hyperparameter tuning for the SVM classifier using cross-validation and selects the best parameters for the model. You are given a code snippet that initializes ...
codefeedback
You are tasked with implementing a class called `SyncHandlerManager` that manages different types of handlers for a messaging system. The class should have a method called `stop()` which stops all the running handlers. The handlers can be of two types: receiver handlers and client event handlers. The `SyncHandlerManage...
codefeedback
You are tasked with creating a Python function that validates the configuration of Docker Swarm nodes based on the information provided by the `docker_info` command output. The function should take the hostname of the node and the `docker_info` output as input and perform the necessary assertions to ensure the correctn...
codefeedback
You are tasked with creating a Django migration to add a new field to an existing model. The model is part of an application named "saef" and the migration should be based on the existing migration "0025_auto_20210809_1555". The new field to be added is not specified in the given code snippet. Your task is to write th...
codefeedback
You are tasked with designing a digital circuit that performs a specific operation on a set of input bits and produces the corresponding output bits. The circuit will have a set of input and output ports, and it needs to be interfaced with a clock signal. Your task is to implement the logic for this digital circuit usi...
codefeedback
You are tasked with implementing a function to perform a specific operation on a complex vector. The complex vector is represented by two arrays: one for the real part and one for the imaginary part. The operation involves calculating the magnitude of each complex number in the vector and then finding the maximum magni...
codefeedback
You are tasked with implementing a function to process an image and identify the number of objects present in it. The function takes an input image in YUV color space and two threshold values, `lower` and `upper`, to create a mask for object detection. After creating the mask, the function uses OpenCV to find contours ...
codefeedback
You are tasked with implementing a DialogEnhancer utility for a web application. The utility should provide methods for opening, destroying, and displaying different types of dialogs, such as success, info, error, warning, and confirmation dialogs. You need to create a JavaScript class that encapsulates this functional...
codefeedback
You are tasked with implementing a class that can perform nested dictionary substitutions in a given template string. The template string may contain placeholders in the form of `${...}` or `{...}` for nested dictionary keys. The class should be able to substitute these placeholders with the corresponding values from t...
codefeedback
You are tasked with implementing a function that processes a list of dependencies and returns a dictionary representing the dependency graph. Each dependency is a tuple containing two elements: the name of the module and the version number. The dependency graph should represent the relationships between modules and the...
codefeedback
You are given three integers, x, y, and bound. Your task is to find all the powerful integers that can be formed by adding the powers of x and y, where the result is less than or equal to the given bound. A powerful integer is a number that can be represented as a^i + b^j, where a and b are integers greater than 0, and...
codefeedback
You are tasked with automating the release process for a Python library called "goopylib." The release process involves pushing files to GitHub, creating a GitHub release, updating the download URL in the setup.cfg file, building a source distribution, uploading the release to TestPyPi, installing and checking from Tes...
codefeedback
You are tasked with implementing a simple layer management system for a 2D game. The provided code snippet shows a part of the layer configuration for the game. Each layer is represented by a `LayerInfo` object, which contains information about the layer, such as its depth. The `Layers` object is used to store and mana...
codefeedback
You are tasked with creating a Python class that simulates a smart plug device. The smart plug should be able to turn on and off, as well as provide information about its current state. You should also implement a method to track the total usage time of the smart plug. Your task is to complete the implementation of th...
codefeedback
You are tasked with creating a script that checks the version of the Autotools suite installed on a system. The Autotools suite includes tools like Autoconf, Automake, and Libtool, which are used for building and distributing software packages. Your script should determine the version of Autoconf and Automake installed...
codefeedback
You are tasked with implementing a function that removes a library from a Blender file using the Blender Python API. The function takes in the path of the library to be removed and should return `True` if the removal was successful, and `False` otherwise. The code snippet provided gives a glimpse of the process, but yo...
codefeedback
You are tasked with implementing a Python class that handles API endpoints for managing schedules within a workforce management system. The class should inherit from the `Auth` class and provide functionality for interacting with three specific endpoints: "accounts", "workers/scripts", and "schedules". Your task is to ...
codefeedback
You are tasked with implementing a Python class for a dataset called `CXR14Dataset` that is used for benchmarking in the context of medical image analysis. The `CXR14Dataset` class should be designed to work with a configuration object named `chexnet_config`. The `benchmark()` method of the `CXR14Dataset` class should ...
codefeedback
You are tasked with implementing a notification system for a chat application. The `Notification` struct contains the following fields: - `read`: a boolean indicating whether the user has sent a read receipt indicating that they have read the message. - `room_id`: the ID of the room in which the event was posted. - `ts...
codefeedback
You are working as a system administrator for a company that manages a large number of servers. As part of your responsibilities, you need to create a script to automate the process of archiving and moving specific directories. Your task is to write a Python script that replicates the functionality of the given shell c...
codefeedback
You are tasked with debugging a multi-threaded Java program that is intended to calculate the total of an array of integers. The given code snippet is a part of the program and contains logging statements and synchronization blocks. Your goal is to identify and fix the issues in the code to ensure that the program func...
codefeedback
You are tasked with creating a script to automate the testing of a software system. The system consists of three components: a PostgreSQL database, an HTTP server, and an AMQP (Advanced Message Queuing Protocol) service. Each component has its own set of tests that need to be run. Your task is to write a script that wi...
codefeedback
You are working on a file management system for a company. The system has various entities such as Checklists, Uploads, Files, Notes, and Comments. Each entity has a relationship with the FileRequest entity, which represents a request for a file. The FileRequest entity has properties for the associated Checklist, Uploa...
codefeedback
You are tasked with creating a script to automate the installation of software using a tool called Mason. Mason is a package manager that allows for the installation and management of software packages. Your goal is to write a Bash script that installs a specific version of the ccache software using Mason. Your script...
codefeedback
You are tasked with creating a script that monitors the response status of an application and takes appropriate action based on the status code. Your script should handle the following scenarios: 1. If the status code is 200, the script should echo "PASS: App is responding with 200" and exit with a status code of 0. 2...
codefeedback
You are tasked with implementing a function that initializes the weights for a neural network using a custom module called `clustre`. The `init_params` function from the `clustre.helpers._weights` module is responsible for initializing the weights based on the specified configuration. The `init_params` function takes ...
codefeedback
You are tasked with creating a Python class that can compare the directory structures of two given paths and report the differences. Your class should be able to identify added, removed, and modified files and directories between the two paths. Your task is to implement the `CompareCommand` class with the following re...
codefeedback
You are tasked with creating a command-line utility that parses and converts human-readable time durations into seconds. The utility should accept time durations in the format of hours, minutes, and seconds, and convert them into the equivalent duration in seconds. For example, the input '1h 30m 15s' should be converte...
codefeedback