instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with creating a custom hook in React that manages the state of a modal component. The modal should be able to detect if it is in fullscreen mode, handle outside clicks to close itself, and adapt its behavior for mobile devices. Additionally, the hook should provide a selector function to access the modal...
codefeedback
You are tasked with implementing a queue setup runner for a messaging system. The provided code snippet outlines the interface `IQueueSetupRunner`, which defines the structure for setting up and running a queue and its associated worker. Your task is to create a class `QueueSetupRunner` that implements the `IQueueSetu...
codefeedback
You are tasked with implementing a function to locate a dynamic library file in a macOS environment using Python. The function should utilize the `dyld_find` method to obtain the real path of the specified dynamic library file. If the `dyld_find` method raises a `ValueError`, the function should handle the exception an...
codefeedback
You are tasked with implementing an image processing algorithm to enhance the sharpness of an image. The algorithm involves applying a Gaussian blur to the original image and then subtracting the blurred image from the original to obtain a sharper version. The formula for obtaining the sharper image is given by: sharp...
codefeedback
You are tasked with implementing a rendering engine for a 3D game. The game requires support for rendering textures on cube-shaped objects using OpenGL 2.1. The code snippet provided defines a macro `GT_Rendering_TextureCube_OpenGL21` which indicates the specific rendering mode to be used for this purpose. Your task i...
codefeedback
You are working on a PHP application that utilizes the repository pattern for data access. The code snippet provided is a part of the repository implementation for managing comorbidities in the application. Your task is to implement a method within the `ComorbidadeRepositoryEloquent` class that retrieves all comorbidit...
codefeedback
You are tasked with implementing a function that calculates the dot product of two given vectors using the Accelerate framework in Swift. The Accelerate framework provides high-performance functions for mathematical operations on large datasets. The dot product of two vectors is the sum of the products of their corresp...
codefeedback
You are tasked with creating a Python function that retrieves data from multiple network devices using gNMI (gRPC Network Management Interface). The function should take a list of network device details and a gNMI path as input, and then fetch the data from each device using the gNMI client. The retrieved data should b...
codefeedback
You are tasked with creating a custom annotation processor for a Java application. The application uses a custom annotation called `StorageReference` to mark fields in classes. The `StorageReference` annotation has two boolean attributes: `mapKey` and `mapValue`, with default values of `true` and `false` respectively. ...
codefeedback
You are tasked with implementing a Python function that simulates a simplified version of the `itertools` module. The `itertools` module provides various functions for creating iterators for efficient looping. Your task is to create a function that mimics the behavior of the `itertools.cycle` function. The `itertools....
codefeedback
You are working on a bioinformatics project and need to develop a Python script to analyze molecular dynamics trajectories. The code snippet provided initializes a molecular dynamics universe using the `mda.Universe` class and calculates the FH distances using the `Calc_FH_Dists` function. However, there are some incom...
codefeedback
You are given a class `Node` representing a node in a tree structure. Each node has a pointer to its parent and a vector of children. Your task is to write a function `findMaxHeight` that takes a vector of nodes and returns the maximum height of the tree formed by these nodes. The height of a tree is defined as the le...
codefeedback
You are tasked with implementing a menu-driven program for array manipulation and sorting. The menu options allow the user to perform various operations on an array, including multiplication, sorting, and printing. The menu options are displayed as shown in the provided code snippet. Your task is to implement the func...
codefeedback
You are tasked with implementing a Python function that generates all possible subsets of a given list and then filters these subsets based on certain criteria. Your task is to complete the implementation of the function `generate_subsets` according to the following specifications: Function Signature: ```python def ge...
codefeedback
You are tasked with creating a Python class that processes and analyzes 3D point cloud data from the S3DIS dataset. The S3DIS dataset contains indoor point cloud data from various environments, such as offices, homes, and schools. Your class should be able to load the dataset, preprocess the point cloud data, and provi...
codefeedback
You are given a dictionary `data_dict` containing two keys: "sentence" and "label". The "sentence" key maps to a list of lists, where each inner list represents a sentence as a sequence of integers. The "label" key maps to a list of integers representing labels for each sentence. Your task is to write a function that t...
codefeedback
You are tasked with creating a PHP function that processes a catalog of products and returns a specific output based on certain conditions. The catalog is represented as an associative array, where each key-value pair represents a product and its corresponding details. Your function should take this catalog array as in...
codefeedback
You are tasked with implementing a function to analyze a given code snippet and identify potential issues related to variable definitions and usage. The code snippet provided is a simplified representation of a static code analysis tool. The tool processes a set of code lines and identifies variable definitions and the...
codefeedback
You are tasked with creating a program that can analyze a given HTML file and count the occurrences of specific HTML tags within it. Your program should be able to handle nested tags and should provide the count of each tag found in the file. For this problem, you are given a sample HTML file snippet as follows: ```h...
codefeedback
You are tasked with creating a script to automate the process of extracting and executing a compressed file containing a shell script. Your script should handle the decompression of the file, extraction of its contents, setting executable permissions, and executing the shell script with any provided command-line argume...
codefeedback
You are working on a baking application that interfaces with a storage system to manage bakes and their attempts. The provided code snippet is part of a class that handles interactions with the storage system. Your task is to implement a method that filters and lists bakes based on certain criteria. You need to implem...
codefeedback
You are tasked with implementing a class that simulates a simple notification system. The system should allow users to subscribe to different types of notifications and receive notifications when they are published. Each notification has a type and a message. Create a class `NotificationSystem` with the following meth...
codefeedback
You are tasked with creating a data validation system for a company's financial data. The system should enforce specific constraints on the properties of a `Company` class. The properties to be validated are `Description`, `RevenueUSD`, and `CEO`. The validation rules are as follows: 1. `Description` should have a max...
codefeedback
You are tasked with implementing a function to read and process image data from an OpenEXR file format. The given code snippet contains a partial implementation of a function to write image data to an OpenEXR file. Your task is to complete the implementation by writing a function to read image data from an OpenEXR file...
codefeedback
You are tasked with implementing a simplified version of a framebuffer attachment system for a graphics rendering API. The provided code snippet is a part of a class method that attaches a specified "Aov" (Arbitrary Output Variable) to the framebuffer. The method has the following behavior: - If the current Aov is not ...
codefeedback
You are tasked with implementing a file management system for temporary Python files within a Swift struct. The struct `HTMLSummaryRenderer` is intended to serve as a summary renderer for HTML content. It contains a private property `tempPyFile` which is initialized with the path of a temporary Python file. Your task ...
codefeedback
You are tasked with implementing a spider class that simulates the movement of a spider on a 2D plane. The spider can move in four directions: up, down, left, and right. The spider starts at the origin (0, 0) on the plane and can move a specified number of steps in each direction. The spider's position is represented b...
codefeedback
You are tasked with creating a Python function that generates an analysis index in Elasticsearch. The function should take in a list of fields and their data types, and then create an index with the specified fields in Elasticsearch. The function should handle potential errors and return the result of the index creatio...
codefeedback
You are tasked with implementing a credit card number validation function. The function should take a credit card number as input and return a boolean value indicating whether the number is valid according to the Luhn algorithm and matches the pattern of a specific credit card provider. The Luhn algorithm is used to v...
codefeedback
You are tasked with creating a function to determine if the number of nodes in a distributed system that are in the process of recovering from a failure is less than a specified quorum. The function `assert_minority_of_nodes_recovering` takes two parameters: `quorum`, an integer representing the minimum number of nodes...
codefeedback
You are tasked with creating a function that processes an order detail and generates an HTML table to display the order information. The function should take in an associative array representing the order details and return a string containing the HTML code for the table. The order details array will have the followin...
codefeedback
You are tasked with implementing a function that parses and extracts information from an SVG (Scalable Vector Graphics) code snippet. The SVG snippet represents a transformation and a group element within an SVG file. Your task is to write a function that takes the SVG snippet as input and extracts the following infor...
codefeedback
You are tasked with implementing a data structure that supports the following operations efficiently: 1. `append(color)`: Add the specified color to the end of the data structure. 2. `appendleft(color)`: Add the specified color to the beginning of the data structure. 3. `pop()`: Remove and return the last color from t...
codefeedback
You are tasked with implementing a generic repository pattern using Entity Framework Core for a help desk application. The provided code snippet is a partial implementation of the `EfCoreTagRepository` class, which is responsible for interacting with the database to perform CRUD operations on `Tag` entities. Your task...
codefeedback
You are tasked with implementing a function that processes a CSV file and returns the average value of a specified column. The CSV file contains data in the form of rows and columns, with the first row containing the column headers. The function should take the file path and the column name as input and return the aver...
codefeedback
You are tasked with implementing a simple currency conversion system in Python. Your task is to create a class `CurrencyConverter` that can convert an amount from one currency to another. The class should handle two custom exceptions: `InvalidAmountError` and `CurrencyMismatchError`. The `CurrencyConverter` class shou...
codefeedback
You are tasked with creating a program that analyzes the information provided in the code snippets related to the game Among Us. The snippets contain details about the number of vents and rooms in two different maps, MIRA HQ and Polus. Your program should extract and process this information to generate a summary repor...
codefeedback
You are tasked with simulating the behavior of a web page's JavaScript execution using a simplified model. Your goal is to implement a function that emulates the behavior of the `requestAnimationFrame` function and a function that waits for a JavaScript condition to be true. You are provided with the following code sn...
codefeedback
You are tasked with creating a Python function that interacts with a C library using the `ctypes` module. The C library provides functionality for parsing and processing Markdown text. Your goal is to implement a Python function that can utilize this C library to parse a given Markdown string and return the resulting H...
codefeedback
You are tasked with implementing a function that converts a given Swift array into a JavaScript array using the N-API library. The N-API library provides a set of functions for interacting with JavaScript objects and values from native addon modules in Node.js. You are provided with a partial code snippet that demonst...
codefeedback
You are tasked with implementing a state class for an AI system in a game server. The state class, `EquippedEntityState`, is responsible for tracking the entity currently equipped in the active hand of a game character. Your goal is to complete the implementation of the `EquippedEntityState` class by defining the neces...
codefeedback
You are tasked with implementing a custom breakpoint handler for a specific architecture. The provided code snippet is a part of a larger system that handles breakpoints in a low-level context. Your goal is to complete the implementation of the `breakpoint_program_exited` function for the ARM and AArch64 architectures....
codefeedback
You are tasked with implementing a function that processes an enum definition in a Rust program. The enum definition is represented as a code snippet, and your task is to extract information about the enum variants and their associated data. You are given a code snippet that represents a part of a Rust program: ```ru...
codefeedback
You are tasked with implementing a Python C++ extension module for a media player application. The provided code snippet is a part of the C++ code for the module. The `Py_INCREF` function is used to increment the reference count of a Python object, and `reinterpret_cast` is used to convert a pointer to one type to a po...
codefeedback
You are tasked with implementing a custom exception class for handling host-related errors in a networking application. The provided code snippet is a static method within a class that returns a new instance of the class with a specific error message. Your task is to create the custom exception class and implement the ...
codefeedback
You are tasked with implementing a class to manage a table in a graphical user interface (GUI) application. The table is represented by a 2D grid with rows and columns. The provided code snippet is a part of the initialization process for the table. The `deleteTable` is an instance of a class that represents the table ...
codefeedback
You are tasked with implementing a Python decorator that allows overriding of function parameters at call time. The decorator should take care of handling the parameter overrides and ensure that the function is called with the correct set of parameters. You are given the following code snippet as a starting point: ```...
codefeedback
You are given a Python class `LinkedList` which represents a singly linked list. The class has the following attributes and methods: - `head`: a reference to the first node in the linked list - `remove(value)`: a method that removes the first occurrence of the specified value from the linked list - `prilst`: a list tha...
codefeedback
You are tasked with implementing a file identity generator tool that can optionally quarantine duplicate files. The tool should also have the ability to generate full file hashes, prevent hashing the contents of files, hash only the container, and provide an option to silence the output. Your task is to implement the ...
codefeedback
You are tasked with creating a PHP class that represents a destination and allows for the manipulation of destination data. The class should include methods for setting and getting the destination's name, location, description, and image. Your task is to complete the `destinasi` class by adding the necessary methods t...
codefeedback
You are tasked with creating a command-line tool to generate documentation for GraphQL schemas. The tool should take a schema file as input and generate documentation in a specified output directory. The tool should also have an option to force overwrite existing documentation in the output directory. Your task is to ...
codefeedback
You are tasked with creating a Python class that simulates a command line wrapper. The class, `CommandWrapper`, is responsible for executing a command and logging its output. The class has the following attributes: - `out_log`: A string representing the file path for the standard output log. If `None`, the output will ...
codefeedback
You are tasked with implementing a function to perform a deep copy of a multi-dimensional array structure in C. The array structure is defined as follows: ```c typedef struct { size_t dims; // number of dimensions size_t *size; // array of dimension sizes void *data; // pointer to the array data } Array; `...
codefeedback
You are tasked with implementing a custom exception class and handling it within a given code snippet. The code snippet provided is a part of a constructor in a C# class. The `_commitStorage` variable is being assigned a value, which is checked for null using the null-coalescing operator (`??`). If the value is null, a...
codefeedback
You are tasked with implementing a simple JWT (JSON Web Token) authentication system in Python. Your goal is to create three functions: `obtain_jwt_token`, `refresh_jwt_token`, and `verify_jwt_token`, which will handle the generation, refreshing, and verification of JWT tokens, respectively. The `obtain_jwt_token` fun...
codefeedback
You are tasked with implementing a simplified version of a button handling system in a Swift application. The provided code snippet is part of a class that manages button interactions. The `buttonPressed` method is called when a button is pressed, and it is overridden by a subclass to define specific behavior for each ...
codefeedback
You are tasked with creating a Python decorator that adds functionality to a web application built using the Django framework. The decorator should check if a user is authenticated before allowing access to a specific view function. If the user is authenticated, the view function should be executed as normal. If the us...
codefeedback
You are tasked with implementing a trait for a client in a Rust application. The trait, `ClientBase`, is defined in the `mitrid_core` and `crypto` modules and has several associated types and methods. Your goal is to create a struct `Client` that implements this trait and satisfies all its requirements. The `ClientBas...
codefeedback
You are tasked with implementing a validation function in TypeScript that composes multiple validation functions into a single validation function. The provided code snippet offers a starting point for the `composeValidations` function, which takes an arbitrary number of validation functions as arguments and returns a ...
codefeedback
You are tasked with implementing a Flask route that authorizes access to a web application based on the user's GitHub credentials. The provided code snippet is a part of a Flask application and includes a Blueprint for handling authorization. The Blueprint is named "auth_protected" and is intended to be used for protec...
codefeedback
You are tasked with creating a Python program that simulates a countdown with a twist. The program should display a countdown from 10 to 1, with a delay of 1 second between each count. However, instead of displaying the numbers in a regular sequence, the program should alternate between displaying the numbers in ascend...
codefeedback
You are tasked with creating a Python function that connects to a database and imports data from it. Your function should handle potential connection issues by implementing a retry mechanism with a specified delay between retries. Write a function `import_data_from_db` that takes the following parameters: - `db_con`: ...
codefeedback
You are tasked with creating a Python function that converts a multi-page PDF into a series of images. The function should take the file path of the PDF as input and save each page of the PDF as a separate JPEG image. You should use the `convert_from_path` function from the `pdf2image` library to achieve this. The fun...
codefeedback
You are tasked with creating a Python program to automate the process of formatting an Excel spreadsheet. Your program should read data from a given input file, adjust the column widths based on the maximum length of the data in each column, and then save the formatted spreadsheet to a specified output file. Your prog...
codefeedback
You are tasked with implementing a custom authentication guard for a Node.js application using NestJS. The application uses a local strategy for authentication, and the guard needs to extend the `AuthGuard` class provided by NestJS. Your goal is to create a custom `Guard` class that extends the `AuthGuard` and triggers...
codefeedback
You are tasked with creating a Python class that manages user information using the Bonita platform. The class should be able to initialize a Bonita client and perform various user management operations. Your task is to complete the implementation of the `User` class by adding methods for user creation, retrieval, upda...
codefeedback
You are tasked with implementing a function that extracts the session name from a given string. The session name is defined as the substring between the first occurrence of the characters "session_" and the subsequent occurrence of the characters "_id". If the session name cannot be inferred from the input string, the ...
codefeedback
You are tasked with implementing a custom dataset class for a computer vision project. The dataset will contain images that are semi-aligned, meaning that each image is a pair of two sub-images, where one sub-image is a cropped portion of the other. Your goal is to create a custom dataset class that loads and preproces...
codefeedback
You are given a partial implementation of a unit testing framework in C++. The provided code snippet is part of the main function that runs the test cases and reports the results. Your task is to complete the implementation of the `UnitTests` class and the `run_test_case` function to enable the framework to execute and...
codefeedback
You are tasked with implementing a class `MatrixSolver` that can perform certain operations on matrices. The class should have a method `get(row, col)` that returns the value at the specified row and column of the matrix. Additionally, the class should support the creation of two instances, `ms1` and `ms2`, and the cod...
codefeedback
You are tasked with implementing a simplified version of the Arduino Serial library in C. The Arduino Serial library provides a way for Arduino boards to communicate with the computer via a serial connection. Your task is to create a C program that simulates the basic functionality of this library for sending and recei...
codefeedback
You are tasked with implementing a simplified version of a request store using MobX, a popular state management library for React applications. The request store is responsible for managing asynchronous requests and their associated state. Your goal is to create a class that represents the request store and its functio...
codefeedback
You are tasked with implementing a thread-safe queue using a mutex and condition variable in C++. The queue should support the following operations: 1. `push`: Add an element to the queue. 2. `pop`: Remove and return the front element from the queue. If the queue is empty, block until an element is available. 3. `empty...
codefeedback
You are tasked with creating a program that simulates a simple access control system for a command-line interface. The system will use a set of checks to allow or deny a user's access to a command. Your goal is to implement the logic for the access control system using Rust. You are given the following code snippet as...
codefeedback
You are given a list of positive integers representing the lengths of different files. Your task is to merge these files into a single file. The cost of merging two files is equal to the sum of their lengths. You need to determine the minimum cost of merging all the files into a single file. For example, given the lis...
codefeedback
You are tasked with creating a Python function that merges a given configuration dictionary with a set of default values. The default values are provided in a nested dictionary structure, and the function should recursively merge the default values with the given configuration, prioritizing the values in the configurat...
codefeedback
You are tasked with creating a filtering system for a product catalog. The provided code snippet is a part of a Django web application that handles the filtering of products based on user input. The `advanced_filter` function takes a request object and filters the products based on the user's specified criteria. The fu...
codefeedback
You are tasked with creating a program that simulates a simple text decryption tool. The program should take an encrypted text as input and decrypt it using a specific algorithm. The decryption algorithm involves reversing the characters of the input text and displaying the decrypted text in a GUI window. You are prov...
codefeedback
You are tasked with creating a Django migration for a new model that includes a custom field. The custom field should be a subclass of `django.db.models.Field` and should store a specific type of data. Your task is to implement the custom field and use it in the migration to create the new model. Create a custom field...
codefeedback
You are tasked with creating a Bash script that takes two input numbers from the user and calculates their product. However, the given code snippet contains some errors that need to be fixed before the script can function properly. Your task is to identify and correct these errors to ensure the script runs as intended....
codefeedback
You are tasked with creating a program that reads and processes data from two files: "config/labels.txt" and "config/train.txt". The "labels.txt" file contains a list of labels, with each label on a separate line. The "train.txt" file contains a list of image file paths, with each path on a separate line. Your program ...
codefeedback
You are tasked with implementing a function that takes a list of strings as input and returns the frequency of each word in the list. A word is defined as a sequence of non-whitespace characters. The function should ignore case sensitivity and consider words with different cases as the same word. The output should be a...
codefeedback
You are tasked with creating a Python function that resizes an input image using the OpenCV library and then displays the resized image in a window. Your function should take the input image file path, target width, and target height as parameters, and it should use the INTER_AREA interpolation method for resizing. The...
codefeedback
You are given a string representing a series of coordinates in the format "x1-y1,x2-y2,x3-y3...". Each coordinate pair represents a point on a 2D plane. Your task is to write a function to calculate the total distance traveled when moving from the first point to the last point in the given order. The distance between ...
codefeedback
You are working on a computer graphics project that involves processing RGB point clouds for direct rendering. The code snippet provided is a part of a larger program that processes RGB point clouds and performs rasterization and blending for visualization. Your task is to implement a function that takes in RGB point c...
codefeedback
You are tasked with implementing a chatbot system that processes user input and responds accordingly. The chatbot has a method `addChat` to add messages to the chat interface. It also has a method `processInput` that takes user input and processes it. If the input matches a recognized command, the chatbot should perfor...
codefeedback
You are tasked with implementing a function that processes mentions in a given text. A mention is a reference to a user or entity, typically denoted by a username preceded by the "@" symbol. The function should handle the removal of mentions based on certain conditions. You are given a Swift code snippet that demonstr...
codefeedback
You are tasked with implementing a Python decorator that disables tracking for specific views in a web application. The decorator should be able to wrap any view function and prevent it from being tracked for analytics or other monitoring purposes. You need to create a decorator function `do_not_track` that takes a si...
codefeedback
You are given a list of integers representing the parameters `n`, `h`, `a`, `b`, and `k`, followed by `k` lines of input. Each line contains four integers: `ta`, `fa`, `tb`, and `fb`. The function `f(l)` is defined to calculate the minimum time required to move from point `ta` to `tb` while picking up a package at poin...
codefeedback
You are tasked with implementing a priority queue system for a messaging application. The application has a `Task` class that represents a task to be processed, and it has a `queue` property that returns the priority queue for processing tasks. The priority queue is managed by a bot and is represented by the `coda` att...
codefeedback
You are tasked with implementing a matrix class in C++ to perform various operations. The matrix class should support addition, subtraction, and multiplication of matrices. Additionally, the class should provide a method to transpose the matrix. You are given a code snippet that initializes an instance of the matrix cl...
codefeedback
You are tasked with creating a script to monitor the CPU usage of a Linux system and store the information in a file. The script should check if the system is running on a Linux platform and then run the `top` command with the `-H` option to display individual threads. The output should be redirected to a file named "t...
codefeedback
You are tasked with implementing a function to determine the result transition for a given event and operation in a boolean operation system. The result transition can be one of the following: `In`, `Out`, or `None`. Additionally, you need to handle the debugging feature by printing the result transition if the `debug-...
codefeedback
You are tasked with implementing a simple radio station management system in Python. The system should allow users to start and stop the radio station, as well as display the station name and its corresponding URL. You are provided with a partial code snippet that demonstrates the usage of the radio station management ...
codefeedback
You are tasked with creating a Python program that simulates a simple counting mechanism using the ROS (Robot Operating System) framework. The provided code snippet initializes a ROS node named 'count' and publishes a sequence of incremented numbers to a topic named 'count_up' at a rate of 20 Hz. Your task is to comple...
codefeedback
You are tasked with creating a custom data collection system for a company's network infrastructure. The system should be able to collect various metrics from different network devices and store them for analysis. To achieve this, you need to implement a Python module that utilizes the `diamond.collector` library to co...
codefeedback
You are tasked with implementing a dependency injection container for a DNS management system. The container is configured using the following code snippet: ```csharp .AddTransient<IDnsNameServerProvider, LinuxDnsNameServerProvider>() .AddTransient(CreateDnsResolverWrapper) .AddTransient<IEnvironmentVariables, Environ...
codefeedback
You are tasked with implementing a custom output stream class that computes an Adler32 CRC checksum for the data being written to it and passes the data along to an underlying output stream. The Adler-32 is a checksum algorithm which was invented by Mark Adler in 1995, and is a modification of the Fletcher checksum. It...
codefeedback
You are tasked with implementing a role-based access control system for a Kubernetes cluster. The system should support self-subject rules review and subject access review, which are essential for determining the permissions a user has within the cluster. You are provided with the following code snippet, which outline...
codefeedback
You are given a code snippet that uses a functional programming approach. The code snippet is written in a hypothetical language that supports functional programming constructs. The snippet uses a `from` function to create a sequence from a given array `{ 1, 2, 1, 1 }`, then applies a `drop_while` operation to remove e...
codefeedback