instruction_seed
stringlengths
29
40.5k
source
stringclasses
6 values
You are tasked with creating a Python function that interacts with a web service to generate a document based on a template and some data. The function will take in the document name, output name, type, and a dictionary of data. The function will then make a POST request to the specified URL with the provided data and ...
magicoder
You are given two sorted arrays, `a` and `b`, of integers. Your task is to merge these two arrays into a single sorted array without using any built-in sorting functions. You should implement the merging logic using the provided code snippet as a starting point. Your task is to complete the implementation of the mergi...
magicoder
You are tasked with creating a custom annotation parser for a PHP application. Annotations are used to add metadata to classes, methods, or properties in PHP code. Your goal is to implement a parser that can extract information from annotations and use it to generate a map of annotation names and their corresponding va...
magicoder
You are tasked with creating a release management script for a software project. The script should automate the process of updating version numbers, creating release notes, committing changes, tagging the release, and pushing the changes to the remote repository. Your task is to write a shell script that performs the ...
magicoder
You are tasked with creating a Python program that interacts with a database using SQLAlchemy. Your program should define a database model for GitHub repositories and perform various operations on the database. The database model should include the following fields: - `id` (Integer, Primary Key): Unique identifier for...
magicoder
You are tasked with implementing a function that calculates the average rating of a product based on the given array of rating values. The function should handle cases where the input array is empty or contains non-numeric values. You are given the following code snippet as a starting point: ```javascript } const...
magicoder
You are tasked with implementing a JavaScript class that manages proponents and regions for a community organization. The class should have the following functionalities: 1. Initialize the proponents array with the provided array `res` or an empty array if `res` is not provided. 2. Initialize the regions array with th...
magicoder
You are tasked with implementing a method to set the language of an album in a music management system. The method `setAlbumLanguage` is part of a class responsible for managing audio files and their associated metadata. The method is expected to take a string parameter representing the language of the album and update...
magicoder
You are tasked with implementing a generic interface in Java that defines a method for finding the maximum value in a collection of elements. The interface `Foo` is provided as a starting point, and you need to complete the interface by adding a method signature for finding the maximum value. Additionally, you need to ...
magicoder
You are tasked with implementing a method to convert input data types into output column types based on certain rules. The input data types can be of different forms, including a product of types or a single type. Your task is to create a method that takes an input data type and returns a list of corresponding output c...
magicoder
You are tasked with implementing a simple localization system for a web application. The `setupLocales` function is responsible for setting up the available locales and their corresponding translations. The `before` function is a part of a testing framework and is used to run a setup function before the tests are execu...
magicoder
You are tasked with implementing a Python class that extends a given StackBuilder class to create and manage AWS IAM (Identity and Access Management) resources using CloudFormation. The IAMBuilder class is responsible for constructing and updating IAM-related CloudFormation stacks. Your task is to complete the implemen...
magicoder
You are tasked with implementing a job scheduling system using Rust. The `jobs` module contains the necessary structures and functions for managing jobs. Your task is to complete the implementation of the `jobs` module by defining a job scheduling algorithm. The `jobs` module contains the following structures: ```rust...
magicoder
You are tasked with implementing a multi-threaded queue system using Python's threading module. The provided code snippet is a part of a class that manages the queue system. The class has the following attributes and methods: Attributes: - `self.next`: A variable that holds the next item to be processed from the queue...
magicoder
You are tasked with creating a simple parser for a custom language using the LALRPOP parser generator. Your goal is to parse a specific grammar and extract relevant information from the input. You are given the following grammar for a simple arithmetic expression: ``` expr = num | expr "+" expr | expr "-" e...
magicoder
You are tasked with creating a Python function that dynamically imports a module and executes a specific function within that module. Your function should take the module name and the function name as input and return the result of executing the specified function from the module. Write a Python function called `execu...
magicoder
You are tasked with creating a function that generates an admin menu for a web application. The function should take an array of menu items as input and return an HTML representation of the menu. Write a function `generateAdminMenu` that takes an associative array of menu items as input and returns a string containing...
magicoder
You are tasked with implementing a simple drawing application that responds to keyboard input to modify various drawing settings. The application has two drawing areas, each with its own set of properties. The properties include the alpha value, stroke cap, and color. The application should respond to specific keyboard...
magicoder
You are given a list of integers representing a sequence of numbers. Your task is to write a function that returns the longest increasing subsequence (LIS) from the given sequence. A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the rem...
magicoder
You are working on a system that processes coded fragments using Reed-Solomon error correction. The given code snippet is a part of a method that decodes the coded fragments and performs certain operations based on the decoding results. Your task is to complete the method by implementing the missing parts. You are giv...
magicoder
You are tasked with implementing a function that processes Handlebars templates. Handlebars is a popular templating language that allows dynamic content to be inserted into HTML or other text-based documents. The function you need to implement will take a Handlebars template and a context object as input, and return th...
magicoder
You are given a C code snippet that manipulates pointers within a linked list. Your task is to understand the code and implement a function to perform a specific operation on a linked list. The given code snippet is part of a larger program that manipulates a doubly linked list. The `rp` and `lp` are pointers to nodes...
magicoder
You are tasked with creating a Python class that manages a playlist of thumbnail images for a media player application. The class should allow adding, removing, and displaying thumbnail images, as well as automatically updating the displayed image at regular intervals. Your task is to implement the `ThumbnailPlaylist`...
magicoder
You are tasked with creating a program to manage conference seat availability and generate announcements for nearly sold-out conferences. The program should utilize a class called `Conference` to represent individual conferences, with a property `seatsAvailable` indicating the number of available seats for each confere...
magicoder
You are tasked with creating a web application that allows users to submit comments. The provided code snippet is a part of the backend implementation using Django, a popular Python web framework. The code snippet includes a form definition for submitting comments. Your task is to implement a function that takes a com...
magicoder
You are tasked with implementing a custom exception handling mechanism for a cloud-based application using Python and the Boto library. The code snippet provided includes the definition of custom exception classes that inherit from the `BotoServerError` class. Your task is to create a new custom exception class and mod...
magicoder
You are tasked with implementing a function to sort a stack in ascending order using only one additional stack. The input stack will contain integers, and you should return the sorted stack. You should implement the `sortStack` function, which takes an unsorted stack as input and returns a sorted stack. The `sortStack...
magicoder
You are tasked with implementing a contact management system that can perform various operations on a list of contacts. Each contact is represented as a dictionary with the following keys: "name", "phone", and "email". You need to write a function that takes a list of contacts and performs a specific operation on each ...
magicoder
You are tasked with implementing a Python class that represents a communication network node. The node should support a configurable number of channels for transmitting data. Your task is to complete the implementation of the `CommunicationNode` class by adding the necessary methods to manage the channels and data tran...
magicoder
You are working on a reinforcement learning algorithm that involves updating weights, flags, and glows based on certain conditions. The code snippet provided is a part of this algorithm and involves manipulating NumPy arrays. Your task is to implement a function that takes in the current state, action index, reward, we...
magicoder
You are tasked with implementing a simple state machine to control the behavior of a virtual mouse input system. The state machine has three states: `MOUSE_BUTTON_DOWN`, `MOUSE_BUTTON_UP`, and `MOUSE_SCROLL`. The virtual mouse input system has two methods: `setScrollUpMouseWheel(bool)` and `setScrollDownMouseWheel(bool...
magicoder
You are tasked with creating a custom validation function for a data processing application. The function should raise a specific type of error when certain conditions are not met. Your task is to implement the custom validation function and handle the raised error appropriately. You are given the following code snipp...
magicoder
You are tasked with implementing a Python class that simulates a simple banking system. The class should have methods for depositing funds, withdrawing funds, and checking the account balance. Additionally, the class should keep track of the account holder's name and account balance. Your task is to complete the imple...
magicoder
You are tasked with implementing a function `since` that takes an array of numbers as input and returns a new array where each element represents the sum of all the numbers in the input array from its current index to the end. The function signature is: ```typescript function since(values: number[]): number[] ``` For...
magicoder
You are tasked with implementing a class for representing a flat surface in 3D space. The class should calculate the normal vector and the distance from the origin to the flat surface based on three input points in 3D space. You are given the following code snippet as a starting point: ```csharp public class Flat { ...
magicoder
You are tasked with creating a Python class that generates and saves line maze images. A line maze is a grid-based maze where the walls are represented by lines. The class should have the following functionalities: 1. Initialize the maze with a specified size and a constant move value. 2. Generate a line maze image wi...
magicoder
You are tasked with implementing a dynamic programming algorithm to find the minimum cost of transforming one sequence of elements into another. The cost of transformation is determined by the cost of adding, deleting, or substituting elements in the sequences. Additionally, a custom comparison function is used to comp...
magicoder
You are tasked with designing a Python program to manage a food delivery service using Flask. The program should include a blueprint for the API, with routes for various functionalities related to members, food items, orders, user profiles, carts, and addresses. Your task is to implement a function that retrieves the l...
magicoder
You are given a Python function that takes two lists `l1` and `l2` as input. The function performs the following operations: 1. If the length of `l1` is less than the length of `l2`, it appends the necessary number of zeros to `l1` to make their lengths equal. 2. It then compares the two lists lexicographically and ret...
magicoder
You are tasked with creating a PHP class that manages a simple inventory system for an e-commerce platform. The class should handle adding, updating, and retrieving product information. Additionally, it should be able to calculate the total value of the inventory. Your task is to implement the `Inventory` class with t...
magicoder
You are tasked with implementing a Python class for managing user profiles in a database. The class should provide methods for creating a new connection to the database and saving user profiles. You are given a code snippet that partially defines the database connection and the `SaveProfile` method. Your task is to co...
magicoder
You are working on a data processing system that involves handling and persisting data packets in HDF5 format. The system utilizes various modules and utilities from the `pyon` and `ion` libraries. Your task is to implement a function that generates a unique identifier for a new data packet and persists the packet to a...
magicoder
You are tasked with creating a simple Vue.js component for a social media service. The component should display a user's profile information, including their username, bio, and number of followers. Additionally, the component should allow the user to edit their bio. You are provided with the following code snippet as ...
magicoder
You are given a Python code snippet that performs a mathematical operation on a variable `a` and then prints the result. Your task is to write a Python function that replicates the behavior of the given code snippet and returns the final value of `a` after the mathematical operation. The given code snippet is as follo...
magicoder
You are tasked with creating a Python function that processes a configuration file for a visualization library. The configuration file contains various settings, and your function needs to parse the file and apply the settings accordingly. The settings are represented as key-value pairs, where the keys are the options ...
magicoder
You are tasked with extending the functionality of a simple 2D game player by adding new states and associated behaviors. The player is represented by the `Player` struct, which has a `state` field of type `PlayerState` and a `frame_idx` field to keep track of animation frames. The `PlayerState` enum currently has one ...
magicoder
You are tasked with creating a Python function that simulates a simple stack data structure. A stack is a Last-In-First-Out (LIFO) data structure, where elements are added and removed from the top of the stack. You need to implement the following operations for the stack: 1. `push(item)`: Add an item to the top of the...
magicoder
You are tasked with implementing a sentiment analysis algorithm for analyzing tweets. The algorithm involves calculating the sentiment score for each tweet based on its polarity and other factors. The sentiment score is calculated using the following formula: \[ v = (w1 \times polarity[q]) + (w2 \times clean\_analysed...
magicoder
You are tasked with creating a Python class that manages configuration settings for a web application. Your task is to implement a `LinkSmearConfig` class that inherits from the `AppConfig` class. The `LinkSmearConfig` class should have a property `name` set to "linksmear". Your task is to complete the implementation ...
magicoder
You are working on a messaging application, and you need to implement a message handling system for various events. The code snippet provided defines a set of constants representing different types of events that can occur in the messaging system. Each constant is assigned a unique short value. Your task is to create ...
magicoder
You are tasked with creating a Python function that simulates a simple database management system. The function should be able to create a database, retrieve the database instance, and close the database when necessary. Your task is to implement the `DatabaseManager` class with the following methods: 1. `create_databa...
magicoder
You are tasked with creating a Python function that extracts specific information from a given string containing metadata about a security system. The metadata string follows a specific format, and your function should parse this string and return a dictionary containing the extracted information. The metadata string ...
magicoder
You are tasked with implementing a Python class that simulates a terrain generator using a simple algorithm. The class should have an `__init__` method to initialize the terrain generator with certain parameters, and a `generate_terrain` method to produce a 2D array representing the generated terrain. The `TerrainGene...
magicoder
You are tasked with creating a web application that calculates and displays the total accumulated recharge and consumption amounts for a user. The provided code snippet is a part of the HTML and PHP code for the user interface. The PHP variables $ctotal and $xtotal represent the total accumulated recharge and consumpti...
magicoder
You are tasked with creating a script to automate the installation of software features on a Linux system. The script should take a list of features as input and install each feature using the provided function `install_feature`. The `install_feature` function is already defined and takes a single argument - the name o...
magicoder
You are tasked with implementing a function that processes a series of sponsor logo changes in a web application. The function should log each sponsor logo change to the console. The code snippet provided is a part of the event handling logic for the sponsor logo change event. Your task is to complete the implementati...
magicoder
You are tasked with implementing a data augmentation pipeline for image processing. The given code snippet sets certain parameters for data augmentation, such as enabling random horizontal flipping and defining the minimum and maximum scales for training images. Your goal is to create a Python function that applies the...
magicoder
You are tasked with implementing a Python function that processes an image using OpenCV library. The function should perform Gaussian blur on the input image and display the blurred image in a window. Additionally, the function should wait for the user to press the 'q' key to close the displayed image. If the 'q' key i...
magicoder
You are given a Python code snippet that defines a dictionary `positionEncoding` using the `defaultdict` from the `collections` module. The dictionary maps a digit to a list of two binary strings. Each binary string represents the encoding of the digit at a specific position. Your task is to write a function that takes...
magicoder
You are working on a quantum computing project and need to create a programming function to construct a variational layer gate. A variational layer gate is a key component in quantum circuit design for variational algorithms. The gate is constructed using a set of qubits, pairs of qubits, specific single-qubit gates, a...
magicoder
You are tasked with creating a script to automate the generation of PDF files from LaTeX (.tex) documents. Your script should handle the compilation of the LaTeX document using pdflatex and optionally display the resulting PDF file using the evince viewer. Additionally, the script should reset a configuration using the...
magicoder
You are tasked with creating a script that automates the deployment of a web server using Nginx and a configuration management tool called Confd. Your script should perform the following steps: 1. Run the Confd tool to fetch configuration data from a backend service and generate Nginx configuration files. 2. Start the...
magicoder
You are tasked with creating a Python script that processes files in a directory based on specific queries and coverage criteria. The script should handle the following functionalities: 1. Read all the files in a directory. 2. Filter the files based on a specific query. 3. Calculate the coverage of the filtered files....
magicoder
You are tasked with implementing a macro in Rust that generates a function to calculate the nth Fibonacci number using dynamic programming. The macro should take the name of the generated function and the type of the input and output as arguments. The generated function should use an array to store previously calculate...
magicoder
You are tasked with implementing a custom neural network model in PyTorch for a specific application. The model consists of two sub-models: a feature extraction model and a pose estimation model. The feature extraction model uses a pre-trained ResNet-50 architecture, while the pose estimation model is a custom 3-layer ...
magicoder
You are tasked with implementing a function to extract the Resin app ID from a given environment file. The Resin app ID is only available on a Raspberry Pi and is stored in the `/proc/1/environ` file. The function should read the contents of this file and extract the Resin app ID. However, the function should raise a `...
magicoder
You are tasked with implementing a Python class to represent complex numbers and performing various operations on them. A complex number is a number that comprises a real part and an imaginary part, typically expressed in the form `a + bi`, where `a` is the real part, `b` is the imaginary part, and `i` is the imaginary...
magicoder
You are tasked with creating a Python Flask application for managing blog posts. The application uses Flask and Flask-Login for authentication and rendering templates. You need to implement a feature that allows authenticated users to create new blog posts. You are provided with the following code snippet from the app...
magicoder
You are tasked with implementing a class method for a fictional `User` class. The method should return the first user with a given name if it exists, or create a new user with the given name and a default status of 0 if no user with that name is found. You are given the following code snippet as a starting point: ```...
magicoder
You are tasked with implementing a program to filter and display words based on a given regular expression pattern. The program should read a list of words and their lengths from a table, apply the regular expression pattern to filter the words, and then display the filtered words along with their lengths in a tabular ...
magicoder
You are working on a project to automate the submission of computational jobs to a high-performance computing (HPC) cluster. The cluster uses a job submission system where you need to create submission scripts to specify the details of the job, such as the executable to run, the input files, and the output files. You h...
magicoder
You are tasked with implementing a custom button component in a React application. The component should accept various props to customize its appearance and behavior. Your task is to create the `Button` component with the following requirements: - The component should be named `Button` and should be a functional compo...
magicoder
You are tasked with implementing a Python function that processes data from a given source and performs specific operations based on the provided parameters. The function is expected to handle various scenarios, including data manipulation and conditional processing. You are provided with a code snippet that calls the...
magicoder
You are tasked with implementing a new class that inherits from the given `ImageWarperFactory` class. Your task is to create a concrete subclass of `ImageWarperFactory` called `CustomImageWarperFactory` that provides a specific implementation for the `getImageWarperName` method and the `getAvailableWarpers` method. The...
magicoder
You are tasked with creating a Python function that processes a form and extracts specific information from it. The form is represented as a dictionary containing various fields and their corresponding data. Your function should validate the form and then extract and print the cleaned data if the form is valid. You ar...
magicoder
You are tasked with creating a program to process and analyze video data stored in a database. The database contains a table named `videos` with the following columns: `id` (unique identifier for each video), `title` (title of the video), `duration` (duration of the video in seconds), and `views` (number of views the v...
magicoder
You are tasked with developing a program to manage the configuration of training jobs for a machine learning model. The program should allow users to specify various parameters for the training job, including the use of spot instances, maximum wait time, and hyperparameters. Your task is to implement a function that ta...
magicoder
You are tasked with creating a program to process formalities data from a database. The formalities are stored in a table called `FormalitiesSicar` and are ordered by their creation date in descending order. Each formality has attributes such as `key_units`, `i_topograf`, and `key_section`. The program needs to filter ...
magicoder
You are tasked with creating a Python function that processes and visualizes data from a CSV file containing information about monthly sales of a company. The function should read the CSV file, calculate the total sales for each month, and then generate a bar plot to visualize the monthly sales data. The code snippet p...
magicoder
You are working on a medical imaging application and need to implement a class method to load patient data from a given path. The method should load the data using the `nib` library, store the patient data as a numpy array, and extract the affine transformation matrix from the loaded data. Write a Python class method ...
magicoder
You are tasked with implementing a custom exception class in C# for handling schema retrieval errors in a database application. The exception class should be designed to provide a meaningful error message containing the name of the table for which the schema retrieval failed. Your task is to create a C# class that ext...
magicoder
You are tasked with implementing a StreamFieldParser class that can parse a stream of values and store them in a list. The StreamFieldParser class should have the following properties and methods: Properties: - private readonly StreamFieldParser _fieldParser: A reference to another StreamFieldParser object. - private ...
magicoder
You are tasked with implementing a function that calculates the number of unique characters in a given string. The function should take a string as input and return the count of unique characters present in the string. For this problem, a character is considered unique if it appears only once in the string. Write a fu...
magicoder
You are given a list of integers `l` and an integer `n`. Your task is to write a function `rotate_list` that rotates the list `l` to the right by `n` steps. This means that the last `n` elements of the list move to the front, and the rest of the elements move to the end. Write a function `rotate_list(l, n)` that takes...
magicoder
You are tasked with implementing a Timer class in Python. The class should have the following methods: 1. `start`: Start the timer initially or resume after pause. 2. `pause`: Pause the timer. 3. `toggle_pause`: Toggle the pause state of the timer. 4. `stop`: Stop the timer and return the elapsed time in seconds and m...
magicoder
You are working on a navigation system that provides route information for a given journey. The system returns a route object containing various details such as total distance, total time, node OSM IDs, points, edges, distances from the starting node, and times from the starting node. Your task is to write a function t...
magicoder
You are tasked with creating a Python unit test for a client-server communication module. The module includes a `ClientChannel` class that represents a client's communication channel to the server. The test is to ensure that the `start_new_session_async` method of the `ClientChannel` class behaves as expected. The `st...
magicoder
You are tasked with designing a custom annotation processor for a Java web application framework. The framework uses annotations to define controller methods for handling HTTP requests. Your goal is to implement a processor that extracts metadata from these annotations and generates corresponding documentation. The pr...
magicoder
You are tasked with implementing a function to grid a set of frames in a graphical user interface (GUI). The function should take a variable number of frame objects as input and arrange them in a grid layout. Each frame should be positioned in a specific row and column within the grid. You are given the following info...
magicoder
You are tasked with creating a class that represents a data transfer object (DTO) for job applications. The DTO should contain fields for the application's ID, job ID, cover letter, full name, email, and location. Your task is to create a PHP class that fulfills these requirements and provides a method to convert the a...
magicoder
You are tasked with creating a Python script that generates a migration file for a Django application. In Django, migrations are used to propagate changes you make to your models (adding a field, deleting a model, etc.) into your database schema. The code snippet provided is a partial implementation of a migration file...
magicoder
You are tasked with implementing a custom data structure called `BDFCard`, which is a list that has a default value of `None` for fields out of range. Your task is to create the `BDFCard` class with the following functionalities: 1. Initialize the `BDFCard` with a given size and default value. 2. Allow setting and gett...
magicoder
You are tasked with creating a custom annotation processor for a Java application. The application uses the MapStruct library for object mapping and has an interface `SysFileMapper` annotated with `@Mapper`. Your goal is to implement a custom annotation processor that will analyze the `SysFileMapper` interface and gene...
magicoder
You are tasked with creating a Python program to analyze event logs using process mining techniques. Process mining is a field that involves extracting insights from event data to discover, monitor, and improve real processes. In this problem, you will be using the `pm4py` library, which provides various algorithms for...
magicoder
You are tasked with creating a Python script to preprocess text data using byte pair encoding (BPE) for language modeling. BPE is a data compression technique that replaces frequent pairs of bytes with a single byte. The given code snippet demonstrates the preprocessing steps using the GPT-2 BPE model on a small datase...
magicoder
You are tasked with creating a Python function that simulates a simple web application routing system. The function should take in a list of routes and their corresponding actions, and then process a given request to determine the appropriate action to take. Write a function `route_request(routes, request_method, requ...
magicoder
You are tasked with implementing a Python class that represents a computer peripheral device. The class should have the ability to track the status of various fields, such as pointing device and headphones. Additionally, the class should provide methods to update and retrieve the status of these fields. Your task is t...
magicoder
You are tasked with implementing a function that adds two quaternions and returns the result. Quaternions are mathematical entities used to represent rotations in 3D space and are often used in computer graphics and physics simulations. Each quaternion is represented by four components: a scalar (real) part and a vecto...
magicoder
You are tasked with creating a Python program to simulate a simple chatbot that responds to user input. The chatbot should greet the user, ask for their name, and then engage in a conversation by echoing the user's input. However, the chatbot should also have a delay of 60 seconds between each response. Your task is t...
magicoder
You are tasked with implementing a Python class that manages tracing configurations for a microservices architecture. The class should handle configurations for Jaeger and Google Cloud Platform (GCP) tracing. Your task is to complete the implementation of the `TracingConfig` class by adding the following functionaliti...
magicoder