instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are working on a script to automate the setup of a Hyperledger Fabric network using the Fabric CA server. The script is responsible for initializing the CA server, copying the root CA's signing certificate to a target directory, and adding organization configuration. Your task is to complete the script by adding th... | codefeedback |
You are tasked with implementing a function that processes Handlebars templates. Handlebars is a popular templating language that allows dynamic content to be inserted into HTML or other text-based documents. The function you need to implement will take a Handlebars template and a context object as input, and return th... | codefeedback |
You are tasked with implementing a class method for data manipulation. Your goal is to create a method that removes empty rows from a given DataFrame. The DataFrame is a two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns). The method should take a DataFram... | codefeedback |
You are tasked with implementing a memory management system for a game engine. The system should support the allocation and deallocation of memory chunks, as well as the ability to persist chunks to disk. To achieve this, you need to create a Chunk struct that represents a chunk of general-purpose memory, essentially a... | codefeedback |
You are tasked with creating a program that processes a specific file format using FlatBuffers. FlatBuffers is an efficient cross-platform serialization library for C++, C#, C, Go, Java, JavaScript, PHP, and Python. The given code snippet demonstrates the use of the `fbs_build` crate to compile a FlatBuffers schema fil... | codefeedback |
You are tasked with implementing a C++ program that utilizes the Boost C++ Libraries to perform grid-based data manipulation. The Boost C++ Libraries provide free peer-reviewed portable C++ source libraries. In this problem, you will be working with the `boost::test::data::monomorphic::grid` module, which provides a co... | codefeedback |
You are tasked with implementing a resource management system for a game development project. The system should allow loading default resources into a resource container. Each resource has a unique identifier and can be of various types such as textures, models, sounds, etc. The resource container should be able to sto... | codefeedback |
You are tasked with implementing a function to generate avatars for an avatar picker component in a web application. The avatars will be used to populate an avatar picker dialog, which can be displayed with or without an image source. The avatars are generated using the `generateAvatars` function from a utility module,... | codefeedback |
You are tasked with creating a Python function that simulates parallel execution of a long-running task using multiprocessing. Your function should take a list of input values and a function to be executed in parallel. The function should return a list of results corresponding to the input values after the parallel exe... | codefeedback |
You are tasked with implementing a function to remove duplicates from a list while preserving the original order of elements. You are given a code snippet that includes two test cases for the function. Your task is to complete the implementation of the `unique` function and ensure that it passes the provided test cases... | codefeedback |
You are tasked with creating a Python class that generates backup scripts based on a given configuration file. The configuration file contains information about the files and directories to be included in the backup, as well as the destination for the backup.
Your task is to implement the `BackupScript` class, which t... | codefeedback |
You are tasked with implementing a class for 3D vectors, `Vec3`, which supports various operations. The class should have the following functionalities:
1. A constructor that initializes the vector with given x, y, and z coordinates.
2. An addition operator overload (`+`) that allows adding two `Vec3` objects together... | codefeedback |
You are tasked with implementing a Bible management system that allows users to install and replace different versions of the Bible from file. The system should handle errors and ensure that only one version of the Bible is installed at a time.
You are provided with a partial implementation of the `BibleManager` class... | codefeedback |
You are tasked with implementing a network protocol manager in Swift. The manager should support setting and getting the keep-alive count for a TCP connection. The keep-alive count represents the number of keep-alive probes to send before considering the connection as lost. The code snippet provided is a part of the Sw... | codefeedback |
You are given an array of positive integers and a target sum. Your task is to find a subarray within the given array that adds up to the target sum. If such a subarray exists, you need to output the starting and ending indices of the subarray (1-indexed). If there are multiple subarrays that satisfy the condition, outp... | codefeedback |
You are tasked with implementing a Python function to fit a model to a set of data points using the least squares method. The model to be fitted is defined by the `model` function, and the residuals (the differences between the model and the actual data) are calculated using the `residuals` function. You are required t... | codefeedback |
You are given a code snippet from a unit test for a function called `join_on_eq_with_dt`. This function takes in two arrays `a1` and `a2`, and two time arrays `t1` and `t2`. It then performs a join operation based on equality with a time window of `dt`. The unit test checks the behavior of the function under different ... | codefeedback |
You are tasked with implementing a simplified version of a remote controller for a smart home system. The remote controller is responsible for establishing a secure connection to a remote device using SSH (Secure Shell) protocol. Your task is to create a Java class that encapsulates the functionality of the remote cont... | codefeedback |
You are given a code snippet that involves the manipulation of multi-dimensional arrays using the Blaze C++ library. Your task is to understand the code and answer a question related to the operations performed.
The code snippet involves the following operations:
1. It defines a `filter_length` variable and uses it in... | codefeedback |
You are tasked with implementing a function that converts a molecular system topology from one syntax to another. The function `to_mdtraj_Topology` takes in a molecular system `item`, a set of `atom_indices`, and a `syntaxis` as input parameters. The `item` represents the molecular system topology to be converted, `ato... | codefeedback |
You are tasked with implementing a configuration parsing utility in Rust. The utility should be able to handle different types of configuration files and provide a unified interface for accessing the configuration values. To achieve this, you need to create a `ConfigurationParser` module that can handle errors during p... | codefeedback |
You are tasked with creating a Python class that processes Twitter data to generate a graph representing interactions between users. The class should be able to extract relevant data from a Twitter stream and convert it into a graph format. Your task is to implement the `Tweets2Graph` class with the following specifica... | codefeedback |
You are working on a robotics project that involves calculating the angle of a sensor and then using that angle to determine a differential value. The angle is initially calculated using the `math.asin()` function, and the result is printed alongside other distance-related values. However, the angle needs to be convert... | codefeedback |
You are tasked with implementing a function that can determine the number of occurrences of a specific word in a given text. The function should be case-insensitive and should only count whole word matches. Punctuation and special characters should be ignored. For example, in the text "The cat, the dog, and the rabbit.... | codefeedback |
You are tasked with creating a JavaScript function that takes in an audio file and converts it into a Blob object. The function should handle the asynchronous nature of loading the audio file and should return a Promise that resolves with the Blob object once the conversion is complete.
The function signature is as fo... | codefeedback |
You are tasked with implementing a consensus network for a distributed system. The consensus network consists of multiple nodes, each responsible for maintaining a shared, consistent state across the network. Your goal is to implement the logic for a single node in the consensus network.
You are provided with a code s... | codefeedback |
You are tasked with implementing a simple event system in C#. The provided code snippet demonstrates the usage of Unity's `UnityEvent.Invoke()` method, which is commonly used in Unity game development to trigger events. Your task is to create a similar event system using C# without relying on Unity's specific classes o... | codefeedback |
You are tasked with creating a Python class that represents a contact in a contact management system. The class should have attributes to store the contact's information and preferences for communication. Your task is to implement the `Contact` class with the following requirements:
Attributes:
- `name`: A string repr... | codefeedback |
You are tasked with creating a search functionality for a web application using PHP and Laravel framework. The application has a view file named `search.blade.php` which contains the HTML and Blade syntax for the search form. Your goal is to implement the backend functionality to handle the search request and return th... | codefeedback |
You are tasked with implementing a data transformation function for a collection of tuples. The input data consists of a collection of tuples, each containing a set of variables and their corresponding values. The transformation function is specified by an enum `Function`, which can take on the value `TRUNCATE`. When t... | codefeedback |
You are tasked with creating a function that simulates a simplified user authentication process. The function should take an email and password as input and perform the following steps:
1. Connect to a database using the `main` function.
2. Retrieve a user account from the database based on the provided email.
3. Use t... | codefeedback |
You are tasked with creating a program that processes HTML code to extract specific information. In this problem, you need to write a function that extracts the label and input type of all form elements with the class "layui-form-item" and "layui-form-text" from the given HTML code.
Write a function `extractFormElemen... | codefeedback |
You are tasked with creating a program to implement a custom stratified k-fold cross-validation algorithm. Stratified k-fold cross-validation is a technique used to evaluate the performance of a machine learning model. It involves splitting the dataset into k consecutive folds while ensuring that each fold maintains th... | codefeedback |
You are tasked with creating a Python class that manages access to a shared resource, in this case, a serial port. The class should ensure that only one operation can be performed on the serial port at a time, and it should handle the opening and closing of the port as well as sending and receiving data.
Your task is ... | codefeedback |
You are tasked with implementing a graph regulation algorithm to remove duplicate nodes from a given graph. The graph is represented as a dictionary where the keys are node identifiers and the values are sets of related nodes. The algorithm should merge duplicate nodes and update the graph accordingly. The provided cod... | codefeedback |
You are given a Python code snippet that calculates the difference in area under the curve (AUC) for different types of structural variants (svTypes). The code iterates through each svType, retrieves the base AUC and swap AUC from respective lists, and then calculates the difference between the swap AUC and base AUC. I... | codefeedback |
You are tasked with creating a benchmarking tool to measure the performance of various sorting algorithms. You have been provided with a Python library called `nac` which includes a `BenchmarkSuite` class for benchmarking algorithms. Your goal is to implement a custom sorting algorithm and use the `BenchmarkSuite` to c... | codefeedback |
You are tasked with implementing a program that processes a collection of sentences. Each sentence should be trimmed of leading and trailing whitespace and converted to lowercase before being added to the collection. You need to write a function that accomplishes this task.
Write a function `ProcessSentences` that tak... | codefeedback |
You are tasked with creating a Python function that processes a list of ForeignKeyConstraint objects and returns a dictionary mapping each table to its associated columns. A ForeignKeyConstraint object represents a foreign key constraint in a database table and contains information about the referencing and referenced ... | codefeedback |
You are tasked with implementing a Python class that represents a simple linear regression model. The class should be able to fit the model to a given dataset and make predictions based on the learned parameters.
Your task is to complete the implementation of the `SimpleLinearRegression` class, which has the following... | codefeedback |
You are tasked with creating a photo management system for a travel app called VirtualTourist. The app allows users to save and organize photos from their travels. You need to implement a Photo class using Swift and CoreData to represent the photos.
The Photo class should have the following properties:
- id: A unique ... | codefeedback |
You are tasked with implementing a parser for a custom language that uses a specific syntax for defining rising functions. A rising function is defined as a function enclosed within parentheses and preceded by the keyword "rising". The function is parsed using a custom parser class `P`. Your task is to write a method t... | codefeedback |
You are tasked with implementing a custom `Enumerable` interface in Java. The `Enumerable` interface represents a collection of elements that can be iterated over. Your task is to complete the implementation of the `CustomEnumerable` class, which is a concrete implementation of the `Enumerable` interface. The `CustomEn... | codefeedback |
You are tasked with creating a Python module that handles environment configuration using type annotations. Your goal is to implement a class that allows for the definition and retrieval of environment variables with specified types. The class should support setting default values for variables and provide a method for... | codefeedback |
You are tasked with creating a Python function that takes a string as input and returns the reversed version of the string. You should implement the function without using any built-in string reversal functions or slicing operations.
Write a function called `reverse_string` that takes a single string parameter `input_... | codefeedback |
You are tasked with creating a widget for a to-do list application. The widget should display a list of the user's upcoming tasks and allow them to interact with the tasks directly from the widget. The to-do list application provides an API for fetching the user's tasks and managing their status.
Your task is to desig... | codefeedback |
You are tasked with implementing a logging system for a software application. The application should support different log levels and have the ability to write logs to different destinations based on the environment (e.g., development, testing, production). Your task is to create a Python class that manages the logging... | codefeedback |
You are tasked with implementing a simplified version of an ActorSystem, a fundamental concept in the actor model of concurrent computation. An ActorSystem manages a hierarchy of actors and provides the necessary infrastructure for actors to communicate with each other. Your goal is to create a Python class that simula... | codefeedback |
You are tasked with creating a Python function that simulates an autoscaling system for a GPU cluster. The function should take in the desired number of GPU nodes to scale to and update the autoscaling group accordingly. Additionally, the function should print a message indicating the scaling action being taken.
Creat... | codefeedback |
You are tasked with implementing a class that manages a simple library system. The library contains books, each identified by a unique ISBN (International Standard Book Number). Your task is to create a class `Library` with the following functionalities:
1. Add a book to the library.
2. Remove a book from the library.
... | codefeedback |
You are given a graph with N nodes numbered from 1 to N. The graph may not be connected, and you need to find the number of connected components in the graph using breadth-first search (BFS).
You are provided with a code snippet that uses BFS to find the number of connected components in the graph. The function `bfs(x... | codefeedback |
You are tasked with writing a script to process a set of text files, each containing data about a specific country. The script needs to extract the country name from the filename, remove any underscores, and then process the data within each file. Specifically, the script should remove any commas or periods from the fi... | codefeedback |
You are tasked with implementing a data transformation function that converts a JSON message from Slack format to Mattermost format. The input JSON message from Slack is represented as a dictionary with the following structure:
```
slack_json = {
"blocks": [
{
"text": {
"text": "... | codefeedback |
You are tasked with creating a Python function that processes an image and applies aspect ratio scaling and various visual modifications using the matplotlib library. Your function should take in the original image size, the desired figure size, and an image file path as input. The function should then generate a modif... | codefeedback |
You are tasked with implementing a custom hashing algorithm using the Rust programming language. The algorithm should combine the functionality of multiple cryptographic hash functions to create a unique and secure hashing mechanism.
Your task is to create a Rust function that takes a string input and produces a hash ... | codefeedback |
You are tasked with implementing a batch request processor for a web service. The `BatchRequest` struct represents a batch request that contains multiple individual requests to be processed in a single batch. Each individual request is represented by the `RequestPreparer` struct. The `BatchRequest` struct has a `prepar... | codefeedback |
You are tasked with creating a Python program that simulates a simple banking system. The program should have the ability to create bank accounts, deposit and withdraw funds, and display the account balance. Additionally, the program should implement a basic user interface to interact with the banking functionalities.
... | codefeedback |
You are tasked with creating a file management system for a media sharing platform. The system should handle the upload of various types of media files and enforce certain restrictions based on the file type and user preferences.
You are given the following interface for a file object:
```typescript
interface MediaFi... | codefeedback |
You are tasked with implementing a function to calculate the Composition of K-Spaced Amino Acid Pairs (CKSAAP) for a given protein sequence. CKSAAP is a method used in bioinformatics to represent protein sequences as fixed-length feature vectors for machine learning applications. The CKSAAP method involves counting the... | codefeedback |
You are tasked with implementing a Python class to manage a collection of screw drive types. The class should provide functionality to add new screw drive types, remove existing ones, and retrieve the total count of screw drive types in the collection. Additionally, the class should allow for checking whether a specifi... | codefeedback |
You are given a list of integers representing the scores of a game and a target score. Your task is to find the number of ways to reach the target score by summing up the scores in the list. Each score can be used any number of times.
Write a function `countWaysToReachTarget` that takes in the following parameters:
- ... | codefeedback |
You are tasked with implementing a function to filter a list of service names based on a given pattern. The pattern can contain wildcard characters to match multiple service names. The wildcard characters are defined as follows:
- `*`: Matches zero or more characters.
- `.`: Matches exactly one character.
You need to ... | codefeedback |
You are given a list of tuples, where each tuple contains a string and a tuple of integers. The string represents a code, and the tuple of integers represents the coordinates and dimensions of a rectangle. Your task is to write a function that takes this list as input and returns a dictionary where the keys are the cod... | codefeedback |
You are tasked with implementing a file locking mechanism in Python. The `try_lock` method is used to attempt to acquire a lock on a specified file. If the lock is successfully acquired, the method returns `True`; otherwise, it returns `False`. The `try_lock` method takes the file path as its argument.
Your task is to... | codefeedback |
You are tasked with implementing a custom support vector data description (SVDD) algorithm in Python. The SVDD algorithm is a one-class classification method that aims to identify a region in the input space that encloses the target class, allowing for the detection of outliers. The provided code snippet is the initial... | codefeedback |
You are tasked with implementing a function to find the maximum depth of a binary tree. The binary tree is represented using a Node class with left and right child pointers. The depth of a node is defined as the number of edges on the longest path from the node to a leaf node. You need to write a function that takes th... | codefeedback |
You are tasked with creating a Python class to manage information related to books and their authors. The class should have methods to add new books, update book details, and retrieve information based on specific criteria. The class should also maintain a count of the number of books written by each author.
You are p... | codefeedback |
You are tasked with creating a caching mechanism for a storage system that stores and retrieves variables. The system consists of three main components: `CacheHelp`, `Store`, and `CheckForVariable`. The `CacheHelp` class provides utility functions for caching, while the `Store` class is responsible for storing variable... | codefeedback |
You are tasked with creating a custom filter in a Django web application that checks whether a user is a moderator in a chat room. The provided code snippet is a Python function used as a custom filter in Django templates. The function `is_bbb_mod` takes two parameters: `room` representing the chat room and `user` repr... | codefeedback |
You are tasked with implementing a simple lens library in Swift. A lens is a functional concept used to focus on a specific part of a larger data structure, allowing for easy access and modification of that part without directly manipulating the entire structure. In this problem, you will create a simple lens library a... | codefeedback |
You are tasked with implementing a function to retrieve error information from a custom error handling module. The error handling module is provided in the form of a C library, and you need to write a function that interacts with this library to obtain error details.
The provided code snippet includes a test case usin... | codefeedback |
You are tasked with implementing a QR code encoding function in Python. A QR code is a type of matrix barcode that is machine-readable and consists of black squares arranged on a white background. The provided code snippet includes a function `encode` that takes in data to be encoded and optional parameters for quiet z... | codefeedback |
You are tasked with creating a program that generates a report of the top GitHub repositories based on the number of stars they have. The program should read a file containing repository names and their corresponding star counts, and then output the top N repositories with the highest number of stars.
The input file w... | codefeedback |
You are tasked with creating a Python program to visualize the spread of a disease using the SIR (Susceptible, Infected, Recovered) model. The SIR model is a simple compartmental model that divides the population into three compartments: susceptible, infected, and recovered. The model is governed by the following diffe... | codefeedback |
You are tasked with creating a Python function that generates OpenGL function bindings for the GL_NV_geometry_program4 extension. The function should take a function as input and return a new function that creates the specified function with error checking.
Write a Python function `generate_opengl_function` that takes... | codefeedback |
You are tasked with implementing a simulation of a queuing system using the M/M/1 model. In this model, arrivals follow a Poisson process with rate λ, and service times follow an exponential distribution with rate μ. The system has one server, and the capacity of the system is limited to a maximum of cp customers. If t... | codefeedback |
You are tasked with implementing a function that updates a dictionary mapping file extensions to programming languages based on certain conditions. The function should take in the current mapping, a list of common languages, and a flag indicating whether verbose output should be printed. The function should update the ... | codefeedback |
You are tasked with creating a web application that handles HTTP requests using the Laravel framework. Your goal is to implement a feature that processes a POST request and returns a JSON response based on the request parameters. The request will contain data related to a user, and your application should validate and ... | codefeedback |
You are given a list of integers representing the scores of a game. The game has a special rule: if the current score is the same as the previous score, the current score is discounted and not added to the total score. Your task is to write a function to calculate the total score of the game according to this rule.
Wr... | codefeedback |
You are tasked with implementing a localization manager for a mobile application. The application has a set of extensions for `UINavigationItem` and `UITabBarItem` that provide a method for setting localized titles. The `localizedTitle` method takes a text string and an optional comment string and sets the title of the... | codefeedback |
You are tasked with implementing a blockchain data structure in Python. A blockchain is a decentralized, distributed ledger that records transactions across many computers in such a way that the registered transactions cannot be altered retroactively. Each block in the blockchain contains a cryptographic hash of the pr... | codefeedback |
You are tasked with creating a Python module for handling file input and output operations. The module should include a function to save data to a file. The function should be imported from the module and used in a separate script.
Your task is to implement the `save` function within the `save.py` module and then use ... | codefeedback |
You are tasked with implementing a custom error type in Rust for a collision detection system. The error type should be able to represent two distinct types of errors: "CollisionError" and "OutOfBoundsError". The "CollisionError" should contain two strings representing the names of the colliding objects, and the "OutOf... | codefeedback |
You are tasked with implementing a function that processes a list of integers and returns the sum of all the even numbers in the list. Additionally, you need to handle potential errors that may occur during the processing of the list.
You are given the following code snippet as a starting point:
```rust
use std::num:... | codefeedback |
You are tasked with creating a Django REST framework API endpoint for managing events. You need to implement a view that allows users to mark events as finished. The `Event` model is provided as follows:
```python
from django.db import models
from django.contrib.auth.models import User
class Event(models.Model):
... | codefeedback |
You are tasked with creating a Python module that simulates a simple banking system. The module should include classes for BankAccount and Customer, as well as methods for depositing, withdrawing, and transferring funds between accounts. Additionally, the module should be able to calculate interest on account balances.... | codefeedback |
You are tasked with creating a script to automate the configuration of firewall rules for Docker containers. The script should retrieve the IP addresses of specific Docker containers and then set up rules to allow public access to certain ports on these containers. Additionally, the script should insert the custom fire... | codefeedback |
You are tasked with creating a Python program that simulates a simple web server. The program should handle HTTP requests and respond with appropriate messages. Your task is to implement a function that parses the HTTP request method and returns a corresponding response message.
You are given a code snippet of a Flask... | codefeedback |
You are tasked with implementing a Swift program that manages facial expressions for an EmotionsViewController. The EmotionsViewController class contains a private dictionary, `emotionalFaces`, which maps emotions (e.g., "angry", "happy", "worried", "mischievious") to corresponding FacialExpression objects. The FacialE... | codefeedback |
You are tasked with creating a Python program that simulates a simple game of rock-paper-scissors. The program should prompt the user to input their choice (rock, paper, or scissors), generate a random choice for the computer, compare the choices, and determine the winner based on the game's rules. The program should t... | codefeedback |
You are tasked with implementing a syntax checker for a custom programming language. The language uses single quotes to denote character literals, and the syntax checker needs to ensure that the characters within the single quotes are valid. The syntax checker should also handle the case where a single quote is used as... | codefeedback |
You are tasked with creating a script to automate the process of managing database migrations for a Node.js application using TypeORM. TypeORM is an Object-Relational Mapping (ORM) library that allows developers to work with databases using TypeScript or JavaScript. The provided code snippet shows two commands executed... | codefeedback |
You are tasked with implementing a C++ class that represents the result of initiating a vault lock in an AWS (Amazon Web Services) environment. The class `InitiateVaultLockResult` has two constructors: a default constructor and a constructor that takes an `Aws::AmazonWebServiceResult<JsonValue>` as a parameter. Your ta... | codefeedback |
You are tasked with implementing a simplified version of the L-BFGS (Limited-memory Broyden-Fletcher-Goldfarb-Shanno) minimization algorithm in Python. L-BFGS is a popular optimization algorithm used for solving unconstrained optimization problems. The algorithm is known for its efficiency in handling large-scale probl... | codefeedback |
You are tasked with creating a program that analyzes the distribution of characters in a given text file. Your program should read a text file and output the frequency of each character present in the file, sorted in descending order of frequency. For the purpose of this problem, consider only alphanumeric characters (... | codefeedback |
You are tasked with implementing a script to automate the deployment of Kubernetes cluster configurations. The script, apply-cluster.sh, is responsible for applying the configuration to the currently configured Kubernetes cluster. The script should be idempotent, meaning it can be safely run multiple times to load the ... | codefeedback |
You are tasked with creating a script to automate the installation of software packages on a Linux system. The script should handle both multiple and single package installations, as well as the installation of specific files to designated directories. Your task is to implement a function that takes care of these insta... | codefeedback |
You are tasked with creating a bash script that logs the CPU temperature of a Linux system and sends an alert if the temperature exceeds a certain threshold. The script should utilize external libraries for logging and environment persistence.
Your script should perform the following tasks:
1. Set the bash options to ... | codefeedback |
You are given a circular list of numbers represented as an array `circular`. Additionally, you are given a list of integers `lengths`. Your task is to implement a function that performs a series of operations on the circular list based on the given lengths.
The operations are as follows:
1. For each length `l` in the ... | codefeedback |
You are tasked with implementing a Python function that processes a list of strings and converts each string to a float, appending the converted values to a new list. If a string cannot be converted to a float, it should be skipped and an error message should be printed. The function should handle both standard floatin... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.