instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with creating a Python class to simulate a caching mechanism for disk I/O operations. The cache will store frequently accessed data to improve read performance. Your task is to implement the `Cache` class with the following methods:
1. `__init__(self, size: int)`: Initializes the cache with the given si... | codefeedback |
You are tasked with implementing a custom string class, `Str`, in C++. The class should have the following functionalities:
1. A constructor that takes a C-style string (char array) as input and initializes the `str` member variable with a deep copy of the input string.
2. A destructor that deallocates the memory allo... | codefeedback |
You are tasked with creating a Rust program that simulates a file management system. Your program should be able to create, delete, and list files and directories within a specified directory. Additionally, it should be able to display the permissions of each file or directory.
Your program should have the following f... | codefeedback |
You are tasked with implementing a Python function that processes a string of comma-separated integers and returns a list containing the integers in descending order. Additionally, you need to write a unit test for this function using the `unittest` framework.
Write a function `listpicle` that takes no arguments and d... | codefeedback |
You are tasked with creating a program to manage and display a collection of catalog items. The catalog items are stored in an array `$All_Cetalogues`, where each item is an associative array with keys `id` and `url`. The program should generate HTML to display each catalog item in a grid layout, with an option to dele... | codefeedback |
You are tasked with implementing an error module in a Swift application. The error module is responsible for displaying error messages and allowing the user to take action when an error occurs. The provided code snippet outlines the initial structure of the error module.
Your task is to implement the `ErrorModuleInput... | codefeedback |
You are tasked with implementing a Java annotation processor that generates code for a custom annotation `@DatabaseTask`. The annotation is used to mark methods that perform database tasks, and the generated code should register these methods as database task handlers in a plugin system.
The `@DatabaseTask` annotation... | codefeedback |
You are tasked with implementing a potion system for a fantasy role-playing game. The game has various types of potions, each with different effects. Your task is to create a class for a specific type of potion called "GreaterPoisonPotion" in C#. The potion should have serialization and deserialization methods to save ... | codefeedback |
You are tasked with creating a layout for a collection view in an iOS app. The collection view will display items in a grid layout with specific dimensions and margins. You need to calculate the size of each item to fit the grid layout based on the given constraints.
Given constants:
- `kItemMargin`: The margin betwee... | codefeedback |
You are tasked with implementing a method to retrieve data from a database using an object-oriented approach. You are provided with a PHP code snippet that demonstrates the usage of a database query builder. Your task is to complete the implementation of the method by adding the necessary query building and execution s... | codefeedback |
You are tasked with creating a Python function that generates an email message in both plain-text and HTML formats. The function should take in the sender's email address, receiver's email address, and the content of the email. The email message should be constructed using the `email` and `smtplib` modules in Python.
... | codefeedback |
You are tasked with creating a Python class that simulates a simple logging system. Your class should have the ability to log messages with different levels of severity and display them with a timestamp and the severity level. The class should also allow the user to set the logging level, and only messages with a sever... | codefeedback |
You are working on a Python web application that manages session data using different storage mechanisms. The code snippet provided is a part of the application's configuration where classes and their constructors are being registered. The `context.registerClass` function is used to register a class along with its cons... | codefeedback |
You are working on a project that involves optimizing a planning score using OptaPlanner, a constraint satisfaction solver. Your task is to implement a constraint provider that defines inverse relation constraints for the planning score.
In the given code snippet, you can see the usage of OptaPlanner annotations and m... | codefeedback |
You are tasked with creating a unit test for a PHP class that utilizes mock objects and method stubs. The class being tested interacts with a container, repositories, and a repository resolver. Your goal is to write a unit test that ensures the proper behavior of the class under various scenarios.
Write a unit test fo... | codefeedback |
You are tasked with creating a custom servlet filter for a web application framework. The filter should log the duration of each request and response cycle in milliseconds. You will need to implement a custom servlet filter that integrates with the existing web application framework and accurately logs the duration of ... | codefeedback |
You are given a code snippet that is part of an image processing algorithm. The code processes an image by iterating through its rows and performing certain calculations. Your task is to understand the code and write a function that simulates the processing of an image based on the given snippet.
The code snippet prov... | codefeedback |
You are tasked with creating a Python Flask API endpoint for user management. Your goal is to implement a POST request handler for creating a new user. The API is already set up using the Flask-RESTPlus library, and the code snippet provided gives a glimpse of the existing setup.
Your task is to complete the implement... | codefeedback |
You are tasked with implementing a Python function that simulates a simplified blockchain mining process. In this simplified model, miners are responsible for finding a partial hash collision for a given block. The block contains a public key, a difficulty key, and a partial hash. The goal is to find a partial hash tha... | codefeedback |
You are tasked with creating a class that manages a list of count types. The class should have a method to add a new count type to the list and another method to retrieve the count types. Additionally, the class should enforce that the count type names are unique and not empty.
Create a PHP class `CountTypeManager` wi... | codefeedback |
You are tasked with implementing a function to determine if a given string `s` matches a given pattern `p`, where the pattern can contain wildcard characters `*` and `?`. The function should return `True` if the string matches the pattern, and `False` otherwise.
The wildcard `*` matches zero or more of any character, ... | codefeedback |
You are tasked with creating a script to handle file transfers and organization within a directory structure. The script should take input from the command line and perform specific operations based on the input parameters. The provided code snippet is a part of the script and contains functionality for transferring fi... | codefeedback |
You are tasked with creating a dependency injection container for a PHP application. The container should be able to manage and resolve dependencies for various transformers and validators used in the application.
You are given a code snippet that demonstrates the registration of transformers and validators into the c... | codefeedback |
You are tasked with creating a program that simulates a simple stock trading system. The program should use the `numpy` library to generate random stock prices for a given number of days and then implement a basic trading strategy to determine the best time to buy and sell the stock for maximum profit.
Your program sh... | codefeedback |
You are tasked with creating a Python function that generates a chessboard pattern using the given code snippet as a starting point. The function should take in the size of each square, the fill color, and the outline color as input parameters and return a visual representation of the chessboard pattern.
The function ... | codefeedback |
You are tasked with implementing a custom class called `FrameBorderPatch` that extends the functionality of the `ProjectedGradientDescent` class. The purpose of this new class is to apply Masked PGD (Projected Gradient Descent) to video inputs, where only the video frame is allowed to be perturbed. Each video is assume... | codefeedback |
You are tasked with implementing a serializer for a custom expression language. The language has various expression types, and you need to handle the serialization of a specific expression type called `CollM`. The `CollM` type has a variant called `Fold`, and you are required to serialize this variant using a provided ... | codefeedback |
You are tasked with implementing a function to detect and resolve collisions in a hierarchical data structure. The data structure is represented as a tree, where each node can have child nodes. The goal is to identify any nodes of type `CGComm` that share the same parent node and resolve the collisions by updating thei... | codefeedback |
You are tasked with creating a Python program that reads an encrypted file, decrypts its contents, and writes the decrypted data to a new file. The decryption algorithm is based on a simple substitution cipher, where each letter is shifted a certain number of positions down or up the alphabet.
Your program should take... | codefeedback |
You are given a code snippet written in a fictional programming language. Your task is to analyze the code and identify the syntax errors, missing elements, and logical issues to fix the code. Once corrected, you need to understand the purpose of the code and implement a specific functionality as described below.
Code... | codefeedback |
You are tasked with creating a job scheduling system using Java and the Quartz library. Your job is to implement a class that will be executed by the Quartz scheduler at a specified time. The class should log a message using the SLF4J logging framework when it is executed.
Your task is to create a Java class that impl... | codefeedback |
You are tasked with implementing a notification system for a patient registration feature in a healthcare application. The system should send a notification when a new patient is created. You are provided with a code snippet from the unit test class for the patient registration feature. Your task is to design and imple... | codefeedback |
You are tasked with implementing a Python class for controlling a home HVAC system. The class includes a method for setting the HVAC mode and a constant representing the fan-only mode. Your goal is to complete the implementation of the `async_set_hvac_mode` method and handle various HVAC modes.
You are provided with a... | codefeedback |
You are tasked with implementing a class that represents a simple game board for a vertical stacking game. The game board consists of a grid of cells, and the objective is to stack blocks vertically in each column. The provided code snippet is a part of the implementation of the `Board` class, which includes a property... | codefeedback |
You are tasked with creating a C# program that involves extending a class with a method to convert a given AnalysedDeclaration into an array of IPropertySymbol objects. The AnalysedDeclaration class has various subclasses, and the method should handle each subclass appropriately. Your task is to implement the AsPropert... | codefeedback |
You are tasked with creating a Python program to display an image on a canvas and allow users to input coordinates to mark specific points on the image. The program should use the Tkinter library for the GUI and the PIL library for image processing.
Your task is to implement a Python class that achieves the following:... | codefeedback |
You are working as a system administrator for a company that uses MySQL as its database management system. Your task is to automate the process of enabling and starting the MySQL service on a Linux server and retrieving the temporary password generated during the installation process.
Write a Bash script that accompli... | codefeedback |
You are tasked with implementing a text classification system using Python's scikit-learn library. Your goal is to preprocess a given dataset of text documents and vectorize the features using either TfIdf or CountVectorizer. However, you need to determine which vectorization method performs better for the given datase... | codefeedback |
You are tasked with implementing a Java method to process CIFAR-10 image data. CIFAR-10 is a well-known dataset consisting of 60,000 32x32 color images in 10 classes, with 6,000 images per class. The code snippet provided is part of a unit test for processing CIFAR-10 data. Your task is to complete the implementation o... | codefeedback |
You are tasked with implementing a function that processes a list of image transformation operations and applies them to a given image. Each operation is represented as a dictionary with a `type` key indicating the type of transformation and additional keys for specific transformation parameters. The supported transfor... | codefeedback |
You are tasked with implementing a circular dependency detection algorithm for a system that manages configuration sets. A configuration set is a collection of configuration parameters used by a software system. The goal is to identify circular dependencies within the configuration sets to prevent potential runtime iss... | codefeedback |
You are tasked with implementing a class method that filters a collection of data based on a given keyword. The method should construct and return an array of expressions to be used for filtering the data. The expressions should be based on the conditions provided by the input filter object. The filter object has a met... | codefeedback |
You are tasked with creating a script to automate the deployment process for a web application. The deployment process involves pulling the latest changes from a Git repository, stopping the production server, running database migrations, installing necessary dependencies, and finally starting the production server.
Y... | codefeedback |
You are tasked with implementing a function that takes a string representing an HTML table and returns the column names found in the table's header. The input string will be in the format of an HTML table with the `<thead>` and `<tr>` tags, and the column names will be enclosed within `<th>` tags.
Write a function `ex... | codefeedback |
You are tasked with creating a program that parses a YAML file containing job definitions and calculates the total time required to run all the jobs. Each job has a specified time duration, and the program should sum up these durations to determine the total time for the entire set of jobs.
You are given a YAML file, ... | codefeedback |
You are tasked with implementing a Python class that represents a Context-Free Grammar (CFG) and optionally a parse table. Your task is to complete the implementation of the `GrammarTestCase` class by adding the necessary functionality to initialize a CFG and parse table based on the provided sections and filename.
Th... | codefeedback |
You are working on a bioinformatics project to process genetic data from a DNA sequence. Your task is to write a Python function that processes genetic features from a DNA record and extracts relevant information for specific types of genetic elements.
You are given a Python code snippet that processes genetic feature... | codefeedback |
You are tasked with implementing a function that can parse a given code snippet and extract specific information from it. The code snippet is a configuration file for a build system and contains declarations for different types of build targets. Each declaration consists of a target type followed by a target name, sepa... | codefeedback |
You are given two dictionaries, `scores_1` and `scores_2`, where each dictionary contains student names as keys and their corresponding scores as values. The scores are represented as strings. Your task is to write a function that calculates the average score for each student, considering the scores from both dictionar... | codefeedback |
You are tasked with implementing a feature for a social media app that allows users to like and retweet tweets. The given code snippet is part of the implementation for handling the user's interaction with a tweet. The `liked` and `retweeted` variables indicate whether the current user has liked or retweeted the tweet.... | codefeedback |
You are tasked with creating a Python class for managing biological nodes in a protein interaction network. The class should be able to represent both protein and non-protein nodes, and provide functionality for interacting with these nodes.
Create a class `BiologicalNode` with the following specifications:
- The clas... | codefeedback |
You are tasked with implementing a Python class that simulates a simple bucket management system. The class should allow users to create, delete, and list buckets, as well as upload and delete objects within the buckets. Your task is to complete the implementation of the `BucketManager` class by adding the necessary me... | codefeedback |
You are tasked with implementing a Swift class that manages network requests. The provided code snippet is a partial implementation of a `URLRequestManager` class. Your task is to complete the implementation of the class by adding a method to make a network request using the `URLSession` and handle the response.
Your ... | codefeedback |
You are tasked with creating a Python function that simulates the behavior of the `shutil.rmtree()` function, which recursively removes a directory and all its contents. Your function should take a directory path as input and delete the directory along with all its subdirectories and files. You are not allowed to use t... | codefeedback |
You are tasked with implementing a function that takes an integer array as input and returns a new array where each element is the count of set bits (1s) in the binary representation of the corresponding element in the input array.
You need to implement the following function:
```java
public int[] countSetBits(int[] ... | codefeedback |
You are tasked with creating a Python program that simulates a simple game using the Pygame library. The game involves a player-controlled character navigating through a maze to reach a goal while avoiding obstacles. Your task is to implement the game logic and user interface using Pygame.
Your program should include ... | codefeedback |
You are tasked with creating a Python function that sets up a logging system for data ingestion processes. The function should take in a data source name and return a configured logger object.
The function should perform the following tasks:
1. Construct the complete path for the log file using the provided `log_base_... | codefeedback |
You are tasked with implementing a custom data structure that supports storing and retrieving key-value pairs. The data structure should have the ability to efficiently insert, delete, and search for key-value pairs. Additionally, it should support iterating through the key-value pairs in a specified order. Your task i... | codefeedback |
You are tasked with creating a program that checks the structure of a Rust code snippet to ensure that the first and last statements inside a for loop are using the `render_text!` macro. The program should take a Rust code snippet as input and output whether the conditions are met or not.
Write a function `check_for_l... | codefeedback |
You are tasked with implementing a caching system for textures applied to 3D body models in a graphics rendering application. The provided code snippet imports modules related to the caching system and texture application. Your goal is to design and implement the caching mechanism for both body and texture data.
You a... | codefeedback |
You are tasked with creating a registration validation system for a web application. The system should handle incoming POST requests containing user registration data in JSON format. The registration data needs to be validated, and any errors should be returned to the client with a status code of 400. If the data is va... | codefeedback |
You are working on a project that involves importing modules from a package. The package contains various modules, including a file named `model.py`. Your task is to create a Python function that dynamically imports all the modules from the package and retrieves a specific attribute from each module.
Write a function ... | codefeedback |
You are tasked with creating a Python program that processes version dates from a given code snippet. The program should extract the version numbers and their corresponding release dates from the provided code snippet and then display the version numbers along with their release dates in a formatted manner.
The code s... | codefeedback |
You are tasked with implementing a parser function that can handle different types of input and return the parsed output. The parser function should be able to handle various data types and formats, such as strings and dates, and return the parsed data accordingly. Your task is to implement the parser function accordin... | codefeedback |
You are given a list of words, where each word is represented as a string. Your task is to write a function that takes this list of words as input and returns a dictionary containing the frequency of each word in the list.
For example, given the input list:
```python
words = ["apple", "banana", "apple", "orange", "ban... | codefeedback |
You are tasked with creating a program that processes a given Markdown text and extracts all the hyperlinks present in it. Your program should be able to identify and display all the URLs along with their corresponding anchor texts.
Write a function `extract_hyperlinks(markdown_text: str) -> List[Tuple[str, str]]` tha... | codefeedback |
You are tasked with implementing a job monitoring system for a computing infrastructure. The system receives job information in the form of classads, which contain various attributes such as infrastructure state, site, type, email, and identity. The job ID is constructed from the cluster ID and process ID. The system l... | codefeedback |
You are tasked with implementing a class for information collection and filling out a form. The class should handle querying the form and filling it out with the collected information.
You are provided with the following code snippet as a reference:
```python
# 以下代码是信息收集的代码
LL.log(1, '即将开始信息收集填报')
collection = Collec... | codefeedback |
You are tasked with creating a Python function that compares two software version numbers and determines which one is greater. The version numbers are represented as strings in the format "x.y.z", where x, y, and z are non-negative integers. The function should return 1 if the first version number is greater, -1 if the... | codefeedback |
You are tasked with implementing a Python package for geometric computer vision applications. The package, named "gbp", is structured with submodules for various functionalities. The provided code snippet is from the "__init__.py" file within the "factors" submodule of the "gbp" package. It imports two modules, "reproj... | codefeedback |
You are tasked with implementing a feedforward neural network using TensorFlow. The network consists of two dense layers: a filter layer and an output layer. The filter layer has a specified filter size, an option to use bias, an activation function (defaulting to ReLU), and a name. The output layer has a hidden size, ... | codefeedback |
You are tasked with implementing a function that generates target sequences based on a given lookforward value and an optional delay. The function should take a list of input sequences and return the corresponding target sequences.
The function signature is as follows:
```python
def generate_targets(input_sequences: L... | codefeedback |
You are tasked with implementing a simple rendering engine for a 3D graphics application. The engine will manage the binding and unbinding of render buffers for different types of meshes. You are provided with a code snippet from the `VanillaMesh` class, which is responsible for binding and unbinding the render buffer ... | codefeedback |
You are tasked with implementing a generic data structure in Rust to manage multi-dimensional layouts. The layout consists of dimensions and strides, and the goal is to create a function that can manipulate and return information about the layout.
You are given a code snippet that defines a generic type `Root<L: Layou... | codefeedback |
You are tasked with implementing a Python module that simulates a circular import scenario. Circular imports occur when two or more modules depend on each other, directly or indirectly. In Python, circular imports can lead to unexpected behavior and errors if not handled properly. Your task is to create a program that ... | codefeedback |
You are working on a geographic information system (GIS) application that requires calculations related to geographic coordinates. In this problem, you are tasked with implementing a function to convert geographic coordinates from a spherical coordinate system to a rectangular coordinate system.
The spherical coordina... | codefeedback |
You are tasked with implementing a resource management system for a cloud computing platform. The system needs to support the cancellation of requested resources for a job across multiple client nodes. Your task is to create a method that cancels the requested resources for a job based on the resource check results and... | codefeedback |
You are tasked with implementing a function that processes and saves scan data. The function takes in a unique scan ID, options, and the current date. It then saves the processed data to a file and returns a boolean value indicating the success of the operation. The code snippet provided gives a glimpse of the data pro... | codefeedback |
You are tasked with implementing a class that manages information about top uploaders and unique species within a group. The class should have methods to get and set the top uploaders' information and to retrieve the count of unique species within the group.
You are given a partial code snippet of the class with the f... | codefeedback |
You are tasked with implementing a registration form for a mobile application. The form consists of various types of cells, such as text fields, checkboxes, and pickers. Each cell type has its own protocol conforming to the `RegistrationCellProtocol`. The `RegistrationPickerModel` is a specific model for a picker cell,... | codefeedback |
You are working on a machine learning project and need to implement a feature extraction class that calculates the mean and standard deviation of the feature vectors. The given code snippet is a part of the implementation for this feature extraction class. The code snippet shows the saving of mean and standard deviatio... | codefeedback |
You are tasked with implementing a game simulation system that involves multiple players taking turns. The provided code snippet is a method within a class that represents a game turn. The method `nextTurn` is responsible for advancing the game to the next turn and returning an object representing the new turn.
The me... | codefeedback |
You are tasked with implementing a function that takes a string representing a DNA sequence and returns its complementary sequence. In DNA, the complementary bases are as follows: A pairs with T, and C pairs with G. Any other characters in the input string should be ignored.
Write a function `complementary_sequence` t... | codefeedback |
You are working on a transportation data analysis project and need to create a function to process driver trip data. The function `load_driver_aggmat_celery(driver_id)` takes a driver ID as input and processes the driver's trip data to generate an aggregated matrix. The code snippet provided is a part of this function ... | codefeedback |
You are tasked with implementing a Java annotation processor that processes annotations on classes. The annotation `@Retention` is used to specify the retention policy for the annotated annotation type. The retention policy determines at what point the annotated annotation is discarded.
Your goal is to create an annot... | codefeedback |
You are given a snippet of code that is used to access a value from an associative array in a template file. The `{{ $item[$content] }}` syntax is used to retrieve the value associated with the key specified by the variable `$content` from the associative array `$item`. Your task is to write a function that emulates th... | codefeedback |
You are given a snippet of code that involves operations on tensors using the PyTorch library. Your task is to understand the operations being performed and write a function to achieve a similar computation using PyTorch.
Write a Python function `relevant_words` that takes in the following parameters:
- `A` (torch.Ten... | codefeedback |
You are tasked with creating a Python unit test for a `UserDataController` class. The `UserDataController` is responsible for managing user data in a system. Your task is to write a test case that ensures the proper integration of the `UserDataController` class with the database. The test should cover the setup process... | codefeedback |
You are tasked with creating a Python program that processes a given configuration file and performs specific operations based on the contents of the file. The configuration file is in the SeisComP format, and the program should handle any errors that may occur during the processing.
Your program should read the confi... | codefeedback |
You are tasked with implementing a function that can parse a given URL path and extract the parameters and their values. The URL path is represented as a string, and the parameters are enclosed within curly braces `{}`. Each parameter is in the format `key=value`. Your task is to write a function `parse_url_params` tha... | codefeedback |
You are tasked with implementing a health monitoring system for a set of devices. Each device periodically sends a health signal to the central controller. If the controller does not receive a health signal from a device within a specified time frame, it marks the device as unhealthy. Your task is to design a system th... | codefeedback |
You are tasked with implementing a list difficulties use case for a software application. The use case involves retrieving a list of difficulties from a repository and performing operations on the retrieved data. The code snippet provided is a part of a test suite for the list difficulties use case.
The `ListDifficult... | codefeedback |
You are tasked with creating a Java interface for a custom repository that assembles CRUD (Create, Read, Update, Delete) functionality and provides an API to invoke manually implemented methods. Your task is to design the interface with the necessary method signatures to support these operations.
Your interface should... | codefeedback |
You are tasked with implementing a function to create a custom data structure called `GWBUF`. The function `create_gwbuf` takes a string `s` as input and returns a pointer to a `GWBUF` object. The `GWBUF` structure is not explicitly defined, but it is assumed to be a custom buffer or data container used in a specific a... | codefeedback |
You are tasked with creating a subclass of `SpecHelper` that extends its functionality to handle a specific type of fixture data. The `SpecHelper` class provides a method `fixtureJSONObject(fixtureNamed: String)` that loads a JSON fixture file and returns its contents as an `AnyObject`. Your task is to create a subclas... | codefeedback |
You are tasked with implementing a function that processes an array of integers and returns the count of unique elements in the array. A unique element is defined as an element that appears only once in the array. You need to write a function `countUniqueElements` that takes an array of integers and its size as input a... | codefeedback |
You are working on a robotics project and need to implement a sensor management system. The system should handle different types of sensors and their configurations. Each sensor has various properties such as type, shape, state, and binding. Your task is to design a class structure to represent these sensors and their ... | codefeedback |
You are tasked with implementing a generic Java class for building requests to perform entity-level actions in a RESTful API client. The class should enforce the requirement that the key or ID of the entity must be present in the request to identify which record to perform the action on.
Your task is to complete the i... | codefeedback |
You are tasked with creating a Python function that parses and extracts information from a log message. The log message is in the format "email Sent! smtp server: {smtp} port: {port}", where {smtp} and {port} are placeholders for the SMTP server and port number used for sending an email. Your function should extract t... | codefeedback |
You are tasked with creating a script to automate the versioning, committing, and deployment process for a software project. The script should prompt the user for the project version name, then use Git to commit the changes with the provided version name, push the changes to a remote repository, and finally create a zi... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.