instruction_seed
stringlengths
29
40.5k
source
stringclasses
6 values
You are tasked with implementing a function that finds all occurrences of a specific pattern within a given text. The function should return a list of indices where the pattern is found in the text. The pattern matching should be case-sensitive. You are given the following code snippet as a starting point: ```python ...
magicoder
You are tasked with creating a Python function that retrieves licensing information from an IBM Security Access Manager (ISAM) appliance. The function should be able to operate in check mode and force mode, as well as handle potential errors that may occur during the retrieval process. You are given the following func...
magicoder
You are tasked with implementing a function that processes a list of visual capsules and returns a modified version of the list. Each visual capsule is represented as a string, and the function should perform a specific transformation on each capsule. The transformation involves converting the visual capsule to upperc...
magicoder
You are given an enum `Colors` representing various colors. Each color is assigned an integer value starting from -1. You need to implement a function that takes an integer value and returns the corresponding color as a string. If the integer value does not correspond to any color, the function should return "Unknown"....
magicoder
You are tasked with implementing a URL routing system for a web application using Python's Django framework. The code snippet provided is a part of the URL configuration for a Django application. The `urls.py` file in a Django project contains a list of URL patterns and their corresponding view functions. Each URL patt...
magicoder
You are given a list of courses labeled from 0 to numCourses - 1, and an array of prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course bi before you can take course ai. Write a function to return the ordering of courses you should take to finish all courses. If it is impossible to finish ...
magicoder
You are tasked with implementing a function to resize an image and save it with specified parameters. The function should take in the path of the input image, the path for the output image, the desired width and height for the output image, and the quality of the output image. The function should resize the input image...
magicoder
You are tasked with creating a Python class that manages version compatibility for a specific software. The class should be able to compare the compatibility of different versions based on their major, minor, and patch numbers. The class should also provide a method to check if a given version is compatible with a mini...
magicoder
You are tasked with implementing a simplified version of a controller class for managing presets in a software application. The controller class, `PnlMnController`, is responsible for updating presets based on certain triggers and notifications. Your goal is to create a method within the controller class that updates a...
magicoder
You are tasked with creating a script to automate the deployment and management of IceGrid registry instances. IceGrid is a distributed computing framework that allows you to build and manage distributed applications. The provided code snippet is a command used to start an IceGrid registry instance in the background. ...
magicoder
You are tasked with implementing a method to retrieve and process a list of stream information. The stream information is obtained from a `Subject` object, and the list should contain a specified number of elements, sorted by timestamp in descending order. Each stream information contains a `Stream` property, which is ...
magicoder
You are tasked with implementing a frustum culling algorithm for a 3D rendering engine. Frustum culling is a technique used in computer graphics to improve rendering performance by eliminating objects that are outside the view frustum of the camera. In the given code snippet, a bounding sphere is created to encapsulat...
magicoder
You are working on a simulation of chemotactic behavior in a biological system. In this simulation, a chemotactic synapse lag is implemented using the given code snippet. The system tracks the age of a target, the time since the last visit, and generates random numbers for comparison. The relevant variables and operat...
magicoder
You are tasked with implementing a module loader for a JavaScript application. The module loader should be able to import and use modules from a specified directory. Your task is to create a function that can load a module from the given directory and use it in the application. You are provided with the following code...
magicoder
You are tasked with implementing a class for managing products in an e-commerce system. The class should have properties for the date the product was added, the image URL, the weight, and the price of the product. Additionally, you need to implement a method to calculate the total price of a given quantity of the produ...
magicoder
You are tasked with creating a Python function that simulates the behavior of the `sudo` command in a simplified manner. The `sudo` command is used in Unix-like operating systems to execute commands with elevated privileges. Your function should take a command as a string and a username as an argument, and then constru...
magicoder
You are tasked with implementing a Python class that manages the painting of icons. The class, named `IconManager`, should provide methods for initializing the painting environment, painting icons, and ending the painting process. Your task is to complete the implementation of the `IconManager` class by adding the nece...
magicoder
You are tasked with implementing a Python class that simulates a simple pipe. The class should have the ability to return the write file descriptor of the pipe and run a thread while logging everything. Your task is to complete the implementation of the `Pipe` class by adding the missing methods. ```python class Pipe:...
magicoder
You are tasked with implementing a custom table view controller in Swift for a scheduling application. The table view controller should display a list of scheduled events and allow the user to interact with the schedule. Each event in the schedule will have a title, time, and possibly other relevant details. Your task ...
magicoder
You are tasked with creating a Python script that processes command-line arguments using the `argparse` module. The script should handle various options related to evaluating a machine learning model. Your task is to implement the missing `add_eval_options` function that adds additional evaluation options to the argume...
magicoder
You are tasked with implementing a reducer function for a shopping cart application using TypeScript and Redux. The provided code snippet includes imports for the initial state of the cart, the reducer state interface, and action types. Your task is to create a TypeScript reducer function that handles various action t...
magicoder
You are tasked with creating a Python function that processes web scraping data to extract and manipulate address information and geographical coordinates. The function should take a web scraping response object as input and return a dictionary containing specific properties extracted from the response. The input resp...
magicoder
You are tasked with creating a script that processes a list of Git repository names and their corresponding test descriptions. Your script should take the input in the format shown below and produce a formatted output. Input format: The input will be a series of lines, each containing a Git repository name followed by...
magicoder
You are tasked with creating a script to automate the process of building a set of base16 color schemes using the base16-elm-builder tool. The base16-elm-builder is a command-line tool used to generate Elm code for base16 color schemes. The provided code snippet is a part of a shell script that navigates to the parent ...
magicoder
You are tasked with creating a Python function that processes a list of strings representing code snippets and identifies the import statements present in each snippet. An import statement is a line that starts with the keyword "from" or "import" and is followed by a valid Python module or package name. Write a functi...
magicoder
You are tasked with implementing a caching mechanism for a Discord bot to efficiently retrieve member information from a guild. The `get_or_fetch_member` function is responsible for looking up a member in the cache and fetching it from the guild if not found. The function takes in a `guild` object representing the Disc...
magicoder
You are tasked with implementing a function that calculates the size of a given data type in bytes. The function should take the data type as input and return the size of the data type in bytes. You are not allowed to use the `sizeof` operator in your implementation. Your task is to implement the `customSizeof` funct...
magicoder
You are tasked with implementing a generic function in Swift that calculates the product of two numbers using a custom multiplication operation. The custom multiplication operation is defined as follows: ```swift func customMultiply<T>(_ a: T, _ b: T) -> T { // Your implementation of custom multiplication goes her...
magicoder
You are tasked with implementing a custom React component that renders a button with an optional icon at the end. The icon is represented by the HTML entity `&loang;`. Your goal is to create a component that meets the following requirements: - The component should be named `IconButton`. - It should accept two props: `...
magicoder
You are working on a Django web application that manages administrative procedures. The application includes a model called `Procedure` which represents different administrative proceedings. The `Procedure` model has the following fields and methods: ```python class Procedure(models.Model): proceedings = models.Ch...
magicoder
You are tasked with implementing a function that simulates a simplified version of a 3D CAD (Computer-Aided Design) software. The function should take an assembly of 3D objects and a view surface as input, and return a representation of the assembly as viewed from the specified surface. You are given the following cod...
magicoder
You are tasked with creating a Python function to interact with the AppDynamics API for managing application performance monitoring. The function should be able to create an action suppression for a specific application within a given time range and for specified health rule IDs. You are provided with a code snippet t...
magicoder
You are tasked with implementing a RequestExecutorInterface and a class that utilizes this interface to execute requests. The RequestExecutorInterface has a method `executeWith` that takes an instance of the interface itself as a parameter. Your goal is to create a concrete implementation of the interface and a class t...
magicoder
You are tasked with creating a simple Angular component that displays a list of items. The component should fetch the list of items from a provided service and display them in a user-friendly manner. Your task is to implement the necessary code for the Angular component to achieve this functionality. You are provided ...
magicoder
You are tasked with creating a custom quantized neural network using QKeras, a library for implementing quantized neural networks in TensorFlow. Your goal is to build a simple quantized neural network model using QKeras layers and activations. You are given the following QKeras imports as a starting point: ```python f...
magicoder
You are tasked with creating a program that simulates a simple ray tracing algorithm. Ray tracing is a rendering technique used to generate an image by tracing the path of light as pixels in an image plane and simulating the effects of its encounters with virtual objects. The given code snippet is a part of a shell scr...
magicoder
You are tasked with creating a middleware component for an OWIN-based web application. The middleware needs to log the incoming HTTP requests and their corresponding response status codes. Your task is to implement the `LoggingMiddleware` class that will log the request information and response status codes to the cons...
magicoder
You are given an array of integers `arr` and a target value `target`. Your task is to find two distinct elements in the array whose sum is closest to the target. If there are multiple pairs with the same sum closest to the target, return the pair with the smallest sum. Write a function `closestSumPair(arr: List[int], ...
magicoder
You are tasked with implementing a function to calculate the factorial of a given non-negative integer. The factorial of a non-negative integer n is denoted as n! and is the product of all positive integers less than or equal to n. For example, 5! = 5 * 4 * 3 * 2 * 1 = 120. You need to implement the `factorial` functi...
magicoder
You are working on a web application that uses JavaServer Pages (JSP) for generating dynamic web pages. The code snippet provided is a part of a JSP file that is responsible for rendering a user's billing information. The snippet shows a JSP custom tag usage to output the value of the `billToFirstName` property from an...
magicoder
You are tasked with implementing a function to extract the post ID from a given request URL in a web application. The URL structure follows a pattern where the post ID is embedded within the URL. The function `getPostIDFromRequestURL` takes two parameters: `request`, which represents the HTTP request object, and `post_...
magicoder
You are tasked with enhancing the functionality of the "Colortex" textual painter, a simple program that allows users to create and manipulate text-based art. The program is based on existing code snippets available at the following URLs: - https://gist.github.com/BigglesZX/4016539 - https://gist.github.com/almost/d283...
magicoder
You are tasked with implementing a custom iterator in Rust that filters out `None` values from a mutable slice of `Option<T>` and yields the inner `T` values. The given code snippet provides a starting point for the custom iterator implementation. Your task is to complete the implementation of the custom iterator `Ite...
magicoder
You are tasked with creating a Python program that connects to a MySQL database and retrieves specific information. The database contains a table named `employees` with the following columns: `employee_id`, `first_name`, `last_name`, `email`, `hire_date`, and `job_id`. Your program should establish a connection to the ...
magicoder
You are tasked with creating a Rust function that utilizes the libsox-sys library to perform audio file format initialization. The libsox-sys library provides bindings to the SoX (Sound eXchange) library, which is used for audio file manipulation. Your function should initialize the audio file format using the libsox-s...
magicoder
You are tasked with creating a PHP class that manages conference configurations. The class should have a method to retrieve all conference configurations and store them in an array. Your task is to implement the `getAllConf` method within the `Conference` class. The `Conference` class should have the following structu...
magicoder
You are tasked with creating a program that analyzes a given software license disclaimer to extract and count the occurrences of unique words. The disclaimer is a multi-line string containing various legal terms and disclaimers. Your program should ignore any special characters, punctuation, and case sensitivity when c...
magicoder
You are tasked with creating a Python program to manage a slideshow of images for a photo booth. The program should alternate between displaying regular images and a prime slide at specific intervals. The program should have the following functionality: 1. Define a default time to wait between images in seconds, store...
magicoder
You are given a Python code snippet that seems to be part of a larger program. Your task is to understand the code and implement a specific functionality based on the given code. The code snippet is as follows: ```python return [(copy_dict(dict), [])] res = [] head, tail = ifs[0], ifs[1:] if head[0] == 'ask': ```...
magicoder
You are tasked with creating a Python function that processes data obtained from a client's SEO (Search Engine Optimization) about page. The function should extract and return specific information from the SEO data. You are given the following code snippet as a starting point: ```python res = client.get_seo_about() ``...
magicoder
You are tasked with implementing a custom form class in Python that allows for the retrieval of specific field values. Your task is to complete the `get_value` method within the `Form` class. The `get_value` method should take a field name as input and return the value associated with that field. If the field does not ...
magicoder
You are tasked with creating a program that will analyze a given HTML file and count the occurrences of specific HTML tags within it. For this problem, you will focus on counting the occurrences of the `<div>` tag. Write a function `countDivTags` that takes a string representing the content of an HTML file as input an...
magicoder
You are tasked with implementing a module for managing movie data within a movie database system. The module should provide functionality for adding, retrieving, and updating movie information. The movie data includes attributes such as title, director, release year, and genre. You need to create a Rust module named `i...
magicoder
You are tasked with creating a Python program that processes a JSON file containing information about entities. Each line of the file represents a separate JSON object. Your program needs to read the file, parse each JSON object, and perform specific operations based on the content of the objects. Your program should ...
magicoder
You are tasked with creating a simple Line chatbot using the Python programming language. The code snippet provided is a part of the chatbot's event handling logic. The chatbot is designed to respond to different types of events, such as receiving a text message or a postback event. Your task is to implement the funct...
magicoder
You are working on a geographic information system (GIS) project and need to write a Python script to process shapefiles and rasters. The script should take command-line arguments for the input shapefile, template raster, and output raster, and handle errors if any of these arguments are missing. Additionally, the scri...
magicoder
You are given a PHP code snippet that processes an array of form fields and their corresponding types and options. Your task is to complete the code by implementing a function that processes the form data and returns an array of processed values. The function signature is: ```php function processFormData($array) { ...
magicoder
You are tasked with implementing a function that processes a given file path and returns the file extension. The file path is represented as a string, and the function should handle both absolute and relative paths. The file extension is defined as the substring following the last occurrence of the dot character ('.') ...
magicoder
You are tasked with creating a custom authentication strategy for a Node.js application using the NestJS framework. The application uses JSON Web Tokens (JWT) for authentication and authorization. Your goal is to implement a JwtStrategy class that extends the PassportStrategy class and uses the passport-jwt library to ...
magicoder
You are tasked with implementing a macro-based resource management system for a Vulkan graphics application. The provided code snippet contains a macro definition for simplifying the destruction of Vulkan objects. Your task is to understand the macro and use it to create a macro for destroying a specific Vulkan object ...
magicoder
You are tasked with creating a script to monitor the status of a server and take appropriate actions based on its status. The script should check if the server has started successfully and display a message accordingly. The server status is indicated by the value of the variable `SUCCESS`, which will be 0 if the server...
magicoder
You are given a string containing a series of opening and closing parentheses. Your task is to write a function to determine if the parentheses are balanced. A string of parentheses is considered balanced if every opening parenthesis has a corresponding closing parenthesis and they are properly nested. Write a functio...
magicoder
You are tasked with creating a version comparison function that compares two version strings and determines which one is greater. A version string is a series of numbers separated by periods, such as "1.2.3". The comparison should follow the standard rules for version comparison, where each number in the version string...
magicoder
You are tasked with implementing a class that manages media player events in a C# application. The class should handle the event of a media player's "IsPlaying" state change and execute a specified action when the player is idle. Your task is to complete the implementation of the `MediaManager` class by adding the nece...
magicoder
You are working on a package manager tool, and you need to implement a function that processes package and workspace information. The function takes in a workspace (`ws`), a package (`package`), and an optional target directory (`target_dir`). The goal is to update the workspace with the package and target directory in...
magicoder
You are tasked with creating a Python function that processes a list of movie titles and returns a list of movies that contain a specific keyword. You are given a code snippet from a Django project's views.py file for inspiration. Create a function called `find_movies` that takes two parameters: 1. `movie_list` (list ...
magicoder
You are working on a project that involves building a modular system for creating and updating witnesses in a distributed network. The code snippet provided imports two modules, `witness_builder` and `update_builder`, which are essential for the functionality of the system. Your task is to implement a function that ut...
magicoder
You are tasked with creating a Python function that processes a Django application configuration file and extracts specific information from it. The Django application configuration file is represented by the `apps.py` file, which is located in the `styles` directory. The file contains a class that inherits from `djang...
magicoder
You are tasked with creating a Python function that processes an XML file and writes its data into a CSV file. The function `request_to_csv` takes three parameters: `xml_file_name` (string) representing the name of the input XML file, `csv_file_name` (string) representing the name of the output CSV file, and `report` (...
magicoder
You are working on a data processing application that involves handling SQL scripts, source data, and destination tables. Your task is to implement a class method that processes input arguments and performs necessary operations based on the provided inputs. The method should handle various scenarios such as specifying ...
magicoder
You are tasked with implementing a Python class that processes price data for international calls. The class should have methods to calculate the cost of a call based on the destination number and duration, as well as to update the price data for different countries. You are provided with a partial code snippet for th...
magicoder
You are tasked with implementing a function to send an email with optional image attachment. The function should take in the recipient's email address, the email subject, the email body, and an optional image file. If an image file is provided, it should be attached to the email; otherwise, the email should be sent wit...
magicoder
You are tasked with creating a Bash script that processes a given directory and its subdirectories to count the number of files with a specific extension. Your script should take two arguments: the first argument is the file extension to search for, and the second argument is the root directory to start the search from...
magicoder
You are tasked with implementing a Python script that processes frequency data and converts it to impedance values. The script should accept command-line arguments and handle different program modes based on the provided input. The script should support the following program modes: 1. `freq2z`: This mode takes frequen...
magicoder
You are tasked with implementing a blockchain network registry for a Key Management System (KMS). The registry maintains a set of registered blockchain chains and provides methods for adding new chains, updating existing ones, and retrieving information about registered chains. The provided code snippet is a part of t...
magicoder
You are tasked with creating a function that processes authorization data for a web application. The function should take in an array of `AuthorizationDataObject` instances and return a new array containing only the objects that have the `role` property set to "admin" and the `accessLevel` property greater than or equa...
magicoder
You are tasked with implementing a Python program that simulates inter-process communication using pipes. The program will create a parent process and a child process, and the two processes will communicate by writing and reading data through a pipe. Your task is to complete the `parent` function, which will create a ...
magicoder
You are tasked with implementing a service that manages toggles for various features in a software system. The service needs to handle the exclusion of specific services from being affected by a global toggle. To achieve this, you need to create a class that represents an excluded service and its properties. Create a ...
magicoder
You are tasked with implementing a Java class that represents a data structure for storing information about a specific sample. The class should have the following requirements: 1. The class should be named `SampleData`. 2. It should have three private instance variables of type `String`: - `instance` to store the ...
magicoder
You are tasked with creating a program that processes a list of file headers and extracts specific information from them. Each file header contains information about a specific database system, and your program needs to extract the database name and the version number from each header. You are given a sample file head...
magicoder
You are tasked with creating a Python program to manage a library's book inventory. Your program should include a class `Book` to represent individual books in the library. Each `Book` object should have attributes for `title`, `author`, `genre`, and `quantity`. Additionally, the program should have a method to display...
magicoder
You are given a list of strings, where each string represents answers to a set of questions. Each line in the list corresponds to a person's answers, and an empty line separates different groups of people. Your task is to calculate the sum of the counts of unique answers for each group. For each group, the unique answ...
magicoder
You are tasked with implementing a function that processes annotations for object detection in an image. The annotations are represented as bounding boxes and corresponding labels. The provided code snippet is part of the process that converts the bounding box coordinates to relative values and assigns the label to the...
magicoder
You are tasked with implementing a login feature for a mobile application using the RxSwift framework. The given code snippet is part of a Swift class that handles the login functionality. The class uses RxSwift's `Driver` and `flatMap` to manage the login process. Your task is to complete the implementation of the log...
magicoder
You are tasked with implementing a Swift class that manages a payload string and supports encoding and decoding operations. The class should have the following requirements: 1. Create a class named `PayloadManager` with a property `payloadString` of type `String`. 2. Implement an initializer `init(payload: String)` th...
magicoder
You are tasked with implementing a RESTful API endpoint for a socks inventory management system. The system should allow users to add new socks to the inventory and retrieve the total number of socks based on color and cotton part. The system uses Spring Boot and leverages the `SocksService` to handle the business logi...
magicoder
You are tasked with implementing a simple image annotation tool using Python and Streamlit. The provided code snippet initializes the necessary session state variables and defines a function for annotating images. Your task is to complete the implementation by creating a Streamlit web application that allows users to a...
magicoder
You are tasked with implementing a custom error type in Rust. Your custom error type should encapsulate an error message and provide a method to convert it to a string. You need to define the error type and implement the necessary functionality to achieve this. Define a custom error type `CustomError` that encapsulate...
magicoder
You are tasked with implementing a class that manages information about properties in a real estate system. The class should have the following functionalities: 1. Add a new property with its details (property ID, address, price, and type). 2. Retrieve information about a property based on its ID. 3. Update the price ...
magicoder
You are working on a security system for a covert agency that uses Python for its backend. The system has a function that handles requests from different agents and returns their information if certain conditions are met. Your task is to implement the logic for this function based on the given requirements. You are gi...
magicoder
You are tasked with creating a Python function that processes geographical data in various formats and performs validation checks on the data. The function should accept a directory path and a zoom level as input parameters. The function should then perform the following tasks: 1. Check if a GeoJSON file, a text file, ...
magicoder
You are tasked with implementing a simplified version of a task management system in a game development environment. The provided code snippet is part of a game development script and contains the initialization of certain tasks and variables. Your goal is to complete the implementation by adding specific functionaliti...
magicoder
You are tasked with creating a Python function that analyzes a given list of package dependencies and returns the count of unique packages required for installation. Each package dependency is represented as a string in the format 'package_name' or 'package_name>=version_number'. The function should consider only the p...
magicoder
You are tasked with implementing an HTTP encoding interface in Java. The interface, `Encoding`, represents an arbitrary HTTP encoding and can be used for request encoding in a client API or for handling encoded requests in a server API. An implementation of this interface should provide the ability to wrap an `OutputSt...
magicoder
You are working on a bioinformatics project and need to process FASTQ files to extract and combine sequence and quality information. The FASTQ format is a text-based format for storing both a biological sequence and its corresponding quality scores. Each record in a FASTQ file consists of four lines: a sequence identif...
magicoder
You are tasked with creating a Python function that processes a list of integers and returns the sum of all the even numbers in the list. However, the function should also handle any exceptions that may occur during the processing and print a specific message when an exception is caught. You are provided with the foll...
magicoder
You are working on a Python script that interacts with an Elasticsearch index. The script contains some configuration settings and user input control parameters. Your task is to implement a function that modifies the user input control parameters based on certain conditions. You are given the following code snippet as...
magicoder
You are tasked with implementing a custom runtime for a blockchain system. The provided code snippet is a partial implementation of the runtime for a blockchain node using the Substrate framework. Your task is to complete the implementation by defining the storage items for the runtime module. The runtime module is re...
magicoder
You are tasked with creating a Python function that takes a task object and serializes it into a JSON string. The task object is represented as a dictionary with various attributes. Your function should handle the serialization process and return the JSON string representation of the task object. Write a Python functi...
magicoder
You are tasked with creating a database upgrade tool that will apply a series of scripts to update a database to a new version. The tool should be able to handle multiple databases and execute the scripts in a transactional manner, ensuring that all scripts are applied successfully or none at all. Your task is to impl...
magicoder