instruction_seed
stringlengths
29
40.5k
source
stringclasses
6 values
You are tasked with creating a program that extracts and processes address information from an HTML snippet. The HTML snippet contains a list item (`<li>`) with a heading (`<h3>`) and a paragraph (`<p>`) containing address information. The address information is structured as a single line with the label "Address" and ...
magicoder
You are working on a Python project that involves importing modules from different directories. The project structure is as follows: ``` project/ main.py permissions/ __init__.py permissions.py reviews/ __init__.py reviews_next_page.py review_history/ __init__.py...
magicoder
You are tasked with implementing a function that simulates a simplified version of the UIView animation in iOS. The function should take in a duration, a closure representing the animation block, and a boolean flag indicating whether the animation should be performed. If the animation flag is true, the function should ...
magicoder
You are tasked with creating a JUnit test for a Spring Boot application. The application has a `TokensRepository` that manages tokens for user authentication. Your goal is to write a test that ensures the proper functionality of the `TokensRepository` class. Write a JUnit test class that includes the following test ca...
magicoder
You are tasked with implementing a simple audio component system for a game engine. The provided code snippet outlines the `AudioComp` struct and its associated methods. Your goal is to extend this system by implementing a method to play a specific audio clip. The `AudioComp` struct contains a field `audio` of type `R...
magicoder
You are tasked with implementing a custom base conversion library in Rust. Your library should support converting numbers from decimal to various bases and vice versa. To achieve this, you need to define a `Base` enum representing different bases and implement the necessary conversion functions. The `Base` enum should...
magicoder
You are tasked with creating a Python function that processes a list of integers and performs a specific operation on each element. The function should handle various scenarios and raise appropriate exceptions for invalid inputs. Write a Python function called `process_list` that takes a list of integers `input_list` ...
magicoder
You are tasked with creating a function that generates tile URLs for a mapping application based on a given set of parameters. The function should take in the host URL, map name, scheme, tilejson version, and tile coordinates, and then construct the appropriate tile URL. Write a function `generateTileURL` that takes i...
magicoder
You are tasked with creating a Python function that sets up a logging system for an application. The function should take in two parameters: the name of the log file and the directory path where the log file should be stored. The function should configure a logger with a specific formatter and log level, and then retur...
magicoder
You are working on a software development team that uses a custom event-driven framework for managing pull requests on GitHub. The framework includes the following code snippet as part of its event handling system: ```python """A pull request is being created.""" template: github.Repository template_branch: str proje...
magicoder
You are tasked with implementing a Python class that simulates a simple command-line interface (CLI) parser. The CLI parser should be able to parse command-line arguments and return them in a structured format. Additionally, you need to create a class for handling authentication to a cloud storage service, specifically...
magicoder
You are tasked with creating a command-line interface (CLI) tool for managing progress bars. The tool should allow users to set and customize progress bars, as well as provide an option to disable progress display entirely. Your task is to implement the logic for parsing command-line arguments and handling the differen...
magicoder
You are tasked with implementing a caching mechanism for the `curses.tparm` function in a Python library. The `curses.tparm` function takes a string `s` and variable number of arguments `args`, and returns a string. The caching mechanism should store the results of previous function calls to avoid redundant computation...
magicoder
You are tasked with creating a Python function that processes a list of Django migration operations and returns a dictionary containing the count of each type of operation. Each operation is represented as an instance of a Django migration operation class, such as `migrations.AddField`, `migrations.AlterField`, etc. Y...
magicoder
You are tasked with implementing a function that converts a given string containing tabs into spaces. The function should take two parameters: the input string and the tab size, and return the modified string with tabs replaced by the appropriate number of spaces. The function signature is: ```java public String conve...
magicoder
You are tasked with implementing a statistics sender module for a monitoring system. The sender periodically collects statistics and sends them to a storage system. Your goal is to write a method that ensures the sender correctly updates the send time and status after sending the statistics. You are provided with a co...
magicoder
You are tasked with creating a script to monitor and manage a set of processes on a Unix-based system. Your script should be able to identify and terminate processes that have been running for an excessive amount of time. You are given a list of processes, each represented by a unique process ID (PID). Your task is to...
magicoder
You are tasked with creating a Java method that simulates making a GET request to a user API endpoint and validating the authorization header. Your task is to implement the method `validateCurrentUserEndpoint` which takes a `UserApiService` object as a parameter. The `UserApiService` class has a method `getCurrentUserE...
magicoder
You are tasked with implementing a method to retrieve a list of sale attribute values for a given SKU item in an e-commerce platform. The provided code snippet is from the `SkuSaleAttrValueEntity` class in the `com.atguigu.gulimall.pms.dao` package, which is part of the product management system. Your task is to creat...
magicoder
You are tasked with implementing a Python class for sharing a secret using Shamir's Secret Sharing algorithm. Shamir's Secret Sharing is a cryptographic algorithm that allows a secret to be divided into parts, called shares, in such a way that the original secret can only be reconstructed when a sufficient number of sh...
magicoder
You are tasked with creating a Python function that simulates a simple database operation. The function should update the name of a tournament in a database and return the number of rows affected by the update. You are given a code snippet that demonstrates the usage of the `Tournament` model and its methods. The `Tou...
magicoder
You are tasked with implementing a function that generates an SVG (Scalable Vector Graphics) file based on the input parameters. The function should take a filename, a title, and a vector of data points as input and produce an SVG file representing the data. Your task is to implement the `render_svg` function, which t...
magicoder
You are tasked with implementing a program to calculate the average vertical bearing of a set of measurements. The vertical bearing is the angle of an object above or below the horizontal plane. The program should take a series of vertical bearing measurements as input and then calculate and output the average vertical...
magicoder
You are tasked with creating a script that processes a directory of files using a set of helper functions. The script should source a file called `helpers.sh` located in the same directory as the script itself. The `helpers.sh` file contains various functions that the main script will utilize for processing the files. ...
magicoder
You are tasked with implementing a function that checks for type mismatches in a programming language. The function will take two input parameters: `params`, a vector of strings representing the expected types of function parameters, and `args`, a vector of strings representing the actual types of function arguments. Y...
magicoder
You are tasked with implementing a graph algorithm to find the maximum clique size and number of edges in a given graph. A clique in a graph is a subset of vertices such that every two distinct vertices in the clique are adjacent. The number of edges in a graph is the count of unique pairs of vertices that are connecte...
magicoder
You are tasked with implementing a BorderStyle struct in Swift to apply borders to UI components. The struct should have three properties: color, radius, and width, along with an initializer to set these properties. Your task is to create the BorderStyle struct with the given properties and initializer, and then demons...
magicoder
You are tasked with implementing a function to perform oversampling of minority classes in a machine learning dataset. The oversampling technique involves adjusting the size of the minority class samples to balance the class distribution. The given code snippet provides a starting point for this task. The oversamplin...
magicoder
You are tasked with creating a Python function that calculates the area of a zone within a given shape. The shape is represented as a list of vertices, where each vertex is a tuple of (x, y) coordinates. The zone is defined by a list of indices that specify the vertices of the shape that form the zone. The area of the ...
magicoder
You are tasked with implementing a text differencing algorithm to compare two versions of a document and generate a human-readable diff output. The algorithm should identify whether each line in the two versions is unchanged, inserted, or deleted, and provide a label for each line accordingly. You are given a code sni...
magicoder
You are tasked with implementing a formatter management system for a text processing application. The system should allow for the addition of default formatters based on a specified condition. Your task is to create a class that manages the default formatters and provides a method to add formatters based on a given con...
magicoder
You are tasked with creating a Swift protocol and a subclass to interact with Ethereum smart contracts. Your goal is to implement a function that retrieves the decimal value of an ERC20 token from the blockchain. You will need to utilize the provided code snippet as a reference for creating the protocol and subclass. ...
magicoder
You are tasked with implementing a function that determines the screen size of a mobile device based on its height and scale factor. The function should take two parameters: `height` (an integer representing the height of the device's screen in points) and `scale` (a floating-point number representing the scale factor ...
magicoder
You are tasked with implementing a class method for generating inline keyboard buttons in a Telegram bot. The method should take in parameters for action, view, year, month, and day, and return an InlineKeyboardButton object with the appropriate label and callback data. You are given the following code snippet as a re...
magicoder
You are tasked with implementing a generic tree data structure in Rust. The tree nodes should be able to store any type that implements the `Display` trait. You need to define the `FormatTreeNode` struct and its associated methods to create and manipulate the tree nodes. Your task is to complete the implementation of ...
magicoder
You are tasked with creating a Swift function that processes images and performs a specific operation on them. Your function should take an input image and apply a series of transformations to it. The goal is to create a new image that has been modified according to the given specifications. Your function should accep...
magicoder
You are tasked with implementing a text content resolver for a content management system. The resolver is responsible for processing configuration settings and resolving the appropriate content to be displayed. The code snippet provided is a simplified representation of the resolver logic. The `resolveEntityValue` met...
magicoder
You are tasked with implementing a priority queue using a max-heap data structure. A priority queue is an abstract data type that operates similar to a regular queue or stack, but where each element has a priority associated with it. In this problem, you will implement the `MaxHeapPriorityQueue` class, which supports t...
magicoder
You are working on a Python package that provides a data synchronization framework. The package includes several modules for different types of data sources, such as databases and external APIs. The code snippet provided is from the package's main module, which is responsible for importing and managing the data source ...
magicoder
You are tasked with implementing a LookoutComponent for a game, which is responsible for allowing a game character to spot and track enemies. The LookoutComponent is initialized with a specific game character (in this case, a dwarf soldier) and has a private field to store the spotted enemy. Your task is to implement t...
magicoder
You are tasked with creating a script to automate the installation of a specific version of dotnet-script. The script should check if the dotnet-script directory exists, and if not, it should download the specified version from GitHub and unzip it into the designated build directory. Your task is to write a Bash scrip...
magicoder
You are tasked with creating a Python function that processes a file containing word vectors and checks for duplicate words. The function should read each line of the file, prepend a given prefix to each word, convert the vector to a NumPy array, and then check for duplicate words in a specified dictionary. Write a fu...
magicoder
You are tasked with implementing a function to parse and process HTTP GET requests in a C++ program. The function should extract and handle the parameters from the request URL. You are given a partial code snippet from a `ConnectionsHandler` class, which includes the `handleGETRequest` method. This method is responsib...
magicoder
You are tasked with implementing a type inference algorithm for a simple programming language. The language supports basic types such as integer, boolean, and float, as well as binary operations like shift left (<<), shift right (>>), and their corresponding assignment operators (<<=, >>=). The algorithm should determi...
magicoder
You are tasked with implementing a file management system that supports writing files to a specified output location. The system should handle file operations and error handling. Your task is to implement the `write` method, which takes the name of the file, the file object, and an optional retry flag. The method shoul...
magicoder
You are working on a cloud management system that interacts with Amazon Web Services (AWS). You are tasked with implementing a method to find Amazon Machine Images (AMI) based on specific tags. The code snippet provided is a part of the method `find_ami` within a class, and it takes in a variable number of keyword argu...
magicoder
You are tasked with creating a Python script to manage APT repositories. APT (Advanced Package Tool) is a package management system used by Debian-based distributions such as Ubuntu. Your script should handle the following functionalities: 1. Display failed APT repositories for a given base URL. 2. Optionally, delete ...
magicoder
You are tasked with implementing a simple image handle manager in Rust. The manager should assign unique IDs to image handles and maintain a mapping between the IDs and the image handles. Additionally, it should support retrieving the ID for a given image handle and vice versa. You are provided with a partial implemen...
magicoder
You are given a Python script that processes text files. The script reads a file, splits each line into words, and writes each word to a new file. However, there is a comment indicating that the script only checks for one error per word. Your task is to implement a Python function that identifies and counts the number ...
magicoder
You are tasked with implementing a logging system for web scraping activities. The provided code snippet is a part of a Python class that logs various metadata related to web scraping activities. The `JsonLinesLogger` class is responsible for writing log entries to a JSON Lines file. The `write_entry` method of this cl...
magicoder
You are tasked with implementing a function that takes an integer as input and returns a Promise that resolves to a string. The function should handle the case where the input is not a number and should reject the Promise with an appropriate error message in such cases. Additionally, the function should handle the case...
magicoder
You are tasked with creating a Python function that processes a list of HTTP API contracts and returns a dictionary containing the titles of the contracts along with their corresponding health check paths. The function should take the list of contracts as input and return the dictionary as output. Each contract is rep...
magicoder
You are tasked with implementing a generic `ValueObject` class in C#. A `ValueObject` is a type of object whose equality is determined by the equality of its values rather than by reference. Your task is to implement the `ValueObject` class and override the necessary methods to ensure that two `ValueObject` instances a...
magicoder
You are tasked with implementing a permission filter for a system that lists ATBDs (Algorithm Theoretical Basis Documents) along with their summary version information. The system should only display versions with status "Published" if the user is not logged in. Additionally, if a user is logged in and has a specific r...
magicoder
You are tasked with implementing a Credential class in Python to manage user credentials. The class should have the following functionalities: 1. Add a new credential to the list of credentials. 2. Remove a credential from the list of credentials. 3. Find a credential by its name. You are provided with a partial code...
magicoder
You are given a Python code snippet that is part of a larger program. Your task is to understand the code and implement the missing functions to complete the program. The code snippet is as follows: ```python return result if __name__ == '__main__': current_file = os.path.splitext(os.path.basename(__file__))...
magicoder
You are tasked with implementing a Weight-Balanced Tree (WBT) data structure in C++. The WBT is a self-balancing binary search tree that maintains a balance condition based on the weights of its nodes. The provided code snippet includes a partial implementation of the WBT, with a `clone` method for node cloning and a `...
magicoder
You are tasked with creating a program to simulate an ATM cash withdrawal process. The program should prompt the user to input the desired withdrawal amount and then calculate the optimal combination of banknotes to dispense the requested amount. The available banknotes for withdrawal are 50, 20, 10, and 1. Your task ...
magicoder
You are tasked with creating a program that generates a specific HTML output based on a given input. The program should take an integer `n` as input and produce an HTML structure with `n` rows, each containing a specific class attribute. The HTML output should be in the form of a string. For example, given `n = 3`, th...
magicoder
You are tasked with implementing a simple virtual machine (VM) that can execute a series of commands. The VM has three event handlers: `OutputReady`, `LineWanted`, and `KeyWanted`. Your goal is to write a method that processes these events and executes the corresponding actions. You are given the following code snippe...
magicoder
You are tasked with creating a Python class that handles reading and writing records to a file. Your class, `RecordJar`, should have methods to read from and write to a file, as well as handle errors that may occur during these operations. Your task is to implement the `RecordJar` class with the following specificatio...
magicoder
You are tasked with implementing a Python class that constructs a search space for a neural network architecture. The class should be able to build a sub-graph with a specified number of layers, given input and output shapes. Your task is to complete the implementation of the `build_sub_graph` method within the `Search...
magicoder
You are tasked with creating a PHP function that interacts with a MySQL database to insert a new record into the "collects" table. The function should take input parameters for the collect site, collect source, object type, object sub type, and object weight. The collect date should be automatically set to the current ...
magicoder
You are tasked with creating a program that simulates a simple banking system. The program should allow users to create accounts, deposit money, withdraw money, and check their balance. Each account should have a unique account number, and the program should support multiple accounts. Your task is to implement the `Ba...
magicoder
You are tasked with implementing a custom view class in Swift that conforms to the `EmptyDataSetSource` and `EmptyDataSetDelegate` protocols. The class, `UEmptyView`, is intended to be used as an empty state placeholder in a user interface, such as when a table view or collection view has no data to display. The class ...
magicoder
You are tasked with implementing a function to batch a collection of sentences based on their lengths. The function should take a dictionary `sents_id2length_dic` as input, where keys are sentence IDs and values are the respective sentence lengths. The function should return a list of batches, where each batch contains...
magicoder
You are tasked with implementing a method to normalize a 3D vector. The vector is represented by its components `x`, `y`, and `z`. Normalizing a vector involves scaling it to have a length of 1 while retaining its direction. The formula for normalizing a vector is to divide each component by the vector's magnitude. The...
magicoder
You are tasked with creating a Python function that verifies the authenticity of a JSON Web Token (JWT) by decoding and validating its signature. The JWT is encoded using the HMAC algorithm with a secret key obtained from a remote server. Your function should retrieve the secret key from the provided URL, decode the JW...
magicoder
You are tasked with implementing a simple moving average calculation for a given set of data points. The moving average is calculated by taking a window of a specified size and computing the average of the values within that window as it moves through the data. Your task is to write a function that takes a list of data...
magicoder
You are tasked with creating a Java program that processes an array of integers to perform a specific operation. The program should take an input array and return a modified array based on the following rules: 1. If the input array contains any negative numbers, they should be replaced with 0. 2. If the input array co...
magicoder
You are working on a security monitoring system that logs and analyzes commands executed on a Linux server. Your task is to write a Python program that processes the logged commands and identifies potential security threats based on specific patterns. You are given a log file containing a series of commands executed o...
magicoder
You are given an HTML code snippet that is intended to display a list item with a link to Instagram and an image. However, the code contains several errors and is not rendering as expected. Your task is to identify and correct the errors in the code to ensure that the list item and image are displayed correctly. Given...
magicoder
You are tasked with implementing a custom content provider for a college database in an Android application. The provided code snippet outlines the initial setup for the content provider, including the definition of the content URI and the base content provider class. Your task is to extend this content provider to han...
magicoder
You are tasked with creating a Python class that manages the training process of a machine learning model. The class should include a method to start TensorBoard, a visualization tool used to monitor the model's performance during training. The `start_tensorboard` method should take the log directory as an argument and...
magicoder
You are tasked with implementing a Python function that processes a list of strings representing code lines and returns the number of leading spaces or tabs in each line. The function should ignore empty lines and return the count of leading spaces or tabs for non-empty lines. The function signature is: ```python def ...
magicoder
You are tasked with implementing a C++ template meta-programming problem that involves understanding and manipulating type traits and function call expressions. You are given the following code snippet as a starting point for your problem: ```cpp typedef typename meta::as_logical<sA0>::type result_type; BOOST_SIMD_FU...
magicoder
You are tasked with implementing a simple GUI application that allows users to select a theme from a dropdown menu. The application should display a window with a dropdown menu containing theme options. When a theme is selected from the dropdown menu, the application's theme should be updated accordingly. Your task is...
magicoder
You are tasked with implementing a function that checks whether a given string is a valid Swift file name. A valid Swift file name should adhere to the following rules: 1. It should end with the ".swift" extension. 2. It should not contain any special characters or spaces. 3. It should start with an uppercase letter. ...
magicoder
You are tasked with creating a Python program that establishes a socket connection to a specified host and port. Your program should be able to handle potential errors and timeouts during the connection process. Write a Python function `establish_socket_connection` that takes in the following parameters: - `host` (str...
magicoder
You are given a Python code snippet that involves a function call and a print statement. Your task is to understand the code and predict the output. The code snippet is as follows: ```python valor = funcao2(multiplicacao, 2) print(multiplicacao) print(int(valor)) ``` You are also given the following information: - T...
magicoder
You are tasked with implementing a Python function that processes a dictionary containing various configuration settings for a messaging system. The function should extract specific settings and return them in a structured format. You are given a dictionary `config_settings` containing the following key-value pairs: `...
magicoder
You are tasked with creating a program to process and validate user input for a Persian e-commerce website. The website has a form for adding products to the shopping cart. The form includes a quantity input field and an "Add to Cart" button. The quantity input field allows users to enter the desired quantity of the pr...
magicoder
You are tasked with implementing a job scheduler for a distributed system. The system consists of multiple nodes, each capable of running jobs. The scheduler needs to keep track of the configuration for error correction codes (ECC) and the configuration for the distributed key-value store (etcd). Additionally, it needs...
magicoder
You are tasked with implementing a function that checks if a given user follows a specific channel on a social media platform. The function will take in the user's name and the channel name as input and should return a boolean value indicating whether the user follows the channel. You are provided with a code snippet ...
magicoder
You are tasked with creating a JavaScript function that processes a given list of file paths and returns a new list containing only the file names without their extensions. You are given a code snippet that demonstrates the use of the `export` statement in JavaScript. Your task is to create a function that extracts th...
magicoder
You are tasked with creating a program that processes a vocabulary file and provides various statistics about the words in the file. The vocabulary file contains a list of words, with each word on a separate line. Your program should read the vocabulary file and perform the following tasks: 1. Count the total number o...
magicoder
You are tasked with creating a program that simulates a simple text-based adventure game. The game will involve the player navigating through different rooms, encountering obstacles, and making decisions that affect the outcome of the game. Your task is to implement a Python program that models this text-based adventu...
magicoder
You are tasked with creating a script to automate the deployment of a Docker image for a Spark application. Your goal is to write a Bash script that will build the Docker image with specific configurations. The script should include the necessary commands to achieve this. Your task is to complete the Bash script by ad...
magicoder
You are working on a computer vision project and need to implement a custom evaluation dataset and data loader for testing a classifier. The code snippet provided is a part of the infrastructure for setting up the test loader. Your task is to complete the implementation of the `EvalDataset` class and the `collate_eval`...
magicoder
You are tasked with implementing a class for managing product discounts in an e-commerce system. The class should have the following attributes: - `key`: A string representing the unique identifier for the discount. It can be `None` if not specified. - `description`: An optional localized string describing the discoun...
magicoder
You are tasked with implementing a simplified version of a class registration system in Python. The system should allow for the registration of different classes or chapters within a larger educational application. You are provided with a code snippet that registers three classes or chapters - 'RegistryApp', 'DiseaseC...
magicoder
You are working on a project to analyze data from a scientific experiment. The experiment involves running multiple jobs in parallel to process data. Each job is represented by a unique identifier and is associated with a specific input file. Your task is to design a program that can efficiently manage and execute thes...
magicoder
You are tasked with creating a React component for a Net Promoter Score (NPS) dialog box. The dialog box should allow users to provide a star rating and submit their feedback. The component should utilize the `useConvergeSettingsContextProvider` hook to access and update the NPS settings. Additionally, the component sh...
magicoder
You are working on a web application that manages orders for a restaurant. The code snippet provided is a part of the application's view file written in PHP and HTML. The application uses a modal to display an order grid for the restaurant's staff to manage orders. The modal is triggered by a button click and contains ...
magicoder
You are tasked with creating a Go package that provides a shared library for interfacing with the InterPlanetary File System (IPFS). The provided code snippet demonstrates the compilation and installation process for the shared library. Your goal is to write a Go program that utilizes this shared library to interact wi...
magicoder
You are working on a project that involves processing data from a question-answering system. The code snippet provided is part of a data processing pipeline that constructs MIL (Multiple Instance Learning) examples from a given input dictionary `x`. The dictionary `x` contains information about a question, its associat...
magicoder
You are tasked with creating a monitoring system for a blockchain node running on an Amazon EC2 instance. The system should monitor the disk usage and block information of the node and take appropriate actions based on the observed data. Your task is to implement a Python function that will analyze the disk usage and ...
magicoder
You are working on a project to simulate the behavior of biological cell membranes. The given code snippet contains method signatures for creating and generating cell membrane components. Your task is to implement a class that utilizes these methods to create a cell membrane structure based on the provided specificatio...
magicoder
You are tasked with implementing a real-time multiplayer game using NestJS and WebSockets. The provided code snippet is a partial implementation of a WebSocket gateway for the game. Your task is to complete the implementation of the `GameGateway` class to handle incoming WebSocket messages and manage game rooms. The `...
magicoder
You are tasked with implementing a Python script that processes a text template and removes leading and trailing newline characters from certain variables. The template contains placeholders that need to be replaced with actual values. Your task is to write a function that takes in the template and a dictionary of vari...
magicoder