instruction_seed
stringlengths
29
40.5k
source
stringclasses
6 values
You are tasked with implementing a function that simulates a requestAnimationFrame (RAF) loop using setTimeout. The goal is to create a function that can execute a given process at a consistent frame rate, similar to the native RAF behavior in web browsers. You are provided with the following code snippet as a startin...
magicoder
You are given a Python code snippet that processes a list of AMRs (Abstract Meaning Representation) and their alignments. The code iterates through the list of AMRs and prints the alignment information for each AMR. An AMR is represented as a graph with nodes and edges, and the alignment information associates nodes in...
magicoder
You are tasked with implementing a function to calculate the vertex normals of a 3D model. Vertex normals are used in computer graphics to determine how light reflects off a surface, and they are crucial for creating realistic lighting effects. You are given a Python code snippet that contains a function `getVertexNor...
magicoder
You are tasked with implementing a Python class that manages the output of a simulation. The class should inherit from a superclass and utilize a plotter object to handle the visualization of the simulation results. Your task is to complete the implementation of the `addOutput` method within the class. The provided co...
magicoder
You are tasked with implementing a Connect Four game using object-oriented programming in Python. The game will be played between two players, and the program should allow players to take turns placing their colored discs into a grid. The first player to connect four of their discs in a row, column, or diagonal wins th...
magicoder
You are tasked with implementing a function to calculate the total number of internal sectors in a given 2D grid. An internal sector is defined as a contiguous area of the grid that is completely surrounded by filled cells. The grid is represented as a 2D array of characters, where 'X' represents a filled cell and '.' ...
magicoder
You are tasked with implementing a function that processes a list of numerical values and returns a specific result based on certain conditions. The function should take in a list of integers and perform the following steps: 1. Calculate the sum of all the even numbers in the list. 2. If the sum is greater than 100, r...
magicoder
You are tasked with implementing a new data source class for a web application. The class, `HubspotFormsDataSource`, extends an `AbstractDataSource` and is intended to handle data from HubSpot forms. The class has a static property, `$identifier`, which is set to the value `'onedrop-form-hubspot-forms'`. Your task is t...
magicoder
You are tasked with creating a function that takes a list of email addresses and returns a list of corresponding GitHub usernames. The GitHub usernames are derived from the email addresses by extracting the username part before the "@" symbol. If the email address is invalid (i.e., does not contain "@"), it should be s...
magicoder
You are tasked with implementing a device management system that tracks the usage statistics of various devices. Each device is represented by a dictionary with the following structure: ```python device = { 'name': 'Laptop', 'serial': 'ABC123', 'times': 0, 'use_time': 0 } ``` Where: - `name` (string):...
magicoder
You are tasked with creating a Python script to monitor the disk usage of a system and write the data to a file. Your script should utilize the `psutil` library to gather disk usage information and the `open` function to write this information to a specified file. Additionally, the script should handle exceptions grace...
magicoder
You are tasked with creating a Python function that simulates the process of purchasing rubber ducks from an e-commerce website using Selenium. The function should handle the selection of different types of rubber ducks and ensure that the same type of duck is not purchased more than once. The function should return a ...
magicoder
You are tasked with implementing a Python function that calculates the numerically stable log probabilities for a mixture distribution. The function takes in a components distribution and a mixture distribution, and it should return the numerically stable log probabilities for the mixture distribution. The input compo...
magicoder
You are tasked with creating a Python class that simulates a message subscriber for a financial trading system. The subscriber will connect to a message broker and receive real-time market data. Your task is to implement the `subscriber` class with the following requirements: 1. The `subscriber` class should be initia...
magicoder
You are given a code snippet from a web application that manages catering services. The snippet is written in a combination of PHP and Blade templating language, commonly used in Laravel framework. The code is responsible for displaying the status of a catering service and providing options to update or delete the cate...
magicoder
You are tasked with implementing a custom assertion macro for pre-conditions in a C++ codebase. The macro should validate certain conditions before the execution of a function. The provided code snippet demonstrates the usage of the macro with three pre-conditions: `nbComponents > 0`, `formatType < Type::NbTypes`, and ...
magicoder
You are given a text file containing a list of words, each followed by a numerical value. Your task is to write a program that reads the file, finds the word with the highest numerical value, and then writes this word along with its value to an output file. The input file will have the following format: ``` apple 5 ba...
magicoder
You are tasked with implementing a class that simulates a 2D object's movement. The class should have methods to set and get the direction of the object's movement. The direction is represented by a 2D vector. Additionally, the class should calculate and store the delta vector, which is the difference between the curre...
magicoder
You are given a string `input` containing a sequence of characters. Your task is to implement a function or method that takes this string as input and returns a new string formed by interleaving the characters of the original string with a cyclically shifted version of itself. For example, if the input string is "abcd...
magicoder
You are given a Python function that processes a list of scores and calculates a mean value. Your task is to implement a function that replicates the behavior of the given code snippet. You need to write a Python function `calculate_mean_score(scores, atop, cfg)` that takes in three parameters: - `scores` (list of int...
magicoder
You are tasked with implementing a function to convert an EFI_STATUS error code into a corresponding error message. The EFI_STATUS type is commonly used in UEFI firmware development and represents various error conditions. Your goal is to create a function that takes an EFI_STATUS as input and returns the corresponding...
magicoder
You are given a program that manipulates sets of integers. The program uses two sets, `v` and `u`, and performs operations on them. Your task is to understand the operations and write a function to replicate the behavior of the given code snippet. The given code snippet is part of a larger program. The relevant part o...
magicoder
You are working on a deployment script for a Linux system and need to automate the setup of user-specific configurations for the XFCE desktop environment. Your task is to write a shell script that performs the following actions: 1. Copy the file "archlogo-full.svg" to the "/usr/share/icons/" directory using sudo privi...
magicoder
You are tasked with creating a unit test for a function that sends an email notification with a confirmation link. The function `mock_send_mail` is a mock object that simulates the email sending process. The test should verify that the `mock_send_mail` function is called, and that the confirmation link in the email poi...
magicoder
You are tasked with creating a Python function that processes a given CSV file and writes specific data to a new text file. The function should read a CSV file containing columns 'Name' and 'Description_Visual', and then write the contents of these columns to a text file, separated by a custom separator '[SEP]'. Write...
magicoder
You are tasked with implementing a role-based access control system for a web application. The system should allow users with different roles to access specific parts of the application. The roles are defined as an enum called `Roles`, which includes the following values: `Admin`, `Supplier`, `Customer`, and `Employee`...
magicoder
You are tasked with implementing a custom hash code and equality comparison method for a class in C#. The class represents a geometric shape and has a property called "Name" that uniquely identifies the shape. The hash code and equality comparison should be based on the "Name" property. Your task is to complete the im...
magicoder
You are tasked with creating a Python function that generates a customized plot based on given data. The function should take in two lists of data points, x_data and y_data, and a title for the plot. The x_data represents the x-axis values, and the y_data represents the corresponding y-axis values. The function should ...
magicoder
You are tasked with implementing a custom neural network model for a natural language processing task. The given code snippet is a part of the model definition, which includes a pooler layer and a loss function. The `forward` method is also provided, which takes various input parameters and performs the forward pass th...
magicoder
You are tasked with creating a simple web application to manage different types of currencies. The application will use a PHP framework that utilizes the Model-View-Controller (MVC) architecture. You need to define a model class for the "moneyType" table, which will represent the different types of currencies supported...
magicoder
You are tasked with implementing a Python function that processes a list of layer configurations for a neural network. Each layer configuration is represented as a dictionary with the following keys: - "type": a string indicating the type of layer (e.g., "conv", "fc", "norm") - "channels": an integer representing the n...
magicoder
You are tasked with implementing a Python function that processes a list of lists comprised of strings. The function should remove any duplicate sub-lists and any duplicate string elements within the sub-lists. If the input does not adhere to the specified data type or structure, the function should raise a TypeError w...
magicoder
You are tasked with implementing a module system for a 2D vector library in Rust. The library should provide functionality for working with points, vectors, lengths, and various beings in a 2D space. Your task is to create the necessary modules and define their contents to achieve the desired functionality. You are pr...
magicoder
You are tasked with implementing a custom data structure to represent a navigation row in a mobile application. The `NavigationRow` should have the ability to store a title, a subtitle, and an optional icon. Your task is to design the `NavigationRow` class with appropriate properties and methods to achieve this functio...
magicoder
You are tasked with implementing a Python class that simulates a simple bank account. The account should support basic operations such as deposit, withdrawal, and balance inquiry. Additionally, the account should have an interest rate associated with it, and the balance should accrue interest over time. Your task is t...
magicoder
You are tasked with implementing a secure password management system for a web application using Python and Flask. The given code snippet includes a User class with methods for setting and checking passwords, as well as a Wotd class for managing Japanese word of the day entries. Your task is to complete the implementat...
magicoder
You are tasked with implementing a web attack protection system that can be toggled on or off. The system is represented by a class `WebAttackProtection` with a property `serviceOn` that indicates whether the protection is active or not. The `serviceOn` property can have the values "ON" or "OFF". Your task is to implem...
magicoder
You are tasked with implementing a drawing application that can render shapes using different drawing APIs. The application should support rendering shapes such as circles, squares, and triangles. To achieve this, you need to create a set of shape classes that utilize a provided drawing API to render the shapes. The dr...
magicoder
You are tasked with creating a TypeScript function that determines the environment based on the value of `process.env.NODE_ENV`. The function should take no parameters and return a string indicating the environment. The possible environments are "development", "production", and "test". If `process.env.NODE_ENV` is not ...
magicoder
You are tasked with creating a Python function that generates a plot of a given mathematical function using the matplotlib library. The function should take the mathematical function, the range of x-values, and the title of the plot as input parameters. The plot should have a grid, and the y-axis limits should be set t...
magicoder
You are tasked with creating a generic class that represents a view model for elements in a software application. The class should be able to handle various types of elements and provide a common interface for interacting with their data. Your task is to complete the implementation of the `ElementViewModel` class, whi...
magicoder
You are tasked with implementing a function that takes two strings, `a` and `b`, as input and returns the longest common subsequence (LCS) of the two strings. A subsequence is a sequence that appears in the same relative order, but not necessarily contiguous. For example, "abc", "abg", "bdf", "aeg", "acefg", .. etc are...
magicoder
You are tasked with creating a Python function that simulates a simplified version of a Discord bot's channel management functionality. The function should take in a list of channel names and create these channels in a guild, while also deleting any existing channels in the guild. The function should follow these speci...
magicoder
You are given a task to implement a function that generates a specific pattern based on the input size. The pattern consists of a series of numbers arranged in a specific format. The function should handle the corner case where the input size is 0, and the pattern should have no contents. Write a Python function calle...
magicoder
You are tasked with creating a Python program to organize image files into different directories based on their file extensions. Your program should take a list of image files and move them to specific directories based on their file extensions. The program should create the necessary directories if they do not already...
magicoder
You are tasked with implementing a sorting algorithm for a custom data structure called `BlockStack`. The `BlockStack` is a stack-like structure that contains blocks, where each block has a color represented by a string. Your goal is to sort the blocks within the `BlockStack` based on their colors in a specific order. ...
magicoder
You are tasked with creating a Bash script to automate the process of moving specific files into a designated folder. Your script should be able to identify the target files and relocate them to the specified destination. Write a Bash script named `file_mover.sh` that accomplishes the following: - Moves the `README.m...
magicoder
You are tasked with creating a Python class to represent a movie. The class should have attributes for the movie's title, storyline, poster image URL, and YouTube trailer URL. Additionally, the class should have a method to show the movie trailer. Create a class `Movie` with the following attributes and method: - `tit...
magicoder
You are tasked with creating a Python program to analyze a file containing time-stamped data. The file contains a series of lines, each representing a time stamp in the format "HH:MM:SS". Your program needs to read the file, calculate the time difference between consecutive time stamps, and then determine the average t...
magicoder
You are tasked with creating a custom form validation function for hostnames in a Swift application. The function should ensure that the provided hostname is valid and properly formatted. A valid hostname should not contain any leading or trailing whitespaces, should not include a protocol prefix (e.g., "http://"), and...
magicoder
You are tasked with implementing a Vector2 class in Python to represent 2D vectors and providing various functionalities for vector manipulation. The class should support operations such as vector addition, subtraction, magnitude calculation, angle calculation, and conversion to a tuple. Your task is to implement the ...
magicoder
You are tasked with creating a PHP function that processes a given HTML string to extract and modify specific elements. Your function should locate the "powered by" attribution in the HTML and replace the URL with a new one. The HTML may contain various elements, but the "powered by" attribution will always be in the f...
magicoder
You are tasked with implementing a singleton pattern for a `GraphicsBitmapLoader` class in a C# application. The `GraphicsBitmapLoader` class is responsible for loading bitmap images for graphics rendering. Your goal is to ensure that only one instance of the `GraphicsBitmapLoader` class can be created, and that this i...
magicoder
You are tasked with implementing a function that processes a remote resource containing time series data and extracts specific information from it. The remote resource is represented as a JSON object, and the time series data is stored in a nested dictionary structure. Your goal is to extract and manipulate this time s...
magicoder
You are tasked with implementing a Python class for representing a Line in a 3D arena. The class should have the following features: - It should be named `Line`. - It should inherit from the `Object` class. - It should have an `__init__` method that takes two optional arguments: `start` and `end`, both of which default...
magicoder
You are tasked with implementing a function that calculates the sum of all prime numbers within a given range. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Your function should take two integers, `start` and `end`, as input and return the sum of all prime numb...
magicoder
You are tasked with creating a Python class to represent a person's physical attributes and calculate their Body Mass Index (BMI). The BMI is calculated as the individual's weight in kilograms divided by the square of their height in meters. Your class should have the following attributes and methods: Attributes: - `n...
magicoder
You are tasked with creating a program to manage a database of vaccinated individuals. The program should allow users to add new vaccinated individuals, remove existing records, and display the total number of vaccinated individuals. To achieve this, you need to implement a class called `VaccinationDatabase` with the f...
magicoder
You are tasked with implementing a Python class that can execute SQL statements. The class should support executing SELECT, INSERT, UPDATE, and DELETE SQL statements on a given database. Your task is to complete the implementation of the `ExecuteSQL` class by adding methods for executing different types of SQL stateme...
magicoder
You are tasked with creating a Python function that reads a directory and returns a list of all files with a specific file extension. Your function should take two parameters: the directory path and the file extension. The function should then traverse the directory and its subdirectories to find all files with the spe...
magicoder
You are tasked with implementing a class for stereo camera calibration in Python. The class should be able to read calibration parameters from XML files and perform stereo calibration and rectification. The provided code snippet shows the initialization of file paths and the usage of a `StereoCalibration` class to read...
magicoder
You are tasked with implementing a simple text-based game where the player navigates through a maze. The maze is represented as a 2D grid, where each cell can be either empty (denoted by '.') or blocked (denoted by '#'). The player starts at the top-left corner of the maze and must reach the bottom-right corner. The pl...
magicoder
You are tasked with creating a PHP class that simulates sending messages. Your task is to implement a `SenderFake` class that extends the `Sender` class and sets the public property `$name` to 'sender_fake'. Your task is to complete the `SenderFake` class by adding the necessary code to achieve the desired behavior. ...
magicoder
You are given a Python code snippet that processes metadata from an experiment. The code uses a lambda function to create a short label for each data item and then iterates through the items to extract the experiment type. Your task is to create a program that simulates the processing of this metadata and extracts spec...
magicoder
You are tasked with creating a function to encrypt a message using a modified Caesar cipher. The function `encrypt(message, key_one, key_two)` takes three parameters: `message` (a string), `key_one` (an integer), and `key_two` (an integer). The function should return the encrypted message based on the following rules: ...
magicoder
You are given a string `strLoc` representing a location code and an empty string `strValue`. Your task is to write a function `ExtractDigits` that extracts all the digits from `strLoc` and concatenates them into `strValue`. The function should then return the resulting `strValue`. For example, if `strLoc = "Loc_000oo"...
magicoder
You are tasked with implementing a resource pool for managing objects of a specific type. The resource pool should allow efficient reuse of objects to prevent unnecessary memory allocation and deallocation. Your goal is to create a resource pool for managing objects of the `AACFrame` class, which represents frames of A...
magicoder
You are tasked with creating a Python function that takes a prompt message as input and prompts the user to input a "yes" or "no" response. The function should handle the possibility of a user interrupting the input process with a keyboard interrupt (Ctrl+C) and return an appropriate value in such cases. The function s...
magicoder
You are tasked with creating a Python function that manipulates lists using list comprehensions. Your function should take a list of integers as input and perform the following operations: 1. Create a new list containing the squares of the input list elements. 2. Create a new list containing tuples of all combinations...
magicoder
You are tasked with creating a custom authentication mixin for a Django web application. The mixin should restrict access to certain views based on a specific user test. You will need to implement a custom mixin class that inherits from `UserPassesTestMixin` and restrict access to a particular view by overriding the `t...
magicoder
You are tasked with creating a program to manage permissions for a cluster management system. The program should allow adding various checks required for starting a cluster on minikube and provide methods to run these checks. Your task is to implement the `ClusterChecker` struct and its associated methods as described ...
magicoder
You are tasked with implementing a Python module that provides a custom hexdump function for displaying the hexadecimal content of a file. The module should also include a helper function for abbreviated usage and a constant for enabling colored output. Your task is to create a Python module that fulfills the followin...
magicoder
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, ...
magicoder
You are tasked with creating a command-line utility using Python's `argparse_flags` library to manage different subcommands. The utility should support two subcommands: `encrypt` and `decrypt`. The `encrypt` subcommand should take a message as input and encrypt it using a simple substitution cipher, while the `decrypt`...
magicoder
You are tasked with creating a command-line interface (CLI) tool for managing configuration files using Python's Click library. Your goal is to implement a CLI command that allows users to create or check cedar configuration files. The command should be part of a larger CLI tool and should be implemented using the Clic...
magicoder
You are tasked with creating a simple Vue.js application that displays a list of items and allows the user to add new items to the list. The application should consist of a single component called `ItemList`, which will be rendered using the provided code snippet. Your task is to implement the `ItemList` component to a...
magicoder
You are tasked with implementing a JavaScript function that takes in an object representing options for a user interface component and returns a string representing the HTML markup for rendering the component. The options object contains properties such as `type`, `label`, `value`, and `options` that need to be utilize...
magicoder
You are tasked with implementing a simplified version of an asynchronous queue in Python. The queue should support adding data to the queue and retrieving data from the queue in an asynchronous manner. Your task is to complete the implementation of the `AsyncQueue` class by adding the `put` and `get` methods. The `Asy...
magicoder
You are tasked with creating a script to automate the build process for a set of projects. The script should iterate through a list of project directories, build each project using the "go build" command, and then move the built executable to a common "bin" directory. You are given a code snippet as inspiration, which...
magicoder
You are tasked with implementing a function to process genetic sequence alignments and extract translations, while handling potential warnings. The function should take an alignment, strip insertions, and then partition the translations into valid results and warnings. The warnings should be encapsulated in a `PeptideW...
magicoder
You are tasked with implementing a custom data structure in C# that represents a simplified version of a linked list. Your custom linked list should support the basic operations of adding elements to the end of the list, removing elements from the list, and checking if a specific element is present in the list. Your c...
magicoder
You are tasked with implementing a function to find all prime numbers up to a given integer N. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Your task is to write a function that returns a vector containing all prime numbers up to N. Your function signature sh...
magicoder
You are tasked with implementing a function that processes and generates HTML output for a pricing plan. The function takes in several parameters and constructs the HTML output based on the provided inputs. Your task is to complete the function by implementing the missing parts. The function `generate_pricing_plan_htm...
magicoder
You are tasked with creating a Python function that processes a list of fairness constraints extracted from a liveness property and returns a modified list of constraints. The function should take into account the conversion of liveness constraints to safety constraints and the folding of fairness constraints using a s...
magicoder
You are tasked with implementing a custom logging system for a software application. The system should handle different types of log messages and provide flexibility for future enhancements. Your task is to design and implement a logging class that supports logging messages with different severity levels and allows for...
magicoder
You are tasked with implementing a settlements API for a financial platform. The API should provide methods for retrieving settlements based on certain criteria. You are given an interface `ISettlementsApi` with two methods: `GetAllSettlements` and `GetSingleSettlement`. The `GetAllSettlements` method retrieves all set...
magicoder
You are tasked with creating a Python program that simulates a simple asynchronous task using the `asyncio` library. Your program should define a coroutine function that simulates a time-consuming task and then use the `asyncio` event loop to execute this coroutine. Your coroutine function, named `simulate_task`, shou...
magicoder
You are tasked with creating a Python class that implements a machine learning model for binary classification. The class should have a method to predict the probabilities of the positive class for a given set of input features. You are provided with a code snippet that represents the usage of this method. Your task i...
magicoder
You are given a Python code snippet that is part of a unit test for a function. The function is expected to compare the actual and expected values of various parameters and return `True` if they match, and `False` if they do not. Your task is to write a function that simulates the behavior of the unit test and returns ...
magicoder
You are tasked with creating a Python function that processes a given file type and returns a list of files with the specified file type. The file type is represented by a string variable `_fileType`. The function should search for files in a specified directory and its subdirectories, and return a list of file names t...
magicoder
You are tasked with creating a Python function that processes a configuration file and extracts the list of plugins specified in the file. The configuration file follows a simple format where each plugin is listed under the "DEFAULTS" section. You need to implement a function `extract_plugins(config_file_path: str) ->...
magicoder
You are tasked with implementing a SystemSleepPreventionToken class in Swift. The SystemSleepPreventionToken class is designed to prevent the system from entering sleep mode by acquiring a token and releasing it when it is no longer needed. The class should provide a mechanism to prevent the system from sleeping and al...
magicoder
You are tasked with implementing a function to retrieve information about a unit from a client in a Rust program. The client has a method `create_unit` to create a unit with a given name, state, and options. Your task is to complete the code by implementing the function `get_unit_info` that retrieves information about ...
magicoder
You are tasked with implementing a custom `Scanner` extension in Swift that can parse a given string and extract specific data from it. The extension should provide a method to parse a string and return a collection of integers found within the string. Your task is to complete the implementation of the `Scanner` exten...
magicoder
You are tasked with creating a script to automate the generation of multiple configuration files for a machine learning model training process. The script should replace specific placeholders in the configuration file and generate new files with updated values. The script should perform the following tasks: 1. Replac...
magicoder
You are tasked with implementing a salary validation service for a tax calculator application. The service should ensure that the provided salary is within the valid range and format. The application uses the `TaxCalculator.Constants.Constants` class, which contains the minimum and maximum salary constants. Your task ...
magicoder
You are tasked with creating a Python function that processes a list of image URLs and extracts the image IDs from them. The image URLs are in the format `https://www.duelingbook.com/images/custom-pics/{image_id}/{image_name}.jpg`, where `{image_id}` is a unique numerical identifier for the image. Your function should ...
magicoder
You are tasked with implementing a simple hardware description language (HDL) parser. HDL is used to describe the behavior of digital circuits and is often used in the design and simulation of electronic systems. Your task is to write a function that parses a given HDL code snippet and extracts the input signals defin...
magicoder
You are tasked with implementing a custom module loader for a JavaScript application. The module loader should be able to dynamically load and register add-ons for a storybook application. The add-ons are provided as separate modules, and the loader should be able to import and register these add-ons based on the confi...
magicoder
You are tasked with creating a Rust library for resolving various computational problems. The library should provide access to the resolution functionality through its public interface. Your task is to implement the necessary code to achieve this. Your goal is to create a module named `resolve` and make it accessible ...
magicoder