instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with creating a memoized selector function in a Redux application using the `reselect` library. The `reselect` library provides a `createSelector` function that allows for efficient memoization of selectors, preventing unnecessary recalculations when the Redux state changes.
Your task is to write a memo... | codefeedback |
You are tasked with creating a Rust macro for generating a list of items. The macro should take a list of item names and generate code to import and use these items in a Rust module. The macro should also ensure that the items are only accessible within the module where the macro is used.
Your task is to implement the... | codefeedback |
You are tasked with implementing a function that processes a list of `raw_matches` and constructs a list of dictionary objects based on certain conditions. Each `raw_match` is an object with attributes `external_references` and `kill_chain_phases`. The function should iterate through each `raw_match` and extract releva... | codefeedback |
You are tasked with implementing a class that simulates a simple banking system. The class should have the ability to create accounts, deposit funds, withdraw funds, and check the balance of an account. Additionally, the class should enforce certain security measures to protect the account balances.
Your task is to im... | codefeedback |
You are tasked with designing a messaging system for a financial data application. The system needs to handle various types of messages, including reactor channel events, default messages, RDM login messages, RDM directory messages, and RDM dictionary messages. To achieve this, you need to create an interface in Java t... | codefeedback |
You are tasked with implementing a class method that checks whether a given set of tags matches the tags associated with a record. The record and the class have a set of tags associated with them. The method should return a boolean value indicating whether the tags match.
You are given the following code snippet as a ... | codefeedback |
You are tasked with creating a program to control an RGB LED connected to a microcontroller via a serial port. The microcontroller expects a specific serial command format to set the color and brightness of the LED. The command should be in the format "red,green,blue,lower,higher\n" where red, green, and blue are integ... | codefeedback |
You are given a date in the format "YYYY/MM/DD". Your task is to write a function to determine the day of the week for that date. The function should take the date as input and return the corresponding day of the week as a string.
For example, given the date "2021/3/31", the function should return "Wednesday".
You ca... | codefeedback |
You are tasked with implementing a custom data structure called `MaybeOwned` in Rust. The `MaybeOwned` data structure can hold either a borrowed reference or an owned value. Your task is to implement the `get_value` method for the `MaybeOwned` enum, which returns the inner value regardless of whether it is borrowed or ... | codefeedback |
You are tasked with implementing a custom hyperparameter search algorithm for a support vector classifier (SVC) using the Hyperband algorithm. The Hyperband algorithm is a resource allocation method that balances the number of configurations evaluated and the resources allocated to each configuration. In this problem, ... | codefeedback |
You are tasked with implementing a function to process a data structure representing joint positions from a motion capture system. The data structure contains an array of 3D vectors representing the positions of 21 joints in a human body, along with a confidence value for the captured data.
You need to implement a met... | codefeedback |
You are tasked with creating a function that will parse a given code snippet and extract the number of GitHub stars for a repository and the name of the search icon file. The code snippet is written in JavaScript and may contain other unrelated code. The GitHub stars count is denoted by the placeholder `<gh_stars>` and... | codefeedback |
You are given a Python code snippet that simulates the generation of a file containing pairs of source and destination addresses. The addresses are represented by indices and offsets into an array of pages. Your task is to write a program to process this file and perform specific operations on the addresses.
The code ... | codefeedback |
You are tasked with creating a Python function that processes configuration files for software packages and starts the ones marked for autostart. The configuration files are in YAML format and are stored in a specific directory. Your function should read each configuration file, check if the package is set to autostart... | codefeedback |
You are tasked with creating a C++ program that interfaces with two different devices: a CMPS14 compass module over I2C and an Arduino for motor control over serial communication. The program should read data from the compass module and send control commands to the Arduino for motor control. The program should also han... | codefeedback |
You are tasked with implementing a command-line argument parser for a tool called `torshammer.py`, which is used for launching a DDoS attack through Tor. The tool has several command-line options that need to be parsed and processed. Your task is to write a Python function that takes a list of command-line arguments an... | codefeedback |
You are tasked with creating a Python class to perform structural analysis on a beam using the finite element method. The given code snippet is part of a larger program that uses the created class to analyze a beam's behavior under various loads and boundary conditions.
Your task is to implement the `BeamAnalysis` cla... | codefeedback |
You are tasked with implementing a custom serializer and deserializer for a Python application that handles Jaeger tracing metadata propagation. The provided code snippet includes a method `deserialize_context` and a class `ProfilerRequestContextSerializer` that needs to be extended to support the serialization and des... | codefeedback |
You are tasked with creating a function that calculates the total area of a given grid layout. The grid layout is represented as a string, where each character represents a cell in the grid. The grid is defined by the number of rows and columns, and each character in the string represents the type of cell in the corres... | codefeedback |
You are tasked with implementing a simple microservice that reads a configuration file and starts a server based on the configuration. The configuration file is in JSON format and contains the following fields:
- `address`: a string representing the IP address and port number to bind the server to (e.g., "127.0.0.1:808... | codefeedback |
You are tasked with creating a Python function that calculates the duration between two given times. The function should take two parameters, `start_time` and `end_time`, both in the format "HH:MM" (24-hour format). The function should return a dictionary containing the duration in hours and minutes.
Create a function... | codefeedback |
You are tasked with creating a function that analyzes the Angular module configuration and returns the list of imported modules. The Angular module configuration is represented using the `@NgModule` decorator in TypeScript. The function should parse the module configuration and extract the list of imported modules.
Th... | codefeedback |
You are tasked with implementing a Python class for natural language processing. The class, named `InferenceEngine`, is responsible for processing input data and running inference to predict tags and part-of-speech (POS) for the given input. The class has several methods that need to be implemented.
The `InferenceEngi... | codefeedback |
You are tasked with implementing a settings form for a desktop application. The form should allow users to input and save various settings for the application. The form should include text boxes, checkboxes, and buttons for saving and resetting the settings.
Your task is to create a class that represents the settings... | codefeedback |
You are given a string `num` representing a non-negative integer. Additionally, you are given an integer `target`. Your task is to write a function `addOperators` that takes the string `num` and the integer `target` as input and returns all possible expressions that evaluate to the `target`. The expressions should be f... | codefeedback |
You are tasked with creating a Python script that automatically generates a version number for a software project. The version number follows the format "major.minor.patch[.dev]", where "major", "minor", and "patch" are integers, and "dev" is an optional development tag. The script should be able to increment the versi... | codefeedback |
You are given a code snippet that appears to contain a comment in a non-English language. Your task is to decipher the comment and translate it into English. The comment is written in a language that uses accented characters and may require special handling for proper translation.
Write a program that takes the given ... | codefeedback |
You are tasked with implementing a custom sequence set data structure in Java. The sequence set should support adding elements, removing elements, and checking if a given element is present in the set. Additionally, the sequence set should maintain the order of elements as they are added.
Your task is to implement the... | codefeedback |
You are tasked with creating a Python function that processes a list of module objects representing components on a printed circuit board (PCB). Each module object contains information about the component's position, orientation, description, layer, and footprint. Your function should filter out modules based on certai... | codefeedback |
You are tasked with implementing the A* algorithm to find the shortest path in a weighted graph. The A* algorithm is an informed search algorithm that uses heuristics to efficiently find the shortest path between two nodes in a graph.
You are given a graph represented as an adjacency list and two nodes: the start node... | codefeedback |
You are tasked with creating a class to manage student groups in a school system. The class should have the ability to store information about the group, such as the ID of the group leader, the class name, the type of class, and timestamps for creation, update, and deletion.
Your task is to create a PHP class called `... | codefeedback |
You are tasked with creating a program to calculate the pay for employees based on their hours worked and hourly rate. The program should prompt the user to input the number of hours worked and the hourly rate, and then calculate the total pay. The pay should be calculated based on the following rules:
- If the number ... | codefeedback |
You are working on a project to implement a factor graph representation for a probabilistic graphical model. In this project, you need to create a function that constructs factor graph edges and factor map entries based on given input data. The factor graph represents the relationships between variables and factors in ... | codefeedback |
You are tasked with implementing a generic function in Rust that reads data from a given source and performs an operation based on the read data. The function signature is as follows:
```rust
pub fn read<W>(&mut self, bytes: W, offset: libc::off_t, event_queue: &mut EventQueue) -> SyscallResult
where W: std::io::Write... | codefeedback |
You are tasked with implementing a simple point-of-sale system for a retail store. The system should be able to display receipts on various output devices. You are given a code snippet that demonstrates the usage of a `display` method on a `device` object. Your task is to create a class representing the `device` and im... | codefeedback |
You are tasked with implementing a view management system for a graphical user interface (GUI) library. The system should support the creation, retrieval, and deletion of views, as well as the ability to check if a view exists. Each view is identified by a unique integer ID. You need to implement the following operatio... | codefeedback |
You are tasked with implementing a higher-order component (HOC) in a React application. The provided code snippet demonstrates the usage of the `BindComponentProps` HOC to bind the state and dispatch functions to the `Card` component. Your goal is to create a similar HOC that binds the state and dispatch functions to a... | codefeedback |
You are tasked with implementing a data loading function for a machine learning project. The function is responsible for loading training and testing data from a specified source and returning the data in the form of tuples. Your task is to complete the implementation of the data loading function based on the provided ... | codefeedback |
You are tasked with creating a function that simulates the behavior of a simplified version of the AutoMapper library. The function should take in two parameters: a source object and a destination class, and return a new instance of the destination class populated with the corresponding properties from the source objec... | codefeedback |
You are tasked with implementing a function that parses a given HTML-like code snippet and extracts all the class names from the `className` attributes within the `span` tags. The function should return a list of unique class names found in the code snippet.
Write a function `extractClassNames(htmlCode: string): strin... | codefeedback |
You are working on a project that involves optimizing a machine learning model using PyTorch and performing calculations on the trained variables. As part of this project, you need to implement a function that calculates the posterior values based on the optimized trained variances. The posterior is assumed to be Gauss... | codefeedback |
You are tasked with implementing a job status management system for a distributed computing environment. The system should support various job lifecycle states and allow for custom messages to be associated with state transitions. Your task is to create a class that encapsulates the job status management functionality ... | codefeedback |
You are tasked with implementing a class that manages the display of video content based on various criteria. The class has several properties that control the behavior of the video display. Your task is to create a method within the class that filters and returns a specified number of videos based on the given criteri... | codefeedback |
You are tasked with implementing a secure password generator using the provided code snippet as a starting point. The `GetBytes` method uses a `RandomNumberGenerator` to generate a byte array of specified length, which can be used to create strong, cryptographically secure passwords.
Your task is to create a password ... | codefeedback |
You are tasked with implementing a custom input function for a machine learning prediction model. The model takes in a single image as input and produces a prediction based on that image. The code snippet provided is a part of a Python script for this task. The script first checks the command-line arguments and exits w... | codefeedback |
You are tasked with implementing a Tiramisu code that performs matrix multiplication. Tiramisu is a domain-specific language for expressing fast and portable data parallel computations. The code snippet provided includes the necessary Tiramisu headers and libraries.
Your task is to write a Tiramisu program that multip... | codefeedback |
You are tasked with creating a Python function that simulates a simple game of dice rolling. The function should take in the number of dice to roll and the number of times to roll them. It should then simulate the rolling of the specified number of dice the specified number of times and return the frequency of each pos... | codefeedback |
You are given a Python function `maxlinedev(x, y)` that takes in two arrays `x` and `y` representing the x and y coordinates of points on a 2D plane. The function is intended to calculate the maximum deviation of a contour formed by these points and return the maximum deviation and the index of the point with the maxim... | codefeedback |
You are tasked with creating a Python program to process a CSV file containing information about gene regulatory binding sites. The program should read in the CSV file, perform some data manipulation, and then generate output figures based on the processed data.
The CSV file, named 'RegulonDB_20170630_BindingSiteSet.c... | codefeedback |
You are tasked with creating a function that generates a report for a user based on their urbanism and neighbors' properties. The function should retrieve the necessary data and format it for display in a view. The provided code snippet is a part of a Laravel application and contains some relevant context for the probl... | codefeedback |
You are working on a project that involves implementing a graph-based algorithm. As part of this project, you need to create a method to update tabu edges in a graph. Tabu edges are pairs of vertices that are temporarily forbidden from being included in a solution. Your task is to implement a function that takes a list... | codefeedback |
You are tasked with creating a custom module for a NestJS application that integrates with an AMQP (Advanced Message Queuing Protocol) system. Your goal is to implement the necessary functionality to establish a connection to an AMQP server and manage its lifecycle within the NestJS application.
Your task is to comple... | codefeedback |
You are tasked with implementing a Python class for image deblurring using various loss functions and a learning rate scheduler. The class should be able to initialize with given options and perform the necessary operations for image deblurring.
Your task is to complete the `ImageDeblur` class by implementing the foll... | codefeedback |
You are tasked with creating a program that analyzes the frequency of words in a given text file. Your program should read a text file and output the top N most frequently occurring words along with their respective counts. For the purpose of this problem, a word is defined as a sequence of alphanumeric characters sepa... | codefeedback |
You are tasked with implementing a function that calculates the intersection area of two rectangles in a 2D plane. The rectangles are defined by their top-left and bottom-right coordinates. The function should take in the coordinates of the two rectangles and return the area of their intersection.
You are given the fo... | codefeedback |
You are working on a Python project that involves symbolic mathematics using the SageMath library. While importing the necessary modules, you encounter a code snippet that uses the `lazy_import` function. This function is used to import modules only when they are first accessed, which can help reduce startup time and m... | codefeedback |
You are tasked with implementing a custom drop connect layer in TensorFlow for a neural network model. The drop connect layer is a variation of the dropout technique, where instead of dropping individual neuron outputs, it drops entire connections between neurons and their subsequent layers. This helps in regularizing ... | codefeedback |
You are tasked with implementing a priority queue using a min-heap data structure. A priority queue is an abstract data type that operates similar to a regular queue or stack, but where each element has a priority associated with it. In a min-heap priority queue, the element with the smallest priority value should be d... | codefeedback |
You are tasked with creating a Python function that simulates the behavior of the `shutil.which` function for Python versions earlier than 3.3. The `shutil.which` function is used to locate a program in the system's PATH. Your function should take the name of a program as input and return the full path to the program i... | codefeedback |
You are given two strings, A and B, each consisting of lowercase English letters. Your task is to find the minimum number of operations required to make the two strings equal. The allowed operations are insertion, deletion, or substitution of a single character. The cost of each operation is 1. You need to implement a ... | codefeedback |
You are tasked with creating a word guessing game in Python. The game will involve a player guessing letters in a word, with a limited number of attempts. The code snippet provided is a part of the main game loop, handling exceptions and updating the game state.
The game has the following components:
- The word to be ... | codefeedback |
You are tasked with creating a Python script that monitors the availability of a Plex media server and sends an alert if the server becomes unreachable. The script should use the `plexapi` library to connect to the Plex server and periodically check its availability. If the server is not reachable, the script should se... | codefeedback |
You are tasked with creating a program that analyzes a given text file to count the occurrences of specific words. Your program should read the text file, tokenize the words, and then count the occurrences of each word. Additionally, the program should ignore any words listed in a provided set of stop words. The stop w... | codefeedback |
You are tasked with implementing a function that converts a given set of coordinates to Well-Known Binary (WKB) format. Well-Known Binary is a binary representation of geometry data, commonly used in geographic information systems (GIS). The WKB format consists of a header byte indicating the geometry type, followed by... | codefeedback |
You are tasked with creating a Python function that parses a list of URL patterns and returns a dictionary mapping the URL patterns to their corresponding view functions. Each URL pattern is represented as a string, and the view function is represented as a string as well.
You are given a list of URL patterns in the f... | codefeedback |
You are tasked with implementing a Python class that simulates a simple text comparison tool. The class should provide a method to compare two strings and identify the differences between them. Your task is to complete the implementation of the `TextComparator` class by adding the `compare` method.
The `TextComparator... | codefeedback |
You are tasked with creating a Python class that generates random instances of various data structures and provides methods for comparing and converting these instances. Your task is to implement the `RandomDataGenerator` class with the following requirements:
1. The class should have a method `generate_random` that t... | codefeedback |
You are tasked with designing a reservation system for a university's lecture rooms. The system should allow students to reserve a room for a specific course at a given time. The provided code snippet is a part of the backend logic for checking and handling reservations.
The code snippet is a Python script that intera... | codefeedback |
You are tasked with implementing a function that extracts values from a database source based on a given expression. The database source is represented by the `source` parameter, which is an `Option` containing a reference to a `Source` object. The `Source` object has a lifetime parameter `'b` and its associated type `... | codefeedback |
You are tasked with implementing a generic ZipFileFilter class that filters a list of FileResource objects based on certain criteria. The provided code snippet includes a method to set the file resources and a method to retrieve the file resources, along with the use of the @JsonIgnore annotation.
Your task is to crea... | codefeedback |
You are tasked with creating a function that validates whether a given string is a valid JSON object or not. You need to implement the `IsJsonString` function in the programming language of your choice. The function should return `true` if the input string is a valid JSON object and `false` otherwise.
The `IsJsonStrin... | codefeedback |
You are tasked with implementing a custom serializer for a blog post model in a Python Django application. The `Post` model has the following fields: `title` (string), `content` (text), `author` (foreign key to the User model), and `created_at` (datetime). Your goal is to create a custom serializer class `PostSerialize... | codefeedback |
You are working on a natural language processing (NLP) project and need to implement a function to create a padding mask for sequences. The input sequences are represented as batched tensors, and you are required to create a mask that identifies the padded positions in each sequence.
You are given the following code s... | codefeedback |
You are tasked with implementing a property wrapper for UserDefaults in Swift. The property wrapper should provide a way to store and retrieve values from UserDefaults with a specified key and default value. Additionally, it should support clearing the stored value.
Your task is to create a `UserDefaultsBacked` proper... | codefeedback |
You are tasked with implementing a simplified version of the Gilded Rose inventory management system. The system manages the inventory of various types of items, each with its own set of rules for quality and sell-in date updates. Your goal is to write a program that updates the quality and sell-in date of each item in... | codefeedback |
You are tasked with simulating a Poisson population of neurons to generate spike trains for a neuroscience research project. The goal is to create a Python function that simulates the firing activity of a population of neurons based on a Poisson process. The function should take into account the simulation time, sampli... | codefeedback |
You are tasked with creating a script to monitor the status of a Selenium server using the `curl` command and a success command defined by the `SUCESS_CMD` variable. The script should continuously check the status of the Selenium server until the success condition is met, and then stop and display the final status.
Gi... | codefeedback |
You are tasked with implementing a URL shortening service. Your goal is to create a function that takes an original URL as input and returns a shortened version of the URL. The shortened URL should be unique and should be generated using a combination of alphanumeric characters. Additionally, you need to implement a fu... | codefeedback |
You are given a text file containing a software license agreement. Your task is to write a program that reads the file and extracts the total count of words in the agreement, as well as the frequency of each unique word. For the purpose of this problem, a word is defined as any sequence of characters separated by white... | codefeedback |
You are tasked with creating a custom feature configuration for a Minecraft mod. The feature configuration will define the properties of a new world feature that will be generated in the game world. Your task is to implement the feature configuration class using the provided code snippet as a reference.
The code snipp... | codefeedback |
You are tasked with creating a PHP class that manages a library of books. The class should have methods to add a new book, retrieve book details by ID, and display all books in the library. You are provided with a partial implementation of the `BookController` class in Laravel framework. Your task is to complete the cl... | codefeedback |
You are given a partial implementation of a class `Rotatable` in C++ that is designed to identify rotatable variables in a Boolean satisfiability problem. The class takes a CNF (Conjunctive Normal Form) as input and is responsible for identifying the rotatable variables based on a given model.
The `Rotatable` class ha... | codefeedback |
You are tasked with implementing a function to calculate the sum of all prime numbers within a given range. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Your function should take two integers, `start` and `end`, as input and return the sum of all prime numbers... | codefeedback |
You are tasked with creating a program that reads a file containing copyright information and extracts the year(s) mentioned in the copyright notice. The copyright notice is a comment block in the file, and the years are mentioned in the format "YYYY". Your program should then output the distinct years mentioned in the... | codefeedback |
You are tasked with creating a program to perform Vigenère cipher encryption and decryption. The Vigenère cipher is a method of encrypting alphabetic text by using a simple form of polyalphabetic substitution. It uses a keyword to shift the letters in the plaintext to produce the ciphertext. The encryption and decrypti... | codefeedback |
You are tasked with creating a program to update SKUs (Stock Keeping Units) in an e-commerce system. The program will read SKU data from a file and update the corresponding records in the system using asynchronous requests to a remote server. The program must handle concurrent requests and enforce a rate limit to avoid... | codefeedback |
You are tasked with creating a Python function that interacts with an API to retrieve information about coding challenges and their rewards. The function should take in two parameters: `url` and `headers`. The `url` parameter specifies the type of reward to retrieve, and the `headers` parameter contains the headers req... | codefeedback |
You are tasked with implementing a PolynomialPredictor class that can predict future values in a time series using polynomial regression. The PolynomialPredictor class takes in a time series of values and the number of periods to predict into the future. The predict_counts() method of the PolynomialPredictor class shou... | codefeedback |
You are tasked with creating a React component that handles search functionality. The component should include a search input field and should be able to pass the search results and any errors to its parent component.
You are given a code snippet that represents part of the React component. The component is enclosed w... | codefeedback |
You are tasked with implementing a payment processing system that involves presenting additional payment details using plugins. The system has a `PaymentDetailPresenter` class with a method `show` that takes additional payment details, a plugin, and a completion handler as parameters. The plugin is responsible for pres... | codefeedback |
You are tasked with creating a web application for a laundry service company. The company offers various features accessible through a navigation menu. The code snippet provided is a part of the HTML code for the navigation menu. Each list item (`<li>`) represents a feature with a corresponding link and icon. The links... | codefeedback |
You are tasked with implementing a class that represents a frequency range. The class should have methods to set the lower and upper bounds of the frequency range in hertz. Additionally, it should provide a method to check if a given frequency is within the defined range.
You are provided with a partial code snippet f... | codefeedback |
You are working with genomic data and need to manipulate BAM files using the Samtools software. Samtools is a suite of programs for interacting with high-throughput sequencing data. One of the tasks involved in this process is to filter out reads with the 0x400 flag and create a new BAM file from the original one. Afte... | codefeedback |
You are tasked with implementing a deep copy method for a custom class in Python. The class has various attributes, including primitive data types, lists, and other objects. Your task is to create a `copy` method within the class that returns a deep copy of the object, ensuring that all attributes and nested objects ar... | codefeedback |
You are tasked with creating a Rust macro that generates a set of HTTP route handlers for a web server framework. The macro should take in a list of keywords and generate corresponding route handler functions for each keyword. Each route handler function should have a specific behavior based on the keyword it is associ... | codefeedback |
You are tasked with creating a PHP class method that performs various actions based on the user and product provided as parameters. Your task is to complete the `actions` method in the given PHP class. The method should perform the following actions based on the user and product:
1. If the user is an admin and the pro... | codefeedback |
You are tasked with implementing a function that processes a two-dimensional array and performs operations based on the input parameters. The function takes in an array of arrays and a parameter that determines the type of operation to be performed. The array of arrays represents a table with rows and columns, and the ... | codefeedback |
You are tasked with creating a program that calculates the sum of all prime numbers up to a given integer `n`. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Your program should take an integer `n` as input and output the sum of all prime numbers less than or eq... | codefeedback |
You are given a Python function that processes a game matrix and returns a solution. Your task is to understand the function and implement a similar function in another programming language.
The function `offdiag_refill` takes four parameters: `run`, `names`, `queue`, and an optional parameter `count`. The `run` param... | codefeedback |
You are tasked with creating a Python function that processes data from a CSV file and generates a graph using the Plotly library. The function, `graph_difficulties`, takes two optional boolean parameters: `is_by_height` and `show`. The function reads data from a CSV file, creates a Plotly figure, and adds a scatter pl... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.