instruction_seed
stringlengths
29
40.5k
source
stringclasses
6 values
You are tasked with creating a program to manage input device mappings for a gaming emulator. The program should allow users to define and configure input mappings for various gaming devices. Each device has a unique name, a command start string, and a set of mappings that associate a description with a corresponding M...
magicoder
You are tasked with creating a Python class that manages environment variables and provides methods to manipulate and retrieve them. Your task is to implement the `EnvironmentManager` class with the following specifications: - The class should have an `__init__` method that initializes an empty dictionary to store env...
magicoder
You are tasked with implementing a custom data provider class in JavaScript that fetches data from an API and provides it to the application. The class should handle making HTTP requests to the API and returning the data to the caller. Your task is to create the `ApiDataProvider` class with the following requirements: ...
magicoder
You are working on a data processing script for a multinational company. The script is responsible for cleaning and formatting a dataset containing employee information. The dataset is stored in a file named `filename` located in the `download` directory. The script contains several functions to perform various data pr...
magicoder
You are tasked with creating a Python function that retrieves a list of books from a server using a given base URL. The function should make an HTTP request to the server and return the list of books in JSON format. You are provided with a code snippet that sets the URL for the HTTP request. Write a function `retrieve...
magicoder
You are tasked with creating a web form for collecting personal information. The form should consist of two input fields: one for the first name and another for the last name. Additionally, the form should include a button for submitting the information. The form should be styled using the provided CSS-in-JS code snipp...
magicoder
You are tasked with implementing a logging system for a network router management application. The application manages multiple routers, each identified by a unique router ID and associated with a domain name. The provided code snippet is a part of the logging functionality for starting and stopping routers. The `print...
magicoder
You are working on a project that involves training a neural network using a Python script. After the training is complete, you need to transfer the trained network's configuration file, `network.json`, to a specific directory within a Chrome extension's folder structure. The provided Bash script snippet is intended to...
magicoder
You are tasked with creating a custom admin interface for an e-commerce platform using Django. The platform has several models representing different aspects of the business, such as products, orders, order items, ratings, and transactions. The code snippet provided registers these models with the admin interface using...
magicoder
You are given a Python function that takes a list of integers as input and is intended to return a new list containing only the unique elements from the input list, preserving their original order. However, the given code snippet is incomplete and contains a logical error. Your task is to identify the error in the code...
magicoder
You are tasked with implementing a C++ class that manages a collection of integers and provides various operations for manipulating and querying the collection. The class should be designed to efficiently handle large sets of integers and support operations such as adding elements, removing elements, finding the minimu...
magicoder
You are tasked with implementing a simple image processing function in C#. The function should create a single-pixel texture with a specified color. You are provided with a code snippet that demonstrates the usage of the `CreatePixel` function. Your task is to complete the implementation of the `CreatePixel` function t...
magicoder
You are tasked with creating a Python program to parse a given text file and extract specific information from it. The text file contains a list of contacts in the following format: ``` Name: John Doe Email: johndoe@example.com Phone: (123)4567890 Name: Jane Smith Email: janesmith@example.com Phone: (987)6543210 ``` ...
magicoder
You are working on a machine learning project that involves testing the accuracy of a model on a dataset. The code snippet provided is a part of the evaluation process. The snippet is responsible for printing the experiment name, iteration number, split type, accuracy, number of correct answers, and total number of que...
magicoder
You are working for a cybersecurity company that specializes in managing digital certificates for secure communication. Your task is to write a program that generates a digital certificate in PKCS#12 format using the OpenSSL command-line tool. The command-line arguments for generating the certificate are provided as a ...
magicoder
You are tasked with implementing a generic builder pattern for creating HTTP request parameters in Rust. The provided code snippet is a part of a builder pattern implementation for constructing parameters for a `POST` operation associated with `SimpleAuthParams`. Your task is to complete the implementation of the `Sim...
magicoder
You are tasked with creating a Python function that converts a given vtkPolyData object into a vtkActor object using the VTK library. The vtkPolyData object represents a 3D surface geometry, while the vtkActor object is used to represent the 3D model in a VTK scene. Your task is to implement the `polyDataToActor` funct...
magicoder
You are tasked with creating a custom Angular pipe to transform a given date into a specific format. The pipe should take a JavaScript Date object as input and return a string in the format "Month DD YYYY, HH:MM" (e.g., "January 01 2020, 00:00"). Your task is to implement the custom Angular pipe called "DateTransformP...
magicoder
You are tasked with implementing a device sweeping algorithm to ensure fair distribution of workload across a set of devices. The algorithm should randomize the order in which devices are processed to prevent bias in case of process restart before the sweep is completed. You are given a Python code snippet that demons...
magicoder
You are tasked with implementing a simple server management system in Python. The provided code snippet sets up a socket for a server and initializes a server manager. Your task is to complete the server management system by implementing the logic for handling incoming client connections and managing client inputs and ...
magicoder
You are tasked with implementing a keyboard input handler for a simulation program. The provided code snippet contains a function `keyboard_keys` that returns a dictionary of user-defined keys and their corresponding callable functions. The keys are associated with specific actions in the simulation program, and the us...
magicoder
You are tasked with implementing a class that manages the removal of various types of data from a web browser. The class should provide methods for clearing local storage, plugin data, and stored passwords. You need to define the class and its methods based on the given code snippet. Your task is to create a TypeScrip...
magicoder
You are tasked with creating a custom tabbed widget in a PyQt application. The given code snippet is a part of a larger PyQt application and is responsible for setting up a tabbed interface with a specific size policy for the log output widget. Your task is to complete the implementation of the tabbed widget by adding ...
magicoder
You are tasked with creating a Python function that validates file paths based on certain criteria. The function should take a file path as input and return True if the path meets the specified criteria, and False otherwise. The criteria for a valid file path are as follows: 1. The file path must not be empty. 2. The ...
magicoder
You are tasked with creating a program that checks the validity of a software license key. A software license key is a unique string that represents the right to use a specific software application. The key is typically formatted as a sequence of groups of characters separated by dashes. Each group must contain only al...
magicoder
You are tasked with implementing a Python function that validates the encoding and decoding of a series of test cases. The function should compare the original decoded string with the re-encoded string and print the validation results for each test case. The code snippet provided is a part of a Python script that perf...
magicoder
You are given a log file containing network traffic data. Each entry in the log file represents a network event and has the following format: ``` log_entry = { "timestamp": "2022-01-01 12:00:00", "source_ip": "192.168.1.1", "destination_ip": "10.0.0.1", "data_in": "100", # or "-" if data is not availa...
magicoder
You are tasked with implementing a function that processes a given array of entity fields and returns a new array with the deleted fields filtered out. Each entity field is represented as an associative array with a "deleted_at" key, which may be null if the field has not been deleted. The function should filter out an...
magicoder
You are tasked with creating a program that simulates a simple online shopping system. The program should allow users to add items to their cart, view the items in their cart, and calculate the total cost of the items in the cart. The program should also handle the connection to the database where the items are stored....
magicoder
You are working on a data processing pipeline that involves handling a large dataset of resources. Each resource has a format associated with it, but some entries have missing format values (NaN). To address this issue, you need to implement a function that retrieves the missing format for resources from a URL. The cod...
magicoder
You are tasked with implementing a function that extracts a specific class from a TypeScript module and returns it as a named export. The module contains a code snippet similar to the following: ```typescript (<any>globalObject).BABYLON.GuiEditor = GUIEditor; // eslint-disable-next-line @typescript-eslint/naming-conve...
magicoder
You are tasked with creating a Python function that generates unique usernames for new users in a web application. The function should take a string representing the user's first name and a string representing the user's last name as input and return a unique username based on the following rules: 1. The username shoul...
magicoder
You are tasked with creating a program that processes and visualizes data from a CSV file using Python's pandas library and the dfgui library for interactive data exploration. Your task is to write a Python program that reads a CSV file, performs some data manipulation using pandas, and then visualizes the processed d...
magicoder
You are tasked with creating a Python class using the `pydantic` library to represent a simple data model for a user profile. The user profile should include the following fields: - `username`: a string with a minimum length of 3 characters and a maximum length of 50 characters - `email`: a valid email address - `age`:...
magicoder
You are tasked with implementing a class that manages a queue of tasks to be executed in a loop. The class has the following methods and properties: 1. `__init__(self, operation: str, loop: int)`: A constructor that initializes the queue with a specific operation and loop count. 2. `nextLoop(self)`: A method that decr...
magicoder
You are tasked with implementing a custom exception class for handling entity not found errors in a Java application. Your task is to create a custom exception class called `EntityNotFoundException` that extends the `Exception` class. The `EntityNotFoundException` class should have a constructor that accepts a `String`...
magicoder
You are tasked with implementing a class that manages payment statuses for a financial system. The class should provide methods to retrieve payment statuses and their corresponding descriptions. The class should also handle cases where a specified payment status is not found. Your task is to complete the implementation...
magicoder
You are tasked with creating a program that processes a given HTML snippet and extracts specific information from it. The HTML snippet contains various text content and a PHP code snippet. Your goal is to extract the text content within the `<p>` tags and identify any PHP code present in the snippet. Write a function ...
magicoder
You are given a string `s` and an integer `m`. Your task is to implement a function that constructs a new string based on the following pattern: Starting from the first character of `s`, the function should append characters to the new string in a specific manner. For each row, the characters are appended in the follo...
magicoder
You are tasked with creating a command-line tool that calculates the ratio of two given numbers. The tool should accept command-line arguments for debug level, input file, and output file. Your task is to implement the functionality to parse the command-line arguments and perform the ratio calculation. Your program sh...
magicoder
You are tasked with implementing a function to validate user input for a registration form. The function should ensure that the provided user data meets certain criteria before allowing the user to be added to the system. The user data includes the user's name, email, and password. Your task is to create a function tha...
magicoder
You are tasked with creating a Swift data structure to manage requests for data sets. The data structure should include a property to store the request ID and an initializer to set the request ID. Your task is to implement a Swift class that fulfills these requirements. Create a Swift class named `DataSetRequest` with...
magicoder
You are tasked with creating a Python function that parses a help text for a Telegram bot and extracts the list of commands along with their descriptions. The help text is structured with each command followed by its description, and the command and description separated by a colon. The commands are prefixed with a for...
magicoder
You are tasked with implementing a pagination mechanism for a robot application listing service. The `listRobotApplicationsPaginator` function takes in a request object of type `ListRobotApplicationsRequest` and provides a closure `onPage` to be called with each block of entries. The closure returns a boolean indicatin...
magicoder
You are tasked with creating a program that processes a series of integers and performs specific operations on them. The program should take an integer input from the user and then perform a mathematical operation on it. The user will input a series of integers, and for each integer, the program should calculate the sq...
magicoder
You are tasked with implementing a method to process a collection of `MiniBgCharaMotion` objects in a C# application. Each `MiniBgCharaMotion` object represents a character motion within a background scene and contains various properties such as Id, BgId, GroupId, SubGroupId, IsMob, MainCharaNum, PosObj, and PositionFi...
magicoder
You are tasked with creating a custom test case class for a PHP application using PHPUnit. Your task is to extend the `TestCase` class provided by PHPUnit and implement a custom test case method that checks the functionality of a specific class or method within your application. Your custom test case class should have...
magicoder
You are tasked with creating a program to analyze and visualize stock price trends for a given set of companies. The program should read stock price data from a CSV file, calculate the cumulative sum of the stock prices, and then plot the trends for the selected companies. Your task is to implement a Python program th...
magicoder
You are tasked with implementing a function that takes an array of objects as input and returns a new array containing only the unique values of a specific property from the objects. You are given the following code snippet as a starting point: ```javascript data: { id, }, ``` Write a function `getUniquePropertyVal...
magicoder
You are tasked with implementing a file upload service that can handle both text and image uploads. Your task is to create a class in TypeScript that encapsulates the functionality for uploading text and image files. The class should have the following properties and methods: Properties: - `description`: A string prop...
magicoder
You are tasked with creating a web application for classifying items into different categories. The application uses Laravel framework and Eloquent ORM for database operations. The code snippet provided is from a Laravel controller that handles the classification functionality. The `index` method retrieves all categori...
magicoder
You are tasked with implementing a Java method that reads data from an input stream and writes it to an output stream. However, there is a bug in the provided code snippet that needs to be identified and fixed. You need to create a method `copyStream` that takes an `InputStream` and an `OutputStream` as parameters and...
magicoder
You are tasked with implementing a function that processes a list of transactions and returns a summary of the total amount for each transaction type. Each transaction is represented as an object with the following structure: ```javascript { type: string, // Type of the transaction (e.g., 'purchase', 'refund', 'trans...
magicoder
You are tasked with creating a script to automate the startup process of a server application called "WormholeServer." The server is written in Java and requires setting the environment variable `WORMHOLE_HOME` before launching the server. Additionally, the server's classpath needs to include specific JAR files. Your s...
magicoder
You are tasked with implementing a function to calculate the minimum and maximum x-values that a chart can currently display, given the zoom level. The chart has a fixed width, and the data to be displayed on the chart ranges from a minimum x-value to a maximum x-value. The zoom level determines how much of the data ra...
magicoder
You are tasked with creating a Django migration for a web application that manages environmental monitoring stations. The application has a model called `FeatureData` which contains data related to various features at the monitoring stations. The `FeatureData` model has a field called `station` which represents the sta...
magicoder
You are tasked with creating a Python class that generates animation commands for displaying a sequence of images. The class should have a method to define an image and another method to generate animation commands for displaying the defined image in a specific sequence. You are provided with a code snippet that defin...
magicoder
You are tasked with creating a web application that manages orders for an online store. The provided code snippet is a part of the HTML template used to display a list of orders in the admin panel. The snippet includes a table with order details and buttons for editing, deleting, and adding items to each order. Your t...
magicoder
You are tasked with implementing a Python class that simulates a simple dummy object. The dummy object should have a method to set its value and another method to retrieve its value. Additionally, the dummy object should be initialized with a default value of 0 if no initial value is provided. Your task is to create a...
magicoder
You are tasked with implementing a function to parse and validate command-line switches for a Python application. The function should take a dictionary of switches and their values, and return a list of valid switches. A valid switch is defined as a key-value pair where the key starts with "--" and the value is not an ...
magicoder
You are tasked with creating a Python function that processes a list of streams and performs specific operations on them. Your task is to implement the function `test_str_idx(list_stream)` that takes a list of streams as input and raises a `TypeError` if an attempt is made to access an element using a non-integer index...
magicoder
You are tasked with implementing a React component that includes a dropdown menu and a button. The dropdown menu should be populated with a list of options, and the button should trigger an action based on the selected option. You are provided with a code snippet that includes the import statement for the `ViewDropdown...
magicoder
You are tasked with creating a Python function that simulates a simple file system traversal and manipulation. Your function should take in a directory path as input and return a list of all the files within that directory and its subdirectories. Additionally, the function should calculate the total size of all the fil...
magicoder
You are tasked with creating a Python function that processes a dictionary containing metadata for a comment in a social media platform. The function should extract specific information from the dictionary and return it in a structured format. You are given the following code snippet as a reference: ```python "json_m...
magicoder
You are tasked with creating a multilingual message handling system for a news posting and contact form feature on a website. The system should support different languages and provide appropriate messages for various user interactions. You are given a Python dictionary `messages` that contains language-specific message...
magicoder
You are tasked with implementing a simple account management system for a financial institution. The `Account` struct has three fields: `available`, `held`, and `locked`. The `available` and `held` fields are of type `Currency`, representing the available and held balances in the account, while the `locked` field is a ...
magicoder
You are tasked with creating a Python function that checks if a given word is a palindrome. A palindrome is a word that reads the same forwards and backwards, such as "radar" or "level". Your function should take a single string parameter and return True if the input word is a palindrome, and False otherwise. Your fun...
magicoder
You are given a Python code snippet that initializes a variable `vector` as a list of dictionaries. Each dictionary contains a "name" and an "age" key. Additionally, there is a commented-out for loop that iterates through the `vector` list and prints the value associated with the "name" key for each dictionary. Your t...
magicoder
You are tasked with creating a custom styling component for a web application using Material-UI library in React. The given code snippet demonstrates the usage of Material-UI's `styled` function to create a custom styled component. Your task is to extend this code to create a new styled component with specific styling ...
magicoder
You are tasked with implementing a database migration system for a web application. The system should support both forward and backward migrations to manage changes to the database schema. You are provided with a code snippet that outlines the interface for executing migrations. The `execute_migration_up` function is ...
magicoder
You are tasked with implementing a function that processes a configuration dictionary based on parsed command-line arguments. The configuration dictionary contains information about a software environment, including the command to be executed and the base image to be used. The function should update the configuration b...
magicoder
You are given a code snippet that appears to be incomplete. Your task is to complete the code to implement a program that generates a specific pattern of numbers. The pattern is as follows: 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 You need to write a C++ program to print this pattern up to a given number of rows. The program sh...
magicoder
You are tasked with implementing a UML (Unified Modeling Language) modeling system that supports various UML elements such as stereotypes, behaviors, data types, associations, interfaces, and deployments. The provided code snippet includes the necessary header files and a namespace declaration for the UML library. You...
magicoder
You are tasked with implementing a circular buffer data structure in C++. A circular buffer is a fixed-size buffer that overwrites old data with new data when it reaches its capacity. Your task is to implement the `CircularBuffer` class with the following functionalities: 1. `CircularBuffer(int capacity)`: A construct...
magicoder
You are tasked with implementing a Python function that processes a list of tuples representing Django migration files and returns a dictionary containing the migration names and their corresponding version numbers. Each tuple in the list contains the app label and the migration name. You need to write a function `pro...
magicoder
You are tasked with implementing a function that processes a JSON response and extracts specific information from it. The response is in the form of a JSON string and contains a key-value pair representing the state of an operation and a message associated with that state. Your task is to write a function that takes th...
magicoder
You are tasked with implementing a session management system for an online MBA (Master of Business Administration) program. The system should allow users to log in, view their course information, and log out. The user's session should be maintained throughout their interaction with the system. You are provided with a ...
magicoder
You are tasked with creating a Python function that efficiently removes specific files from a given directory based on a set of criteria. The function should take in a configuration dictionary containing the directory path and a list of file names to be removed. The function should then remove the specified files from ...
magicoder
You are tasked with creating a Python class that handles web automation using the Selenium library. Your class should include error handling for the case when a NoSuchElementException is raised, and it should also capture a screenshot of the web page when this exception occurs. Your task is to complete the implementat...
magicoder
You are given a Python code snippet that swaps the values of two variables `a` and `b`. Your task is to implement a function that performs the same variable swap operation as shown in the code snippet. The function should take two input parameters, `a` and `b`, and swap their values without using a temporary variable....
magicoder
You are tasked with implementing a simple TCP server using Netty, a popular asynchronous event-driven network application framework for rapid development of maintainable high performance protocol servers and clients. Your task is to complete the implementation of a TCP server that listens for incoming connections and ...
magicoder
You are tasked with implementing a Python function that calculates the Laplacian of an image using the second derivatives in the x and y directions. The Laplacian is a measure of the second spatial derivative of an image and is used for edge detection and feature extraction in image processing. You are given a code sn...
magicoder
You are given a list of coordinates representing points on a map. Each coordinate is represented as a pair of latitude and longitude values. Your task is to write a function that calculates the distance between two given coordinates using the Haversine formula. The Haversine formula is used to calculate the distance be...
magicoder
You are tasked with creating 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. Create a Python class named `BankAccou...
magicoder
You are given a Rust function that takes an `Option<i32>` as input and returns a modified `Option<i32>` based on the following pattern matching logic: ```rust fn increment_option(a: Option<i32>) -> Option<i32> { match a { Some(num) => Some(num + 1), None => None } } ``` Your task is to impleme...
magicoder
You are tasked with implementing a class method that normalizes HTML meta tag attribute names. The method should take a string representing the attribute name and return the normalized version according to the following rules: - If the input is 'Name' or 'name', the method should return 'name'. - If the input is 'HttpE...
magicoder
You are tasked with implementing a simple dictionary parser that extracts key-value pairs from a given input string. The input string represents a series of key-value pairs in the format "key = value". Your task is to write a function that takes the input string and returns a dictionary containing the extracted key-val...
magicoder
You are working on a Django project that involves creating and modifying models. One of the models, `RSD`, needs to be updated with a new field. The new field, `Link_Osz_join_LSP`, should store a URL link to a resource and can be left blank or set to `null`. Your task is to write a migration script to add this new fiel...
magicoder
You are tasked with implementing a Swift initializer for a custom payment component. The initializer takes in several parameters and assigns them to the corresponding properties of the component. Your task is to complete the implementation of the initializer based on the given code snippet. The `PaymentComponent` stru...
magicoder
You are tasked with implementing a thread-safe dictionary in Python. The dictionary should support concurrent read and write operations from multiple threads without causing data corruption or race conditions. To achieve this, you need to implement a `ThreadSafeDict` class that wraps the access to a regular dictionary ...
magicoder
You are tasked with creating a Python function that processes and validates TIFF image files within a Django web application. The function should take a TIFF image file as input and perform the following tasks: 1. Check if the file format is TIFF using the `tifffile` library. 2. Ensure that the file size does not excee...
magicoder
You are working on a security system that uses sensors to detect various types of activities. The system has different sensor types and needs to classify the detected activities as either suspicious or normal. You are given a Python code snippet that defines a sensor type and a classification enum. Your task is to impl...
magicoder
You are given a Python code snippet that contains a copyright notice. Your task is to write a Python function that takes the code snippet as input and extracts the years mentioned in the copyright notice. The function should return a list of years found in the copyright notice. Function Signature: `def extract_years(c...
magicoder
You are tasked with implementing a class that manages the output of color data to either standard output or a file. The class, named `ColorOutputManager`, has the following requirements: 1. The class should have a constructor that takes a boolean parameter `useStandardOutput` to determine whether the color data should...
magicoder
You are tasked with implementing a unit testing framework for a simple Python program. The program consists of two functions: `test_model()` and `test_single()`. Your goal is to create a test suite that verifies the correctness of these functions. The `test_model()` function takes no arguments and is responsible for ...
magicoder
You are tasked with implementing a function that processes a list of events related to different aggregate IDs and returns the count of events for each unique aggregate ID. Each event is represented by an object with a property `aggregateId` containing the ID of the aggregate it belongs to. You need to write a functio...
magicoder
You are tasked with implementing a Python class that simulates a shift register slider. A shift register is a digital circuit that can store and shift data. The shift register slider is responsible for controlling the shift register and performing various operations on it. Your task is to implement the `ShiftRegSlider...
magicoder
You are working on a Django REST framework project and have a view that includes a method called `perform_create`. This method is responsible for creating a new instance of a model using the data provided in a serializer. Your task is to create a custom validation for the data before the new instance is created. You n...
magicoder
You are tasked with creating a Python function to compute accuracy metrics for a set of methods used to predict rankings. The function takes in the number of methods, gold preferences, predictions, and optional metrics, number of runs, and a specific run index. The function should compute accuracy metrics for each meth...
magicoder
You are tasked with implementing a data validation system for a Python application. The system should be able to handle various types of input data and validate them based on predefined rules. The code snippet provided contains a series of test cases for the data validation system, along with the expected exceptions th...
magicoder