instruction_seed stringlengths 29 40.5k | source stringclasses 6
values |
|---|---|
You are tasked with implementing a function to handle a store query for email IDs. The function should take in a list of arguments and a string of comma-separated email IDs. It should then extract the command and flags from the arguments and use them to perform an IMAP store query on the given email IDs.
You are provi... | magicoder |
You are tasked with implementing a function that checks for potential file overwrites in a package management system. The function `check_overwrites` takes several parameters: `dst` (destination path), `pkg` (package), `filter` (compile filter), `prev` (previous crate listing), and `force` (boolean flag). The function ... | magicoder |
You are given a Python class representing a node in a molecular graph. The class has the following attributes and methods:
```python
class Node:
def __init__(self, mol):
self.mol = mol # The molecular structure associated with the node
self.neighbors = [] # List of neighboring nodes
self.... | magicoder |
You are tasked with implementing a function that processes a given JSON object and returns a modified version of it. The function should remove any keys with empty string values and convert any string values containing only digits to integers. If a key contains a nested object, the function should recursively apply the... | magicoder |
You are tasked with creating a simple RESTful API using Flask to manage a collection of books. The API should allow users to perform basic CRUD (Create, Read, Update, Delete) operations on the book collection. You need to implement the necessary routes and functions to handle these operations.
Your task is to complete... | magicoder |
You are tasked with implementing a sorting algorithm for a list of user objects based on specific criteria. The user objects have attributes such as username, email, and registration date. Your task is to create a function that takes in the list of user objects and a sort criteria, and returns the sorted list of user o... | magicoder |
You are tasked with creating a program to simulate a deck of playing cards and perform various operations on it. The deck consists of 52 cards, with 4 suits (spades, clubs, hearts, diamonds) and 13 ranks (2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A). Your program should be able to shuffle the deck, deal a specified number o... | magicoder |
You are working on a project that involves implementing a neural network using PyTorch. As part of this project, you need to create a custom loss function that incorporates both the mean squared error (MSE) and a regularization term. To achieve this, you decide to use PyTorch's autograd functionality to define a custom... | magicoder |
You are tasked with creating a program to calculate the average of a list of user ratings. The ratings are stored in a dictionary called `predict_val`, where the keys are user IDs and the values are lists of ratings. Your program should calculate the average rating for each user and store the results in a new dictionar... | magicoder |
You are tasked with creating a script to automate the renewal of SSL/TLS certificates using Let's Encrypt and then reload the Nginx web server to apply the updated certificates. Let's Encrypt is a certificate authority that provides free SSL/TLS certificates for websites. Nginx is a popular web server and reverse proxy... | magicoder |
You are tasked with implementing a virtual UART (Universal Asynchronous Receiver/Transmitter) receive test for a Nucleo-446RE board. The test involves using the `capsules::virtual_uart::MuxUart` to perform parallel reads of 3 bytes and 7 bytes. The goal is to verify that both reads are functioning correctly by typing c... | magicoder |
You are tasked with creating a Python function that tests a range of numbers for evenness or oddness based on a given range and a specified type of numbers (even or odd). You are provided with a code snippet that includes a function `testRange` and a helper function `isEven`. Your task is to complete the `isEven` funct... | magicoder |
You are given a code snippet from a shell script that includes comments describing the expected output and some diagnostic checks. Your task is to write a program that processes the output of the given shell script and performs the diagnostic checks mentioned in the comments.
Write a program that reads the output of t... | magicoder |
You are tasked with creating a Python module that simulates a simple banking system. The module should include a class `BankAccount` with the following functionalities:
- Initialize a bank account with a given account number and initial balance.
- Deposit funds into the account.
- Withdraw funds from the account.
- Che... | magicoder |
You are given a string `S` consisting of lowercase English letters. Your task is to find all non-overlapping substrings in `S` that consist of at least three identical consecutive characters. For each such substring found, you need to output the starting and ending indices of the substring within the original string `S... | magicoder |
You are tasked with implementing a user authentication system for a web application. The provided code snippet is a part of a Django web application that handles user registration and activation. The `authenticate` function is used to verify the user's credentials, and upon successful authentication, the user is logged... | magicoder |
You are tasked with implementing a rendering system for a 2D game. The game world is composed of tiles, each of which has a specific appearance and may be occupied by various entities. Your goal is to render the tiles and any associated entities onto the game screen.
You are provided with a code snippet that demonstra... | magicoder |
You are tasked with implementing a simple counter application in Rust. The counter should support two actions: increment and decrement. To achieve this, you need to define an enum representing the different actions and implement a function to update the counter state based on the dispatched action.
You are provided wi... | magicoder |
You are given a graph represented as an adjacency matrix `is_connected` and a starting node `start_node`. Your task is to implement a depth-first search (DFS) algorithm to traverse the graph and return the order in which the nodes are visited.
The graph is represented as a 2D boolean array `is_connected` of size n x n... | magicoder |
You are tasked with implementing a custom sorting algorithm for a specific data structure. The data structure represents a collection of objects, and the sorting algorithm should compare the objects based on their string representations.
You are given a class `CustomObject` with a method `CompareTo` that compares the ... | magicoder |
You are working on a bioinformatics project that involves processing FASTQ files containing DNA sequencing data. Your task is to write a Python function that takes a FASTQ file as input and extracts barcode information from the sequencing reads.
You are given a code snippet that partially accomplishes this task. The s... | magicoder |
You are tasked with creating a Python program to manipulate and process images using the `reportlab` library. The `reportlab` library is commonly used for creating PDF documents with Python. In this problem, you will be working with the `Image` class from the `reportlab.platypus` module to perform various operations on... | magicoder |
You are working on a natural language processing (NLP) project and need to implement a custom recurrent neural network (RNN) module for sequence processing. Your task is to create a Python class that includes methods for processing input sequences using an RNN and returning the hidden states of the RNN. The RNN should ... | magicoder |
You are tasked with implementing a class that represents a collection of functions. Each function is represented as a string, and the class should provide methods to manipulate this collection. Your task is to implement the missing methods in the given class.
```csharp
public class FunctionCollection
{
public stri... | magicoder |
You are tasked with creating a Python function that simulates a network device interaction using the `scrapli` library. The function will take in a list of interaction events and a list of strings that represent failed commands/interactions. The function will then use the `scrapli` library to send the interaction event... | magicoder |
You are tasked with creating a Python function that processes a list of database migration operations and returns a dictionary containing the count of each type of operation. Each operation is represented as a dictionary with a key "operation" indicating the type of operation.
The function should have the following si... | magicoder |
You are tasked with implementing a class that represents a 2D point with private attributes `__x` and `__y`. The class should have methods to get the values of `__x` and `__y` using a regular method for `__x` and a property for `__y`.
Create a Python class `Point` with the following specifications:
- The class should ... | magicoder |
You are tasked with creating a script to process a directory containing comic book archive files (CBR) and identify covert CBZ files within it. A covert CBZ file is a file with a .cbr extension that is actually a ZIP file (CBZ) in disguise. Your script should identify these covert CBZ files and output their filenames.
... | magicoder |
You are working on a project that involves processing and analyzing data from a sensor network. The code snippet provided is a part of a data processing module that deals with observed and unobserved targets. The code uses NumPy for array manipulation and logical operations.
Your task is to implement a function that t... | magicoder |
You are tasked with implementing a custom error handling mechanism for asynchronous operations using Python's `asyncio` library. Your goal is to create a function that takes in a list of `asyncio.Future` objects and a default value, and returns the result of the first successful future or the default value if all futur... | magicoder |
You are tasked with implementing a custom string literal operator for the C++ programming language. The operator should be able to create `std::string` objects from string literals with a specific suffix. Your task is to create a string literal operator that appends a given suffix to the end of the string literal and r... | magicoder |
You are tasked with implementing a role-based access control system for a service. The system should generate a role based on the service name and the name of the function being accessed. Additionally, it should allow for the specification of other authorized roles.
You are given a code snippet that partially impleme... | magicoder |
You are tasked with creating a web application for managing boutique stores. As part of this application, you need to implement a feature that allows the selection of managers for each boutique. The code snippet provided is a part of the HTML form used for this feature. The form is submitted to the URL specified by the... | magicoder |
You are tasked with creating a Python function that utilizes Celery and a web scraper utility to asynchronously scrape data from multiple URLs and log the results. The function should take a list of URLs as input, scrape the data from each URL using the provided `scraper` utility, and then log the results using Celery'... | magicoder |
You are tasked with implementing a graph traversal algorithm that supports different match strategies. The given code snippet is a part of a method that initializes collections of previously visited edges and vertices based on the traversal code and match strategy.
Your task is to complete the implementation of the `i... | magicoder |
You are working on a Python application that interacts with a Microsoft SQL Server database. Your task is to implement a method to generate the Engine URL for connecting to the database. The Engine URL is a string that contains the necessary information to establish a connection to the database.
You are provided with ... | magicoder |
You are tasked with implementing a function to calculate the nth Fibonacci number using an iterative approach. The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. The function should take an integer `n` as input and return the nth Fibon... | magicoder |
You are tasked with implementing a recipe management system that allows users to register and retrieve recipes. Each recipe is represented as a tuple containing the recipe name and its corresponding arguments. Your goal is to create a class that manages the registration and retrieval of these recipe tuples.
You need t... | magicoder |
You are tasked with creating a Python program to manage a train center. The program should utilize threading to handle concurrent tasks and should also read configuration settings from a file. The configuration file is expected to contain settings for the admin module.
Your task is to implement the `start_train_center... | magicoder |
You are working on a deployment script for a mobile application. The script is responsible for cleaning up the existing build artifacts and creating a new directory for the iOS build. The provided code snippet is a part of this deployment script.
Your task is to write a Bash function that simulates the behavior of the... | magicoder |
You are working on a tool to generate an eBook in mobi format using Python. The code snippet provided contains commented-out lists and a list of excluded files. Your task is to write a function that processes these lists and generates the final list of files to be included in the mobi file.
You need to implement a fun... | magicoder |
You are tasked with implementing a function that processes a CSV file and returns the average value of a specified column. The CSV file contains data in the form of rows and columns, with the first row containing the column headers. The function should take the file path and the column name as input and return the aver... | magicoder |
You are tasked with implementing a class that manages an in-memory backing store with dirty tracking of changes. The class should allow for setting and getting values, as well as registering callbacks to be invoked when a value changes.
You are provided with the following code snippet as a starting point:
```typescri... | magicoder |
You are tasked with creating a Python function that utilizes the Support Vector Machine (SVM) algorithm to classify a given dataset. The function should take in the dataset, train the SVM model, and then make predictions on a test set. Additionally, you need to implement a performance evaluation metric to assess the ac... | magicoder |
You are tasked with creating a Python program that scrapes a website for images and saves them to a local directory. The program should take a URL as input and download all the images found on the webpage to a specified folder. Additionally, the program should be able to handle potential errors, such as invalid URLs or... | magicoder |
You are tasked with creating a Python function that processes a JSON report generated by a testing tool and converts it into a specific format for further analysis. The JSON report contains test results in a nested structure, and the function needs to extract relevant information and convert it into a specific output f... | magicoder |
You are tasked with creating a program that can analyze the frequency of words in a given text. Your program should take a string of text as input and output a list of unique words along with their frequencies in descending order.
For example, given the input string "the quick brown fox jumps over the lazy dog", the p... | magicoder |
You are tasked with creating a program that simulates a simple CPU scheduling algorithm. The program should implement a round-robin scheduling algorithm to allocate CPU time to a set of processes. Each process has a unique process ID, arrival time, burst time, and priority. The round-robin algorithm should allocate a f... | magicoder |
You are tasked with creating a Python module that handles error documentation for a development tool. The module should be able to import the necessary functions from another module and handle any potential errors that may occur during the documentation process.
Your task is to implement a function `handle_error` with... | magicoder |
You are tasked with creating a Python class that performs linear fitting for categorical target variables. Your task is to implement the `LinearFitOperator` class, which takes a pandas DataFrame as input and fits a linear model to predict a categorical target variable. The class should provide methods to process the in... | magicoder |
You are tasked with implementing a Python function that simulates the behavior of a Peano object in a 3D animation environment. The Peano object is manipulated through a series of modifiers and keyframe animations. Your function should take in a list of modifiers and a timestep number, and then apply the corresponding ... | magicoder |
You are tasked with implementing a class for managing a grid of cells in a game. The class should ensure that either a view factory or a set of cells is provided, and that the number of cells matches the specified number of rows and columns.
Your task is to create a `GridManager` class with the following requirements:... | magicoder |
You are tasked with implementing a Java program to manage financial account types. The program should include a class to represent a financial account type and an event class to handle the addition of a new financial account type. Your task is to complete the implementation of the `FinAccountType` class and the `FinAcc... | magicoder |
You are tasked with creating a Python function that processes a list of integers and returns the count of prime numbers in the list. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself.
Your task is to implement the function `count_primes` that takes a list of intege... | magicoder |
You are tasked with implementing a custom post type in WordPress. A custom post type allows you to define a new type of content in WordPress, separate from posts and pages. The code snippet provided below is a partial configuration for a custom post type. Your task is to complete the configuration by adding the necessa... | magicoder |
You are tasked with implementing a logging system for a software application. The system should support logging key-value pairs associated with different log IDs. Your task is to create a class that provides a method to log key-value pairs for a given log ID.
You are given a code snippet that represents the interface ... | magicoder |
You are tasked with implementing a Python class method that processes input parameters and updates the state of an object. The method is responsible for extracting specific parameters, setting attributes of the object, and updating a dictionary of initial conditions. Your task is to complete the implementation of the m... | magicoder |
You are tasked with creating a command-line tool that can handle commands for installing and managing software packages. The tool uses a custom CLI library called `toolsCli`, which allows adding commands and versions. The code snippet provided demonstrates the addition of an "install" command and setting a default vers... | magicoder |
You are tasked with simulating the processing and escalation of messages within a system. The system consists of a `MessageProcessor` class responsible for processing basic and rich messages, a `Script` class containing basic and rich messages, a `Snapshot` class representing a snapshot of the system's state, an `Escal... | magicoder |
You are tasked with implementing a function that parses and extracts specific information from an XML document. The XML document contains data related to entity roles in a Microsoft Dynamics CRM system. Your task is to extract the value of the "EntityRole" element as an enumeration and return it.
You are given the fol... | magicoder |
You are tasked with creating a Python function that processes a given dictionary representing a software package. The dictionary contains various attributes of the package, including its name, version, dependencies, and whether it is installable. Your task is to extract specific information from the dictionary and perf... | magicoder |
You are tasked with creating a program that simulates a simple file system. The file system will support basic operations such as creating, deleting, and listing files and directories. Your task is to implement the functionality to delete test entries from the file system.
You are given a code snippet that appears to ... | magicoder |
You are tasked with implementing a custom array class in Python that supports the following operations:
1. `push_item(item)`: Adds the given item to the end of the array.
2. `delete_item(index)`: Removes the item at the specified index from the array.
3. `data`: Returns the current content of the array.
You need to c... | magicoder |
You are tasked with creating a Python class that represents a student. The class should have a method to set the student's remark and another method to retrieve the remark. The remark should be a private attribute of the class and should only be accessible through the provided methods.
Create a Python class `Student` ... | magicoder |
You are tasked with implementing a function that reverses the order of elements within a given sequence. The sequence is represented as an array of integers, and the reversal operation should be performed based on a specified axis. The axis indicates the dimension along which the reversal should occur. For example, if ... | magicoder |
You are tasked with implementing a function that processes a nested dictionary representing a set of filtering conditions for a database query. The dictionary contains column names as keys and filtering conditions as values. The filtering conditions can be simple (e.g., equality, inequality) or complex (e.g., logical A... | magicoder |
You are tasked with creating a Python class that processes and stores data from web scraping using the Scrapy framework. Your class should include a method to clean and format the scraped data before storing it.
Create a class named `ScrapyDataProcessor` with the following requirements:
- The class should have a cons... | magicoder |
You are tasked with creating a Python program that simulates a simple game using the Pygame library. The game involves a character that can move left and right using the 'a' and 'd' keys, respectively. Your task is to implement the functionality that moves the character left when the 'a' key is pressed.
Your program s... | magicoder |
You are tasked with implementing a password generator function in Python. The function should generate a random password of a specified length and complexity level. The complexity level is determined by the presence of uppercase letters, lowercase letters, numbers, and special characters in the generated password. The ... | magicoder |
You are given an array of integers `arr` of length `n` and an integer `k`. Your task is to implement a function `MaxK` that finds the maximum element in each subarray of size `k` within the given array. The function should return a vector containing these maximum elements.
The function signature is:
```cpp
vector<int>... | magicoder |
You are tasked with creating a program to manage recruitment contacts for different countries. The program should allow adding and retrieving contacts for specific countries. You are given the following code snippet as a starting point:
```python
countries_of_recruitment = []
contacts = {}
```
You need to implement t... | magicoder |
You are tasked with implementing a database model for storing citizenship records. The `Citizenship` model has three properties: `personName` (String), `countryName` (String), and `native` (Boolean). Your goal is to create a method to insert a new citizenship record into the database and another method to fetch a speci... | magicoder |
You are tasked with implementing a class that simulates a simple connection status checker. The class, named `ConnectionChecker`, should have the following functionalities:
1. A constructor that takes a boolean parameter `initialStatus` to initialize the connection status.
2. A method `open()` that sets the connection... | magicoder |
You are tasked with creating a Python program to generate a form based on a given set of fields and their corresponding categories. The form should be structured as a dictionary where the keys are the categories and the values are lists of fields belonging to each category. Additionally, the program should be able to v... | magicoder |
You are tasked with implementing a function that processes a list of words and returns a modified list based on the following rules:
1. If a word ends with the substring "None", the word should be replaced with the Python None value.
2. If a word does not end with "None", it should remain unchanged in the modified list... | magicoder |
You are tasked with implementing a Python class that interacts with the PickPoint API for package delivery services. The class should handle the configuration and execution of API requests. Your task is to complete the implementation of the `PickPointAPIClient` class by adding a method called `get_delivery_status` that... | magicoder |
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... | magicoder |
You are tasked with implementing a function that converts a 2D tensor to a vector in C++. The function should take the dimensions of the tensor and the tensor data as input and return a vector containing the elements of the tensor in row-major order.
The function signature should be:
```cpp
template <typename T>
std::... | magicoder |
You are tasked with implementing a variadic template function that calculates the sum of all the arguments passed to it. The function should be able to handle any number of arguments of various types, including integers, floating-point numbers, and other arithmetic types. You should also handle the case when no argumen... | magicoder |
You are tasked with creating a program that analyzes a given text file to count the occurrences of specific words. The text file contains a legal disclaimer, and your program should count the occurrences of the words "LIABILITY", "INFRINGEMENT", and "CONTRACT" within the disclaimer. The disclaimer is formatted as a com... | magicoder |
You are tasked with creating a Python script to automate the installation of a custom Conda environment for data analysis and machine learning. The script should handle the creation of the environment, activation, installation of a Jupyter kernel, and setting appropriate permissions for the installation script.
Your s... | magicoder |
You are tasked with implementing a Swift class for managing player results in a game. The class, `PlayerManager`, should maintain a player's name, a collection of their results, and the total score achieved. The class should have an initializer to set the player's name and should provide methods to add new results and ... | magicoder |
You are tasked with implementing a simple text-based user interface for a music player. The program should allow users to perform various operations such as playing the next song, pausing the current song, and increasing the volume. The snippet below shows a part of the code responsible for handling the user input for ... | magicoder |
You are tasked with creating a custom configuration service for a web application. The application uses the ASP.NET Core framework, and you need to implement a custom configuration provider to load configuration data from a specific source. Your task is to create a custom configuration provider that retrieves configura... | magicoder |
You are tasked with creating a FastAPI application that simulates a mode selection system for a device. The application should have an API endpoint that allows users to retrieve the current mode of the device and another API endpoint to update the mode. The modes available for the device are "normal", "silent", and "ai... | magicoder |
You are tasked with implementing a function to validate and process JSON data. The function should check for the presence of specific fields within the JSON object and handle missing fields according to a specified behavior.
You are given a code snippet that defines a boolean function `throwExceptionOnMissingFieldsInJ... | magicoder |
You are tasked with creating a user authentication system using Python's Tortoise ORM and Werkzeug library for password hashing. Your goal is to define a User model with the necessary fields and methods for secure password management.
Define a User model with the following requirements:
- The model should have fields ... | magicoder |
You are tasked with implementing a logistic regression model for a binary classification problem. The logistic regression model is a fundamental algorithm in machine learning used for binary classification tasks. In this problem, you will need to create a Python class that represents a logistic regression model and imp... | magicoder |
You are tasked with creating a Python function that processes date-related queries for a blog post database. The function should take in either a start and end date or a single date and return a MongoDB query to find posts based on the provided date(s).
The function should be named `generate_date_query` and should hav... | magicoder |
You are tasked with implementing a function that searches for specific documents within a file system and returns the matching results. The function `doc_full_search_tuple` takes two parameters: `thepath` (the path to the file system to be searched) and `myverbosity` (the verbosity level for the search). The function r... | magicoder |
You are tasked with implementing a C++ class that manages texture atlas data for the SFML library. The provided code snippet is the beginning of the implementation of the `SFMLTextureAtlasData` class. Your task is to complete the implementation of this class by adding necessary member variables and methods to manage te... | magicoder |
You are tasked with creating a Python function that processes a list of file paths and extracts specific information from each file. The function should take in three parameters: `save_dir` (string), `wsi_patch_info_dir` (string), and `extract_info` (function). The `wsi_patch_info_dir` contains multiple text files, eac... | magicoder |
You are tasked with implementing a function to perform whole image prediction with variable overlap. Given an input image and a model for prediction, the function should produce a prediction for the entire image with the ability to control the overlap between adjacent prediction patches.
The function signature is as f... | magicoder |
You are tasked with creating a script that automates the process of verifying the integrity of files in a given directory. The script should calculate the checksum of each file and compare it with a pre-existing checksum file to ensure that no unauthorized changes have been made to the files. Your task is to implement ... | magicoder |
You are tasked with creating a Bash script to automate the installation and setup of a service that publishes the device's IP address on boot using Mosquitto MQTT. Your script should perform the following steps:
1. Update the package list using `apt-get`.
2. Install the `mosquitto-clients` package using `apt-get`.
3. D... | magicoder |
You are tasked with implementing a custom tab bar widget in a Qt application. The tab bar should emit signals when different mouse buttons are clicked on a tab. The code snippet provided is a part of the implementation for handling the middle button click event on the tab bar.
Your task is to complete the implementati... | magicoder |
You are tasked with implementing a Metropolis-Hastings MCMC (Markov Chain Monte Carlo) algorithm for sampling from a target distribution. The Metropolis-Hastings algorithm is a popular method for generating samples from a probability distribution when direct sampling is difficult. The algorithm uses a proposal distribu... | magicoder |
You are tasked with creating a custom exception class and implementing a program that utilizes this exception to handle specific error conditions.
Create a Python class called `CustomError` that inherits from the built-in `Exception` class. The `CustomError` class should have a constructor that takes in a message as ... | magicoder |
You are tasked with creating a script to automate the setup of a development environment for a web application. The script should check for the presence of a `.env` file, create one from a provided `.env.example` file if it does not exist, and then start the Supervisor process manager using the configuration file `supe... | magicoder |
You are tasked with creating a SQL query to retrieve the latest 10 tasks created by a specific user. The database contains a table named `task` with columns `id`, `create_date`, and other unspecified columns. The `create_date` column stores the timestamp of when the task was created. The user's information is stored in... | magicoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.