instruction_seed stringlengths 29 40.5k | source stringclasses 6
values |
|---|---|
You are tasked with implementing a JavaScript function that simulates a progress bar with a timeout feature. The function should display a progress modal, initiate an action, and handle potential errors. Your task is to complete the implementation of the `simulateProgress` function based on the given code snippet.
The... | magicoder |
You are working for a medical imaging software company that specializes in processing DICOM (Digital Imaging and Communications in Medicine) files. Your task is to create a Python function that extracts specific information from DICOM files using the `ifree.processing` and `ifree.dicom` modules. The `ifree.processing` ... | magicoder |
You are tasked with implementing a class that manages notes for a graphical user interface (GUI) component. The class should provide methods to set a tooltip for the header, label, and note indicator, as well as a method to toggle the visibility of the note indicator. Additionally, the class should ensure that the visi... | magicoder |
You are tasked with implementing a command-line argument parser for a machine learning training script. The script should support various optimizer options, including the choice of optimizer, optimizer epsilon, and optimizer betas. Your task is to write a Python function that parses the command-line arguments and retur... | magicoder |
You are tasked with implementing a Python function that processes feature names based on certain conditions. The function should take in a list of feature names and a native estimator, and then return a modified list of feature names based on the categories of the native estimator.
The function signature should be:
``... | magicoder |
You are working on a project using Lerna, a tool for managing JavaScript projects with multiple packages. Lerna allows you to run commands across all packages in the project using the `lerna run` command. The `clean` command is a custom script defined in the `package.json` file of each package, and the `--stream` flag ... | magicoder |
You are tasked with creating a unit test for a mobile application feature that involves navigating from an image preview to a web view. The code snippet provided is the beginning of a unit test written in Swift using XCTest framework. The test is intended to verify that when the "image preview" action is called, the ap... | magicoder |
You are tasked with implementing a simple data structure to store the results from a benchmark. The data structure should be designed to hold the results of various benchmark tests, including the test name, the time taken for the test, and any additional metadata associated with the test.
Your task is to create a C++ ... | magicoder |
You are tasked with creating a Python function that simulates a simplified version of a build process. The function will take in the number of build cores, environment variables, and build directory, and then execute a "make install" command with the specified parameters. If the command fails (returns a non-zero exit s... | magicoder |
You are tasked with creating a Python function that parses a given dictionary containing project details and extracts specific information. The dictionary contains the project's homepage URL and author details. Your function should extract the homepage URL and the author's name and return them as a tuple.
Create a fun... | magicoder |
You are tasked with creating a Python function that generates an HTML page displaying a chessboard image and a title. The function should take in the file path of the chessboard image and the title to be displayed. The HTML page should include the title, the chessboard image, and the title again, all formatted appropri... | magicoder |
You are working on a web application that utilizes the Laravel framework to build dynamic data tables. The code snippet provided is part of a Laravel controller method responsible for generating a JSON response to populate a data table. The method uses the DataTables library to create the table and define its columns. ... | magicoder |
You are tasked with creating a Python program that simulates the behavior of an Eddystone beacon. Eddystone is a protocol specification that defines a Bluetooth low energy (BLE) message format for proximity beacon messages. The program should use the `EddystoneBeacon` class to broadcast a URL and then wait for a specif... | magicoder |
You are tasked with implementing a transaction fetching system for a financial application. The system should retrieve a list of transactions from a provider, starting from a specified date and time. You are provided with a code snippet that outlines the structure of the transaction fetching system. Your task is to com... | magicoder |
You are tasked with implementing a C++ program that processes a list of transactions and calculates the total amount of money spent by each user. Each transaction is represented by a tuple containing the user ID, transaction type, and transaction amount. The program should output the total amount spent by each user.
Y... | magicoder |
You are tasked with implementing a simplified version of a device driver initialization process. The provided code snippet initializes an input device driver using the function `lv.indev_drv_init()`. The `indev_drv` parameter is a structure that contains configuration settings for the input device driver. Your task is ... | magicoder |
You are tasked with implementing a function to initialize a linear programming problem using the given code snippet as a reference. The function should take in an affine LP (linear programming) problem represented by a sparse matrix and a matrix of real numbers, and initialize the problem based on the provided boolean ... | magicoder |
You are tasked with creating a custom method within the `Huesped` class in Laravel's Eloquent model. The `Huesped` class extends the `Model` class provided by the Laravel framework. Your custom method should retrieve all the guests (huespedes) who have a specific age. The method should accept the age as a parameter and... | magicoder |
You are tasked with implementing a data structure to manage the state of sectors in a storage system. The system has two states for sectors: staged and sealed. The staged state contains sector IDs and their corresponding metadata, while the sealed state only contains sector IDs and their sealed metadata.
Your task is ... | magicoder |
You are tasked with implementing a connection manager for a distributed system. The connection manager is responsible for handling connections to various remote resources. Your goal is to create a Python class that manages these connections and gracefully handles connection failures.
Your task is to implement a `Conne... | magicoder |
You are tasked with creating a custom resource handler for a web application. The resource handler should serve static resources from a specific location when requested with a particular URL pattern. Your task is to implement the necessary Java code to achieve this functionality.
You are provided with a Spring MVC con... | magicoder |
You are given a string containing a sequence of opening and closing brackets, including round brackets "()", square brackets "[]", curly braces "{}", and angle brackets "<>". Your task is to determine if the sequence of brackets is valid. A valid sequence is one where every opening bracket has a corresponding closing b... | magicoder |
You are tasked with implementing a class that calculates token weights based on the degree and frequency of tokens in a given text. The class should have a method to update the token weights for a given token.
You are given a code snippet from the class that calculates the token weights based on the degree and frequen... | magicoder |
You are given the following code snippet for a linked list data structure:
```cpp
void print_forward_recursion(node *p){
if(p == NULL){
return ; //exit condition for the recursion !!
}
cout<<p->data<<" " ;
print_forward_recursion(p->next) ;
}
void print_backward_recursion(node *p){
if(p == NULL){
return... | magicoder |
You are tasked with creating a Python function that processes a list of Google Cloud SDK release tracks and returns the count of each release track type. The release tracks are represented as strings and can be one of the following: "ALPHA", "BETA", or "GA" (General Availability). Your function should take a list of re... | magicoder |
You are given a list of strings, where each string represents a numeric digit. Your task is to write a function that takes this list of strings as input and performs two operations on it. First, it should join the strings using a hyphen (-) as the separator and print the result. Second, it should join the strings witho... | magicoder |
You are tasked with implementing a pagination system for a list of items. The provided code snippet defines an abstract class `PaginatedInput` with two properties: `take` and `skip`. The `take` property represents the number of items to retrieve, and the `skip` property represents the number of items to skip before ret... | magicoder |
You are tasked with implementing a Python function that processes a list of database migration operations and extracts specific information from it. Each operation is represented as a dictionary containing details about a database migration. The function should extract the model name, field name, and field type for eac... | magicoder |
You are tasked with implementing a class that simulates a simple key-value pair data structure. The class should provide methods for setting and retrieving the key and value, as well as for checking equality with another pair object.
You need to implement the following class:
```java
public class Pair<K, V> {
pri... | magicoder |
You are working on a web application that needs to send POST requests to different ports based on user input. Your task is to implement a function `sendPost` that takes two parameters: `$port` (an integer representing the port number) and `$data` (an array of data to be sent). The function should use the Guzzle HTTP cl... | magicoder |
You are tasked with implementing a window manager for a graphical user interface. The window manager will use a tiling layout to arrange windows on the screen. The code snippet provided contains a list of different layout options, each represented by a class instance. Your task is to create a function that selects a la... | magicoder |
You are tasked with creating a Python class to manage schedule requests for a blockchain network's primary validator. The class should handle the creation of schedule change requests and provide a method to verify the validity of the schedule change request based on certain criteria.
Your task is to implement the `Pri... | magicoder |
You are tasked with implementing a simple shell script that manipulates a variable `city`. The script contains three commands: `echo $city`, `city="nanjing"`, and `unset city`. Your goal is to predict the output of each command and explain the reasoning behind it. | magicoder |
You are tasked with implementing a feature for a web application that manages Gloomhaven campaigns. The application has a component that handles the selection and deletion of campaigns. The provided code snippet is a part of this component and includes the declaration of event emitters, a query list for element referen... | magicoder |
You are tasked with creating a Bash script that configures a user with non-root privileges, but only if a user is specified. If no user is specified, the script should not change the user. Your task is to complete the Bash script by implementing the logic to achieve this configuration.
The provided code snippet initia... | magicoder |
You are tasked with implementing a function that queries and allocates memory for EGL devices using the EGL (Embedded Graphics Library) API. The code snippet provided demonstrates part of the process, but your task is to complete the implementation of the function to handle the allocation and querying of EGL devices.
... | magicoder |
You are tasked with creating a Python class that manages configuration settings for a web application. The class should handle the retrieval and storage of configuration settings, and raise a custom exception when a requested configuration setting is not found.
Your task is to implement the `ConfigManager` class with ... | magicoder |
You are tasked with creating a Node.js service for managing domains. The service interacts with a MongoDB database using Mongoose. Your task is to implement a method for creating a new domain and checking if a domain with the same ID already exists in the database.
You are provided with a partial code snippet from the... | magicoder |
You are tasked with implementing a class that calculates the average and maximum values of two arrays. The class should have methods to compute the average and maximum values for both the "host" and "path" arrays. You are given a code snippet as inspiration:
```python
avg_host=self.avg(arr_host)
max_host=self.max(arr_... | magicoder |
You are tasked with implementing a WeightNote class in Python that represents a weight measurement along with an optional note. The class should have the following functionalities:
1. A constructor that takes in a weight (in grams) and an optional note as parameters.
2. A method to retrieve the weight.
3. A method to ... | magicoder |
You are tasked with implementing a utility function for setting authorization headers in an HTTP request. The function should support setting both Bearer token and Basic authentication headers. You are provided with a code snippet that demonstrates the structure of the functions for setting these headers.
Your task is... | magicoder |
You are tasked with creating a Python class that manages a library of forms for user authentication. The class should allow for the addition and retrieval of different forms, such as login and registration forms. Each form should be associated with a unique identifier and should be easily accessible through the class i... | magicoder |
You are tasked with implementing a function that processes MP3 audio frames. An MP3 frame typically contains audio data and metadata, and it is crucial to extract and process this information accurately. Your task is to write a function that takes a byte array representing an MP3 frame and extracts the sample rate and ... | magicoder |
You are tasked with implementing a function that calculates the size of a single-line attributed string in a given bounding box. The function should take an attributed string and a CGSize as input, and modify the CGSize to reflect the size of the attributed string when rendered on a single line within the specified bou... | magicoder |
You are tasked with implementing a simple package management system in a programming language of your choice. The system should allow users to create packages and perform basic operations on them.
You are provided with a code snippet for a `package` function, which is intended to create a new package. Your task is to ... | magicoder |
You are tasked with creating a shell script that automates the process of downloading and extracting a specific version of a software package from a given source URL. Your script should be able to handle errors and provide feedback on the download process.
Write a shell script that accomplishes the following tasks:
1.... | magicoder |
You are tasked with creating a Python class that manages user forms for a web application. The class should have a method `get_form` that takes a form class as an argument and returns an instance of that form class initialized with the current user and additional form keyword arguments.
You are provided with the follo... | magicoder |
You are tasked with implementing a function to compute the mean average precision (mAP) for object detection. The function takes in two lists of bounding boxes: predicted bounding boxes and ground truth bounding boxes. Each bounding box is represented as a tuple of four values: (x_min, y_min, x_max, y_max), where (x_mi... | magicoder |
You are tasked with creating a class for managing insurance companies in a multi-language environment. The given code snippet is a part of the class definition and contains the initialization of some properties and the construction of the class.
Your task is to implement the missing parts of the class and create a met... | magicoder |
You are tasked with creating a program that processes an image to identify and count the number of distinct objects present in the image. To achieve this, you will need to utilize image processing techniques and libraries in Python.
You are provided with a grayscale image named `face`, which is loaded using the `scipy... | magicoder |
You are tasked with creating a custom exception class in C# that extends the base `Exception` class. Your custom exception, `ConsensusOnChainTypeNotSupportedException`, should be used to handle situations where a consensus mechanism for a specific on-chain type is not supported in a blockchain node application.
Your t... | magicoder |
You are tasked with creating a Rust program that utilizes the `rhabdophis` library to perform lexical analysis and parsing on a given input file. The `rhabdophis` library provides utilities for lexical analysis, parsing, and runtime execution of code.
Your program should perform the following steps:
1. Read the conten... | magicoder |
You are tasked with implementing a function that checks whether a given string is a valid palindrome. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward, ignoring spaces, punctuation, and capitalization.
You need to write a function `isPalindrome` that take... | magicoder |
You are tasked with implementing a dynamic user interface for a mobile application. The code snippet provided is a part of the setup for the user interface. It involves adding various UI elements to a view and setting a layout constraint for one of the elements.
Your task is to write a function that calculates the pos... | magicoder |
You are given a snippet of code that processes rows of data and populates various lists and variables. Your task is to implement a function that takes the processed data and returns a specific data structure based on the given variables.
Write a function `extract_data_structure` that takes the following inputs:
- `tic... | magicoder |
You are given a Java code snippet that manipulates a doubly linked list. Your task is to implement a method to insert a new node after a specified node in the list.
The Node class is defined as follows:
```java
class Node {
Node prevNR;
Node nextNR;
boolean isInNR;
int sizeNR;
// Other methods... | magicoder |
You are working on a script to manage hyperparameters for a machine learning model. The script reads from a file containing information about different hyperparameters and their values. Each line in the file represents a hyperparameter setting in the format `<filename><hparam_str><gh_stars>`, where:
- `<filename>` is t... | magicoder |
You are tasked with creating a Rust module that handles various types of output. The module should provide functionality for formatting and displaying different types of data. Your task is to implement the necessary functions and structures to achieve this.
Your module should include the following:
1. A structure nam... | magicoder |
You are tasked with implementing a simplified version of an asynchronous file upload manager in Swift. The manager is responsible for uploading files to an internal S3 storage system and handling the result of the upload operation.
You are provided with a partial code snippet that includes a method signature for the `... | magicoder |
You are tasked with creating a Python function that processes a list of videos to detect clothing items in each frame. The function should utilize a clothing detection pipeline and be able to handle a large number of videos efficiently. The provided code snippet gives a glimpse of the existing codebase and the configur... | magicoder |
You are tasked with implementing a Python function that validates the input arguments and raises a ValueError if no arguments are provided. Your function should handle both positional and keyword arguments.
Write a function called `validate_arguments` that takes in any number of positional and keyword arguments. The f... | magicoder |
You are tasked with creating a Python class that represents an OAuth2 configuration for a web application. The class should have attributes for various configuration parameters and a method to validate the configuration. The configuration parameters include:
- `additional_info`: A JSON node containing additional inform... | magicoder |
You are tasked with creating a Bash script that processes a Genomic Transfer Format (GTF) file to extract specific information. The GTF file contains genomic annotation data, including details about gene locations, exons, and other features. Your script should take the GTF file as input and perform the following tasks:... | magicoder |
You are tasked with creating a program that checks for self-citations in a given list of academic papers. A self-citation occurs when a paper cites itself, either directly or indirectly through a chain of citations.
Your program should take as input a list of tuples, where each tuple represents a paper and its citatio... | magicoder |
You are tasked with implementing a class method that retrieves a list of keys from a configuration file section. The configuration file is represented by a `ConfigFile` class, and the method to be implemented is `get_section_keys(section: str) -> List[str]`. The `ConfigFile` class has an attribute `sections` containing... | magicoder |
You are tasked with implementing a function that simulates a simple text-based adventure game. The game will involve navigating through different rooms, encountering obstacles, and making decisions that affect the outcome of the game.
Your task is to implement the `adventureGame` function, which takes in a series of c... | magicoder |
You are given a Python code snippet that processes image data and saves images based on certain conditions. Your task is to implement a function that achieves the same functionality as the code snippet.
You are given the following information:
- `df` is a pandas DataFrame containing image data.
- `pixel_col` is the co... | magicoder |
You are tasked with creating a mock function for a baseMuzzle object in a JavaScript unit test. The baseMuzzle object has a method called `getEnemyTransform` that is being mocked using Jest, a popular JavaScript testing framework. The mock function is set up to return a value called `enemyTrans`. Your goal is to write ... | magicoder |
You are tasked with creating a Python class that represents a comment reply in a web application. The class should have attributes for the reply content, the comment it is replying to, and the user who made the reply. Additionally, you need to implement a method to generate a string representation of the comment reply ... | magicoder |
You are given a list of publications in the format "Title, Author, Journal/Conference Year," where each publication is represented as a string. Your task is to write a function that takes this list of publications as input and returns a dictionary where the keys are the unique authors and the values are lists of public... | magicoder |
You are working on a machine learning project and need to split a dataset into training and testing sets. The dataset is stored in a pandas DataFrame and contains a column named 'target' that represents the target variable. You want to ensure that the data split is reproducible, so you decide to set a random seed for t... | magicoder |
You are tasked with implementing a function to determine whether a given set of three integers forms a Pythagorean triple. A Pythagorean triple consists of three positive integers (a, b, c) such that a^2 + b^2 = c^2. Your task is to write a function `is_pythagorean_triple(a, b, c)` that takes three integers as input an... | magicoder |
You are tasked with implementing a function that filters a list of shape names based on the number of parts each shape has. The function should take in a dictionary containing the names of shapes as keys and the corresponding number of parts as values, along with minimum and maximum thresholds for the number of parts. ... | magicoder |
You are tasked with creating a program to parse and extract the supported product versions from an HTML snippet. The HTML snippet contains a list of supported versions for a specific product. Your program should be able to extract these versions and store them in a suitable data structure for further processing.
Write... | magicoder |
You are tasked with implementing a function to parse and extract information from an OpenAPI document. The OpenAPI document is represented in Rust using the given code snippet as a starting point. Your task is to write a function that takes the OpenAPI document as input and returns specific information from it.
You ar... | magicoder |
You are tasked with creating a function that calculates the distance between two geographical coordinates using the Haversine formula. The Haversine formula is used to calculate the distance between two points on the Earth given their latitude and longitude in decimal degrees. The formula is as follows:
```
a = sin²(Δ... | magicoder |
You are tasked with implementing a Python class that represents an entity with a creation timestamp and a unique ID. The class should have two properties: `created_at` and `id`. The `created_at` property should return the creation timestamp as a `datetime` object, and the `id` property should return the unique entity I... | magicoder |
You are tasked with implementing a module resolution algorithm for a JavaScript project. The project has a set of module files, each representing a component or feature. The module files are organized in a directory structure and are imported using ES6 module syntax. Your task is to write a function that resolves the i... | magicoder |
You are working on a content management system that uses an object-oriented approach to handle database queries. The system has a class `ContentQuery` with a method `_createQuery` that constructs a database query based on the provided context and bundle. Your task is to implement a new method `getUserPosts` in a subcla... | magicoder |
You are tasked with implementing a class that validates a form input for a sketching application. The class `FormSketchName` takes in a `Sketchbook` object and a `Map` representing form input data. The form contains a parameter named `FORM_PARAM_NAME`, and the `FormSketchName` class provides methods to retrieve the val... | magicoder |
You are tasked with creating a program that determines whether the current day is a weekday or not. The program should output "Yes, unfortunately today is a weekday" if it is a weekday, and "It's the weekend, yay!" if it is a Saturday or Sunday. You can assume that the program will be run on a system where the current ... | magicoder |
You are tasked with creating a Python class that can generate memes by adding captions to images. Your class should have a method `make_meme` that takes in the path of the original image, the text for the caption, the author of the meme, and an optional width for the meme. The method should return the path of the saved... | magicoder |
You are working on a pharmaceutical software system that manages the dosing of medications for clinical trials. The system includes a class `Medication` with the following abstract method and property:
```python
@abc.abstractmethod
def drop_dose(self):
...
@property
def num_dose_groups(self):
```
Your task is to... | magicoder |
You are working on a project to develop a text processing tool that extracts segments and boundaries from a given input. The segments are defined as continuous sequences of characters, and the boundaries are the points where the segments start or end. Your task is to implement a function that takes a string as input an... | magicoder |
You are given a code snippet that reads a number from the standard input, processes it, and then prints the result. Your task is to understand the code and implement the function `f` used in the code snippet. The function `f` takes an integer `n` as input and returns the factorial of `n`. You need to write the function... | magicoder |
You are tasked with implementing a simple stack data structure in Java. Your stack should support the following operations:
1. `push(int val)`: Add an element to the top of the stack.
2. `pop()`: Remove the element at the top of the stack and return its value.
3. `peek()`: Return the value of the element at the top of ... | magicoder |
You are working on a web application that uses the LESS preprocessor to compile stylesheets. The given code snippet is a part of a function that preprocesses a LESS file and caches its contents for future use. However, there seems to be a bug in the code that needs to be fixed.
The function takes in two parameters:
- ... | magicoder |
You are tasked with implementing a decorator pattern in Python to manage the access control and response formatting for a set of API endpoints. The provided code snippet lists the different types of decorators that need to be implemented. Each decorator serves a specific purpose, such as controlling access, formatting ... | magicoder |
You are tasked with implementing a simplified interrupt handling mechanism for a microcontroller. The microcontroller has an interrupt request (IRQ) line and a status register. When an interrupt is requested, the IRQ line is asserted, and the microcontroller's interrupt service routine (ISR) is called. Additionally, th... | magicoder |
You are tasked with implementing a function that processes a given array of integers and returns the count of pairs of elements that sum up to a specified target value. The function should take in the array of integers and the target value as input and return the count of such pairs.
You are given the following code s... | magicoder |
You are tasked with implementing a Django REST framework view for currency conversion. The provided code snippet shows the URL patterns for the views. The `CurrenciesViewSet` and `RatesViewSet` are responsible for listing available currencies and exchange rates, respectively. The `ConvertView` is used for converting a ... | magicoder |
You are tasked with implementing a Python function that calculates the sum of all even numbers in a given list. The function should take a list of integers as input and return the sum of all the even numbers in the list.
Function signature: `def sum_of_even_numbers(numbers: List[int]) -> int`
Example:
```
Input:
numb... | magicoder |
You are tasked with implementing a cache management system for scheduling data. The `LeaderScheduleCache` struct provides a method `retain_latest` to retain the latest schedules in the cache. The code snippet below demonstrates the usage of this method and includes assertions to validate the correctness of the retained... | magicoder |
You are tasked with creating a program that processes a file containing information about views and stars for various resources in a web application. The file contains data in the following format:
```
<filename>resources/views/yonetim/layouts/partials/sidebar.blade.php<gh_stars>0
<div class="list-group">
```
Each li... | magicoder |
You are tasked with implementing a function that converts a given string to a boolean value based on certain predefined rules. The function should take a string as input and return a boolean value according to the following rules:
- If the input string is "yes", "true", "t", or "1" (case-insensitive), the function shou... | magicoder |
You are tasked with implementing a Python program to convert a given DNA sequence into its corresponding amino acid sequence using the provided codon table. The codon table maps each codon (a sequence of three DNA nucleotides) to its corresponding amino acid. Your program should take a DNA sequence as input and output ... | magicoder |
You are tasked with creating a Python script that generates a unique email address based on the given name and version of a software project. The email address should be in the format `<name>_<version>@domain.com`. Additionally, the script should validate the email address to ensure it meets the following criteria:
- I... | magicoder |
You are given a C++ program that contains a function with a return statement. Your task is to complete the function by implementing the necessary logic to return the expected output.
The function signature is as follows:
```cpp
int calculateSum(int a, int b);
```
You need to implement the `calculateSum` function to r... | magicoder |
You are tasked with creating a Python program to perform a simple HTTP GET request to a specified URL. Your program should handle potential errors and print appropriate messages based on the outcome of the request.
Your program should consist of the following components:
1. A function `http_get_request(url_path, host)... | magicoder |
You are tasked with implementing a Java program to categorize numerical values into specific ranges based on the given code snippet. The code snippet defines a set of categories, each with a minimum and maximum value. Your task is to write a method that takes a numerical value as input and determines the category to wh... | magicoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.