instruction_seed
stringlengths
29
40.5k
source
stringclasses
6 values
You are tasked with creating a migration operation for a Django application. The application has a model named `CommitteeMember` in an app called `history`. The migration operation involves altering a field in the `CommitteeMember` model. Your task is to write a migration operation that alters the field named `member`...
magicoder
You are tasked with creating a program that simulates the behavior of a simplified shell environment. Your program should implement the functionality of the `export` and `eval` commands, as well as handle the initialization of environment variables. Your program should support the following commands: - `export VAR=VAL...
magicoder
You are tasked with implementing a function that converts a given 2D NumPy array into a string representation, with each element formatted to a specified precision. The function should take the NumPy array and the precision as input and return the formatted string representation of the array. The function signature sh...
magicoder
You are tasked with implementing a function to analyze algebraic data types (ADTs) in Rust. An ADT is a type composed of distinct alternatives, such as enums or structs. The function `analyze_adt` takes a type `ty` and a `TyCtxt` (Type Context) `tcx` as input, along with a mutable set of visited types `visited_types`. ...
magicoder
You are tasked with creating a Python function that simulates a simplified version of a REST API call. Your function should take three parameters: the HTTP method (GET, POST, PUT, DELETE), the endpoint URL, and the payload (if applicable). The function should then print a message indicating the type of request being ma...
magicoder
You are tasked with creating a Python function that parses details from a web response and yields a dictionary containing specific information. The function should take a `response` object as an argument, which contains the web page content, and should extract the name, image URL, telephone number, and email address fr...
magicoder
You are tasked with creating a Python program to process a set of images and convert them from PNG format to JPEG format with reduced quality. The program should traverse a specified directory containing subdirectories, each representing a category of images. Within each subdirectory, the program should convert all PNG...
magicoder
You are tasked with creating a program to manage a database of clients and their civil responsibility records. The program should generate fake data for clients and their corresponding civil responsibility records using the Faker library in PHP. Your task is to create a PHP class that utilizes the Faker library to gen...
magicoder
You are tasked with implementing a function that calculates the resource count for a specific operation based on the input parameters. The function takes in a structure `TI_RES_COUNT` representing the resource count, an enumeration `INTRINSIC` representing the intrinsic operation, and an integer `num_multiplies` repres...
magicoder
You are tasked with creating a Python script that processes a batch file and replaces a specific filename within it. Your script should read the contents of the batch file, replace occurrences of "search.cpp" with "search_tmp.cpp", and then execute the modified batch file. Write a Python function `process_and_execute_...
magicoder
You are tasked with implementing a custom error handling system in Rust. Your goal is to create a macro that generates error handling code for a given type. The macro should generate an implementation of the `std::error::Error` trait for the specified type and provide a `from` macro for converting other error types int...
magicoder
You are tasked with implementing a React component that manages the editing of a list of subtitles. The component should allow users to double-click on a title to enable editing, and it should display a list of subtitles with the ability to edit each subtitle. The component should utilize React hooks for state manageme...
magicoder
You are tasked with implementing a Python class that manages processing instructions (PIs) for an XML tree. PIs are special instructions included in XML documents that are not part of the document's actual content. Your class should be able to store PIs and append them to an existing XML tree using the `etree` module f...
magicoder
You are tasked with creating a script to automate the installation of software packages on a Linux system. The script should handle both multiple and single package installations, as well as the installation of specific files to designated directories. Your task is to implement a function that takes care of these insta...
magicoder
You are given a file `gene_info.txt` containing gene information in tab-separated format. Each line in the file consists of three columns: gene ID, gene name, and gene description. The gene description may contain additional information enclosed in square brackets. The provided Python code snippet reads the `gene_info....
magicoder
You are working on a data sampling module for a machine learning framework. The module is responsible for randomly selecting samples from a given dataset. The code snippet provided is a part of the sampling module's implementation. The `reset_sampling` method is used to reset the sampling process to the beginning of th...
magicoder
You are tasked with implementing a fault-tolerant microservice using Spring Boot and its associated annotations. The code snippet provided is a partial implementation of a service called `HelloService`. This service is annotated with `@Service` and utilizes two other annotations: `@Retry` and `@CircuitBreaker`. The `@R...
magicoder
You are tasked with implementing a custom error type and a function to parse a string into a specific data type. The custom error type should represent two distinct error cases: "InvalidFormat" for when the input string cannot be parsed into the desired data type, and "OutOfRange" for when the parsed value is outside a...
magicoder
You are working on a data processing pipeline for a Go game AI system. The code snippet provided is a part of the configuration setup for the pipeline. The `PATH_TEMPLATE` and `OUTPUT_PATH` variables are used to construct file paths for reading and writing data. The `flags.DEFINE_string` and `flags.DEFINE_boolean` func...
magicoder
You are tasked with creating a Python program that processes a given HTML file and extracts specific information from it. The program should read the HTML file, locate a specific tag structure, and then extract the href attribute from the anchor tag within the specified tag structure. The extracted href values should b...
magicoder
You are tasked with creating a function that checks whether a given disk image file has already been attached to the system. The function should take a string representing the path to the disk image file and return a boolean value indicating whether the disk image is already attached. You are provided with a code snip...
magicoder
You are tasked with creating a Python function that validates a configuration file and extracts specific information from it. The configuration file is in YAML format and contains various settings for a software application. The function should load the configuration file, validate its structure, and extract a specific...
magicoder
You are working on a project that involves creating a character management system for a text-based role-playing game. As part of this system, you need to implement a class hierarchy for different characters in the game. One of the character types is a "Parahuman," which has special abilities and attributes. Your task ...
magicoder
You are tasked with creating a program that simulates a simple file packaging system. The program should take a list of files and exclude certain file patterns, then package the remaining files into a specific format. Your task is to implement a function `package_files` that takes in a list of file names and a list of...
magicoder
You are tasked with implementing a class that manages a list of repository information. The class should allow adding repository information to a list and selecting a repository from the list. The repository information includes the path to the root and the branch name. You need to implement the methods to add reposito...
magicoder
You are tasked with creating a function that processes a given HTML template and extracts specific attributes from it. The HTML template contains a `<div>` element with a class attribute of "btn-group action-btn" and two child elements, each representing a button. The buttons have attributes for their IDs and associate...
magicoder
You are tasked with creating a script to automate the release process for a Node.js package. The script should perform the following steps: 1. Wait for 60 seconds to ensure any necessary preparations are completed. 2. Publish the Node.js package to the npm registry using the `npm publish` command. 3. Display the full ...
magicoder
You are tasked with creating a Python function that interacts with a REST API to retrieve and parse data. The function should make an asynchronous HTTP GET request to a specified endpoint, handle query parameters, and validate the response. Write a Python async function `fetch_and_parse_data` that takes in the followi...
magicoder
You are given a file containing a sequence of integers. Each integer represents the size of a specific data structure in bytes. Your task is to write a program to calculate the total size of all the data structures in kilobytes (KB). Write a function or program that takes the file path as input and returns the total s...
magicoder
You are tasked with implementing a class for managing survey archives. The provided code snippet is part of a larger system and demonstrates the creation of a new survey archive and the handling of existing archives. Your task is to create a Python class `SurveyArchive` with the following requirements: - The class sho...
magicoder
You are tasked with creating a Python function that interacts with a web API to retrieve and cache XML data. Your function should take a query string as input, send a request to the Youdao translation API, and then store the XML response in a local cache file. The function should handle file I/O, HTTP requests, and URL...
magicoder
You are tasked with implementing a thread-safe permission management system for a service. The system should allow adding permissions for services, with the ability to filter permissions based on a provided filter. The code snippet provided is a part of the implementation for adding permissions to the system. Your task...
magicoder
You are tasked with implementing a function that parses a given JavaScript object and extracts specific information based on certain criteria. The object represents a nested structure of routes and their corresponding properties in a web application. Each route object contains properties such as `orderNo`, `icon`, `tit...
magicoder
You are tasked with implementing a Python function that performs image resizing and mask interpolation using PyTorch. The function takes an input image, a target dictionary containing masks, and specific size constraints. The function resizes the image and interpolates the masks accordingly. Your task is to complete th...
magicoder
You are tasked with implementing a function that simulates a simple text-based adventure game. The game will involve navigating through different rooms, interacting with objects, and making decisions that affect the outcome of the game. Your task is to implement the `adventureGame` function, which takes no parameters ...
magicoder
You are tasked with implementing a function to perform local sharding of a given dataset. Local sharding is a technique used in distributed computing to divide a dataset into smaller, non-overlapping subsets for parallel processing by different workers. The function should take the total size of the dataset, the rank o...
magicoder
You are tasked with implementing a function that processes a list of datasets and extracts specific information from each dataset. Each dataset is represented as a tuple containing the dataset's name, description, and data categories. The function should extract the names of datasets with a specific data category and r...
magicoder
You are tasked with creating a script to synchronize data between two drives using the `syncdrive.sh` command. The script takes five arguments in the following order: 1. Source directory: The directory from which data will be synchronized. 2. Destination directory: The directory to which data will be synchronized. 3. O...
magicoder
You are tasked with implementing an image processing pipeline in Swift. The pipeline should be able to apply a series of operations to an input image and produce the processed image as output. The operations to be applied include scaling and adjusting the alpha value of the image. You are provided with a code snippet ...
magicoder
You are tasked with implementing a file encryption and decryption system. The system consists of an `encryptor` and a `decryptor` which are responsible for encrypting and decrypting data, respectively. The `encryptor` takes a `secret_bytes` as input and returns the encrypted data along with some metadata. The `decrypto...
magicoder
You are tasked with implementing a Python class for a simple neural network layer using the PyTorch library. The provided code snippet is a partial implementation of the `LayerBiVanilla` class, which is intended to be a bidirectional vanilla RNN layer. Your task is to complete the implementation of the `LayerBiVanilla`...
magicoder
You are tasked with implementing a gene set z-score calculation method in Python. The gene set z-score is a statistical measure used in bioinformatics to assess the enrichment of a gene set within a larger dataset. You are provided with a class `GeneSetAnalyzer` that contains a method `gs_zscore` for calculating the z-...
magicoder
You are tasked with creating a script to automate the deployment of a software artifact. The script should copy specific files from one directory to another based on certain conditions. Your task is to write a Bash script that achieves this functionality. The script should perform the following steps: 1. Enable debugg...
magicoder
You are tasked with implementing a version control system for a document management application. The system should support versioning of documents, tracking changes, and managing transactions. Your task is to design and implement a class hierarchy to support version control operations. You are provided with a list of ...
magicoder
You are tasked with implementing a Python class that manages temporary directories. The class should provide methods for creating, accessing, and cleaning up temporary directories. Additionally, the class should support checking whether the temporary directory is still active or has been finalized. Your task is to com...
magicoder
You are tasked with creating a Python function that processes a given text and returns a list of unique emojis present in the text. An emoji is defined as any Unicode character that represents an emoji. You should use the `emoji` library to achieve this. Write a function `extract_unique_emojis(text)` that takes a stri...
magicoder
You are tasked with creating a Python function that retrieves benchmark data from a source store based on the provided source name and language. The function should handle two scenarios: when the language is specified and when it is not. If the language is not specified, the function should default to retrieving the be...
magicoder
You are tasked with implementing a Python function that compares the output of a Markdown conversion with an expected output, while ignoring any whitespace differences. The function should take a Markdown string and its corresponding expected output string as input, and return a boolean indicating whether the output ma...
magicoder
You are tasked with implementing a function that adds a child view controller to a parent view controller and sets the child view controller's view frame to match the bounds of a given container view. You are given the following code snippet as a starting point: ```swift if let view = controller.view { addChild(co...
magicoder
You are tasked with creating a bash script that processes a given directory and its subdirectories to find all files with a specific file extension. Your script should then display the total count of files found and their respective sizes in a human-readable format. Your bash script should accept the following command...
magicoder
You are tasked with creating a Python class that represents a simple bank account. The class should have methods for depositing funds, withdrawing funds, and checking the current balance. Additionally, the class should enforce a minimum balance requirement, and any attempt to withdraw funds that would result in the bal...
magicoder
You are tasked with creating a Django migration for a medical records system. The system includes a "patients" app, and a new migration needs to be added to alter a field in the "Patient" model. The field that needs to be altered is not specified in the given code snippet. Your task is to complete the migration by prov...
magicoder
You are tasked with implementing a function to calculate the maximum exponent array for a given precision. The maximum exponent array is used in the context of a Bancor formula, which is a mathematical formula used in the field of finance and economics. The function should take the maximum precision as input and return...
magicoder
You are tasked with creating a Python class that simulates a simple banking system. The class should have methods to deposit funds, withdraw funds, and check the account balance. Additionally, the class should be initialized with the account holder's name and an initial balance. The class should also keep track of the ...
magicoder
You are tasked with creating a Python class that simulates a simple banking system. The class should be able to create bank accounts, deposit funds, withdraw funds, and provide the account balance. Additionally, the class should have a method to generate a unique account number for each new account. Your task is to im...
magicoder
You are tasked with implementing a program to process a file containing records and sub-records. Each record may contain multiple sub-records, and the program needs to read and process these sub-records based on certain conditions. Your task is to write a function `processRecords` that takes in a file path as input an...
magicoder
You are tasked with implementing a function that processes a state dictionary and returns a modified version of the dictionary based on specific criteria. The state dictionary contains information about different states and their attributes. Your task is to create a function that takes this dictionary as input and retu...
magicoder
You are tasked with implementing a simplified file storage system using Python. Your task is to create a class `FileStorage` that provides methods for reading and writing data to a file. The class should have the following methods: 1. `__init__(self, file_path: str)`: Constructor that initializes the file path for the...
magicoder
You are tasked with implementing a gesture recognition system for a robotic device. The system will receive binary input representing various gestures and should output the corresponding gesture name. The provided code snippet outlines a dictionary mapping binary representations to gesture names. However, it seems that...
magicoder
You are tasked with implementing a WindowManager class that manages the windows of a web browser using Selenium WebDriver. The class should provide methods for switching between windows, closing windows, and retrieving the handles of all open windows. Your task is to complete the implementation of the WindowManager cl...
magicoder
You are working on a deployment script for a cloud storage service called Pithos. The script sets environment variables for the Pithos service. The environment variables `PITHOS_CASSANDRA_HOST` and `PITHOS_SERVICE_URI` are being set with default values if they are not already defined. The `PITHOS_CASSANDRA_HOST` defaul...
magicoder
You are tasked with implementing a simple mail module in JavaScript. The provided code snippet shows the export of a `Mail` class using both CommonJS and ES6 module syntax. Your task is to create the `Mail` class with the following functionalities: 1. A constructor that initializes the `from`, `to`, and `subject` prop...
magicoder
You are tasked with creating a Python program that simulates a simple text-based game. The game involves a player navigating through a series of rooms, each with its own unique challenges and rewards. The player's goal is to reach the final room and claim the ultimate prize. Your task is to implement the logic for the...
magicoder
You are tasked with implementing a thread-safe mechanism for managing authentication triggers in a Swift application. The provided code snippet includes the declaration of some relevant properties and a lock object. You need to create a class `AuthenticationManager` with the following requirements: 1. Implement a meth...
magicoder
You are tasked with creating a Python programming problem that involves testing a command-line tool using the `unittest` framework. The problem will require students to write a test case for a specific command-line tool and verify its functionality. You are provided with a code snippet that imports the necessary modul...
magicoder
You are tasked with writing a Bash script to perform a series of calculations for a computational fluid dynamics simulation. The script takes in a single command-line argument, `ROOT`, which represents the root directory for the simulation. The script also initializes several arrays: `ps`, `etas`, `angles`, `angles_str...
magicoder
You are tasked with implementing a Python function that processes HTTP requests and responses. The function should take a list of request objects, send them to a server, and then validate the responses. Each request object contains information about the request to be made, and each response object contains information ...
magicoder
You are tasked with implementing a simple stack data structure in Swift. A stack is a collection of elements with two main operations: push, which adds an element to the top of the stack, and pop, which removes the top element from the stack. Your implementation should support these operations and also include a method...
magicoder
You are tasked with creating a custom hook in React that manages the state of a modal component. The modal should be able to detect if it is in fullscreen mode, handle outside clicks to close itself, and adapt its behavior for mobile devices. Additionally, the hook should provide a selector function to access the modal...
magicoder
You are tasked with implementing a class method that processes a buffer and extracts mentions from a "SEND" message. The method should handle the extraction of mentions from the message and raise assertions for specific conditions. You are given the following code snippet as a starting point: ```python def get_mentio...
magicoder
You are tasked with implementing a StateManager class that manages multiple StateMachine instances. Each StateMachine represents a state machine with a specific name and a set of possible states. The StateManager should allow adding StateMachine instances and provide methods to transition the states of the machines. Y...
magicoder
You are tasked with implementing a simple property decorator in TypeScript. A property decorator is a special kind of declaration that can be used to observe, modify, or replace a property definition. In this case, you need to create a property decorator that logs the value of the property whenever it is accessed or mo...
magicoder
You are tasked with implementing a depth-first search algorithm to traverse a tree-like data structure. The data structure is represented as a collection of objects, each containing a set of fields and their corresponding values. The goal is to visit each object in the data structure and perform a specific operation on...
magicoder
You are tasked with implementing a simple login system using Python. The system should prompt the user to enter their username and password. If the entered credentials match the predefined username and password, the system should display a success message. Otherwise, it should display a failure message. Your task is t...
magicoder
You are working for a computer store and have been tasked with writing a program to calculate and display the total sales and average rating for the computers sold. You have been given the following code snippet as a starting point: ```python counter_sales += real_sales average_rating = total_ratings / number_of_comp...
magicoder
You are given a string `s` consisting of lowercase English letters and curly braces. The string may contain nested curly braces. Your task is to determine if the string is properly nested, meaning that for every opening curly brace there is a corresponding closing curly brace, and they are properly nested within each o...
magicoder
You are tasked with implementing a pagination system for a web application that displays a list of users. The server sends a response with pagination information in the form of a JSON object in the "X-Pagination" header. The JSON object contains the following properties: - TotalCount: The total number of users in the s...
magicoder
You are working on a software development project and need to ensure that the codebase adheres to specific linting and validation standards. Your task is to create a script that automates the linting and validation process for a given codebase. The script should perform the following tasks: 1. Check if the `helm` comm...
magicoder
You are tasked with implementing a class method that sets a bearer token for a given email address. The method should be asynchronous and return a Promise. The bearer token is a string that will be used for authentication purposes. You need to implement the `setBearer` method in the `AuthManager` class. The `AuthManag...
magicoder
You are tasked with implementing a function that processes a series of PTX (Parallel Thread Execution) elements and generates a modified PTX output. The PTX elements are represented as a struct with various fields and methods. Your task is to complete the implementation of the `generate_modified_ptx` function, which ta...
magicoder
You are given a Python code snippet that involves the use of NumPy and some custom functions. Your task is to create a problem related to computational geometry and NumPy manipulation based on the given code snippet. Write a function that takes a set of 2D points as input and calculates the area of the convex hull for...
magicoder
You are tasked with implementing a function that processes file paths in a file system. The function should take a base directory path and construct a new file path by appending a specific directory path to the base directory. You need to write a function in C++ that accomplishes this task. Function Signature: ```cpp ...
magicoder
You are tasked with writing a shell script to automate the installation of specific software versions. The script should utilize the environment variables provided and install the corresponding software versions using the appropriate package manager. Given the following environment variables: ``` export gdsVersion="1....
magicoder
You are tasked with creating a Python function that reads a configuration file in YAML format and initializes a logging system based on the configuration. The function should return the logger object for use in the application. The provided code snippet is a partial implementation of the function, and your task is to c...
magicoder
You are tasked with implementing a simple text processing system using Python. The system should utilize the `FairseqIncrementalState` class to maintain an incremental state while processing a sequence of text inputs. The `FairseqIncrementalState` class has an `init_incremental_state` method that initializes the increm...
magicoder
You are tasked with creating a Python program to simulate a simple coin toss game. The program should prompt the user to guess the outcome of the coin toss (heads or tails) and then reveal the actual outcome. The program should use a random number generator to simulate the coin toss. Your task is to complete the Pytho...
magicoder
You are tasked with implementing a simplified version of a Java class hierarchy for a graphical user interface (GUI) library. The library includes classes for various GUI components, and you are required to create a new class called `NSImageView` that extends the existing `NSControl` class. The `NSControl` class is a ...
magicoder
You are tasked with implementing a simple encryption algorithm for a messaging application. The algorithm involves shifting each letter in a message by a certain number of positions in the alphabet. For example, if the shift is 3, then 'a' would be encrypted as 'd', 'b' as 'e', and so on. The encryption algorithm shoul...
magicoder
You are tasked with creating a file upload feature for a web application using TypeScript and the `@typeix/resty` framework. The application should allow users to upload files through an API endpoint and handle the file upload process in a controller. Your task is to implement the necessary code to achieve this functi...
magicoder
You are tasked with creating a program that compares two files and generates an edit script to transform one file into the other. An edit script is a sequence of edit operations (insert, delete, and replace) that, when applied to the first file, results in the second file. Your program should take three command-line ar...
magicoder
You are given a simplified code snippet representing a maze-solving algorithm. The algorithm uses a depth-first search to navigate through a maze represented by a grid. The grid contains cells, some of which are blocked and cannot be traversed. The algorithm aims to find a path from the start cell to the end cell, avoi...
magicoder
You are tasked with creating a script to automate the build process for a set of repositories related to the XCP-NG project. The provided code snippet is a part of this automation process. Your task is to complete the script by adding the necessary commands to build each repository and handle any potential errors that ...
magicoder
You are tasked with implementing a firewall rule management system. The system should allow users to drop all existing rules or add a new rule to permit specific traffic. The rules are represented as a list of tuples, where each tuple contains the source and destination addresses, as well as the action (permit or drop)...
magicoder
You are tasked with implementing a Python package management system that can handle the installation and removal of packages. The system should support adding, removing, and listing packages, as well as checking for package dependencies. You are given a code snippet representing the structure of the package system: `...
magicoder
You are tasked with implementing a function to generate a random double within a given range. The function should take in a minimum and maximum value and return a random double within that range. You are provided with a code snippet that includes a function `getRandouble` which can be used as a starting point for your ...
magicoder
You are tasked with creating a Python class that represents a generic model in a machine learning framework. The class should have the ability to store the model's name and provide a method to set the model's name. Additionally, the class should have a method to retrieve the model's name. Create a Python class `Model`...
magicoder
You are given a string containing a series of characters. Your task is to write a function that finds the longest substring of consecutive, non-repeating characters within the given string. If there are multiple substrings with the same length, return the first one found. If there are no non-repeating substrings, retur...
magicoder
You are working with a dataset containing information about individuals, including their marital status. The dataset is represented as a pandas DataFrame `df`. Three new columns are being created based on the existing data: `evrmarry`, `divorced`, and `separated`. The code snippet provided shows how these new columns a...
magicoder
You are tasked with implementing a neural network architecture using PyTorch for a specific problem. The architecture consists of three linear layers: `fc21`, `fc22`, and `fc3`. The input dimension for `fc21` and `fc22` is 400, and the output dimension is 20. The input dimension for `fc3` is 20, and the output dimensio...
magicoder
You are tasked with creating a Python function that validates a configuration file. The configuration file is represented as a string containing key-value pairs separated by newline characters. Each key-value pair is in the format "key = value". Your function should check if a specific key-value pair exists in the conf...
magicoder