instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a password management system that filters and prints out specific passwords based on certain conditions. The system has a `names` field containing a list of names, a `ctx` field representing a context, and a `tree` field indicating whether to print the passwords. The `ctx` object has a ... | codefeedback |
You are tasked with implementing a message handling system for a messaging application. The system should support adding various types of additions to messages, such as emojis, images, or files. Each addition has specific methods that can be applied to it. Your task is to design and implement a class structure in Swift... | codefeedback |
You are tasked with implementing a protocol-oriented design pattern in Swift. The goal is to create a protocol and its conforming extensions to facilitate the creation of presenter and API service instances for a characters list feature in an iOS application.
The given code snippet is a part of a test class `Character... | codefeedback |
You are tasked with implementing a custom max reduction function for an observable stream in Python using the RxPY library. The max reduction function should operate on a stream of numeric values and emit the maximum value encountered so far. You need to create a function that takes a list of numbers as input, uses the... | codefeedback |
You are tasked with creating a Python program that takes a four-digit integer as input and then separates and prints the individual digits in the thousands, hundreds, tens, and units places.
Write a function called `print_digits` that takes an integer `number` as input and prints the digits in the following format:
``... | codefeedback |
You are tasked with implementing a delivery tracking system for a courier service. The system should be able to track the courier's location at specific time points and calculate the estimated arrival time at a given destination.
You are provided with a Swift code snippet that defines a `Courier` class and a variable ... | codefeedback |
You are tasked with implementing a function to load cards and investigators from a JSON file into a database, and then fetching a specific card from the database. The database operations are performed using the provided `AHDatabase` class and the `DatabaseTestsHelper` class. Your task is to write a function that accomp... | codefeedback |
You are tasked with implementing a simple event listener in Python. The `listener` function should continuously listen for user input and perform specific actions based on the input received. The program should terminate when a specific exit command is entered.
Your task is to complete the `listener` function, which s... | codefeedback |
You are tasked with implementing a watermark positioning system for an image processing application. The application has a class with the following attributes and methods:
Attributes:
- `stamp_location`: A dictionary containing the stamp positions for each image.
- `stamps`: A dictionary to store the watermark stamps.... | codefeedback |
You are tasked with implementing a custom TensorFlow layer for a neural network model. The layer, named `CustomLayer`, has a specific structure and functionality. The provided code snippet is a part of the `CustomLayer` class, and your task is to complete the implementation of this class based on the given requirements... | codefeedback |
You are tasked with simulating the movement of a robotic arm in a controlled environment. The environment is represented by an `env` object, which provides methods for setting the arm's position, retrieving the positions of its tips, and executing steps. The arm's movement is controlled by the `action` variable, which ... | codefeedback |
You are tasked with creating a program that analyzes the frequency of words in a given text file. Your program should read a text file and output the top N most frequently occurring words along with their frequencies. The program should ignore common stop words (e.g., "the", "and", "is") and should be case-insensitive ... | codefeedback |
You are tasked with implementing a function that can parse a given date string in the format "dd/mm/yy" and return the corresponding day, month, and year as separate integers. The function should handle both single and double-digit day and month values, and should also account for the two-digit year format. If the inpu... | codefeedback |
You are tasked with implementing a custom web component called `context-array` that will manage an array of data and display it in a specific format. The component should support dynamic data binding and manipulation through attributes and properties.
The `context-array` component should have the following features:
-... | codefeedback |
You are tasked with implementing a Python class that manages role data in an LDAP structure. The class should handle the retrieval and manipulation of role information using the provided code snippet as a reference.
Your task is to complete the implementation of the `RoleApi` class by incorporating the necessary data ... | codefeedback |
You are tasked with creating a Python script to automate the process of managing Docker containers. Your script should interact with the Docker daemon to execute commands within a specified container. Specifically, you need to implement a function that takes the container name and a command as input and then executes t... | codefeedback |
You are tasked with implementing a simple tree traversal algorithm using the Tree-sitter library in Swift. The given code snippet demonstrates the usage of the Tree-sitter library to navigate a tree structure. The `withUnsafeMutablePointer` function is used to safely access and manipulate the underlying memory of the `... | codefeedback |
You are working on a project to develop a software tool for analyzing flow data from microfluidic chips. The code snippet provided is a part of the software module responsible for flow correction. The `FlowCorr` class is used to perform flow correction on the data obtained from different types of microfluidic chips.
T... | codefeedback |
You are tasked with implementing a Python class that simulates a simple event input/output (I/O) system for handling event data in a particle physics experiment. The provided code snippet gives a glimpse of the operations involved in this system. Your task is to create a class `EventIO` that manages event data and prov... | codefeedback |
You are given a sorted array of distinct integers and a target value. Your task is to implement a function `search` to determine if the target is in the array and return its index. If the target is not found, the function should return -1. You need to implement the `search` function using a binary search algorithm.
Th... | codefeedback |
You are tasked with implementing a service discovery mechanism for a distributed system. Service discovery is the process of automatically detecting and locating services within a network. In this scenario, you are required to create a function that performs a GET request to a service discovery endpoint and handles pot... | codefeedback |
You are tasked with creating a program that processes a user's input to determine the frequency of each character in the input string. Your program should ignore case sensitivity, consider only alphabetic characters, and output the frequency of each letter in alphabetical order. For example, if the user inputs "Hello, ... | codefeedback |
You are tasked with implementing a function that creates a neural machine translation (NMT) model using TensorFlow. The function `create_nmt_model` takes several parameters, including a TensorFlow session, a boolean flag `forward_only`, an optional model path, a boolean flag `use_best`, a `FLAGS` object, a list of `buc... | codefeedback |
You are tasked with implementing a dependency resolution algorithm for a software package management system. The system maintains a list of dependencies between different software packages, where each dependency is represented as a tuple containing the name of the dependent package and the version of the dependency. Th... | codefeedback |
You are tasked with implementing a caching mechanism for a web application using Python and SQLAlchemy. The cache should improve the performance of the application by storing frequently accessed data in memory. Your goal is to create a cache decorator that can be applied to SQLAlchemy query methods to cache their resul... | codefeedback |
You are tasked with creating a custom exception class in C# that extends the `System.Exception` class. This custom exception will be used to handle errors related to a specific database operation. Your task is to implement the custom exception class and demonstrate its usage in a sample program.
Your custom exception ... | codefeedback |
You are tasked with creating a program to calculate the break-even point and potential profit or loss from selling options in a financial trading scenario. In options trading, the break-even point is the price at which an option buyer neither makes a profit nor incurs a loss. The potential profit or loss is determined ... | codefeedback |
You are tasked with creating a simple logging utility for a multi-threaded application. The utility should allow different log levels to be set for different modules, and it should format log messages with timestamps. Your task is to implement the `Logger` struct and associated functions to achieve this functionality.
... | codefeedback |
You are working on a software system that deals with components and subcomponents. The code snippet provided is part of a function that manipulates these components and subcomponents. Your task is to implement a function that performs a specific operation on the components based on the given code snippet.
You are give... | codefeedback |
You are tasked with creating a program that extracts the license information from a given source code file. The license information is typically found within comments at the beginning of the file. The license text may span multiple lines and can be preceded by any number of comment characters (e.g., #, //, /*, etc.).
... | codefeedback |
You are tasked with implementing a Python class for calculating the covariance matrix. The class should have the following features:
- It should be initialized with a data matrix `X`, a boolean parameter `unbiased` (defaulting to `True`), and a scalar multiple `scalar_multiple` (defaulting to `1.0`).
- The class should... | codefeedback |
You are tasked with creating a function to handle the validation and database operation for adding a new warehouse shelf. The function should take input parameters for the maximum number of layers on the shelf and any remarks about the shelf. The function should perform the following tasks:
1. Validate the input parame... | codefeedback |
You are tasked with implementing a custom extension trait for the Rust programming language. The trait, named `TryStreamExt2`, is intended to extend the functionality of Rust's `TryStream` type. The `TryStream` type represents a stream of values that may contain errors, and the goal of the extension trait is to add a m... | codefeedback |
You are tasked with implementing a multi-threaded image processing system. The system is designed to capture RGB frames from a camera and process them concurrently. The provided code snippet is a method within the system's camera class, responsible for obtaining an RGB frame. The method acquires a lock before accessing... | codefeedback |
You are tasked with implementing a Python function that processes a form containing checkboxes and text fields. The function should take in three parameters: `col2`, `checkbox_dict`, and `checked`. The `col2` parameter is a list of text strings to be placed in the second column of the form. The `checkbox_dict` paramete... | codefeedback |
You are given a JavaScript function that is intended to reverse a string. However, the code snippet provided is incomplete and contains some errors. Your task is to complete the function and fix any issues to ensure that it correctly reverses the input string.
The given code snippet is as follows:
```javascript
funct... | codefeedback |
You are tasked with implementing a Python class that interacts with a SQL database. The class, named `SQLQuery`, is initialized with the following parameters:
- `table_name`: a string representing the name of the SQL table to query
- `condition_str`: a string representing the SQL condition to be applied to the query
- ... | codefeedback |
You are tasked with creating a function that retrieves the user group name based on the user's group ID and the route key associated with the current action. The user's group ID is obtained from the request, and the route key is extracted from the given code snippet. You need to implement a function that uses this info... | codefeedback |
You are tasked with implementing a thread-safe counter class in Java. The class should provide methods for incrementing the counter value, getting the current value, and resetting the counter to zero. Additionally, the class should be designed to be used in a multi-threaded environment, ensuring that concurrent access ... | codefeedback |
You are tasked with creating a dependency resolution algorithm for a package manager. The package manager uses a configuration file to define targets and their dependencies. Each target can depend on other targets within the same package or on products in packages which this package depends on.
Your task is to impleme... | codefeedback |
You are working on a project involving the manipulation of biological network data represented as a graph using the PyBEL library. Your task is to implement a function that adds nodes and edges to the graph based on certain conditions.
You are given a Python function snippet that partially implements the required func... | codefeedback |
You are given a 2D array representing a logo, where each element in the array represents a color (N for navy, G for green, and R for red). The logo is represented as a 8x8 grid. Your task is to write a function that takes this 2D array as input and returns the number of pixels that are part of the logo, i.e., the count... | codefeedback |
You are tasked with creating a Python program that generates LaTeX code for documenting modules and their contents. The program should take module names and their contents as input and produce the corresponding LaTeX code for documentation.
Your task is to implement a function `generate_latex_documentation` that takes... | codefeedback |
You are tasked with implementing a frequency synthesizer for a communication system. The frequency synthesizer uses a set of configuration registers to control its operation. One of the key components of the frequency synthesizer is the RF configuration, which includes settings for the VCO (Voltage Controlled Oscillato... | codefeedback |
You are given the definition for a singly-linked list node in C++:
```cpp
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(nullptr) {}
};
```
Your task is to implement a function `reverseList` that takes the head of a singly-linked list as input and returns the head of the reverse... | codefeedback |
You are tasked with implementing a reinforcement learning algorithm using an actor-critic architecture. The actor-critic algorithm involves two neural networks: the actor, which learns a policy for selecting actions, and the critic, which evaluates the actions taken by the actor. Your goal is to implement the actor net... | codefeedback |
You are tasked with creating a Python class that represents a platform for a specific hardware device. The platform class should inherit from the `XilinxPlatform` class and have specific attributes and methods to configure the platform for a Xilinx FPGA device. Your task is to complete the implementation of the `Platfo... | codefeedback |
You are given a code snippet that calculates the number of unique binary search trees that can be formed with `n` nodes. The code uses dynamic programming to solve this problem. Your task is to complete the implementation of the `numTrees` function and write a program to find the number of unique binary search trees th... | codefeedback |
You are tasked with implementing a logging system for monitoring the parameters of a machine learning model. The provided code snippet demonstrates a function `store_model_indicators` that iterates through the named parameters of a PyTorch model and stores the parameters that require gradient computation using a logger... | codefeedback |
You are tasked with implementing a custom data structure in C# to represent a binary search tree (BST) and performing various operations on it. A binary search tree is a binary tree where for each node, all elements in its left subtree are less than the node, and all elements in its right subtree are greater than the n... | codefeedback |
You are given a code snippet representing a class with various properties. Each property is decorated with attributes such as `Ordinal` and `RED`. The properties have different data types and are related to inkCanvasWidgetReference, CUInt32, CFloat, and inkTextWidgetReference. Your task is to create a program that proc... | codefeedback |
You are tasked with creating a password validation system. Your task is to implement a class `PasswordValidator` with the following requirements:
1. The class should have a property `Password` of type string, which represents the password to be validated.
2. The password must satisfy the following criteria:
- At le... | codefeedback |
You are tasked with creating a program that extracts the copyright information from a given source code file. The copyright information is typically found in comments at the beginning of the file and may contain multiple lines. The program should be able to identify and extract the copyright notice from the comments an... | codefeedback |
You are tasked with implementing a Python module that provides a custom import behavior for a package. The package contains a file named `__init__.py` and a module named `trellab.py`. The `__init__.py` file is empty, and the `trellab.py` module contains a class named `TrellabOrganizationClient`.
Your goal is to modify... | codefeedback |
You are tasked with creating a memory monitoring system for a microcontroller running MicroPython. The system should periodically report the amount of free memory and perform other tasks concurrently. You are provided with a code snippet that uses MicroPython's `uasyncio` module for asynchronous task management and the... | codefeedback |
You are tasked with implementing a circular buffer data structure in C++. A circular buffer, also known as a ring buffer, is a fixed-size buffer that overwrites old data with new data when the buffer is full. Your task is to create a class template for a circular buffer that supports the following operations:
1. `push_... | codefeedback |
You are given a vector of integers `nums`. Your task is to find the length of the longest increasing subsequence (LIS) within `nums`. A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements. An increasing subsequence is a... | codefeedback |
You are tasked with implementing a file decryption function in Swift. The function takes in a file URL, a decryption key, and a callback function. The goal is to decrypt the contents of the file using the provided key and then invoke the callback function with the decrypted file URL. If any errors occur during the decr... | codefeedback |
You are tasked with implementing a custom assertion method for testing exceptions in Java. Your goal is to create a method that can be used in JUnit tests to assert whether a specific exception is thrown or not thrown when a certain piece of code is executed.
Your task is to implement the `assertThrows` and `assertDoe... | codefeedback |
You are tasked with simulating a chat server using Python's Pyro library. The provided code snippet is a part of a multi-threaded chat client that interacts with the chat server. Your goal is to implement a chat client class that can send and receive messages to and from the chat server using Pyro.
Your task is to com... | codefeedback |
You are tasked with implementing a function that checks if a given file descriptor is ready for reading within a specified timeout period. You are provided with a code snippet that includes the necessary header files for the function implementation. Your task is to complete the function and ensure that it correctly uti... | codefeedback |
You are tasked with creating a program that parses a SQL CREATE TABLE statement and extracts the table name, column names, data types, default values, and column constraints. Your program should be able to handle both regular and temporary tables, and it should support multiple columns and constraints.
Write a functio... | codefeedback |
You are tasked with creating a user interface for a 3D visualization application using the ImGui library in C++. The snippet provided shows a part of the code responsible for handling user input and displaying options related to raw pose, automatic camera control, and calibration settings. Your task is to extend this c... | codefeedback |
You are tasked with creating a program that simulates a simple messaging system between a server and a client. The server and client are connected, and the server is continuously receiving messages from the client. The server uses a fixed-size header to determine the length of the incoming message and decodes it using ... | codefeedback |
You are given a directed weighted graph with N nodes and M edges. The graph is represented by an adjacency matrix dp, where dp[i][j] represents the weight of the edge from node i to node j. If there is no edge from node i to node j, dp[i][j] is set to infinity. Additionally, the diagonal elements dp[i][i] are all initi... | codefeedback |
You are tasked with implementing a transpose operation for a given 2D array using OpenCL. The provided code snippet is a part of the `opencl` namespace and contains a template function `transpose_inplace` that performs an in-place transpose operation on the input array. The function takes an `Array` reference `in` and ... | codefeedback |
You are tasked with simulating the process of obtaining login credentials for a Tesla API. The process involves generating parameters, making HTTP requests, and handling responses. Your goal is to implement a function that performs the necessary steps to obtain the login page and extract the required parameters for aut... | codefeedback |
You are tasked with implementing a simple class hierarchy for managing different types of employees in a company. The company has three types of employees: full-time employees, part-time employees, and contractors. Each type of employee has different attributes and behaviors.
Create a class hierarchy with the followin... | codefeedback |
You are tasked with implementing a custom reference-counted cow (clone-on-write) data structure in Rust. The cow data structure should support both owned and borrowed data, and it should be able to efficiently clone the data when it is mutated. Your task is to complete the implementation of the `RCow` struct and its as... | codefeedback |
You are tasked with implementing a function that takes a person's full name as input and returns their initials. The initials should be a string consisting of the first letter of each word in the name, capitalized and without any spaces. If the input name contains any non-alphabetic characters, they should be ignored.
... | codefeedback |
You are tasked with implementing a music library management system. The system should be able to store information about various artists and their latest albums. You are provided with a `MockService` class that contains a static method `getArtistInfos()` which returns an array of `Artist` objects. Each `Artist` object ... | codefeedback |
You are tasked with implementing a Singleton class that maintains a history of values and provides methods to update the value, set the maximum history length, and retrieve statistics about the history.
Your task is to implement the Singleton class with the following requirements:
- The class should have a method `upd... | codefeedback |
You are tasked with implementing a function that formats a numerical value with an appropriate unit based on its magnitude. The function should take a numerical value and an optional decimal precision as input and return a tuple containing the formatted value as a string and its corresponding unit.
The function signat... | codefeedback |
You are tasked with implementing a function to calculate the total number of lines between two given positions in a document. The document is represented as a collection of blocks, and each block contains a certain number of lines. The given positions are represented by block numbers within the document.
You are provi... | codefeedback |
You are tasked with creating a program to parse and extract information from a series of HTML elements representing posts on a web page. Each post is contained within a `div` element with the class `kns-konten`, and contains the following structure:
```html
<div class="container mb-5 pb-4">
<div class="row mb-2">
... | codefeedback |
You are tasked with implementing a Lua binding for a C++ class representing an item stack in a game. The provided code snippet is a part of the implementation for binding the C++ class `LuaItemStack` to Lua. The code snippet uses the Lua C API to create a metatable, fill a method table, and register the class in Lua. Y... | codefeedback |
You are tasked with creating a script to automate the setup of a MySQL server on a Linux system. The script should perform the following tasks:
1. Create the necessary directories for MySQL data, runtime, and log files: `/var/lib/mysql`, `/var/run/mysqld`, and `/var/log/mysql`.
2. Add specific configuration entries to... | codefeedback |
You are tasked with implementing a function to evaluate comparison expressions in a custom scripting language. The language supports comparison operators such as "eq" (equal), "gt" (greater than), and "lt" (less than). The function takes in three parameters: `$evalStringResult`, `$valueLeft`, and `$valueRight`. The `$e... | codefeedback |
You are tasked with implementing a time-based key-value store. The store should support the following operations:
1. `set(key: String, value: V, timestamp: u64)`: Set the key to the given value at the given timestamp.
2. `get(key: String, timestamp: u64) -> Option<&V>`: Get the value at the given key and timestamp. If... | codefeedback |
You are given a binary tree where each node has a value and may have a left and/or right child. The depth of a node is defined as the number of edges from the node to the tree's root node. The diameter of a tree is the number of nodes on the longest path between any two nodes in the tree.
Write a function `diameterOf... | codefeedback |
You are tasked with creating a program to process and store network data into a database. The given code snippet is a part of this program and is responsible for inserting network information into a database table. The `datum.metadata.networks` collection contains network data that needs to be inserted into the `networ... | codefeedback |
You are given an array of integers and an integer target. Your task is to find two distinct numbers in the array that sum up to the target. If such a pair exists, return their indices. If there are multiple pairs, return the indices of the first pair encountered. If no such pair exists, return an empty array.
You need... | codefeedback |
You are working on a project that involves processing and analyzing motion capture data. The provided code snippet is part of a Python class that loads motion capture data from a specified path and performs some operations on it. The data is stored in a NumPy array with dimensions representing the number of samples, ch... | codefeedback |
You are tasked with implementing a user authentication and subscription management system for a chat application. The system involves several components, including a `UserManager`, `SubscriptionManager`, and `PushManager`. The provided code snippet is a part of the authentication and subscription management process.
... | codefeedback |
You are tasked with implementing a class for validating and processing command-line parameters for a graphics application. The class, `validation_parameters`, is responsible for extracting and validating specific parameters from the command line using the `twisted_works::cli_parser` library. The class has a constructor... | codefeedback |
You are tasked with creating a function that analyzes a given Swift source code file and counts the number of test cases defined within it. Test cases are defined within classes that inherit from XCTestCase and are marked with the prefix "test" in their function names.
Write a function `countTestCases` that takes a st... | codefeedback |
You are tasked with creating a Python script that monitors the status of a given process and alerts the user if the process is not running. The script should take the process name as input and continuously check if the process is running. If the process is not running, the script should send an email notification to th... | codefeedback |
You are tasked with implementing a filter for a web application that handles user authentication and session management. The provided code snippet is a part of the filter logic and contains a segment that deals with user logout functionality. Your task is to understand the code and design a method to handle user logout... | codefeedback |
You are tasked with creating a Python program that simulates a simple banking system. The program should be able to handle basic banking operations such as account creation, balance inquiry, deposits, and withdrawals. The program should also incorporate user authentication to ensure the security of the accounts.
Your ... | codefeedback |
You are tasked with implementing a C++ class that simulates a simple linked list. Your class should support basic operations such as insertion, deletion, and traversal of the linked list. Additionally, you need to implement a method to reverse the linked list.
Your task is to complete the implementation of the `Linked... | codefeedback |
You are given a list of integers representing the start and end points of several intervals. Your task is to write a function that merges overlapping intervals and returns a new list of non-overlapping intervals.
For example, given the list of intervals:
```
intervals = [[1, 3], [2, 6], [8, 10], [15, 18]]
```
The func... | codefeedback |
You are given a 4x4 matrix of integers. Your task is to find the maximum sum of a hourglass shape in the matrix. An hourglass shape is defined as a subset of values in the matrix arranged in the following pattern:
```
a b c
d
e f g
```
Where a, b, c, d, e, f, and g are distinct values in the matrix.
Write a functi... | codefeedback |
You are tasked with creating a test case for an e-commerce website's payment process using Protractor, a popular end-to-end testing framework for Angular and AngularJS applications. The provided code snippet is a TypeScript class that represents a page object for the payment page. The class contains an ElementFinder fo... | codefeedback |
You are tasked with creating a program to manage and execute parallel jobs based on a given input file. The program should read the input file, which contains a list of jobs, and execute them in parallel using a specified number of threads. Your task is to implement a function or method that accomplishes this job execu... | codefeedback |
You are working on a document management system that utilizes the Incode framework. In this system, there is a class `VetoDocFragmentDeleteSubscriber` which subscribes to events related to the deletion of document fragments. The class contains a method `on` that is triggered when a `DocFragment.DeleteDomainEvent` occur... | codefeedback |
You are tasked with creating a Django model for a user management system. The model should include fields for user ID, phone number, creation time, and update time. Your task is to define the model class and its meta information according to the given requirements.
Define a Django model class called `UserModel` that i... | codefeedback |
You are working for a data science team that is building a machine learning model using the XGBoost library. Your task is to create a Python function that loads a pre-trained XGBoost model from a file and makes predictions on a new dataset. The model files are stored with a specific naming convention, and you need to i... | codefeedback |
You are working on a Python project that involves interfacing with a C++ library using SWIG (Simplified Wrapper and Interface Generator). As part of this project, you need to understand and modify the provided code snippet, which is a part of the SWIG-generated Python wrapper for a C++ class.
The code snippet includes... | codefeedback |
You are tasked with creating a Python function that takes in a dataset and performs a specific data preprocessing task. The function should be able to handle both numerical and categorical features, and it should return the preprocessed dataset ready for machine learning modeling.
You are given the following code snip... | codefeedback |
You are tasked with implementing a parser for a simple expression language. The language consists of binary operations, such as addition, subtraction, multiplication, and division, as well as parentheses for grouping. The expressions are represented using a custom abstract syntax tree (AST) format.
The AST nodes have ... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.