instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a custom comparator for a scoring system used to prioritize loading of background tabs in a web browser. The scoring system assigns a numerical score to each tab, and the comparator will be used to sort the tabs based on their scores. The scoring system is based on a set of rules that c... | codefeedback |
You are tasked with implementing a Python module for working with finite state automata (FSA). An FSA is a mathematical model used to describe the behavior of systems that can be in only a finite number of states at any given time. The code snippet provided imports two modules: `fsa` and `fsa_util`, which are used for ... | 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 frequency of each word in the file, ignoring case and punctuation. Additionally, the program should exclude common English stop words such as "the", "and", "of", etc. The... | 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 copyright notice, list of conditions, and the disclaimer. The text file may contain multiple occurrences of these sections, and you need to extract all of them.
Your program should ou... | codefeedback |
You are tasked with creating a Python function that interacts with network devices using the `netmiko` library. The function `send_cmd_with_prompt` takes in a `device` dictionary containing connection details, a `command` string to be executed on the device, a `wait_for` parameter that can be either a string or a list ... | codefeedback |
You are tasked with creating a Python function that processes resource data and updates specific YAML files based on certain conditions. The function should take in the path to a directory and a list of resources. It should then perform the following steps:
1. Check if a file named "resources.txt" exists in the specifi... | codefeedback |
You are tasked with extending the `BaseSerializer` class to create a specialized serializer for ROS (Robot Operating System) messages. The ROS system uses topics to publish and subscribe to messages, and these messages can be recorded into bag files for later playback and analysis. Your goal is to implement a ROS messa... | codefeedback |
You are tasked with implementing a repository pattern for managing `Wheel` objects in a C# application. The `WheelRepository` interface provides methods for retrieving, creating, updating, and deleting `Wheel` objects. Your goal is to implement a concrete class that fulfills this interface and provides the necessary fu... | codefeedback |
You are tasked with creating a custom assertion macro for a graphics programming library. The macro should compare the components of two vertex structures and report any differences. The vertex structure contains position, texture coordinates, and color information. Your task is to implement the custom assertion macro ... | codefeedback |
You are tasked with creating a script that processes command-line arguments to configure a virtual machine. The script should handle different options and provide appropriate feedback for unsupported architectures.
Your script should accept the following command-line arguments:
- `--root=<value>`: Specifies the root d... | codefeedback |
You are working on a software deployment automation script that clones Git repositories and performs certain operations based on the repository configuration. The script reads a configuration file and processes the repositories based on the specified criteria. Your task is to implement a function that simulates the beh... | codefeedback |
You are tasked with creating a Python function that generates a specific type of keyboard markup for a chatbot application. The function should take a 2D list of tuples as input and return an InlineKeyboardMarkup object. Each tuple in the input list represents a button to be displayed on the keyboard, with the first el... | codefeedback |
You are tasked with creating a web scraping algorithm to extract specific links from a website. The given code snippet is a part of a Python Scrapy spider, which is a web crawling and scraping framework. The `rules` list contains instances of the `Rule` class, which define the behavior for following and parsing links o... | codefeedback |
You are tasked with implementing a multi-threaded program that simulates a simple resource management system. The program will create and manage multiple threads, each representing a device that needs to access a shared resource. The resource management system should ensure that only one device can access the resource ... | codefeedback |
You are working on a server application that handles requests for data cutouts from a large dataset. The server has a restriction that the total size of the requested cutout must not exceed 1GB when uncompressed. You need to implement a function to check if a given cutout request exceeds this size limit.
You are given... | codefeedback |
You are tasked with implementing a function that processes component requests based on a given code snippet. The code snippet provided is a TypeScript function that takes in a `CascaderProp` object and returns the result of a component request. The function makes use of various TypeScript features such as interfaces, t... | codefeedback |
You are tasked with creating a Python function that processes time series data to prepare it for input into a neural network. The function should take a pandas DataFrame containing time series data and transform it into a format suitable for training a neural network. The input DataFrame contains a column "time" with t... | codefeedback |
You are tasked with creating a Python class that processes data from a game and generates a map with specific information displayed on it. The class should read data from a file, manipulate it, and then use the processed data to draw on an image of a game map.
Your task is to implement the `GameMap` class, which shoul... | codefeedback |
You are tasked with implementing a function to process a dataset of texts and their corresponding labels. The dataset is represented as a list of tuples, where each tuple contains an integer identifier, a list of strings representing the text, and a list of dictionaries. Each dictionary in the list contains enriched st... | codefeedback |
You are tasked with implementing a custom view in a Swift iOS application that displays a form for creating a new user profile. The form should include fields for the user's name, email, and date of birth. Additionally, the form should include a button to submit the user's information.
Your task is to create a custom ... | codefeedback |
You are tasked with designing a system for managing various background jobs in a distributed storage service. The system will handle different types of jobs such as status reporting, metrics collection, server management, cleanup, metadata handling, and service advertisement. Each job will be implemented as a separate ... | codefeedback |
You are tasked with implementing a Python function that constructs and configures solvers for two different model parts in a simulation framework. The provided code snippet initializes two model parts, `main_model_part_bg` and `main_model_part_bf`, and then proceeds to construct solvers for each model part using the sp... | codefeedback |
You are tasked with implementing a function to calculate the factorial of a given non-negative integer using recursion. However, you need to ensure that the function is efficient and does not lead to a stack overflow error for large input values.
Your task is to create a recursive function `factorial` that takes an in... | codefeedback |
You are tasked with creating a script to deploy a standard vault and its components on the Rinkeby network using Hardhat. The script should take the address of wrapped ether (WETH) as a parameter and deploy the necessary components for the vault.
Your task is to write a JavaScript script using Hardhat that accomplishe... | codefeedback |
You are tasked with refactoring a legacy codebase that includes a class representing a cable with segments. The legacy code provides two member functions for accessing cable segments: `cable` and `segments`. The `cable` function returns a pointer to a cable segment given an index, and the `segments` function returns a ... | codefeedback |
You are tasked with implementing a Python script that dynamically imports a module based on the Python version being used. Your script should import the `find_spec` function from the appropriate module (`importlib` for Python 3.5 and above, and `imp` for Python 2). The `find_spec` function is used to find the module sp... | codefeedback |
You are given a 2D matrix `mat` of integers, where each row is sorted in non-decreasing order. Your task is to write a function `smallestCommonElement` to find the smallest common element in all rows of the matrix. If there is no common element, return -1.
The function signature is:
```python
def smallestCommonElement... | codefeedback |
You are tasked with creating a web application for a banking system. The application should allow users to make deposits and withdrawals from their accounts. The backend of the application is built using Django, and the provided code snippet is a part of the Django admin interface setup.
The code snippet imports two f... | codefeedback |
You are tasked with implementing a Python class method that constructs a SQL query based on the attributes of a given object. The method should iterate through the object's attributes, construct a SELECT query string, and handle the case where an ID is provided for filtering the query.
You are given the following Pyth... | codefeedback |
You are tasked with implementing a program to calculate the average of a set of values and format the results into a specific string format. The program should take a list of integers as input and calculate the average of these values. Then, it should format the average into a specific string format and store the resul... | codefeedback |
You are tasked with creating a Python class method that generates a list of potential usernames based on certain criteria. The method should take into account a configuration object, a deity name, a region name, and specific constraints for the generated usernames.
You are given the following code snippet as a startin... | codefeedback |
You are tasked with creating a function that preprocesses and splits a dataset for training and testing a machine learning model. The function should take in four pandas DataFrames representing training and testing data for a binary classification task. The training data is unbalanced, containing unequal numbers of pos... | codefeedback |
You are tasked with implementing a simple asset management system for a game engine. The system should support hot reloading of assets and utilize multithreading for concurrent access. You are provided with a partial implementation of the `Casset` struct and its associated methods in Rust.
The `Casset` struct represen... | codefeedback |
You are tasked with implementing a function to determine if a given binary string meets specific criteria. The function should return `True` if the binary string consists of all zeroes or all ones, and `False` otherwise. The binary string will be provided as input to the function.
Write a function `check_binary_string... | codefeedback |
You are tasked with implementing a custom error type and handling its instances in Rust. The custom error type, `Error`, has multiple variants, one of which is `CgroupLineNotFound` that takes two `String` parameters. The `CgroupLineNotFound` variant is used to represent an error condition where a specific line related ... | codefeedback |
You are tasked with creating a Python function that can interpret and execute Larch scripts. Larch is a domain-specific language for scientific computing and data analysis. Your function should be able to take a Larch script as input and return the output of the script's execution.
You are provided with a partial code... | codefeedback |
You are tasked with implementing a custom dataset class for loading images and their corresponding depth maps for a computer vision project. The provided code snippet is a part of the dataset class, which includes the `__getitem__` and `__len__` methods. The `__getitem__` method loads an image as a float and its corres... | codefeedback |
You are tasked with implementing a simple HTML parser in Java. Your goal is to create a method that extracts the text content from a given HTML element. The HTML element is represented by a class `HTMLElement` with the following structure:
```java
public class HTMLElement {
private String tag;
private String t... | codefeedback |
You are tasked with implementing a registration system for committee candidates using Python. The system should allow committee candidates to register for tasks and keep track of the number of registered nodes. You are provided with a code snippet that sets up a committee candidate, assigns a registration channel, and ... | codefeedback |
You are tasked with creating a Python class that can generate SQL queries for a given database table. Your class should be able to dynamically generate SQL queries for common operations such as SELECT, INSERT, UPDATE, and DELETE. To achieve this, you need to implement a class called `SQLQueryBuilder` that provides meth... | codefeedback |
You are tasked with implementing a system for managing bids in an online auction platform. The provided code snippet shows the constructor of a service class called BidsServices, which is responsible for interacting with the database through repositories for Bid, User, and Auction entities. However, the comment "// TOD... | codefeedback |
You are tasked with creating a Python function that simulates a simple file loading and plotting process. Your function should take a directory path as input, load data from files within that directory, and then plot the loaded data using the `matplotlib` library. Additionally, you need to ensure that the function is p... | codefeedback |
You are tasked with implementing a Java class that represents a service schema problem. The class should override the `toString` method to provide a string representation of the service schema problem, including the service name and any errors associated with it.
Your task is to create the `ServiceSchemaProblem` class... | codefeedback |
You are given a sorted list of distinct integers `nums` and a target integer `target`. Your task is to write a function `searchInsert` that returns the index where the target should be inserted in the list `nums` to maintain its sorted order. If the target is already present in the list, the function should return its ... | codefeedback |
You are tasked with creating a custom JSON formatter for an ASP.NET Core MVC application that can handle newline-delimited JSON (NDJSON) using asynchronous streams. NDJSON is a convenient format for streaming large datasets, where each line represents a separate JSON object. Your custom formatter should be able to seri... | codefeedback |
You are tasked with implementing a task management system using a RESTful API. The provided code snippet is a part of a TypeScript class that handles HTTP requests for managing tasks. The class uses decorators to define the HTTP methods and their corresponding routes.
Your task is to complete the implementation of the... | codefeedback |
You are tasked with implementing a function that transforms a list of strings into a single string by joining the elements with a specified delimiter. Your function should take a list of strings and a delimiter as input and return the resulting string.
Write a function called `join_with_delimiter` that takes two param... | codefeedback |
You are tasked with implementing a function that calculates the number of days remaining until a specific matchup start date. The function should take into account the current date and time, as well as the start date of the matchup.
You are given the following code snippet as a starting point:
```javascript
const Pla... | codefeedback |
You are tasked with implementing a Python generator function that processes data from a custom CID (Customer Identification) system. The CID system has various tag types defined in the `cidlineclasses` module. Your task is to create a generator function that validates the CID tag against the `cidlineclasses` and yields... | codefeedback |
You are tasked with creating a Python class that retrieves the time elapsed since the last visit to a local server. The class should inherit from the `StdAns` class and implement a method `GETMSG` that fetches the time elapsed in hours, minutes, and seconds from the server and returns a formatted string indicating the ... | codefeedback |
You are tasked with implementing a traffic control system for an intersection using the given code snippet as a reference. The system will have different modes and will control the traffic lights and pedestrian signals based on the current mode and the state of the intersection.
You need to create a Python class `Traf... | codefeedback |
You are tasked with creating a script to automate the training process for a machine learning model with various attack methods and parameters. The script should iterate through different attack parameters and execute the training process for each combination.
Your task is to write a Python script that generates and e... | codefeedback |
You are working on a financial data visualization project and need to create a Python script to generate a technical analysis plot for the Accumulation/Distribution Oscillator (ADOSC). The code snippet provided is a part of the script that sets up the plot's style, colorway, title, and interactive settings using the Pl... | codefeedback |
You are tasked with implementing a neural network module in PyTorch for a custom architecture. The provided code snippet is a part of the module definition and shows the forward pass of the module. Your task is to complete the module definition by implementing the missing parts and ensuring that the forward pass is cor... | codefeedback |
You are tasked with implementing a function to generate product recommendations based on word embeddings. The function `get_recommendations` takes a JSON object as input, containing a list of products and an integer `n`. It loads a pre-trained word embedding model and uses it to find the most similar products to the on... | codefeedback |
You are tasked with creating a Python function that processes ultrasound data to perform refocusing and image enhancement. The function will take in raw ultrasound data and return the refocused and enhanced image.
The function will utilize the following libraries and modules:
- `numpy` for numerical operations
- `focu... | codefeedback |
You are tasked with implementing a custom data structure to represent a hierarchical tree-like structure. The structure consists of nodes, each of which can be either a KeyedNode or a Node. A KeyedNode contains a key and a reference to a Node, while a Node contains a tag, a set of attributes, and a list of children nod... | codefeedback |
You are tasked with creating a Python function that takes a text string as input and returns the frequency of each word in the text, excluding common English stopwords. Stopwords are words that are filtered out before or after processing of natural language data. The NLTK library provides a list of common English stopw... | codefeedback |
You are tasked with implementing a function to calculate the shear force equations for each section of a beam. The given code snippet is part of a larger codebase and indicates that the sign convention used in the calculation needs to be fixed. Your task is to create a Python function that takes the necessary input and... | codefeedback |
You are tasked with implementing a C# program that involves working with memory offsets and data structures. Your goal is to create a class that represents a specific data structure and then manipulate its fields using memory offsets.
You are given the following code snippet as a starting point:
```csharp
[FieldOffse... | codefeedback |
You are tasked with creating a Python function that processes a list of strings and returns a dictionary containing the frequency of each unique word in the list. The function should ignore case sensitivity and consider only alphanumeric characters when identifying words.
Create a function called `word_frequency` that... | codefeedback |
You are tasked with implementing a Python function that calculates the factorial of a given non-negative integer using recursion. The factorial of a non-negative integer n is denoted as n! and is the product of all positive integers less than or equal to n. For example, 5! = 5 × 4 × 3 × 2 × 1 = 120.
You need to implem... | codefeedback |
You are tasked with implementing a memoization decorator in Python. Memoization is a technique used to improve the performance of a function by caching its results and returning the cached result when the same inputs occur again. The provided code snippet is a partial implementation of a memoization decorator using the... | codefeedback |
You are tasked with implementing a Java method that calculates the factorial of a given non-negative integer using the `BigDecimal` class to handle large numbers. The `b` method provided below can be used to create a `BigDecimal` instance from a `double` value.
```java
import java.math.BigDecimal;
import java.math.Mat... | codefeedback |
You are tasked with creating a test case for an end-to-end test of a web application. The test case involves interacting with a web page, verifying the presence of a specific element, and validating its content. The provided code snippet is a part of the test case written using a testing framework.
Your task is to wri... | codefeedback |
You are working on a continuous integration (CI) pipeline for a cloud-native application deployment. As part of the pipeline, you need to write a script to test the Helm chart templates for a Kubernetes deployment. The script uses Helm to generate the Kubernetes manifests from the chart templates and then applies some ... | codefeedback |
You are tasked with creating a Python script that interacts with the KEGG (Kyoto Encyclopedia of Genes and Genomes) API to retrieve information about a specific pathway and save the results in a JSON file. The KEGG API provides access to a wealth of biological data, including pathways, genes, and compounds.
Your scrip... | codefeedback |
You are tasked with creating a Python function that utilizes the Selenium WebDriver to automate a specific user action on a web page. The function should handle potential exceptions that may occur during the automation process.
You are given the following code snippet as a starting point:
```python
from selenium.webdr... | codefeedback |
You are tasked with implementing a function to receive data from a socket using Swift. The function should take a buffer, a position within the buffer, and the number of bytes to receive. The function should use the `recv` function to receive data from the socket and return the number of bytes received. If an error occ... | codefeedback |
You are tasked with creating a web application that dynamically generates meta tags for search engine optimization (SEO) based on the content of the page. Your application should parse a given HTML file and extract the content within specific HTML tags to generate the meta tags. In this case, you need to extract the co... | codefeedback |
You are tasked with implementing a progress bar system for a graphical user interface (GUI) on an embedded device. The device has a display with a resolution of 320x240 pixels. The progress bar should be displayed at specific coordinates on the screen and should be able to show the progress of a task as a filled bar wi... | codefeedback |
You are tasked with implementing a function to calculate the Hilbert-Schmidt Independence Criterion (HSIC) statistic for a given pair of input datasets. The HSIC statistic is a measure of independence between two random variables and is commonly used in statistical independence testing. Your task is to create a Python ... | codefeedback |
You are tasked with implementing a simple weak reference virtual proxy class in Swift. A weak reference virtual proxy is a design pattern used to control access to an object that is expensive to create or is located on a remote server. The proxy acts as a stand-in for the real object and is responsible for creating, ma... | codefeedback |
You are tasked with creating a Python program to generate and push fake employee data into a database. The program should utilize the `faker` library to create realistic fake names and job titles for the employees. The generated data should then be inserted into a database table using Python's `sqlite3` module.
Your p... | codefeedback |
You are tasked with implementing a custom syntax factory for generating name colon syntax in a programming language. The `SyntaxFactory` class provides two static methods for creating `NameColonSyntax` objects. The first method, `NameColon(IdentifierNameSyntax name)`, takes an `IdentifierNameSyntax` object and returns ... | codefeedback |
You are tasked with creating a script to automate the installation process of a software package. The script should handle extracting files, setting appropriate permissions, and patching files with the correct installation path.
Your task is to complete the script by implementing the missing parts. Specifically, you n... | codefeedback |
You are tasked with implementing a Python class method that starts a specified program asynchronously. The method `async_start_program` takes in three parameters: `program_key`, `options`, and `program`. The `program_key` is a string representing the key of the program to be started. The `options` parameter is a sequen... | codefeedback |
You are tasked with creating a Python program that retrieves and processes data from a public API. The program should accept command-line arguments to specify the API endpoint, request parameters, and output file. Additionally, it should log the details of the API request and response to a file.
Your program should pe... | codefeedback |
You are tasked with creating a Python function that reads configuration settings from a file and decides whether to run a data uploading process based on the presence of certain variables. The function should check the configuration file for specific settings and then determine whether to execute the data uploading pro... | codefeedback |
You are tasked with creating a Python program that simulates a simple drawing application using the Tkinter library. The program should allow the user to draw on a canvas and then automatically adjust the scroll region of the canvas to fit the entire drawing.
Your task is to complete the `adjust_scroll_region` functio... | codefeedback |
You are given a string `s` consisting of only the characters 'A', 'B', and 'C'. The goal is to find the minimum number of operations required to transform the string `s` into one of the strings in the array `DB`. The allowed operation is to swap two adjacent characters in the string.
You need to implement a function `... | codefeedback |
You are tasked with implementing a custom loss function for a generative adversarial network (GAN). The GAN has two components: a discriminator and a generator. The discriminator aims to distinguish between real and fake data, while the generator aims to produce data that is indistinguishable from real data.
The code ... | codefeedback |
You are tasked with creating a script to automate the installation of the latest release of Syncthing, a continuous file synchronization program. Your script should retrieve the latest version number and download the appropriate binary based on the system's architecture.
Your script should perform the following steps:... | codefeedback |
You are tasked with creating a Python class that handles the generation of code files for a routine in a software system. The class, `CodeGenerator`, has several methods for reading template files, writing output files, and generating code based on the provided templates and routine information.
One of the methods in ... | codefeedback |
You are tasked with implementing a custom cache key maker for an IndexedCache data structure. The cache key maker should be designed to work with instances of the IndexedCache where the cache key can be the same type as the cache value. However, this is only applicable when the value type overrides `Object.hashCode()` ... | codefeedback |
You are tasked with creating a simplified version of an effect system used in a front-end application. The effect system is responsible for triggering actions based on certain conditions and asynchronous operations. Your goal is to implement a similar effect system using a simplified version of RxJS.
You are provided ... | codefeedback |
You are tasked with implementing a reinforcement learning (RL) algorithm for a robotic navigation system. The system uses a combination of semantic mapping and policy learning to navigate through an environment. The code snippet provided includes imports for necessary modules and classes.
Your task is to create a Pyth... | codefeedback |
You are tasked with implementing a function that converts a given C command assembly language instruction into its corresponding binary representation. The C command assembly language is used in a hypothetical computer architecture and consists of three main parts: the destination mnemonic, the computation mnemonic, an... | codefeedback |
You are tasked with implementing a function that processes a configuration file for a parallel processing system. The configuration file contains a series of key-value pairs, where the keys represent configuration parameters and the values represent their corresponding settings. Each key-value pair is separated by a co... | codefeedback |
You are tasked with implementing a hash table data structure in C++ using separate chaining for collision resolution. The hash table should support key-value pairs, and the keys will be of type `int` and the values will be of type `string`. You need to implement the following functionalities for the hash table:
1. Inse... | codefeedback |
You are given a Python class with a method that processes data from a CSV file. The method reads each row of the CSV file and updates a dictionary `self.data` based on the values in the "case" column. The code snippet provided is a part of this method. The `self.data` dictionary is structured as follows: `self.data = {... | codefeedback |
You are tasked with implementing a function to simplify a given Unix-style file path. The function should take a string representing the file path and return the simplified version of the path.
The rules for simplifying the path are as follows:
- The path starts with a '/' character.
- Any consecutive multiple slashes... | codefeedback |
You are working on a web application that manages orders for a restaurant. The code snippet provided is a part of the application's view file written in PHP and HTML. The application uses a modal to display an order grid for the restaurant's staff to manage orders. The modal is triggered by a button click and contains ... | codefeedback |
You are tasked with implementing a simplified version of a decision-making algorithm for a real-time strategy game. The game involves controlling units with various abilities and making decisions based on the game state. The provided code snippet is part of the decision-making logic for a unit in the game.
The code sn... | codefeedback |
You are tasked with implementing a code generator for a database table. The `generator` method takes in a list of `ColumnInfo` objects representing the columns of the table, a `GenConfig` object containing generation configuration, and the name of the table as a string. Your goal is to generate the code that will creat... | codefeedback |
You are tasked with implementing a card game mechanic in which a player can select and destroy a specific type of card from play. The game is implemented in C# using Unity, and the code snippet provided is a part of the game's logic. The snippet shows a conditional check for dealing damage and initiating the destructio... | codefeedback |
You are tasked with implementing a function to standardize apart a first-order logic sentence in place. First-order logic sentences often contain quantified variables, and standardizing apart involves renaming variables to ensure that no two quantified variables have the same name. This is necessary to prevent unintend... | codefeedback |
You are tasked with creating a Rust FFI (Foreign Function Interface) binding for the `pam_open_session` function from the PAM (Pluggable Authentication Modules) library. The `pam_open_session` function is used to initiate a user session within the PAM framework. Your goal is to create a Rust function that can call the ... | codefeedback |
You are tasked with implementing a user authentication system for a web application using PHP and Laravel. The given code snippet is part of a Laravel controller responsible for handling user login functionality. Your task is to complete the implementation of the login process by validating the user's input and authent... | codefeedback |
You are tasked with implementing a custom future in Rust that represents a stream resizing operation. The future should asynchronously poll a stream of data and, upon receiving a signal, resize the stream to a new size. Your goal is to implement the `ResizeFuture` type, which is a future that, when polled, returns a `R... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.