instruction_seed stringlengths 29 40.5k | source stringclasses 6
values |
|---|---|
You are tasked with creating a Python program to simulate a simple web traffic monitoring system. The program should utilize multithreading to handle multiple fake visitors and a main "guardian" thread to oversee the monitoring process.
Your task is to implement the `TrafficMonitor` class, which will have the followin... | magicoder |
You are given a code snippet that appears to set environment variables and contains a placeholder `<gh_stars>0`. Your task is to write a program that parses the code snippet and replaces the placeholder with the actual number of stars for a given GitHub repository.
Write a function or program that takes the code snip... | magicoder |
You are working on a data management system and need to create a command-line tool to migrate related items to datagatherings. The tool should also support converting notes from markdown to HTML. You are provided with a code snippet that outlines the commands and their descriptions. Your task is to implement the functi... | magicoder |
You are tasked with creating a script to automate the setup and deployment of a Node.js application using Docker. The script should handle the installation of dependencies and starting the application within a Docker container. Below are the specific requirements for the script:
1. The script should be written in Bash... | magicoder |
You are tasked with creating a Python function that validates the configuration settings for a cryptocurrency wallet. The function should check if the RPC (Remote Procedure Call) user password is empty and log an error message if it is. The configuration settings are stored in a dictionary named `config`, and the RPC u... | magicoder |
You are tasked with implementing a Discord bot command using the discord.py library. The bot should have a command called "tie_the_pie" that takes a single argument, which is a string representing a type of pie. The bot should then respond with a message that ties the mentioned pie. For example, if the user types "!tie... | magicoder |
You are tasked with implementing a simple module system in Rust for handling HTTP requests and responses. The provided code snippet is a part of the module declaration for handling HTTP communication. The `response` module is being imported and re-exported for external use.
Your task is to create a module structure th... | magicoder |
You are tasked with creating a Java method to parse and validate event data received from an API response. The method should take the API response content as input and perform the necessary checks to ensure the correctness of the event data.
You are provided with a code snippet that demonstrates the initial steps of p... | magicoder |
You are tasked with creating a service for a sports management system that retrieves player information based on their unique matricula (registration number). The system uses a `GetPlayerByMatriculaService` class to interact with a `playerRepository` to fetch player details. The `GetPlayerByMatriculaService` class take... | magicoder |
You are tasked with implementing a lazy property in Swift that initializes a view controller with a specific configuration. The view controller should be of type `SecuredViewController` and should be initialized with a child view controller `formViewController` and a style `style`.
Your task is to complete the impleme... | magicoder |
You are given a directed graph represented as a collection of nodes and edges. Each edge has an associated weight, and the graph may contain cycles. Your task is to implement a function to find the shortest path from a given source node to a target node using Dijkstra's algorithm.
The Dijkstra's algorithm is an algori... | magicoder |
You are tasked with creating a Python function that manipulates a given string representing a variable name. The function should perform the following operations:
1. Remove any leading or trailing whitespace from the variable name.
2. Convert the variable name to lowercase.
3. Replace any occurrences of a period ('.') ... | magicoder |
You are tasked with implementing a function that calculates the area of a given polygon. The polygon is represented by a sequence of vertices in a 2D plane. Each vertex is defined by its x and y coordinates. The area of a polygon can be calculated using the shoelace formula, which states that the area is half the absol... | magicoder |
You are tasked with implementing a Python class for controlling a differential drive robot. The robot has two wheels with individual control for angular velocity. The class should calculate the robot's linear and angular velocity and update its angular position based on the wheel velocities and time elapsed.
You are g... | magicoder |
You are tasked with creating a Python function that processes project uploads in a Django web application. The function should handle the upload type and perform necessary actions based on the type of the project. You are given a code snippet that imports necessary modules and defines a function `run_upload(upload)` wh... | magicoder |
You are tasked with creating a Python function that processes a list of strings representing Python code and extracts all unique methods used from the `selenium` package. The function should return a sorted list of unique method names.
The function signature should be:
```python
def extract_selenium_methods(code_snipp... | magicoder |
You are tasked with implementing a simplified version of a mesh builder class in C++. The mesh builder is responsible for constructing a mesh and submitting it to a renderer for rendering. The provided code snippet includes a `MeshBuilder` class with a `submit` method and a constructor.
The `submit` method takes a ref... | magicoder |
You are tasked with implementing a Rust function that converts a room ID or alias ID into its canonical form. In the Matrix communication protocol, room IDs and alias IDs are used to uniquely identify rooms and aliases within a Matrix homeserver. The canonical form of a room ID or alias ID is the fully qualified identi... | magicoder |
You are tasked with implementing a property management system for a Cascading Style Sheets Object Model (CSSOM) library. The system should support the retrieval and creation of property values associated with property names.
Your task is to implement two functions within the `property_manager` class: `get_property_id`... | magicoder |
You are tasked with implementing a function to calculate a health score based on various health indicators. The function takes in three parameters: HbA1c (glycated hemoglobin) level, systolic blood pressure (SBP), and total cholesterol to HDL cholesterol ratio (TCHDL). The function first cleans the input values using s... | magicoder |
You are tasked with implementing a delayed painting mechanism for a text editor component. The code snippet provided is a part of a larger codebase for a text editor application using the wxPython library. The snippet shows a class method that sets up the delayed painting functionality and binds it to the text editor c... | magicoder |
You are working on a software project that involves managing external dependencies using Bazel, a build tool. Your task is to create a Bazel rule for importing an external Maven artifact and its associated files. The code snippet provided is a partial implementation of the Bazel rule for importing the "javax.servlet-ap... | magicoder |
You are working on a healthcare data processing system that deals with blood pressure measurements. Your task is to write a Python function that calculates the standard deviation and variability of diastolic blood pressure readings from a given dataset.
You are given the following code snippet as a starting point:
``... | magicoder |
You are tasked with creating a program to compare two HashMaps in Rust. Each HashMap contains a set of locators, where a locator is represented as a key-value pair. Your task is to implement a function that checks if the two HashMaps are equal based on their locators.
You are given the following code snippet as a star... | magicoder |
You are given three grayscale images, 'man.jpg', 'j.jpg', and 't.jpg', represented as arrays of floating-point values. Each image is represented as a 2D array, where each element represents the intensity of a pixel. Your task is to write a function that performs a specific image processing operation on these images and... | magicoder |
You are tasked with implementing a custom hook in React that utilizes the Intersection Observer API to track when a specified element comes into view within the viewport. The custom hook should return a boolean value indicating whether the observed element is currently intersecting with the viewport.
Your task is to c... | magicoder |
You are working on a data visualization project and need to create a plot using Python's matplotlib library. The plot will display the rate of change of a vector `Pij_next_vector` with respect to its corresponding x-values. You are given the x-values in the `x_values` array and the vector `Pij_next_vector`. Your task i... | magicoder |
You are tasked with creating a Python function that processes a list of software dependencies and their associated patches. The function should extract and organize the information from the given input and return a structured representation of the dependencies and patches.
The input will consist of a list of strings, ... | magicoder |
You are tasked with implementing a custom `BlinkingLabel` class in Swift that creates a label with a blinking effect. The `BlinkingLabel` class should have the following properties and behavior:
- It should inherit from `UILabel`.
- It should have a `text` property to set the text of the label.
- It should have a `bli... | magicoder |
You are tasked with implementing a JavaScript class that represents a library book. The class should have the following properties and methods:
Properties:
- `title`: a string representing the title of the book
- `author`: a string representing the author of the book
- `ISBN`: a string representing the ISBN of the boo... | magicoder |
You are tasked with implementing a function to retrieve the appropriate form class for a given user and submission in a web application. The function `get_edit_form_class_for_user_and_submission(user, submission)` takes two parameters: `user` representing the user object and `submission` representing the submission obj... | magicoder |
You are tasked with implementing a task scheduling system in PHP. The system should allow the creation of tasks and their subsequent execution. Each task will be a subclass of the `Task` class and will need to implement a `run` method to define its specific behavior. Your task is to create a subclass called `Task_Daily... | magicoder |
You are tasked with implementing a custom logging system in Swift. The `Logger` class has a method `verbose` that takes in various parameters to log detailed information. Your goal is to create a function that formats and prints the log message based on the given parameters.
You need to implement a function `logVerbos... | magicoder |
You are tasked with implementing a context manager in Python that initializes a configuration directory and composes a configuration using the `compose` function. The `initialize_config_dir` context manager takes a `config_dir` argument, which specifies the directory path for the configuration. Inside the context manag... | magicoder |
You are working on a sports analytics platform that processes and analyzes various types of datasets related to different sports. The platform uses a Python package called "kloppy" to handle the domain models and data processing. The code snippet provided includes imports from the "kloppy" package, which contains domai... | magicoder |
You are tasked with creating a Python function that retrieves the SHA hash of the latest commit in a Git repository using the `gitpython` library. Your function should take the path to the local Git repository as an argument and return the SHA hash of the latest commit.
The function signature should be:
```python
def ... | magicoder |
You are tasked with implementing a function that expands a given product object by including additional information for the specified attributes. The product object contains various attributes, and the expansion involves retrieving and adding detailed information for specific attributes from an external data source.
Y... | magicoder |
You are tasked with implementing a class to represent a mathematical set operation. The class should support the union operation and provide methods for equality comparison, hashing, and string representation.
You need to create a Java class `SetUnion` that represents the union of two sets. The class should have the f... | magicoder |
You are given a graph with N nodes and M edges. Each node is labeled from 0 to N-1. The graph is represented as an adjacency list, where graph[i] contains a list of nodes that are adjacent to node i.
Your task is to write a function that returns the maximum depth of the graph starting from a given node. The depth of a... | magicoder |
You are tasked with implementing a Python class that represents a configuration container for managing access lists and their associated maximum server limits. The class should provide methods for setting and retrieving the access list name and maximum server limit.
Your task is to complete the implementation of the `... | magicoder |
You are given a list of integers representing the scores of a game. The game has a rule that a player's score is the sum of the scores of the last two turns. If there are fewer than two turns, the player's score is the sum of all the turns. Write a function `calculateTotalScore` to calculate the total score of the game... | magicoder |
You are tasked with implementing a Python class that represents a 3D mesh object. The mesh object consists of vertices and faces, and you need to create methods to manipulate and retrieve information about these components.
Your task is to complete the implementation of the `Mesh` class by adding methods to add vertic... | magicoder |
You are tasked with implementing a Python class method that formats a given string with indentation. The method should take a string and an integer count as input, where the count represents the number of times the indentation string should be repeated before each line of the input string. The indentation string is rep... | magicoder |
You are tasked with implementing a 2D array data structure that supports the following operations: create, get, and set. The create operation initializes the 2D array with a given size. The get operation retrieves the value at a specific position in the array. The set operation updates the value at a specific position ... | magicoder |
You are tasked with implementing a function that converts a Blackbird operation into an instruction. Blackbird is a quantum programming language, and the function should take a mapping of Blackbird operation names to corresponding instruction classes and a Blackbird operation dictionary as input. The function should th... | magicoder |
You are tasked with creating a custom test report generation system for a software testing framework. The system should be able to generate detailed reports for test cases executed using the TestNG testing framework. TestNG is a popular testing framework for Java that provides various annotations to mark test methods a... | magicoder |
You are tasked with creating a script to automate the testing of a machine learning library, Theano, using specific configurations and flags. The script should set the necessary environment variables and execute the testing process with the specified parameters.
Your task is to write a Bash script that accomplishes th... | magicoder |
You are tasked with implementing a function to perform a long-range scan in a space exploration game. The function `l_range_scan` takes two parameters: `the_game`, a mutable reference to the game state, and `sout`, a mutable reference to a writer for output. The function returns a `StResult` representing the success or... | magicoder |
You are tasked with implementing a binary tree data structure in Rust. The tree should have the following functionalities:
1. Insert a new node into the tree.
2. Search for a specific value in the tree.
3. Traverse the tree in-order and return the values in a vector.
4. Get the value of the node at a specific index, wh... | magicoder |
You are given a snippet of HTML code representing a product display on an e-commerce website. The code contains an anchor tag `<a>` with a class "secondary_img" and an image tag `<img>` with a class "lazy". Additionally, there is a `<span>` tag with a class "label_sale" representing a discount label.
Your task is to w... | magicoder |
You are tasked with implementing a custom formatting method for a struct representing a programming language. The struct has a field `language` of type `String`, and the custom formatting method should display the language name followed by a line of asterisks. Your task is to complete the implementation of the `fmt` me... | magicoder |
You are tasked with creating a Python program that processes a directory of files and returns a list of all the unique file extensions present in the directory. You should use the `glob` module to retrieve the list of files in the directory and then extract the file extensions from the file names.
Your program should ... | magicoder |
You are tasked with implementing a lazy loading mechanism for Python modules. Lazy loading is a design pattern where the actual loading of a resource is delayed until it is accessed for the first time. In this case, you need to create a `lazy` function that takes the name of a module as a string and returns a lazy-load... | magicoder |
You are tasked with implementing a function to process a list of blocks and identify the candidate uncles based on certain criteria. An uncle block is a valid block that is not part of the main chain but is still considered valid for certain purposes. In this problem, you need to identify the candidate uncles from a li... | magicoder |
You are tasked with implementing a command-line argument parser for a Python script. The parser should handle both positional and optional arguments and provide a user-friendly interface for the script's functionality.
You are provided with a partial code snippet for a Python script that includes a function `printErro... | magicoder |
You are tasked with implementing a class that manages update intervals for a system. The class should have the following functionality:
- Set a minimum update interval for the system.
- Get the current update interval, which should be the maximum of the minimum update interval and a default update interval.
You are pr... | magicoder |
You are working on a web application that stores user passwords in a database. The application uses the MD5 hashing algorithm to securely store and verify user passwords. However, MD5 is known to have vulnerabilities and is no longer considered secure for password hashing. Your task is to implement a more secure passwo... | magicoder |
You are working on a script to scrape data from a website and write it to an Excel spreadsheet. The script encounters exceptions during the process and handles them accordingly. Your task is to implement a function that processes the scraped data and handles exceptions based on specific conditions.
You are given the f... | magicoder |
You are tasked with creating a Python program that processes a given GitHub repository's README file and extracts information about the repository's name, owner, and the number of stars it has received. The README file is assumed to follow a specific format, as shown in the code snippet below:
```markdown
<gh_stars>0
... | magicoder |
You are tasked with implementing a data validation function for a Python class that represents a physics element. The class has three fields: `metadata`, `ode`, and `name`. The `metadata` and `ode` fields are optional and have specific metadata associated with them, while the `name` field is mandatory and has a default... | magicoder |
You are tasked with implementing a simple iOS application that simulates a button state transition. The application will have a button that can be in one of three states: Unknown, Checking, or Success. You need to create a Swift class that represents the button's state and provides methods to transition between these s... | magicoder |
You are tasked with implementing a simple alert management system for a user interface. The system should handle the display and dismissal of alerts, as well as a ticker mechanism for tracking time. The provided code snippet is a part of the implementation for this system. The `Ui::instance.alertManager.dismiss()` func... | magicoder |
You are tasked with implementing a SongViewModel class for a music application. The SongViewModel class is responsible for managing the data and behavior related to a song in the application. The class should encapsulate the song's information and provide methods for interacting with the song data.
Your task is to com... | magicoder |
You are working on a software project that involves implementing a strategy pattern for a specific module. The strategy pattern allows a family of algorithms to be defined, encapsulated, and made interchangeable. Your task is to create a Go program that demonstrates the use of the strategy pattern for a simple scenario... | magicoder |
You are tasked with implementing a reward data merge helper class in C#. The `RewardDataMergeHelper` class needs to implement the `IDeinitializable` interface. The `IDeinitializable` interface contains a single method `void Deinitialize()`, which the `RewardDataMergeHelper` class must implement. The `Deinitialize` meth... | magicoder |
You are working as a DevOps engineer for a company that uses Docker for managing its development environments. Your task is to create a script that automates the process of starting a JupyterHub service within a Docker container. The company's naming convention for the development environment is to prefix it with "tljh... | magicoder |
You are tasked with creating a Python class that represents a contact in an address book. The class should have the following attributes and methods:
Attributes:
- `name`: a string representing the name of the contact
- `email`: a string representing the email address of the contact
- `phone`: a string representing th... | magicoder |
You are tasked with implementing a simple TCP server in Rust that can handle multiple client connections concurrently. Your server should be able to receive messages from clients and broadcast those messages to all connected clients. To achieve this, you will need to use the `tokio` library for asynchronous I/O and the... | magicoder |
You are tasked with implementing a gRPC client for the Google Ads API in Python. The provided code snippet is a part of the client setup for making a unary unary call to the `MutateCampaignBidModifiers` method of the `CampaignBidModifierService`.
Your task is to complete the implementation of the gRPC client by writin... | magicoder |
You are tasked with implementing a data processing algorithm to calculate the moving average of a given dataset. The dataset is represented as a dictionary `data` containing a list of `datapoints`, and the algorithm should use the number of `periods_to_graph` specified in the `settings` dictionary to determine the numb... | magicoder |
You are tasked with designing a module system for a financial management software. The software needs to handle various aspects of financial transactions, including bills, deposits, withdrawals, money nodes, organizations, persons, products, statements of accounts, transaction entities, transactions, types, finance, an... | magicoder |
You are tasked with implementing a class for managing a game window using the Pygame library. The provided code snippet is a partial implementation of the class. Your task is to complete the class by adding methods to handle image resizing and frame rate control.
The class should have the following attributes:
- `resi... | magicoder |
You are given a JSON object representing a list of targets for a shooting game. Each target has a name and a set of properties. Your task is to write a function that takes this JSON object as input and returns a modified version of the object with the following changes:
1. Add a new property called "score" to each targ... | magicoder |
You are tasked with creating a Python program that simulates a simple user interface for a settings menu using the `win32con` library. The program should display a checkbox with the label "visible" and enable the tab stop functionality. Your task is to write a function that takes the necessary parameters and returns th... | magicoder |
You are tasked with creating a script that monitors the changes in a directory and its subdirectories. Your script should continuously check for any modifications in the specified directory and its subdirectories and print the names of the modified files. To achieve this, you need to implement a solution using bash scr... | magicoder |
You are tasked with creating a Python function that generates a user agent string for HTTP requests. The user agent string should follow a specific format and include the name and email of the user.
Write a function `generate_user_agent` that takes two parameters:
- `name` (string): The name of the user.
- `email` (st... | magicoder |
You are tasked with creating a Python unit test for a function that calculates the factorial of a given number. The function to be tested is called `calculate_factorial` and is defined in a module named `factorial_module`. Your goal is to write a unit test using the `unittest` framework to ensure that the `calculate_fa... | magicoder |
You are tasked with creating a program to manage domain applications and their associated signed marks. A domain application contains information about a domain name registration, and a signed mark is a cryptographic signature associated with a trademark.
Your task is to implement a method to reload a domain applicati... | magicoder |
You are tasked with implementing a Python function that takes an iterator and an integer `n` as input and returns a new iterator that repeats the items of the original iterator `n` times. If the original iterator is exhausted, the new iterator should continue to yield `None` indefinitely.
The function signature is:
``... | magicoder |
You are given a Python code snippet that involves the creation of a linked list and a function to convert the linked list to a Python list. Your task is to implement a function that checks whether a given linked list is a palindrome. A palindrome is a sequence that reads the same forwards and backwards.
You are provid... | magicoder |
You are given a slice of elements of a certain type and a target element type. Your task is to implement a function `convert_slice` that converts the given slice to a new slice of the target element type, following the rules below:
1. If the target element type is a different size from the current element type, and th... | magicoder |
You are tasked with creating a Python class that represents a simple data structure for storing information about a person. The class should have attributes for the person's name, age, and ID. Additionally, you need to implement a method that allows for the comparison of two instances of this class based on their ID va... | magicoder |
You are tasked with creating a Python program that processes a dataset using Latent Dirichlet Allocation (LDA) for topic modeling. The program should be able to read a dataset, perform topic modeling using the TCVB0 algorithm from the LDA module, and display the results. The program should also handle user input for sp... | magicoder |
You are tasked with creating a Java program to manage a repository of districts. Each district has a unique identifier of type `Long`. The `District` class has already been defined and contains the necessary properties and methods. Your task is to implement the `DistrictRepository` interface, which extends the `JpaRepo... | magicoder |
You are working on a storage management system that includes a class `StoragePolicy` with a method `get_os_requirements()`. The `StoragePolicy` class has a private attribute `_san_policy_map` which maps string representations of SAN policies to their corresponding integer values. The method `test_get_os_requirements()`... | magicoder |
You are tasked with implementing a class that manages serialized fields and ensures that the object is properly loaded before accessing certain attributes. Your task is to create a Python class `SerializedObject` with the following requirements:
1. The class should have a constructor `__init__` that takes a dictionary... | magicoder |
You are tasked with creating a Python program to analyze a dictionary containing URLs as keys and a list of related URLs and keywords as values. The program should implement a function that takes this dictionary as input and returns a new dictionary containing only the URLs that have a specific keyword in their related... | magicoder |
You are tasked with implementing a Python class for managing articles in a content management system. The class should have the following functionalities:
1. Initialize the article with an ID, title, content, create time, click number, and comment number.
2. Provide a method to update the click number and comment numb... | magicoder |
You are tasked with creating a Python function that simulates a simple banking system. The function should take in three parameters: the account balance, the amount to deposit, and the amount to withdraw. The function should perform the deposit and withdrawal operations and return the updated account balance.
Your tas... | magicoder |
You are tasked with testing a Python function that updates the status of nodes in a distributed system. The function takes in a batch size, a flag indicating whether the update should be all-or-nothing, and a mock Boto3 response. It then updates the nodes based on the response and returns the number of failed nodes, th... | magicoder |
You are tasked with creating a Python script that parses a configuration file and extracts specific information from it. The configuration file is in the form of a Python dictionary, containing various settings for a software package. Your goal is to extract the list of classifiers and the console script entry points f... | magicoder |
You are working on a script to set up symbolic links for various configuration files in a user's home directory. The script should create symbolic links for the `.clang-format`, `.gdbinit`, `.gitconfig`, and `.bashrc` files from a specified directory (`$DIR`) to the user's home directory. If a symbolic link already exi... | magicoder |
You are tasked with implementing a class method that determines whether a given number is a multiple of a specified attribute. You are provided with a code snippet that initializes the attribute `multiple` and retrieves its value using the `get_attribute` method. Your task is to complete the `is_multiple` method to det... | magicoder |
You are given a 2D grid of size 20001x20001, initially filled with zeros. The grid has a central point at coordinates (10000, 10000). You are also given a series of movements represented by pairs of integers (ax, ay), where ax and ay represent the change in x and y coordinates, respectively. Starting from the central p... | magicoder |
You are tasked with creating a custom form in a Python web application using the Django framework. The form should include a specific field configuration and widget customization.
You are given the following code snippet as a starting point:
```python
fields = '__all__'
widgets = {
'body': Textarea()
}
```
Your t... | magicoder |
You are tasked with creating a command-line utility that processes and stores command history from a shell session. The utility, named "mcfly," is designed to capture the text of the last command executed in the shell and save it to a database. The provided code snippet is a part of a Zsh shell function that integrates... | magicoder |
You are tasked with implementing a DialogEnhancer utility for a web application. The utility should provide methods for opening, destroying, and displaying different types of dialogs, such as success, info, error, warning, and confirmation dialogs. You need to create a JavaScript class that encapsulates this functional... | magicoder |
You are tasked with creating a Python class for a simple betting game. The class, named `BettingGame`, should have a method `validate_bet` that checks if a player's bet is valid. The method should return `False` if the player wants to exit the game or if the bet is not a positive integer. Otherwise, it should return `T... | magicoder |
You are tasked with creating a Rust function that processes a list of notifications and logs any errors encountered during the notification process using the `tracing` crate. The function should handle both successful and failed notifications and log appropriate messages for each case.
You are given the following code... | magicoder |
You are given a binary tree where each node represents a house and the value of each node represents the amount of money the house contains. You are a professional robber planning to rob houses along a street. However, you cannot rob two adjacent houses because the owner will immediately contact the police. Given the r... | magicoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.