instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with creating a Python function that monitors the status of services and triggers a handler function if the service status is not 'running'. The function `watchdog_handler` takes a `job` object as its input parameter. The `job` object contains information about the service to be monitored. The function u... | codefeedback |
You are tasked with implementing a graph data structure and its associated algorithms. The graph is represented using an adjacency list and supports directed edges. You need to implement the functionality to load the graph from a JSON file and perform edge removal operations. Additionally, you must ensure that the modi... | codefeedback |
You are tasked with creating a program that simulates a simple file system. The file system will consist of directories and files, and you need to implement basic operations such as creating directories, creating files, listing the contents of a directory, and navigating through the file system.
Your task is to implem... | codefeedback |
You are working on a project that involves integrating various components using PHP and its related libraries. As part of this project, you need to write a function that performs dependency injection using the Nette\DI\Container and Doctrine\ORM\EntityManager classes. The function should override the default behavior o... | codefeedback |
You are working on a network management system for controlling and monitoring devices in a network. The system interacts with various devices and needs to handle events related to port status changes and role requests. You are tasked with implementing a component that processes these events and takes appropriate action... | codefeedback |
You are tasked with creating a Bash script that simulates a simple file management system. Your script should be able to perform basic file operations such as creating, deleting, and listing files and directories. Additionally, it should support navigating through directories and displaying the current working director... | codefeedback |
You are tasked with creating a CSS class management system for a web development project. The system should allow for the addition, removal, and retrieval of CSS classes associated with HTML elements. Additionally, the system should support the ability to set and retrieve specific style properties for individual classe... | codefeedback |
You are tasked with implementing a job scheduling system that can handle concurrent updates to the list of jobs. The system uses a locking mechanism to ensure that only one update operation can be performed at a time. Your task is to design a class that manages the job updates and ensures thread safety.
Your class sho... | codefeedback |
You are tasked with creating a Python program that simulates a simple login system. The program should prompt the user to enter their username and password. If the entered credentials match the predefined values, the program should grant access and display a welcome message. However, if the credentials do not match, th... | codefeedback |
You are tasked with creating a custom logging system for a machine learning project using Python. The logging system should integrate with PyTorch Lightning and utilize the `hydra`, `torch`, `torchmetrics`, and `omegaconf` libraries. Additionally, the system should make use of custom utility functions and logging capab... | codefeedback |
You are tasked with implementing a function that can parse and extract information from an HTML code snippet. The HTML code snippet represents a section of a web page layout, and your function should be able to identify and extract the column layout structure from the given HTML.
Write a function `extractColumnLayout(... | codefeedback |
You are tasked with implementing a custom user model for a web application. The user model should have specific fields and methods to handle user permissions.
You are provided with a code snippet that includes a list of required fields and two methods: `__str__`, `has_perm`, and `has_module_perms`. The `__str__` metho... | codefeedback |
You are given two arrays `f` and `g` of floating-point numbers. The code snippet provided is a part of a function that performs some operations on these arrays. Your task is to complete the function by implementing the remaining part.
The function should perform the following steps:
1. Assert that the first element of... | codefeedback |
You are tasked with implementing a GUI library that allows setting a default font for all widgets added to the GUI. The library should provide a method to set the default font, and any widget added to the GUI should use this default font unless explicitly overridden. Your task is to design and implement the necessary c... | codefeedback |
You are tasked with implementing a Python function that processes a series of version control system status lines and returns a tuple containing the number of changes, the number of lines ahead, the number of lines behind, and the number of conflicts.
The function should take a list of strings as input, where each str... | codefeedback |
You are tasked with implementing a function that processes input arguments and keyword arguments, while also handling and logging any unused arguments. The function should take into account the possibility of receiving a namedtuple as the first argument and should appropriately unpack its elements. Additionally, the fu... | codefeedback |
You are tasked with implementing a Vue.js component that enforces the restriction of allowing only synchronous functions to be used as getters. In Vue.js, getters are functions used to compute derived state based on the store state. Your task is to create a custom Vue.js plugin that validates and enforces this restrict... | codefeedback |
You are tasked with implementing a function to find the length of the Longest Common Subsequence (LCS) of two given strings. The Longest Common Subsequence is the longest sequence of characters that appear in the same order in both strings, but not necessarily consecutively.
You are given the following code snippet as... | codefeedback |
You are tasked with implementing a command-line argument parser for a natural language processing (NLP) model training script. The script accepts various command-line arguments to configure the training process. Your task is to write a function that parses these arguments and returns a dictionary containing the parsed ... | codefeedback |
You are tasked with implementing a program that reads a series of binary numbers from the standard input, converts each binary number to its hexadecimal representation, and then prints the hexadecimal representation to the standard output.
Your program should take each binary number, convert it to its hexadecimal equi... | codefeedback |
You are tasked with implementing a Python function that processes a dataset containing comma-separated values and extracts specific attributes for further analysis. The dataset is stored in a file named `ppd.txt`, and each line of the file represents a record with attributes separated by commas. The function should rea... | codefeedback |
You are given a Python code snippet that processes sequencing data from DNA reads. The code iterates through a list of sequencing records called `normal`, and for each record, it checks if the record is supplementary or unmapped. If the record meets these conditions, it skips to the next record. Otherwise, it determine... | codefeedback |
You are given a class `Point` with the following attributes and methods:
```java
public class Point {
private int x_6;
private int y_6;
private int x_14;
private int y_14;
public Point(int x, int y) {
this.x_6 = x;
this.y_6 = y;
}
public void copy_from_6_to_14() {
... | codefeedback |
You are tasked with implementing a TypeScript class that extends a base API class and provides methods for registering routes and uploading images using the Express framework.
You need to create a `CommonApi` class that extends the `BaseApi` class and implements the following methods:
1. `constructor()`: The construct... | codefeedback |
You are tasked with creating a Python function that filters a list of file paths based on inclusion and exclusion patterns. The function should take in a list of file paths, an inclusion pattern, and an exclusion pattern, and return a filtered list of file paths based on these patterns.
The function signature should b... | codefeedback |
You are given a scenario where a group of members needs to be assigned to different tasks, each with a certain cost associated with it. Your task is to find the minimum cost assignment of members to tasks, ensuring that each member is assigned to exactly one task and each task is assigned to exactly one member.
You ar... | codefeedback |
You are tasked with implementing a method to generate random byte values within a specified range. The method should throw an exception if the maximum value provided is less than or equal to 0. Your task is to write a Java method that fulfills these requirements.
Write a Java method `generateRandomByteInRange(int maxV... | codefeedback |
You are tasked with creating a Python class that manages project contracts for a company. The class should include methods for creating a new project, retrieving a list of contracts associated with a project, and testing the functionality of the class.
Your task is to implement the `ProjectManager` class with the foll... | codefeedback |
You are tasked with creating an Ansible playbook to automate the setup of a secure server environment. The playbook should configure SSH and WireGuard settings based on the provided variables. Your task is to write an Ansible playbook that accomplishes this task.
The playbook should perform the following tasks:
1. Set... | codefeedback |
You are tasked with implementing a class for managing data fields and relation fields in a semantic data management system. The data fields store specific data values, while the relation fields define relationships between different classes. Your task is to create a Python class that can handle the creation and managem... | codefeedback |
You are tasked with implementing a Python class method that converts a given binary tree node into an ASDF representation. The binary tree node has attributes `offset`, `size`, and `name`. The ASDF representation is a dictionary containing the node's `offset`, `size`, and `name` if it is not `None`.
You need to comple... | codefeedback |
You are tasked with creating a Python program that simulates a simple banner printing system. The program should display a banner when executed and handle user interruptions gracefully.
Your program should consist of the following components:
1. `print_banner()`: A function that prints a banner when called. The banne... | codefeedback |
You are tasked with implementing a generic class called `MinMaxStack` that supports the following operations:
1. `push(T element)`: Adds the given element to the top of the stack.
2. `pop()`: Removes the element from the top of the stack and returns it. If the stack is empty, this operation should return null.
3. `getM... | codefeedback |
You are tasked with implementing a stack trace unification algorithm. A stack trace is a list of method calls in the order they were executed, typically used for debugging purposes. In this problem, you are given a snippet of code that is part of a larger algorithm for unifying stack traces from managed and native code... | codefeedback |
You are tasked with implementing a method to extend the functionality of a RichTextBox control in a C# application. The RichTextBoxExtensions class provides a starting point for this task. Your goal is to add a method that will highlight all occurrences of a specified word within the RichTextBox control.
You need to i... | codefeedback |
You are tasked with creating a simple text editor application using Python and PyQt. Your task is to implement a class that inherits from QMainWindow and includes a QVBoxLayout and a QTextEdit widget. The QVBoxLayout will be used to arrange the QTextEdit widget within the main window.
Your task is to complete the impl... | codefeedback |
You are tasked with implementing a function to update a todo item in a todo list application. The function should take the todo ID and a payload containing the updated title and description of the todo item. After updating the todo item, the function should perform certain assertions to ensure the correctness of the up... | codefeedback |
You are tasked with implementing a class that manages a collection of results from a series of operations. The class should provide methods to add new results, retrieve the average of all results, and reset the collection.
You are given a code snippet for inspiration, which includes a protected property `$results` to ... | codefeedback |
You are tasked with creating a class that manages the relationship between fathers and their children. The class has a method `createChild` that takes two parameters: `father` and `name`. It first checks if the `father` exists, and if not, it throws an error. If the `father` exists, it creates a new child with the give... | codefeedback |
You are given a set of 2D points represented by their x and y coordinates. Your task is to write a function to find the closest pair of points in the set. The distance between two points is calculated using the Euclidean distance formula: distance = sqrt((x2 - x1)^2 + (y2 - y1)^2).
You are provided with a code snippet... | codefeedback |
You are tasked with creating a Python function that parses a Django URL configuration file and extracts the URLs mapped to views. The URL configuration file follows the standard Django format, where URLs are mapped to views using the `urlpatterns` list.
You need to implement a function `extract_urls` that takes the UR... | codefeedback |
You are given three integers: n, a, and b. Your task is to find the sum of all integers from 1 to n (inclusive) whose digit sum falls within the range [a, b] (inclusive). The digit sum of a positive integer is the sum of its digits. For example, the digit sum of 123 is 1 + 2 + 3 = 6.
Write a function `sum_of_digit_sum... | codefeedback |
You are tasked with creating a language detection system using the langid.py library. The system should take a list of texts as input and identify the language of each text. However, the identified language should be checked against a whitelist of allowed languages before being output. If the identified language is in ... | codefeedback |
You are tasked with implementing a Python function that generates variable font names based on the given input. A variable font is a font file that contains multiple variations of a typeface, allowing for a wide range of font styles to be generated from a single file. The function should take in a list of discrete axes... | codefeedback |
You are given a log file containing a series of transactions in the format "operation amount", where the operation can be either "credit" or "debit", and the amount is an integer representing the transaction amount. Each line in the log file represents a single transaction. Your task is to process the log file and calc... | codefeedback |
You are tasked with developing a command-line tool for importing airport data from a JSON file into a database. The tool should support parallel insertion of data using multiple worker threads. Your task is to implement the logic for parsing command-line arguments and managing the insertion workers.
You need to implem... | codefeedback |
You are tasked with implementing a multi-threaded file downloader in Python. The given code snippet is a part of the class that manages the file downloading process. The class has attributes for thread number, queue size, file size, and current position in the file. Your task is to complete the implementation of the `d... | codefeedback |
You are tasked with implementing a performance metrics calculation function for a machine learning model. The function takes in the actual test data labels, predicted labels, a test dataframe, a task type, and a data type as input. Your goal is to create a function that calculates and prints performance metrics based o... | codefeedback |
You are tasked with implementing a multi-threaded video processing system. The system is designed to process a series of video objects concurrently using a queue and worker threads. Each video object is represented by a tuple containing the video object itself and a transaction ID. The worker threads will dequeue tasks... | codefeedback |
You are given the definition for a singly-linked list in Python:
```python
# Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
```
You are also given the file name and the number of stars (1-10) for a specific LeetCode problem.... | codefeedback |
You are tasked with implementing a custom EnumField class that extends the functionality of the Peewee ORM's basic types. The EnumField should allow the user to define a set of choices for a field, similar to how enums work in other programming languages. Your task is to create the EnumField class and ensure that it in... | codefeedback |
You are given a binary tree data structure and a function `sizeTree(node)` that calculates the size of the tree. The size of a tree is defined as the total number of nodes in the tree. The `sizeTree` function takes the root node of the tree as input and returns the size of the tree.
Your task is to implement a Python ... | codefeedback |
You are tasked with implementing a custom namespace and using it within a C++ program. The namespace should encapsulate a set of functions and classes related to a specific domain. Your goal is to create a namespace called `math_operations` and define a function within it to calculate the factorial of a given integer. ... | codefeedback |
You are tasked with creating a program that analyzes a given text file to count the occurrences of each unique word. Your program should ignore punctuation and consider words regardless of their case (i.e., "Hello" and "hello" should be considered the same word). Additionally, the program should output the top N most f... | codefeedback |
You are tasked with creating a Python function that generates a Directed Acyclic Graph (DAG) for a workflow management system. The function should take in a dictionary of default arguments and a list of task definitions, and return a DAG object that represents the workflow.
The default arguments dictionary contains ke... | codefeedback |
You are tasked with creating a Python function that can compress or decompress a file based on the specified compression algorithm. The function should support two compression algorithms: "gzip" and "bz2". If the compression algorithm is "gzip", the function should compress the file using the gzip algorithm. If the com... | codefeedback |
You are tasked with implementing a simple test case framework for a custom INI file parser in Swift. An INI file is a configuration file format used to store settings for software applications. Each setting is represented by a key-value pair within a section. For example:
```
[Database]
Server = localhost
Port = 3306
... | codefeedback |
You are tasked with implementing a generic asynchronous trait for a polling mechanism in Rust. The trait `Pollable` represents an asynchronous operation that can be polled for readiness. Your goal is to implement the `poll_ready` method for a specific type that implements the `Pollable` trait.
The `Pollable` trait is ... | codefeedback |
You are tasked with implementing a Python function that performs a cubic fit to a set of data points using the method of least squares. The function should take two input arrays, `x` and `y`, representing the independent and dependent variables, and return the coefficients of the cubic polynomial that best fits the dat... | codefeedback |
You are tasked with implementing a simple text editor that supports the following operations:
1. Create a new file and open it for editing.
2. Insert text at the current cursor position.
3. Delete the character at the current cursor position.
4. Move the cursor left or right within the text.
5. Save the file and exit ... | codefeedback |
You are tasked with creating a script to automate the deployment and testing of Android applications using ADB (Android Debug Bridge). The script should stop the currently running app in a specified namespace, then start a new instance of the app in the same namespace and activity.
Given the provided code snippet, cre... | codefeedback |
You are working on a machine learning project and need to implement a function to build histograms for gradient boosting decision trees. The function `build_func` takes in several parameters including `sample_indices`, `binned_feature`, `ordered_gradients`, `ordered_hessians`, and `hist`. The `sample_indices` represent... | codefeedback |
You are tasked with creating a script to organize and process files in a directory. Your script should perform the following operations:
1. Create two new directories named "toto" and "titi".
2. Place all files from the current directory into the "toto" and "titi" directories.
3. Remove the "toto" and "titi" directori... | codefeedback |
You are tasked with creating a script to automate the process of packaging and submitting a library to the Haxelib repository. Haxelib is the package manager for the Haxe programming language, and it allows developers to share and distribute libraries. The provided code snippet is a part of the automation process, but ... | codefeedback |
You are given an array `a` of `n` integers. Your task is to find the maximum sum of a subarray with the constraint that you cannot take two consecutive elements from the array.
Write a function `maxNonAdjacentSum` that takes in an array of integers `a` and its size `n` as input and returns the maximum sum of a subarra... | codefeedback |
You are tasked with implementing a Java method to determine the classification of a given floating-point number based on IEEE 754 standard. The IEEE 754 standard defines the format for representing floating-point numbers in computers, including special values such as positive infinity, negative infinity, and NaN (Not a... | codefeedback |
You are working on a script to download and update time zone files for a system. The script needs to download three big-endian files from a given base URL and store them in a temporary directory. The files to be downloaded are `metaZones.res`, `timezoneTypes.res`, and `windowsZones.res`. You need to write a function th... | codefeedback |
You are tasked with implementing a custom hook in a React application that handles the conversion of a numerical value to a binary representation. The hook should update the binary representation whenever the input value changes. Your task is to complete the implementation of the custom hook `useBinaryConverter` by fil... | codefeedback |
You are tasked with creating a reinforcement learning environment for a simple game. The game environment is represented by a Python class `venv`, which provides the following methods:
- `reset()`: Resets the environment and returns the initial observation.
- `step(action)`: Takes an action as input and returns the new... | codefeedback |
You are tasked with implementing a class to manage the actions and signals of a sequence object context. The context has four possible states represented by the enum `SequenceObjectContext`, and for each state, there is a corresponding action and signal to be managed. The actions are `doNotTranslateAction`, `translateA... | codefeedback |
You are tasked with creating a PHP class that manages a simple inventory system for an e-commerce platform. The class should handle adding, updating, and retrieving product information. Additionally, it should be able to calculate the total value of the inventory.
Your task is to implement the `Inventory` class with t... | codefeedback |
You are tasked with creating a program that processes command-line arguments to perform various mathematical operations. The program should accept the following command-line options:
- `--val`: Indicates that the subsequent arguments are to be used for value calculations.
- `-x <value>`: Specifies the value of x for t... | codefeedback |
You are tasked with implementing a class that performs validation on a given number based on certain criteria. The class should have a method that takes a number as input and returns an enum value indicating the validation result. The enum should include the following values:
- `NumberTooLarge` (value: 1) if the input ... | codefeedback |
You are tasked with creating a Python class to manage cryptocurrency trading fees for different exchanges. The class should allow for the retrieval and manipulation of fee information for various trading pairs on different exchanges.
You are provided with a code snippet that contains some initial configuration setting... | codefeedback |
You are tasked with implementing a C++ function that performs a specific type of printing based on the type of input argument. The function should have two overloads, one for lvalue references and one for rvalue references. Your task is to complete the implementation of the `print` function for both lvalue and rvalue r... | codefeedback |
You are working on a project that involves creating a simple inventory management system for a small retail store. The store has a variety of products, each with a unique identifier, name, price, and quantity in stock. Your task is to implement a Python class called `Inventory` that will manage the store's inventory.
... | codefeedback |
You are tasked with implementing a Python function that converts a given priority level from a Resilient incident to an equivalent priority level for an ICD (Incident, Change, and Defect) ticket. The Resilient incident priority levels range from 1 to 10, with 1 being the highest priority, while the ICD ticket priority ... | codefeedback |
You are tasked with implementing a class that performs encoding and decoding of messages using a specific algorithm. The class should have methods for setting the version of the algorithm, encoding a message, and decoding a message. The algorithm version determines the encoding and decoding rules. The class should also... | codefeedback |
You are given a list of integers representing the temperatures on different days. Your task is to create a function that, for each day, finds the next day (if any) when a warmer temperature will be encountered. If there is no such day, the value should be set to 0. The function should return a list of integers represen... | codefeedback |
You are tasked with implementing a function to extract and count the unique class names from an HTML snippet. The function should take an HTML string as input and return a list of unique class names found within the HTML.
For example, given the input "<a class=\"x a s\"></a>", the function should return ["x", "a", ... | codefeedback |
You are tasked with creating a GraphQL mutation for user registration using Python and Graphene library. Your goal is to implement a mutation that takes in user details as input, creates a new user object, and saves it to the database. You will need to handle any potential errors that may occur during the user creation... | codefeedback |
You are tasked with creating a Python program that simulates a simple banking system. The program should be able to handle basic banking operations such as account creation, deposit, withdrawal, and balance inquiry. The program should also be able to handle errors gracefully and provide informative error messages to th... | codefeedback |
You are tasked with implementing a function to determine the number of closing curly braces (`}`) that are not preceded by any opening curly brace (`{`) within a given string. The function should take a string as input and return the count of such closing braces.
For example, given the input string:
```
}abc}def}ghi}j... | codefeedback |
You are working on a Python project that involves managing user roles, user information, and analysis logs. The project has the following file structure:
```
project/
main.py
app/
__init__.py
role.py
user.py
logs/
__init__.py
analyses_log.py
```
The `rol... | codefeedback |
You are tasked with implementing a function that processes a given string based on a specific rule. The function should take a string as input and return a modified version of the string according to the following rule:
The input string contains a sequence of characters. If the character 'x' is encountered, it should ... | codefeedback |
You are tasked with creating a program to validate CSS code submissions using a linter. The program should be able to handle both valid and invalid CSS code and provide appropriate feedback.
Your task is to implement a Python function that takes a solution object as input and performs the following steps:
1. Update th... | codefeedback |
You are tasked with creating a program that utilizes the `PermutationImportance` class from the `eli5` library to calculate and display feature importances for a given machine learning model. The `PermutationImportance` class is used to calculate feature importances for black-box models by permuting the values of each ... | codefeedback |
You are tasked with creating a Python class that simulates a remote task manager for controlling swarm robots. The task manager will be responsible for assigning tasks to individual robots and monitoring their progress. Your task is to implement the `RemoteTaskManager` class with specific methods for task assignment an... | codefeedback |
You are tasked with implementing a simple 2D game character movement system. The game character can move left or right based on user input from either a game controller joystick or D-pad buttons. The character's movement is constrained by the game boundaries, and the character can push crates in the game world.
You ar... | codefeedback |
You are tasked with creating a program to parse and process a table of employee data from an HTML file. The HTML snippet provided represents the beginning of a table containing employee information. Each row in the table represents an employee, and the columns contain the employee's ID, name, place and date of birth, a... | codefeedback |
You are tasked with creating a Python class that manages language settings for a user interface. The class should allow for language switching and reading the current language setting from a configuration file. Your task is to implement the `LanguageManager` class with the following requirements:
1. The class should h... | codefeedback |
You are working on a radio astronomy project and need to develop a function to grid a gaintable to a screen image. The gaintable contains visibility data, and the screen represents a virtual screen above the telescope. Your task is to implement the `grid_gaintable_to_screen` function, which takes the gaintable, screen,... | codefeedback |
You are tasked with implementing a Python function that processes a CGI form and performs a specific operation based on the form data. The form data is expected to contain parameters for a minimization process, and upon processing the form, an email is sent with the results and certain temporary files are removed. Your... | codefeedback |
You are tasked with simulating the configuration of Open vSwitch (OVS) interfaces and ports using the `nmcli` command-line tool. Your goal is to create a Python program that generates the necessary `nmcli` commands based on a given set of network configurations.
You are given the following information:
- A list of net... | codefeedback |
You are tasked with implementing a Python function that generates and prints a representation of a ballot based on the given dimensions and coordinates. The ballot will be represented as a grid of stars (*) and spaces, with specific patterns based on the provided coordinates and dimensions.
You are given the following... | codefeedback |
You are tasked with creating a program that processes and manipulates a structured document represented by a series of nodes. Each node can be of different types, such as paragraphs, tags, or line breaks. Your goal is to implement a function that counts the number of paragraphs in the document and returns the total cou... | codefeedback |
You are tasked with creating a program that reads a software source file and extracts the copyright year and the name of the author. The source file is written in C++ and follows a specific format for the copyright notice. The format is as follows:
```
// Copyright (C) <YEAR> <AUTHOR>
// All rights reserved.
//
// This... | codefeedback |
You are tasked with implementing a Python function that prints a given value in a specific format. The function should take a single argument, `value`, and print it in a human-readable format. The function should handle various data types such as integers, floats, strings, lists, dictionaries, and nested structures. Ad... | codefeedback |
You are tasked with creating a type checking utility for a React component library. The utility should ensure that the props passed to the components adhere to the specified types. The code snippet provided is a part of the type checking configuration for a component called `CheckTypes`. The `Props` object contains the... | codefeedback |
You are tasked with implementing a module resolution algorithm for a JavaScript module system. The module system uses the `export` and `import` keywords to define and use modules. When an `export` statement is encountered, it makes the local binding available for use in other modules. The `export * from 'module'` synta... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.