instruction_seed stringlengths 29 40.5k | source stringclasses 6
values |
|---|---|
You are tasked with implementing a simple performance testing tool for a software application. The tool will measure the time taken to execute a given function a specified number of times. Your task is to create a class `PerformanceTester` with the following specifications:
Class Name: PerformanceTester
Attributes:
-... | magicoder |
You are working on a project that involves processing output tensors from a machine learning model. The code snippet provided is part of a larger system that handles these tensors. The `model_output_tensors_` is a vector containing pointers to the model's output tensors, and `output_tensors_` is a vector of tensors tha... | magicoder |
You are tasked with creating a Python function that processes HTML content and extracts specific information using BeautifulSoup and requests libraries. The function should take a URL as input, navigate to a specific link within the page, retrieve the content of that link, and then switch to using BeautifulSoup version... | magicoder |
You are tasked with implementing a function that processes label data for a GitHub issue tracker. The function should take in an array of labels and return two arrays: one containing the available labels and another containing the selected labels.
The label data is represented as an array of objects, each with a `name... | magicoder |
You are tasked with creating a program to parse and analyze HTML code to extract specific information. Given a snippet of HTML code as shown below, your task is to write a function that identifies and counts the occurrences of different HTML elements and their attributes.
HTML Code Snippet:
```html
... | magicoder |
You are tasked with creating a program that simulates a simple file system navigation tool. Your program should take a command-line argument representing a directory name and then execute the corresponding client program to navigate the file system within that directory.
Your task is to write a program that takes the ... | magicoder |
You are tasked with creating a Python package for a new project. As part of this task, you need to set up the project's `setup.py` file, which contains metadata about the project such as author information, project license, project URL, package details, entry points for console scripts, and dependencies.
Your task is ... | magicoder |
You are tasked with creating a Python function that utilizes the Keras library to build a ConvLSTM2D model for a given set of input and output shapes. The function should also allow for specifying a dropout probability for the model.
The function signature is as follows:
```python
def create_model_ConvLSTM2D(INPUT_SHA... | magicoder |
You are tasked with implementing a memory allocator for a custom heap in Rust. The allocator should support allocation and deallocation of memory blocks using the `alloc` and `dealloc` functions. The `dealloc` function is already provided, and you need to implement the `alloc` function to complete the memory allocator.... | magicoder |
You are working on a build system for a software project. The build system organizes the project into different modules, each of which has its own directory. To clean up the build artifacts, you need to write a script that removes the build directories for specific modules.
Given the following directory structure:
```... | magicoder |
You are tasked with implementing a Python function that processes a given string containing nutritional information and calculates the total calories based on the provided macronutrient values. The nutritional information is represented in the format "name fat/protein/carbohydrates kcal", where "name" is the food item ... | magicoder |
You are tasked with implementing a middleware in a Laravel application to restrict access to the `/v1/user` endpoint based on the user's role. The application uses Laravel's routing system and middleware to handle incoming requests.
Your task is to create a middleware named `RoleMiddleware` that will check the role of... | magicoder |
You are tasked with implementing a middleware for a command dispatcher in a C# application. The middleware is responsible for handling parameter binding exceptions that may occur during command execution.
Your task is to complete the implementation of the `HandleParameterBindExceptionMiddleware` class by adding the ne... | magicoder |
You are working on a Django project for an educational platform. The project includes a model for storing theoretical content related to various courses. The code snippet provided is a part of the model definition for the "Theory" model in Django.
Your task is to create a Django model for the "Theory" model with the g... | magicoder |
You are given an array of integers `nums`. You can perform at most one operation: choose any contiguous subarray of `nums` and reverse it. You need to find the maximum possible value of the final array after performing at most one operation.
Write a function `maxValueAfterReverse(_ nums: [Int]) -> Int` to calculate th... | magicoder |
You are tasked with creating a PHP program that reads a file containing GitHub repository information and calculates the total number of stars for all repositories. The file contains lines in the following format:
```
<gh_stars>0
```
Where `<gh_stars>` is the number of stars for a GitHub repository. Each line represent... | magicoder |
You are tasked with creating a Python function that orchestrates the downloading of YouTube videos using the `youtube_dl` library. The function should take in a list of YouTube video post IDs and their corresponding links, and then use the `youtube_dl` library to download the videos.
You are provided with the followin... | magicoder |
You are tasked with implementing a simple event action factory in PHP. The factory should create instances of different event actions based on the type of event provided. Each event action should implement a common interface and be able to perform a specific action when triggered.
You are provided with the following c... | magicoder |
You are tasked with creating a program that manages different color palettes for a user interface. The program uses a `PaletteModeManager` to set the global palette mode, and based on the selected mode, it returns a corresponding result string. The available palette modes are `ProfessionalSystem`, `ProfessionalOffice20... | magicoder |
You are tasked with implementing a risk assessment system for a financial institution. The system should include a method to validate and assert the risk values provided by clients. The risk values are represented as a dictionary where the keys are risk categories and the values are the corresponding risk levels. Your ... | magicoder |
You are tasked with creating a network simulation using the ns-3 network simulator. The given code snippet is a part of the setup for a point-to-point communication link in the simulation. The `PointToPointHelper` class is used to configure the attributes of the point-to-point link. The `SetDeviceAttribute` method is u... | magicoder |
You are tasked with implementing a function to classify items based on their scores. The function `classify_items_slug` takes in a list of items and a minimum score threshold. It should return a dictionary where the keys are the items and the values are lists of items that have a score higher than the minimum threshold... | magicoder |
You are tasked with creating a TypeScript class that manages server configurations for a web application. The class should have the ability to validate and manipulate the server configuration properties.
You need to implement a `ServerConfigManager` class with the following requirements:
1. The class should have a con... | magicoder |
You are tasked with creating a Python function that generates a random mesh using the PyGmsh library. The function `rand_Amesh_gen(mesh)` takes a parameter `mesh` and should produce a random mesh based on certain conditions. The function uses random points and a convex hull to create the mesh. Your task is to complete ... | magicoder |
You are tasked with creating a Python program that calculates either the sum or the factorial of a given positive integer based on the user's choice. The program should prompt the user to input a positive integer and then select an operation (sum or factorial). Depending on the chosen operation, the program should perf... | magicoder |
You are tasked with implementing a simple server-state management system in Rust. The `State` struct is responsible for maintaining connections to clients, storing a password, and managing a memory-mapped file. Your goal is to implement a method for the `State` struct that allows clients to update the server state by p... | magicoder |
You are tasked with creating a custom exception class for a game application. The game application has a base exception class called `GameException`, and you need to create a new exception class called `InvalidPlayException` that inherits from `GameException`. The `InvalidPlayException` class should be used to handle s... | magicoder |
You are tasked with implementing a function to analyze time travel data. The time travel data is represented as a list of tuples, where each tuple contains three elements: the traveler's name (a string), the time of departure (an integer), and the time of arrival (an integer). The time of departure and arrival are repr... | magicoder |
You are tasked with implementing a training time monitoring system for a machine learning platform. The provided code snippet is a part of a Python class that manages the training process. The class has a few attributes and methods related to tracking the training time and expected number of learners. Your task is to c... | magicoder |
You are tasked with implementing a simple 3D graphics rendering program. The program should utilize OpenGL for rendering and should be capable of disabling back-face culling and setting the color of an object with transparency.
You are given the following code snippet as a starting point:
```cpp
glDisable(GL_CULL_FAC... | magicoder |
You are tasked with implementing a simple ray tracer in Rust. Your goal is to create a function that calculates the color of a ray after it intersects with a Lambertian material. The Lambertian material is a type of matte material that scatters light uniformly in all directions, making it appear dull or matte. You will... | magicoder |
You are tasked with creating a form that allows users to select a division from a dropdown menu. The division options are to be populated dynamically from a backend data source. Your task is to write a function that takes an array of division names and generates the HTML code for the dropdown menu.
Write a function `g... | magicoder |
You are given a Python code snippet that appears to be related to image processing. The code includes a commented-out section and an empty dictionary called `colores`. Your task is to create a program that populates the `colores` dictionary with pixel coordinates and their corresponding RGB color values.
You are also ... | magicoder |
You are tasked with creating a program that analyzes a given text file to determine the frequency of words and phrases. The program should read in a text file and then output the top N most frequently occurring words and phrases, along with their respective frequencies. A word is defined as a sequence of characters sep... | magicoder |
You are tasked with creating a script to automate the configuration of a VPP (Vector Packet Processing) instance. VPP is an open-source networking platform that provides fast packet processing for network functions virtualization (NFV) and software-defined networking (SDN) applications. The given code snippet demonstra... | magicoder |
You are tasked with creating a Python program to calculate the required diameter of a pipe for different pressure ratios. The program should utilize the given code snippet as a starting point and implement the necessary calculations to determine the diameter based on the specified pressure ratios.
The given code snipp... | magicoder |
You are tasked with implementing a function to parse and extract the algorithm options from a given Python code snippet. The code snippet contains comments that specify different algorithm options, and your task is to extract these options and return them as a dictionary.
You need to write a Python function called `ex... | magicoder |
You are tasked with creating a program that simulates a simple text-based game. The game involves a character navigating through a grid-based world, collecting treasures, and avoiding obstacles. The character's movements are controlled by a sequence of commands, and the game ends when all treasures are collected or the... | magicoder |
You are working on a project that involves using TensorFlow, a popular open-source machine learning library. As part of the project, you need to initialize global and local variables using TensorFlow's session (sess). The global variables are typically used for model parameters, while local variables are used for other... | magicoder |
You are tasked with implementing a custom subset sampler for a machine learning dataset. The provided code snippet includes the loading of examples and fields from pickled files using PyTorch and dill libraries. Additionally, a class named `SubsetSampler` is defined, which is intended to sample elements from a given li... | magicoder |
You are tasked with implementing a function that constructs test cases for a specific programming language. The function takes in a configuration object and generates test cases based on the provided settings. The configuration object contains test case information for different programming languages, and the function ... | magicoder |
You are tasked with implementing a decorator system for composing audio effects in Python. The provided code snippet outlines the beginning of this system, with a decorator `effect` and an empty dictionary `EFFECTS` to store the composed effects.
The `effect` decorator is used to declare composable effects. When a fun... | magicoder |
You are tasked with creating a Python package version checker. Your program should take in a list of package names and their respective versions, and then determine if the versions are up to date or if there are newer versions available. The program should compare the provided versions with the latest versions availabl... | magicoder |
You are tasked with implementing a file encoding and decoding utility in Rust. The utility will take input from the command line and perform encoding or decoding based on the provided arguments. You need to write the code for the `EncoderArgs` and `DecoderArgs` structs and implement the functionality to encode and deco... | magicoder |
You are tasked with creating a Java program that interacts with a database to retrieve and display a list of items. The program uses MyBatis, a persistence framework that maps Java methods to SQL statements. Your goal is to implement a method that retrieves a list of items from the database and returns it as a JSON res... | magicoder |
You are tasked with creating a simple chatbot program for a robot. The robot has a configuration that includes its name and language settings. The chatbot program should be able to greet users in the specified language and respond to their messages. The robot's configuration is provided as a dictionary with the followi... | magicoder |
You are working on a notification system for an application that sends out email notifications to different recipients based on certain conditions. The code snippet provided is a part of this notification system. The snippet includes exception handling and email sending logic. Your task is to understand the code and de... | magicoder |
You are tasked with creating a web application for managing students and teachers. The application uses Django, a high-level Python web framework, for its backend. You need to implement a form for adding and updating student information using Django's ModelForm.
Given the provided code snippet, you are required to com... | magicoder |
You are tasked with creating a program that generates a scatter plot of random data points and then calculates the distance between each pair of points. The program should then find the pair of points with the shortest distance and output the coordinates of these two points along with the distance between them.
Your p... | magicoder |
You are working on a Django web application that manages friend requests between users. The code snippet provided is a part of a database migration script that modifies the `friend_request` model. The migration removes the `accepted` field from the `friend_request` model and adds a new field called `status`, which repr... | magicoder |
You are tasked with implementing a Python function for segmenting ECG (electrocardiogram) signals to detect R peaks using the Pekkanen algorithm. The algorithm is based on the work of Kathirvel et al. (2001) with some modifications, primarily involving the robust estimation of the rectified signal cutoff threshold.
Yo... | magicoder |
You are tasked with implementing a function to create a definition footprint based on a given instance collection parameter and a footprint. The function should take in the instance collection parameter and the footprint as input parameters and return a boolean value indicating the success of the operation. The functio... | magicoder |
You are tasked with creating a parser for a testing framework that can extract and process specific commands and options from PHP code snippets. The parser needs to handle scenarios and features defined within the code and perform various operations based on the extracted information.
Your task is to implement a PHP p... | magicoder |
You are tasked with implementing a C++ header file for a toy compiler's abstract syntax tree (AST) declaration. The provided code snippet is the beginning of the header file, which includes the declaration of the AST declaration class.
Your task is to complete the implementation of the AST declaration class by adding ... | magicoder |
You are tasked with implementing a middleware component for an ASP.NET application. The middleware should log the incoming HTTP requests and their corresponding response status codes. You are provided with a partial implementation of the `Startup` class, which is responsible for configuring the application's middleware... | magicoder |
You are tasked with implementing a set operator class in Python that supports the SET operation. The SET operation is a fundamental operation in set theory, which involves creating a new set that contains all the elements from two given sets without any duplicates. Your task is to implement the `SetOperator` class that... | magicoder |
You are tasked with implementing a simple state management system in Python. Your goal is to create a class `State` that allows for the storage and retrieval of key-value pairs, as well as the ability to track the history of changes made to the state.
Your `State` class should have the following functionalities:
1. A ... | magicoder |
You are tasked with implementing a debugging macro system in C++ to facilitate conditional debugging output. The given code snippet provides a set of macros for conditional debugging output, which can be enabled by defining the `DEBUG` preprocessor directive. Your task is to create a set of C++ macros that replicate th... | magicoder |
You are tasked with creating a Python class to manage firewall operations for a cloud networking service. The class should include methods to create a new firewall and to display information about an existing firewall. The cloud networking service provides a Python SDK with the necessary functions to interact with its ... | magicoder |
You are tasked with implementing a simple interpreter for a custom programming language. The interpreter is responsible for executing a series of commands and handling any errors that may arise during the execution. Your task is to implement the `main` method of the interpreter, which takes no arguments and returns a `... | magicoder |
You are tasked with implementing a class that manages subscriptions to various stream topics. The class should provide methods to initialize the stream topic map and subscribe to specific topics.
You are given a partial code snippet for the class:
```java
import java.util.*;
public class StreamManager {
private Ma... | magicoder |
You are tasked with creating a program that populates a database table with student names. The given code snippet is a method within a PHP class that uses Laravel's Eloquent ORM to insert student names into a table named "marks". The placeholder "<NAME>" indicates where the student names should be inserted. Your task i... | magicoder |
You are tasked with implementing a class method for generating PDF documents using the provided code snippet as a reference. The method should create an instance of the `Html2Pdf` class with customizable options. Your task is to complete the `factory` method within the `Html2Pdf` class to accept an array of options and... | magicoder |
You are given a task to find the sum of all the multiples of 3 or 5 below a given number. Write a function that takes an integer `n` as input and returns the sum of all the multiples of 3 or 5 below `n`.
For example, if the input `n` is 10, the multiples of 3 or 5 below 10 are 3, 5, 6, and 9, and their sum is 23. If t... | magicoder |
You are tasked with implementing a custom extension for the `UIEdgeInsets` struct in Swift. The extension should add a method that calculates the area of the rectangle defined by the insets. The `UIEdgeInsets` struct represents the inset distances for views. It contains four properties: `top`, `left`, `bottom`, and `ri... | magicoder |
You are tasked with implementing a multi-threaded data processing system for a train scheduling application. The system is designed to handle incoming train data and process it concurrently using multiple threads. The provided code snippet is a part of the system's implementation.
The `train_data_queue` is a thread-sa... | magicoder |
You are tasked with creating a program that generates a set of arithmetic problems for students to solve. Each problem will consist of two randomly generated numbers and an arithmetic operation. The program should display five such problems in a formatted manner, and the student should provide the correct answer for ea... | magicoder |
You are working on a project that involves creating pages based on data retrieved from a GraphQL query. The code snippet provided is a part of a Node.js script that processes the result of a GraphQL query and creates pages based on the retrieved data. The `edges` array contains objects representing individual pages, ea... | magicoder |
You are tasked with implementing a function to process and manipulate geographical coordinates for a navigation application. The function should take a list of latitude and longitude coordinates and return the total distance traveled along the path defined by these coordinates. The distance should be calculated using t... | magicoder |
You are tasked with implementing a simple path following algorithm for a game character in a 2D environment. The character should smoothly follow a predefined path over time. You are given a `PathFollowingNode` class with a constructor and an `update` method. Your task is to complete the implementation of the `update` ... | magicoder |
You are tasked with implementing a context manager for a custom database client in Python. The context manager should handle the connection to the database and ensure proper resource management. Your task is to create a class that acts as a context manager and allows for seamless interaction with a MongoDB database usi... | magicoder |
You are tasked with implementing a JSON parsing and rendering system for a 3D graphics application. The given code snippet is part of a function responsible for updating the rendering settings based on the values parsed from a JSON configuration file. The function is responsible for updating the far clipping plane and ... | magicoder |
You are tasked with creating a program that reads a file containing a list of words and counts the frequency of each word. The program should then output the word along with its frequency in descending order of frequency.
You are given a code snippet that reads the file line by line:
```python
with open('word_list.tx... | magicoder |
You are working on a project that involves processing astronomical data using the FITS (Flexible Image Transport System) format. As part of this project, you need to create a function that generates a FITS World Coordinate System (WCS) object with specific properties.
Write a Python function `generate_fits_wcs` that t... | magicoder |
You are tasked with implementing a finite element method to solve the Darcy flow equation for a unit square medium with pressure boundary conditions. The Darcy flow equation describes the flow of a fluid through a porous medium and is commonly used in various engineering and environmental applications.
The Darcy flow ... | magicoder |
You are tasked with implementing a Python function that interacts with a Windows DLL using the `ctypes` library. The DLL contains a function called `VariantInit` which is used to initialize a VARIANT data type. The `VariantInit` function takes a pointer to a VARIANT as its argument and does not return any value. Your g... | magicoder |
You are tasked with creating a Python function that performs a specific file manipulation operation. The function should take in two parameters: `file_path` (a string representing the path to the input file) and `new_file_path` (a string representing the desired path for the output file). The function should perform th... | magicoder |
You are tasked with implementing a function to parse and process OpenGL extension constants and determine the availability of a specific extension. The given code snippet contains a partial implementation of this task. Your goal is to complete the implementation of the `glInitColorClampINGR` function and create a funct... | magicoder |
You are tasked with implementing a class that calculates the interception point of two lines in a 2D plane. The lines are defined by their slope and y-intercept. The class should provide a method to calculate the interception point and store the slope and y-intercept of each line.
You need to implement the `Line` clas... | magicoder |
You are tasked with creating a Python function that verifies the existence and type of a file on a given host. Your function should take in a `host` object and a file path, and then assert whether the file exists and is a symbolic link.
Write a Python function `verify_file` that takes two parameters:
- `host`: A host ... | magicoder |
You are tasked with implementing a custom `SetChange` class that represents a change to a set of elements. The `SetChange` class should override the `equals` method to compare two `SetChange` objects for equality based on their contents. The `equals` method should return `true` if the two `SetChange` objects have the s... | magicoder |
You are tasked with implementing a function that interacts with a web service to perform a search operation. The function will take in a start index and return the result of the search operation.
You are provided with a code snippet that sets up the parameters for the search and makes use of two helper functions: `cre... | magicoder |
You are tasked with creating a TypeScript function that takes an array of `CompileResult` objects and returns a new array of `SummarizedResult` objects. The `SummarizedResult` type is a subset of the `CompileResult` type, containing only the `filename`, `version`, and `original` properties.
The `CompileResult` interfa... | magicoder |
You are tasked with creating a Swift class that handles HTTP responses and errors. Your goal is to implement a method that parses a given JSON string and returns a specific value based on the provided key. The class `HTTPResponseHandler` has an initializer that takes a JSON string, an HTTP status code, and an optional ... | magicoder |
You are working on a social media platform where users can post on their walls. The platform uses a caching mechanism to store and retrieve posts efficiently. You need to implement a method to set posts in the cache based on certain criteria.
You are given a Python code snippet that includes a method `set_posts` withi... | magicoder |
You are given a Python function that manipulates a list and returns a modified version of the list. Your task is to reverse-engineer the function and implement a new function that achieves the same result.
The given function is as follows:
```python
def modify_list(numlist, an):
oo = []
for ii1 in range(len(a... | magicoder |
You are tasked with creating a program to parse and process a list of notifications from a web page. Each notification is represented as an HTML list item (`<li>`) containing an anchor (`<a>`) with an image (`<img>`) and text content, followed by a `<div>` containing the notification timestamp. The goal is to extract t... | magicoder |
You are tasked with creating a Python function that takes a directory path as input and performs a specific operation on the configuration files within that directory. The operation involves loading YAML files, merging their contents into a configuration object, and then returning the merged configuration.
You are pro... | magicoder |
You are tasked with creating a Python function that processes a dictionary containing file information and returns a modified version of the dictionary. The dictionary will have the following structure:
```python
file_info = {
'version': 1,
'type': f_type,
'length': os.path.getsize(file),
# Other key-v... | magicoder |
You are working on a game development project and need to implement a loot distribution system. The system should handle various actions such as giving loot to players for fishing, killing targets, and mining, as well as inserting loot at specific positions. The loot distribution is based on loot tables, and the system... | magicoder |
You are tasked with creating a Python module that interfaces with a server for handling process variables. The given code snippet is a part of the module initialization process. The module registers server and client components and adds integer constants for different log levels. Your task is to implement a function th... | magicoder |
You are tasked with creating a command-line utility for managing a simple file system. The utility should support basic file system operations such as creating, reading, updating, and deleting files. The utility will be invoked using the following command-line syntax:
```
./sfs -f <file_system_name> <operation> [opera... | magicoder |
You are tasked with creating a script that automates the process of running a Python script through PyInstaller to generate a standalone executable file. PyInstaller is a program that converts Python scripts into standalone executables, which can be run on a target machine without the need for a Python interpreter. You... | magicoder |
You are tasked with implementing a Python class that represents a geometric shape. The class should have methods to calculate the area and perimeter of the shape. Additionally, you need to create a subclass of the geometric shape class to represent a specific shape and override the area and perimeter calculation method... | magicoder |
You are tasked with implementing a function that takes a list of integers as input and returns a new list with the same integers, but with the sign reversed. If the input integer is positive, it should be changed to negative, and vice versa. If the input integer is zero, it should remain unchanged.
Your task is to imp... | magicoder |
You are given a list of integers representing the daily stock prices of a certain stock. Your task is to write a function that calculates the maximum profit that can be obtained by buying and selling the stock at most once. If it is not possible to make any profit, the function should return 0.
You need to implement t... | magicoder |
You are tasked with implementing a method to parse and handle a configuration file for a BungeeCord plugin. The configuration file contains a map of BungeeCord server names and their corresponding protocol versions. Your task is to write a method that processes this configuration and returns a map of server names and t... | magicoder |
You are tasked with creating a Python function that retrieves the list of open files for a given process using the `lsof` command and saves the output to a temporary file. However, the current implementation of the function has a potential issue where it prints an annoying message to the console if the `lsof` command i... | magicoder |
You are tasked with creating a Python function that processes a list of file paths and returns a dictionary containing the count of files with specific extensions. You are provided with a code snippet that imports certain modules and defines a variable `<gh_stars>`.
Write a function `count_file_extensions` that takes ... | magicoder |
You are tasked with implementing a function that processes a collection of images and applies a mapping function to each image. The mapping function takes an input image and returns a modified version of the image. Your goal is to implement the `applyMapping` function that takes a list of images and a mapping function ... | magicoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.