instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a fuzz testing function for a cryptographic library. The library contains a `Ciphertext` struct representing encrypted data and a `PrivateKey` struct representing a private key for encryption and decryption. Your goal is to create a fuzz testing function that takes an input of type `Inp... | codefeedback |
You are tasked with implementing a logging system in C#. The system should support multiple types of loggers, such as FileLogger, DatabaseLogger, and ConsoleLogger. To achieve this, you need to create a class that manages a collection of loggers and provides a way to add new loggers to the collection. Additionally, the... | codefeedback |
You are tasked with implementing a function to determine the tiers of tanks in a game based on their level and class. The game has specific rules for certain tanks, and the function should account for these special cases. The provided code snippet contains a partial implementation of the function `_getTiers(level, cls,... | codefeedback |
You are tasked with creating a Python class for a combined retrieval-extraction training system. The class is responsible for sampling training data and generating examples for combined retrieval-extraction training. The class has a method `get_rex_example` that samples training data and creates examples for combined r... | codefeedback |
You are tasked with creating a Python function that simulates a simple banking system. The function should allow users to create accounts, deposit funds, withdraw funds, and check their balance. Each account should have a unique account number, and the system should be able to handle multiple accounts.
Your task is to... | codefeedback |
You are tasked with creating a web form using Python's Flask framework and WTForms library. The form should include fields for a user's name, email, age, and a checkbox for agreeing to terms and conditions. Additionally, the form should have a submit button.
Your task is to create a Flask route that renders the form t... | codefeedback |
You are working on a GIS application that manages different types of files containing geographic information system (GIS) data. The application uses marker interfaces in Zope 3, a web application server written in Python, to define browser layers and mark specific file types.
Your task is to create a Python class that... | codefeedback |
You are working on a natural language processing (NLP) project and need to write a Python function to extract entities from a given text and store relationships between these entities in a database. The function should take a text as input, identify entities within the text, and then store the relationships between the... | codefeedback |
You are working on a cybersecurity tool that performs entropy analysis on files. Entropy is a measure of randomness or unpredictability in a data set. In this problem, you are tasked with implementing a function to calculate the entropy of a given data set.
You need to write a Python function `calculate_entropy(data)`... | codefeedback |
You are given an array of integers `nums`, where you need to find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.
Write a function `maxSubArray` that takes in an array of integers `nums` and returns the sum of the largest contiguous subarray.
Function signature: ... | codefeedback |
You are tasked with implementing a generic uniform builder for a custom data type in Rust. The `uniform_builder` function takes a mutable reference to `Self::UniformBuilderRepr`, which represents the builder for the custom data type, and a string `name` as input parameters. It returns a result containing either a `Unif... | codefeedback |
You are given a binary search tree (BST) and a target value. Your task is to write a function to find the smallest element in the BST that is greater than the given target value. If no such element exists, return -1.
You should implement the following function:
```java
public int findNextSmallestElement(TreeNode root... | codefeedback |
You are tasked with creating a Python program to measure the performance of various algorithms on a given dataset and log the results to a file. The program should read a list of algorithm names and corresponding functions from a dictionary called `algos`. For each algorithm, it should call the `measure_algo` function ... | codefeedback |
You are tasked with creating a program that analyzes the copyright information in a given file and extracts the year and the copyright holder. The copyright information is provided in a specific format within a comment block at the beginning of the file. The format is as follows:
```
* AEM Permission Management
* %%
... | codefeedback |
You are given a 2D matrix of integers, `matrix`, and a pair of indices `(row, k_row_i)`, representing a specific cell in the matrix. The code snippet provided attempts to access the value of the cell to the right of the given cell in the matrix. However, the code snippet is incomplete and lacks the necessary condition ... | codefeedback |
You are tasked with creating a Python function that validates a configuration dictionary for a web application. The dictionary contains settings for a Flask application, including database connection details and security configurations. Your function should check if all the required keys are present in the dictionary a... | codefeedback |
You are tasked with implementing a session management system for a web application. The system should support session expiration based on a specified time interval. You are provided with a Python class snippet that includes an `__init__` method for initializing a session with a unique ID and an optional reactor for sch... | codefeedback |
You are tasked with implementing a Python class to simulate the motion of a mechanical system. The class, named `Mechanism`, should provide methods for calculating motion parameters, generating tables, and plotting motion characteristics. The motion parameters include acceleration, velocity, and position. The class sho... | codefeedback |
You are tasked with implementing a Python class that manages a list of hosts and performs asynchronous operations to retrieve hostnames and process search operations. Your task is to complete the implementation of the given class by adding the missing methods and ensuring the proper functionality of the class.
You are... | codefeedback |
You are tasked with creating a Python class that represents a user in a system. The class should have attributes for username, email, and account status. Additionally, you need to implement methods to set the user's email, activate the account, and promote/demote the user to/from staff status.
Your task is to complete... | codefeedback |
You are working on a migration tool for a database management system. The tool supports different types of migrations, such as SQL and MongoDB migrations. The code snippet provided is a part of the migration tool's implementation.
Your task is to implement a new feature for the migration tool. You need to extend the e... | codefeedback |
You are tasked with implementing a simplified version of a map data structure in C++. The provided code snippet offers a template class `Map` and a print function for the map entries. Your task is to complete the implementation of the `Map` class by adding functionality to insert key-value pairs and retrieve values bas... | codefeedback |
You are given a grid represented as a 2D array of integers. Each cell in the grid has an initial value of 0. Additionally, you are given a list of line segments, where each segment is represented by four integers: x1, y1, x2, y2. These integers represent the coordinates of the two endpoints of the line segment in the g... | codefeedback |
You are tasked with implementing a service register for a furniture company that specializes in sofas. The register should allow users to add, remove, and retrieve information about different sofa services offered by the company. Each sofa service will have a unique ID, a name, a description, and a price.
Your task is... | codefeedback |
You are tasked with creating a Python class to manage the power management unit (PMU) of an embedded system. The PMU is controlled through an I2C interface and provides various functionalities such as battery charging, power supply monitoring, and voltage regulation. Your task is to implement a Python class that intera... | codefeedback |
You are tasked with creating a script to manage Docker containers using different Docker Compose files based on the user's input. The script should accept command-line arguments to determine which set of containers to start. The script should support the following options:
- `--dev` or `-d`: Start development container... | codefeedback |
You are tasked with implementing a class that manages RabbitMQ (RMQ) configuration settings for a messaging system. The IRMQConfigurationManager interface provides the contract for managing RMQ configurations. Your goal is to create a concrete class that implements this interface and provides functionality to manage RM... | codefeedback |
You are tasked with implementing a function that processes a series of mouse events and updates the state of an HTML element. The function should handle mouse down, mouse up, mouse out, and drag events, and it should also manage the shift key state. The function should be designed to work within the context of an HTMLA... | codefeedback |
You are working on a project that involves parsing and handling JSON data. You have a base class `JsonParser` with several methods for parsing and handling JSON nodes. Your task is to implement a subclass `CustomJsonParser` that extends `JsonParser` and overrides certain methods to customize the behavior.
The `JsonPar... | codefeedback |
You are tasked with implementing a simplified event listener system in Java. The system should allow registration of event listeners, triggering events, and notifying the registered listeners.
Your task is to create a class `EventListenerSystem` that manages event listeners and event triggering. The class should have... | codefeedback |
You are tasked with creating a custom exception class in PHP to handle invalid arguments. Your task is to implement a custom exception class called `CustomInvalidArgumentException` that extends the built-in `InvalidArgumentException` class. This custom exception class should add a new method called `getCustomMessage()`... | codefeedback |
You are given a function `climbStairs` that takes an integer `n` as its parameter. The function is intended to return the number of distinct ways to climb to the top of a staircase with `n` steps. You need to complete the implementation of the `climbStairs` function using the following algorithm:
- Initialize two vari... | codefeedback |
You are tasked with implementing a Python class that utilizes the Word2Vec algorithm to transform a given text corpus into word embeddings. Word2Vec is a popular technique used to represent words as dense vectors in a continuous vector space, capturing semantic and syntactic word relationships. Your task is to complete... | codefeedback |
You are tasked with implementing a simple caching system using Python's generator functions. Your task is to create a class `CacheManager` that has the following requirements:
1. The class should have an `__init__` method that initializes an empty list called `cache`.
2. The class should have a method called `add_to_c... | codefeedback |
You are tasked with creating a simplified version of a task scheduler in Rust. Your goal is to implement a function that schedules and executes a given task at regular intervals. You will need to use the `actix_web` and `tokio` libraries to achieve this.
You are provided with a code snippet that demonstrates the usage... | codefeedback |
You are tasked with creating a program that simulates a simple banking system. The system should be able to handle basic banking operations such as creating accounts, depositing funds, withdrawing funds, transferring funds between accounts, and providing balance information.
Your task is to implement the `BankingSyste... | codefeedback |
You are tasked with implementing a Python function that takes a dictionary as input and returns a modified version of the dictionary. The function should convert any nested dictionaries within the input dictionary into regular dictionaries. If the input is not a dictionary, the function should return an empty dictionar... | codefeedback |
You are tasked with implementing a sprite animation system for a 2D game. The provided code snippet is a part of the animation logic for a sprite in the game. The `animation` method is responsible for updating the sprite's image based on its current state.
The method has two branches based on the `state` attribute of ... | codefeedback |
You are tasked with automating the deployment process for a .NET Core web application called "NetPips" using a CI/CD pipeline. The deployment process involves building the application, updating the database using Entity Framework Core migrations, publishing the application in release mode, and starting the server as a ... | codefeedback |
You are tasked with implementing a size calculation protocol for a feed cell view in a social media app. The provided code snippet is part of a feed cell view class and includes a property `model` of type `CZFeedModel` and a property `cellComponent` conforming to the `CZFeedCellViewSizeCalculatable` protocol. The `conf... | codefeedback |
You are working on a physics simulation project and need to implement a function to calculate the Fourier harmonics of a system. The code snippet provided is a part of the implementation for this function. The function takes in several parameters and performs calculations using NumPy.
The relevant variables and operat... | codefeedback |
You are tasked with implementing a utility function to determine the type of a MIME message. MIME (Multipurpose Internet Mail Extensions) is an Internet standard that extends the format of email messages to support text in character sets other than ASCII, as well as attachments of audio, video, images, and application ... | codefeedback |
You are tasked with creating a program that simulates the functionality of the `coverageBed` command from the BEDTools suite. The `coverageBed` command calculates the depth and breadth of coverage of features in a genome, such as aligned sequence reads from a high-throughput sequencing experiment. Your program should t... | codefeedback |
You are tasked with creating a Python web application that involves user authentication using Flask. Your goal is to implement a registration and login system using Flask's blueprint feature. Blueprints in Flask are used for structuring large applications by grouping related views and other code. The code snippet provi... | codefeedback |
You are tasked with implementing a program to manage the states of a dynamic array of rows. Each row contains a collection of states. Your task is to create a class that represents a row of states and implement a method to find the maximum number of consecutive states of a given type within a row.
You are given the fo... | codefeedback |
You are tasked with implementing a custom text formatter in Python. Your text formatter should be able to format text by replacing specific placeholders with corresponding values. The placeholders will be enclosed in curly braces and will consist of alphanumeric characters and underscores only. For example, `{name}` co... | codefeedback |
You are tasked with creating a Python function that extracts specific information from a news article on the Xinhua website. The function should take an article URL as input and return a dictionary containing details such as the author, link URL, publication time, title, and all pictures associated with the article.
Y... | codefeedback |
You are tasked with implementing a text wrapping algorithm to format a given string into a paragraph with a specified maximum line width. The algorithm should wrap the text at word boundaries, ensuring that no word is split across two lines. If a word is longer than the maximum line width, it should be hyphenated and s... | codefeedback |
You are working on a project that involves processing Earth observation data using the FlyingPigeon library, which provides various utilities for handling geospatial data. One of the tasks involves renaming complex input files and managing cache paths. You need to create a Python function that can handle these tasks ef... | codefeedback |
You are working on a GraphQL-based authentication system for a web application. The provided code snippet is a part of a GraphQL mutation to verify a user's email address. The mutation takes two input variables: `id` of type UUID and `token` of type String. Upon successful verification, the mutation returns a `VerifyEm... | codefeedback |
You are given a string containing a series of parentheses, curly braces, and square brackets. Your task is to determine if the order of the brackets is valid. A valid order means that for every opening bracket there is a corresponding closing bracket of the same type, and they are properly nested.
For example, the str... | codefeedback |
You are tasked with creating a program to generate random dish names and their corresponding prices for a restaurant menu. The program should utilize the Faker library to create realistic dish names and prices. The dishes and their prices should be stored in a database table using Laravel's Eloquent ORM.
Your task is ... | codefeedback |
You are working on a movie dataset processing task. The given code snippet is a part of a function that combines a one-hot encoding table for movie tags with the original movie dataset. The function takes the original movie dataset and a one-hot encoding table for movie tags as input, and then performs the following op... | codefeedback |
You are tasked with implementing a session organizer for a conference management system. The session organizer is responsible for printing the organized conference schedule to a file and calculating the score of the organization based on certain criteria.
The provided code snippet is part of the session organizer clas... | codefeedback |
You are tasked with optimizing the performance of a YouTube downloader application. The application has a method `renderPopularVideos()` to display popular videos and a method `renderVideoPage(String videoId)` to render a specific video page. The application uses a caching mechanism to improve performance. However, the... | codefeedback |
You are tasked with creating a custom attribute system for a C# application. The attribute system should allow developers to annotate properties of a class with metadata that can be used for various purposes, such as serialization, validation, or other custom behaviors.
Your task is to implement a custom attribute cal... | codefeedback |
You are given an array `outcome` of length `n`, where each element represents the outcome of a game. The outcome array contains only 0s and 1s. You need to find the maximum number of points a player can score by following a specific set of rules.
The rules for scoring points are as follows:
- If the player wins a game... | codefeedback |
You are tasked with implementing a file transformation system for a web asset pipeline. The system should be able to compile source files using a specified compiler and then return the compiled output as a stream. Your task is to implement the `CompileAsset` class and its associated methods to achieve this functionalit... | codefeedback |
You are tasked with implementing a Python class that handles asynchronous operations and error logging. The class, named `AsyncHandler`, is responsible for managing asynchronous tasks and logging any errors that occur during their execution. Your goal is to extend the functionality of the `AsyncHandler` class by adding... | codefeedback |
You are tasked with creating a command-line utility for managing different applications within a production environment. The utility should allow users to launch various production-like applications, such as a WSGI server and a Celery worker, with the ability to specify the application to run as a command-line argument... | codefeedback |
You are given a code snippet in a fictional programming language. Your task is to analyze the code and identify the syntax errors, missing components, and potential improvements. Based on the given code, you need to rewrite the code snippet to make it syntactically correct and semantically meaningful.
Code snippet for... | codefeedback |
You are given the following C++ code snippet that manipulates a linked list using a stack:
```cpp
void manipulateLinkedList(stack<Node*>& c) {
Node* tail = nullptr;
while (!c.empty()) {
Node* tmp = c.top();
if (tail != nullptr) {
tmp->next = tail;
tail = tmp;
}
... | codefeedback |
You are tasked with creating a Python function that processes a list of objects obtained from a wallet and performs specific assertions on the objects' attributes. The objects are represented as JSON strings and need to be parsed to extract and validate certain fields.
You are given the following code snippet as a sta... | codefeedback |
You are tasked with implementing a text preprocessing function that normalizes Unicode characters in a given text dataset. The function should utilize the `textacy` library and handle potential errors using custom exceptions.
Write a Python function `normalize_text_dataset` that takes a list of strings `text_dataset` ... | codefeedback |
You are tasked with creating a Python decorator that logs the execution time of a function. The decorator should use the `time` module to measure the elapsed time and log the result using the `logging` module.
Your task is to implement the `log_execution_time` decorator function, which takes a function as an argument ... | codefeedback |
You are tasked with creating a JUnit test for a Spring Boot application. The application has a `TokensRepository` that manages tokens for user authentication. Your goal is to write a test that ensures the proper functionality of the `TokensRepository` class.
Write a JUnit test class that includes the following test ca... | codefeedback |
You are tasked with creating a custom implementation of a resource owner password validator for a user authentication system. The provided code snippet shows the beginning of a C# class named `CustomResourceOwnerPasswordValidator` that implements the `IResourceOwnerPasswordValidator` interface. The class has a construc... | codefeedback |
You are tasked with creating a script to automate the deployment of a Docker image for a Raspberry Pi virtual machine. The script should perform the following tasks:
1. Enable SSH for a Raspberry Pi OS image using a shell script located in the `$SCRIPT_DIR` directory.
2. Build a Docker image with the target `dockerpi-... | codefeedback |
You are tasked with creating a Python context manager that temporarily redirects the standard output to a file, allowing the user to suppress the output of specific code blocks. Your task is to implement the `suppress_output` context manager class, which should redirect the standard output to a file when entered and re... | codefeedback |
You are tasked with implementing a C++ template class that converts Python objects to C++ objects using the Python C API. The provided code snippet is the beginning of the implementation of the `from_python` class template. Your task is to complete the implementation of the `from_python` class template by adding a memb... | codefeedback |
You are tasked with creating a Python class that interacts with the AerisWeather API to retrieve weather data. Your class should include a method for making a custom endpoint request to the API. The provided code snippet initializes an instance of the AerisWeather class and calls the custom_endpoint method.
Your task ... | codefeedback |
You are working on a data visualization project and need to create a program that generates a scatter plot with specific requirements. The scatter plot should display data points representing the performance of students in a class. Each data point should be color-coded based on the students' grades, and the plot should... | codefeedback |
You are given a string containing a series of opening and closing parentheses. Your task is to determine if the parentheses are balanced. A string of parentheses is considered balanced if every opening parenthesis has a corresponding closing parenthesis and they are properly nested.
Write a function `isBalancedParenth... | codefeedback |
You are tasked with creating a secret management system for a company's internal applications. The system should allow for the secure storage and retrieval of sensitive information such as API keys, database passwords, and other credentials. To achieve this, you need to design a class that provides methods for storing,... | codefeedback |
You are tasked with creating a program that parses and extracts information from a given license file. The license file follows a specific format, as shown in the code snippet below:
```
* Copyright 2011 <NAME> <<EMAIL>>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this fil... | codefeedback |
You are working on a data visualization dashboard application that allows users to interact with and analyze data. The application has a feature that enables users to select a specific region within a plot, and the application then performs data filtering based on the selected region. You need to implement a function t... | codefeedback |
You are tasked with creating a Python class that represents a database table. Your class should have a metaclass that sets the table name, and it should also include methods for adding, updating, and deleting records from the table.
Create a Python class `DatabaseTable` with the following requirements:
- The class sho... | codefeedback |
You are tasked with creating a Swift program to parse and extract information from a message definition in the given code snippet. The message definition is for a `SingleJointPositionAction` in the `control_msgs` namespace. Your program should extract the following information from the message definition:
1. MD5 sum of... | codefeedback |
You are tasked with creating a Telegram bot that allows users to select a date from a calendar. The bot will utilize the `python-telegram-bot` library and the `aiogram` framework. The provided code snippet is a part of the bot's functionality, specifically handling the callback query when a user selects a date from the... | codefeedback |
You are tasked with implementing a function that initializes models based on a target culture and options. The function should handle the initialization process for various models based on the provided parameters. The target culture will determine the specific cultural or regional settings to be applied, while the opti... | codefeedback |
You are tasked with implementing a function that processes and validates waypoint epochs in a blockchain network. A waypoint is a cryptographic hash of a specific block in the blockchain, used to synchronize nodes and ensure they are on the same version of the ledger. The provided code snippet contains a part of a larg... | codefeedback |
You are tasked with implementing a function to check the effect type for a given target actor graph in a C++ application. The provided code snippet is part of a larger system that handles actor graphs and their associated effects. The function is responsible for verifying the existence of a matching animGraph type for ... | codefeedback |
You are tasked with implementing a program that measures the execution time of a specific code segment. Your program should be able to accurately measure the time taken for the execution of the code and provide the result in a human-readable format.
Your task is to create a function or method that takes the code segme... | codefeedback |
You are working on a security monitoring system that processes a list of instructions to detect potential security threats. Each instruction is represented as a string and consists of three parts: an operation code, a register identifier, and a value. The operation code can be one of the following: "MOV" (move), "ADD" ... | codefeedback |
You are tasked with implementing a function that generates unique combinations of characters from a given set. The function should take a set of characters as input and return a list of all possible unique combinations of these characters. A unique combination is a string that contains all the characters from the input... | codefeedback |
You are tasked with creating a Python Lambda function for an IoT application. The function receives a device ID and a text-to-speech (TTS) message, sends a request to an IoT device, logs the response, and returns a success message.
The function takes two parameters:
- `device_id` (string): The unique identifier of the... | codefeedback |
You are tasked with implementing a Java class called `MaskReader` that reads a text file and masks specific sensitive information. The class should provide a method `maskSensitiveInfo` that takes in the file path of the input text file and the file path of the output text file. The method should read the input file, ma... | codefeedback |
You are tasked with creating a program to parse and analyze SVG (Scalable Vector Graphics) data. SVG is an XML-based vector image format for two-dimensional graphics. Your program should be able to extract specific information from the SVG data and perform calculations based on that information.
Write a function `calc... | codefeedback |
You are tasked with creating a custom annotation processor for a Java application that uses the Hibernate framework for database operations. The goal is to implement a custom annotation `@Audit` that automatically tracks the update timestamp of entities in the database. The annotation should work in conjunction with th... | codefeedback |
You are tasked with creating a Python script that extracts relevant information from the given code snippet, which contains metadata related to a Python package. The metadata includes author email, URLs, and classifiers. Your script should parse the given code snippet and extract the following information:
1. Author's... | codefeedback |
You are tasked with creating a trajectory calculation module for a rocket simulation program. The module should be able to calculate the trajectory of a rocket given its initial conditions and environmental parameters. The code snippet provided imports a module named `trajectory_calc` which contains the necessary funct... | codefeedback |
You are tasked with implementing a Java program that parses a JSON string and extracts specific information from it. The JSON string represents a list of employees, each with their name, department, and salary. Your program should extract the names of all employees who belong to a specific department and have a salary ... | codefeedback |
You are working on developing a quantum computing library and need to implement a quantum circuit simulator. The code snippet provided includes some commented-out import statements for various quantum computing components and algorithms. Your task is to create a Python class that represents a quantum circuit and implem... | codefeedback |
You are tasked with implementing a command-line interface (CLI) menu system in C#. The provided code snippet outlines a basic structure for the `CliMenu` class, which represents a menu in the CLI. Your task is to extend this class and implement additional functionality to create a fully functional CLI menu system.
You... | codefeedback |
You are tasked with creating a PHP function that processes an array of tags and generates an HTML string representing a tag cloud. The function should take an array of tags as input and produce an HTML string containing links to the tags, styled as a tag cloud.
The function signature should be:
```php
function generat... | codefeedback |
You are given three integers `m`, `a`, and `b`, and two integers `y` and `z`. Your task is to write a function to calculate the minimum cost, `cost_0`, to achieve a specific goal. The goal is to distribute `m` items among two groups, such that the first group receives items in multiples of `a` and the second group rece... | codefeedback |
You are tasked with implementing a function that monitors network connectivity changes in an Android application. The function should utilize the provided code snippet as a starting point and build upon it to create a robust network connectivity monitoring mechanism.
Your task is to complete the implementation of the ... | codefeedback |
You are tasked with creating a Python class that processes data from a given source. The class should have methods to read, process, and output the data in a specific format. You are provided with a code snippet that imports a `DataProcessor` class from a module named `data_processor`.
Your task is to create the `Data... | codefeedback |
You are tasked with implementing a Python function that calculates the sigmoid function using the given code snippet as a reference. The sigmoid function is a mathematical function that maps any real value to the range of 0 to 1. It is commonly used in machine learning for binary classification problems.
Your task is ... | codefeedback |
You are tasked with implementing a Python class that processes image patches for a machine learning dataset. The class should handle the loading of image patches from a specified dataset directory and provide functionality to manipulate and analyze the patches. The code snippet provided is a part of the class construct... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.