instruction_seed
stringlengths
29
40.5k
source
stringclasses
6 values
You are tasked with creating a password validation function that checks whether a given password meets specific criteria. The function should ensure that the password contains at least one character from each of the following categories: lower-case characters (a-z), upper-case characters (A-Z), digits (0-9), and non-al...
magicoder
You are tasked with creating a PHP function that processes a given array of messages and generates HTML output based on their status. The function should take an array of message statuses as input and produce the corresponding HTML output. The message statuses can be one of the following: - "unread": Indicates an unre...
magicoder
You are tasked with creating a file upload validation system for a web application using PHP. You need to implement a method within the `Files` class that validates the uploaded file based on certain rules. The `Files` class is a model class that represents files in the application. It has a public property `$file` wh...
magicoder
You are tasked with creating a Python function that manipulates file paths and names. Your goal is to implement a function that takes a file path as input and returns the path and the file name separately. Additionally, you need to create a function that generates a timestamp in the format of YYYY-MM-DD_HH-MM when a sp...
magicoder
You are tasked with implementing a Python class that represents a simple bank account. The class should have the following functionalities: 1. Initialize the account with the account holder's name and an initial balance. 2. Deposit funds into the account. 3. Withdraw funds from the account. 4. Return the current balan...
magicoder
You are tasked with creating a Python class to represent a device in a home automation system. The class should have attributes to store the device's UUID, AKS ID, description, unit, creation timestamp, and update timestamp. Additionally, you need to implement a method to retrieve the device information from the system...
magicoder
You are tasked with creating a dynamic module system in a TypeScript application using NestJS. The goal is to implement a feature module that can be dynamically registered with different configurations and then retrieved for use within the application. Your task is to complete the implementation of the `MyDynamicRootM...
magicoder
You are tasked with implementing a custom loss function for a machine learning model. The loss function should compute the difference between the model's prediction and the target. You are provided with a Python code snippet for a `Loss` class, which is a stateful object that computes the loss. Your task is to extend t...
magicoder
You are tasked with implementing a CycleSweep class that performs a specified number of passes across a Timeline until a stop signal is given. The CycleSweep class should be designed to work with Subscriber and Timeline classes, and it should utilize the Sweepline class as a base. Your task is to implement the CycleSw...
magicoder
You are tasked with creating a Python class that represents a collection of items and allows for various operations to be performed on the items. Your task is to implement the `DemoItemList` class, which is a subclass of `ItemList` from the `pyscrap3` library. The `DemoItemList` class should have the following function...
magicoder
You are tasked with creating a Python script that dynamically generates a list of required packages for a given module based on the code snippet provided. The script should parse the code snippet and extract the required package names from the `REQUIRED` list. The script should then print the names of the required pack...
magicoder
You are tasked with implementing a simple cryptocurrency trading system. The system consists of two modules: `faucet` and `indexer`. The `faucet` module is responsible for simulating the distribution of new cryptocurrency tokens to users, while the `indexer` module is responsible for tracking and indexing all transacti...
magicoder
You are tasked with creating a program to manage a system of payment channels for a platform. Each payment channel is associated with a unique ID and belongs to a specific platform. Your task is to implement a method that establishes a relationship between the payment channel and its associated platform. You are given...
magicoder
You are tasked with implementing a PDF extraction function that can extract text and metadata from a given PDF file. Additionally, the function should support an optional parameter to extract images from the PDF. You are provided with a code snippet that contains test cases for the PDF extraction function. Your task is...
magicoder
You are tasked with creating a spellbook management system for a magical academy. The system should allow wizards to add, remove, and search for spells in their spellbook. Each spell is represented as an object with a name and a description. Create a class `Spellbook` with the following methods: 1. `addSpell(name: str...
magicoder
You are tasked with creating a Python program to monitor and manage a job queue for a high-performance computing cluster using SLURM Workload Manager. The program should periodically check the status of submitted jobs by comparing the corresponding .com and .log files and resubmit any failed jobs until all jobs are suc...
magicoder
You are tasked with implementing a function that processes geographic coordinates data for China. The provided code snippet is a part of a larger program that contains a map of China with various features and properties. The `ChinaCoordinatesL1` object contains the name and coordinates of different regions in China. Yo...
magicoder
You are tasked with implementing a WPF converter that takes in a `WindowState` enum value and returns a corresponding `Visibility` enum value based on the provided parameter. The converter should return `Visibility.Visible` if the `WindowState` matches the parameter condition, and `Visibility.Hidden` otherwise. Your t...
magicoder
You are tasked with implementing a checkpoint management system for a deep learning model using TensorFlow. Checkpoints are used to save the model's parameters during training, allowing the model to be restored at a later time. Your goal is to create a class that handles the saving and restoring of checkpoints using Te...
magicoder
You are tasked with implementing a file snapshot function for a version control system. The function should take in a list of files, a specific revision node, and a temporary root directory, and create a snapshot of the files as they were at the given revision. The function signature is as follows: ```python def snaps...
magicoder
You are given a sequence of integers representing the positions of holes on a road. The goal is to determine the minimum number of patches required to cover all the holes using patches of length L. A patch can cover a range from position x to position x+L. If a hole cannot be covered by any existing patch, a new patch ...
magicoder
You are tasked with implementing a simple module loader for a JavaScript application. The module loader should be able to resolve and import modules based on their file paths. Each module is represented by a file, and the module loader should be able to handle both relative and absolute file paths. Your task is to imp...
magicoder
You are tasked with creating a Python function that parses and processes URL routes based on a given configuration. The configuration consists of route names and their corresponding URL patterns. Each URL pattern may contain placeholders for dynamic values, such as IDs. Your function should be able to match a given URL...
magicoder
You are working on a structural analysis software and need to implement a function to define and integrate beam sections. The software uses the OpenSeesPy library for structural analysis. The code snippet provided demonstrates the usage of various functions to define and integrate beam sections. Your task is to implem...
magicoder
You are tasked with implementing a function to animate the layout of a header based on certain conditions. The function `animateHeaderLayout` takes two parameters: `direction` (either `.horizontal` or `.vertical`) and `duration` (the duration of the animation in seconds). The conditions for calling this function are as...
magicoder
You are tasked with implementing a function that copies a specific portion of a struct from one position to another within a given array. The function `copy_inline_struct` takes in four parameters: `dst_pos`, `src`, `p`, and `src_pos`. The `src` parameter is an array that contains the struct to be copied, and `p` is a ...
magicoder
You are tasked with creating a script to automate the process of downloading a dataset and extracting its contents. The dataset is the IMDb movie review dataset, which is available for download as a compressed file from the URL `http://ai.stanford.edu/~amaas/data/sentiment/aclImdb_v1.tar.gz`. Your script should downloa...
magicoder
You are tasked with analyzing a dataset containing information about public keys. The dataset is represented as a list of dictionaries, where each dictionary contains information about a public key. Your goal is to write a function that processes this dataset and returns a summary of the key types and their respective ...
magicoder
You are tasked with creating a function that processes a message template and a list of project names to generate a formatted message. The message template contains placeholders for the project names and a link to a URL. The function should replace the placeholders with the project names and the URL, and return the for...
magicoder
You are tasked with implementing a simple counter using messaging over a channel in Rust. The counter should have the ability to increment and decrement its value based on messages received over the channel. Your task is to complete the implementation of the `Counter` struct and its associated methods. The `Counter` s...
magicoder
You are tasked with implementing a command-line tool for image processing. The tool allows users to apply various adjustments to images, such as changing the hue, brightness, and contrast. The code snippet provided is a part of the implementation for adjusting the hue of an image. The `$this->addCommand(['op_hue' => $a...
magicoder
You are tasked with implementing a URL shortening service that takes a long URL and converts it into a shorter, more manageable form. To achieve this, you need to create a class that handles the conversion of URLs to their corresponding file system paths. The class should have the following attributes: - `max_len`: An ...
magicoder
You are tasked with creating a Python package management system that can handle the installation and management of various packages. Your system should be able to parse a configuration file, extract package information, and perform the necessary actions to set up the packages. For this problem, you will focus on parsin...
magicoder
You are tasked with creating a custom Angular directive that dynamically generates breadcrumb navigation based on the current route. The directive should be able to parse the route hierarchy and display a breadcrumb trail for easy navigation within the application. Your task is to implement the `NgxCrumbDirective` tha...
magicoder
You are tasked with implementing a function that interacts with a web service to place an order. The function takes in a list of root certificates, a data builder function, and a URL. It then makes a POST request to the specified URL using the provided root certificates and data builder function. The response is expect...
magicoder
You are tasked with creating a script to manage a directory structure. Your script should take a list of directory names as input and perform the following operations for each directory: 1. If the directory already exists, it should be removed. 2. A new directory with the same name should be created. Your script shou...
magicoder
You are tasked with implementing a simplified version of the Kohonen self-organizing map algorithm for a digit recognition system. The Kohonen algorithm is a type of artificial neural network used for clustering and pattern recognition. In this problem, you will need to implement the training and recognition logic for ...
magicoder
You are tasked with implementing a simplified version of an event-driven order processing system. The system consists of an `Instance` class, which represents a specific instance of order processing, and various event classes that can be processed by the `Instance` to update its data. The `Instance` class has the foll...
magicoder
You are tasked with implementing a Python class that publishes messages to an MQTT broker using the Paho MQTT client library. The class should handle the connection to the broker and provide a method for publishing messages. Your task is to complete the implementation of the `PublishAction` class by adding the necessar...
magicoder
You are tasked with implementing a function that processes a list of notifications and returns a summary of the notifications for display. Each notification is represented as an object with the following structure: ```javascript { id: string, // unique identifier for the notification message: string, // content of ...
magicoder
You are tasked with creating a Python program that simulates a simple web server using the `wsgiref` module. Your program should accept command-line arguments for the server address and port, and it should serve a static file using the WSGI server. Your program should perform the following tasks: 1. Parse command-line...
magicoder
You are tasked with creating a Python function that processes a list of GitHub repository names and their star counts, and then generates a report based on certain criteria. The function should take in a list of tuples, where each tuple contains the repository name as a string and its corresponding star count as an int...
magicoder
You are working on a project that involves processing chemical compounds using the RDKit library in Python. Your task is to create a program that reads a ligand file in SDF (Structure Data File) format, assigns bond orders from a template molecule, and then converts the modified molecule to a PDB (Protein Data Bank) fi...
magicoder
You are tasked with implementing a validation function in TypeScript that composes multiple validation functions into a single validation function. The provided code snippet offers a starting point for the `composeValidations` function, which takes an arbitrary number of validation functions as arguments and returns a ...
magicoder
You are tasked with creating a custom field class in Python that will be used for deserialization in a data processing application. The custom field, named `CronField`, should be designed to handle the deserialization of cron expressions, which are used to define time intervals for scheduling tasks. A cron expression c...
magicoder
You are tasked with implementing a simple asynchronous task manager in Swift. The task manager should support registering completion handlers for different tasks and then invoking these handlers when the task is completed. You need to implement a class `TaskManager` with the following requirements: - The class should ...
magicoder
You are tasked with implementing a custom parser for a simplified markup language. The parser is responsible for processing input tokens and creating nodes based on the parsed information. Your task is to complete the implementation of the `parse` method within a class, which takes a `parser` object as an argument. The...
magicoder
You are given a dictionary containing key-value pairs where the keys are strings representing different technology acronyms and the values are the corresponding full names of the technologies. Your task is to write a function that converts the dictionary into a list of strings, where each string represents the full nam...
magicoder
You are tasked with creating a SwiftUI component for a digital magazine app. The component should display a series of pages, allowing the user to swipe left or right to navigate through the pages. Each page should occupy the entire screen width and height. The component should also support gestures for navigating betwe...
magicoder
You are tasked with creating a program that generates a simple image with a specific pattern. The program should use the Python Imaging Library (PIL) to create a new RGB image with dimensions 300x28 and draw a pattern on it. Your task is to draw a series of rectangles on the image using the ImageDraw module from the P...
magicoder
You are tasked with implementing a game management system for a mobile game. The system needs to handle the transition between different scenes and perform specific actions during these transitions. The provided code snippet is from the script responsible for transitioning from the gameplay scene to the menu scene. The...
magicoder
You are tasked with implementing a function to determine whether a given line segment intersects with a quadrangle in a 2D plane. The quadrangle is defined by a list of four points, and the line segment is defined by its start and end positions. The intersection test should consider the line segment as part of the inte...
magicoder
You are tasked with implementing a Python class that delegates method calls to another object. Your goal is to create a class `Delegator` that takes an instance of another class as an attribute and delegates method calls to that instance. The `Delegator` class should have a method `do_something()` that delegates the ca...
magicoder
You are tasked with creating a script to automate the process of updating a software repository. The script should perform the following steps in sequence: 1. Pull the latest changes from the remote repository and rebase the current branch. 2. Merge the changes from a specified branch into the current branch. 3. Clean...
magicoder
You are tasked with implementing a function that performs a specific tensor manipulation operation using the PyTorch library. The function takes a 4-dimensional input tensor `x` with dimensions representing batch size, channels, height, and width, and applies a series of operations to rearrange its dimensions and resha...
magicoder
You are tasked with creating a script that automates the user management process for a development environment. The script should take user input and use it to create a new user with specific configurations. Additionally, the script should then execute a command with the newly created user's privileges. Write a Bash s...
magicoder
You are tasked with implementing a token authentication middleware for a web server. The middleware is responsible for extracting a token from the request headers and populating a context dictionary with the token information. Your task is to complete the implementation of the `TokenAuthMiddleware` class by adding the ...
magicoder
You are tasked with implementing a Java class that utilizes nested generic types. Your task is to create a class with a specific nested generic type structure and provide a method to set and retrieve a value of the innermost generic type. Create a Java class called `NestedGenericClass` with the following nested generi...
magicoder
You are tasked with creating a program to perform frequency analysis on a given ciphertext. Frequency analysis is a technique used in cryptanalysis to study the frequency of letters or symbols in a ciphertext. The provided code snippet is a part of a Python program that visualizes the frequency analysis results using a...
magicoder
You are given a 2D grid represented by a matrix of integers. The grid contains cells, and each cell has a value. Starting from a given cell, you need to move in four directions (up, down, left, and right) and update the values of the cells you visit. The updates are as follows: - When moving up, increment the value of ...
magicoder
You are tasked with creating a form component for a project management application. The form should allow users to add and manage project tasks. The code snippet provided is a part of the form component's logic written in TypeScript using Angular's Reactive Forms. The snippet initializes form controls for various prop...
magicoder
You are tasked with implementing a program to manage a warehouse inventory system. The inventory consists of various items, each with a unique name. Your program should support adding new items to the inventory, removing items, and displaying the current inventory list in alphabetical order. You are given a list of it...
magicoder
You are tasked with creating a web application for managing machines in a factory. The application should allow users to add new machines and view existing ones. The code snippet provided is a part of the application's view file written in Laravel's Blade templating engine. The snippet shows the HTML markup for a butto...
magicoder
You are tasked with implementing a custom decorator that measures the execution time of a function in Python. Your decorator should be able to calculate the time taken for the function to execute and print the result in milliseconds. You should also ensure that the original function's return value is preserved and retu...
magicoder
You are tasked with implementing a class that handles the state of a button. The class should track whether the button has been pressed or released since the last time its state was checked. The class should also provide a method to reset the state of the button. You are given the following code snippet as a starting ...
magicoder
You are tasked with creating a Python plugin for a build automation tool that checks the adherence of Python code to PEP 8 style guidelines. The provided code snippet is a part of the plugin development process. The plugin should integrate with the build tool and ensure that the `pep8` tool is available for code analys...
magicoder
You are tasked with implementing a function `to_datetime` that takes a dictionary representing a date and time and returns a string in the format "YYYY-MM-DD HH:MM:SS". The input dictionary will have the following keys: "year", "month", "day", "hour", "minute", and "second", each corresponding to the respective compone...
magicoder
You are tasked with implementing a custom `randrange` function that mimics the behavior of Python's `random.randrange` function. The `randrange` function should take in two parameters, `start` and `stop`, and return a randomly selected element from the range created by the `start` (inclusive) and `stop` (exclusive) par...
magicoder
You are given a list of test parameters, where each parameter is a list of strings representing coordinates on a grid. Each string consists of a letter (A-L) and a number (1-9) representing a cell on the grid. Your task is to write a function that processes these test parameters and returns a dictionary where the keys ...
magicoder
You are tasked with implementing a TaskManager class that can handle the execution of tasks. The class should support starting and finishing tasks, with the ability to log task execution if required. Each task can have optional metadata associated with it. Your task is to complete the implementation of the TaskManager...
magicoder
You are tasked with implementing a class loader system for a PHP framework. The class loader system should be able to load various types of classes in a specific order. The classes to be loaded are provided as an array of class names. Each class loader should load the classes in the order specified and provide a method...
magicoder
You are tasked with creating a program that simulates a simple database management system. The program should handle the creation of databases and provide feedback if a database already exists. Your task is to implement the logic for checking if a database already exists and printing an appropriate message. You are gi...
magicoder
You are tasked with implementing a Python decorator that ensures a function is only called if certain conditions are met. The decorator should be able to handle the following scenario: if the function is called with a specific message text, it should reply with the current state of a handler object. Your task is to co...
magicoder
You are tasked with implementing a ProjectileQueue class that manages a queue of projectiles in a game engine. The class should support adding projectiles to the queue, updating their positions, and drawing them using a provided renderer. The update method should advance the position of the front projectile in the queu...
magicoder
You are given a Python code snippet that processes a list of lists to create two matrices. Your task is to implement a function that takes the input list and returns the count of occurrences of a specific character in the second matrix. You need to write a Python function called `count_char_occurrences(matrix, char)` ...
magicoder
You are tasked with creating a program that utilizes the AWS Rekognition service to detect labels in images. The AWS Rekognition service provides an API for image analysis, including label detection, facial analysis, and text recognition. In this problem, you will be focusing on the label detection functionality. Your...
magicoder
You are tasked with creating a simple iOS app that displays a list of items in a table view. The app should have a navigation bar at the top and each item in the list should be tappable to navigate to a detail view. You need to implement the necessary SwiftUI code to achieve this functionality. Your task is to complet...
magicoder
You are tasked with implementing a WebSocket server that authenticates incoming connections using an authentication token and manages session tokens for each connected client. The server should use the `aioredis` library to interact with a Redis database for token validation and session management. Additionally, the se...
magicoder
You are tasked with implementing a Python class method that tests whether a given number falls within a specified range. The method `testRange` should take two parameters: `num` (an integer) and `range_tuple` (a tuple of two integers representing the inclusive lower and upper bounds of the range). The method should ret...
magicoder
You are tasked with implementing a Python class that represents a client cache for storing and computing paths involved in the execution of Conan commands. The class should inherit from the `SimplePaths` class and provide functionality for accessing the disk, reading, and writing files. Your task is to complete the imp...
magicoder
You are tasked with implementing a simple JavaScript class that manages resources using a repository pattern. The provided code snippet is a part of a method that is responsible for creating a new instance of a repository and initializing it with a resource and a data mapper. Your task is to complete the implementatio...
magicoder
You are tasked with implementing a function to process time entries and generate a report based on the time spans. The time entries are represented as tuples of start and end times in the format (hour, minute). The report should categorize the time spans into days and calculate the total duration for each day. You nee...
magicoder
You are tasked with creating a Django model for a new feature in a web application. The model should represent a global alert that can be displayed to all users of the application. The alert should have a flag to indicate whether it is currently active and a field to store the content of the alert message. Your task i...
magicoder
You are tasked with creating a script to automate the setup and execution of a deep learning model for adversarial detection. The script should utilize Nvidia Docker to run the model within a specific environment and execute a detection script. Given the following code snippet as a starting point: ``` nvidia-docker r...
magicoder
You are tasked with implementing a custom exception class for handling labeling operations on read replica nodes in a database system. The provided code snippet is a Java class definition for the exception `ReadReplicaNodeLabelingOperationException`. This exception is thrown when a labeling operation on a read replica ...
magicoder
You are tasked with creating a Python function that parses a given list of strings representing metadata for Python packages and returns a dictionary containing the parsed information. Each string in the input list represents metadata for a single Python package and follows the format: ``` 'Package :: PackageName', 'A...
magicoder
You are tasked with creating a class that represents a resource in a software system. The class should have properties for the resource's full name and type. Additionally, the type property should be marked as required, indicating that it must have a value assigned to it. Your task is to implement the class with the re...
magicoder
You are tasked with creating a custom validation system for a data processing application. The system should include two specific validators: `NumericValidator` and `BooleanValidator`. The `NumericValidator` is responsible for validating and converting numeric values, while the `BooleanValidator` is responsible for val...
magicoder
You are tasked with creating a Java program that parses a collection of SGF (Smart Game Format) files and extracts specific information from them. SGF is a text-based format for storing board game data, particularly for Go, chess, and similar games. Your program should be able to read an SGF file and extract the number...
magicoder
You are tasked with implementing a text similarity computation function using n-grams and weights. The function should take two strings as input and return their similarity score based on the provided parameters. You are given the following parameters: - `first`: The first input string. - `second`: The second input st...
magicoder
You are tasked with creating a Django web application for a book library. The application should have a model for books with the following fields: title, author, genre, and publication date. Additionally, you need to create a view to display all the books in the library. Write a Django model for the book with the spec...
magicoder
You are given a Python function that determines whether a given number is abundant, deficient, or perfect based on its aliquot sum. The aliquot sum of a number is the sum of all its proper divisors (excluding the number itself). The function is as follows: ```python def classify_number(number: int) -> str: classif...
magicoder
You are tasked with creating a Python class that represents a code system for RoleLinkStatus. The class should have attributes for description, status, version, and a URL. Additionally, you need to implement a method to retrieve the code system's URL. Create a Python class called `RoleLinkStatus` with the following re...
magicoder
You are tasked with creating a program that processes text content to identify and extract specific patterns using regular expressions. Your program should be able to identify and extract various types of text patterns, such as block quotes, code spans, and mathematical expressions, based on the provided regular expres...
magicoder
You are tasked with creating a custom serializer in a Django REST framework application. The application has a model called `AccountsUser` which represents user accounts. Your goal is to create a serializer that can handle the serialization and deserialization of `AccountsUser` objects. The serializer should include sp...
magicoder
You are tasked with implementing a function that parses a URI and extracts various components from it. The URI follows the format `scheme://username:password@host:port/path?query#fragment`. Your goal is to create a Python function `parse_uri` that takes a URI string as input and returns a dictionary containing the pars...
magicoder
You are tasked with creating a program to process and analyze metadata related to data assets in a decentralized data marketplace. The metadata is stored as an array of strings, each representing a statement about Ocean Protocol, a platform for enabling decentralized data marketplaces. Your program needs to perform the...
magicoder
You are tasked with implementing a Python function to parse a package information file and return its contents as a dictionary. The package information file follows a specific format where each line contains a key-value pair separated by a colon. For example, the file may contain lines like `'Name: name\n'` and `'Versi...
magicoder
You are tasked with implementing a Java method to convert a transit map into a JSON object. The transit map is represented as a graph, where each node represents a location and each edge represents a transit route between two locations. The method should take the transit map as input and produce a JSON object that repr...
magicoder
You are tasked with implementing a method to remove a specific node from a scene graph. A scene graph is a data structure used to organize and represent the objects in a graphical scene. Each node in the scene graph may have children nodes, forming a hierarchical structure. Your task is to write a function that removes...
magicoder