instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a custom collection class in Java that mimics the behavior of a simple list. Your custom collection class, named `CustomList`, should support adding elements, removing elements, and retrieving elements at specific indices. Additionally, you need to override the `toString` method to prov... | codefeedback |
You are tasked with designing a Rust trait and implementing it for multiple modules to create a flexible I/O abstraction. The provided code snippet outlines the beginning of this task, where different modules are conditionally included based on feature flags. Your goal is to extend this code to define the `IOStream` tr... | codefeedback |
You are tasked with implementing a function to validate a substring expression in a specific programming language. The substring expression is defined by a set of rules, as indicated by the given code snippet. Your task is to write a function that checks whether a given substring expression adheres to these rules.
The... | codefeedback |
You are tasked with creating a script to automate the installation and setup of Linkerd service mesh on a Kubernetes cluster. Linkerd is a popular service mesh designed for cloud-native applications. The script should perform the following tasks:
1. Download and install Linkerd using the provided script.
2. Add Linkerd... | codefeedback |
You are tasked with creating a script to automate the management of Ruby gem dependencies using the Bundler tool. The script should handle the installation and verification of gem dependencies based on specified versions and configuration parameters.
Your script should perform the following tasks:
1. Define a function... | codefeedback |
You are tasked with implementing a parallelized optimization algorithm for the evidence lower bound (elbo) over different initializations. The elbo optimization is to be performed for a given dataset Y using a specified set of parameters. The code snippet provided is a part of this implementation and involves checking ... | codefeedback |
You are tasked with creating a script to securely transfer configuration files and logs to a remote server using SSH. The script should ensure that the destination directories exist and should also hide any SSH public keys present in the configuration files.
Your script should perform the following tasks:
1. Check if ... | codefeedback |
You are tasked with creating a command-line utility for a new operating system. The utility should allow users to perform various tasks by entering specific commands. The utility should support the following commands:
1. `fi`: This command should display information about the current file system, including the total s... | codefeedback |
You are tasked with creating a Rust module that provides functionality for managing a simple to-do list. The module should include the following features:
1. Adding a new task to the to-do list.
2. Marking a task as completed.
3. Listing all tasks in the to-do list.
4. Removing a task from the to-do list.
Your task is... | codefeedback |
You are tasked with creating a custom validation rule in Laravel to check if an email address is from a specific domain. The code snippet provided is the beginning of a Laravel job class called `SaveEmail` that will be responsible for saving email addresses to a database. Your task is to implement a custom validation r... | codefeedback |
You are tasked with implementing a denoising algorithm for images using Python and the PyTorch library. The given code snippet is a part of the denoising process and involves the application of a denoising neural network model to a noisy image.
The code snippet performs the following steps:
1. If a GPU is available, t... | codefeedback |
You are tasked with implementing a Python function that generates 3D reconstructions from a given input and provides a user interface for visualizing the reconstruction frames using a slider. The function should utilize the matplotlib library for visualization.
Write a function `generate_3d_reconstruction` that takes ... | 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. You should write a function called `sumOfEvenNumbers` that takes in a list of integers and returns the sum of all the even numbers in the list.
Function Signature:
```swift
func sumOf... | codefeedback |
You are tasked with creating a Python program that can remotely execute commands on a virtual machine (VM) using SSH. Your program should establish an SSH connection to the VM, execute the specified command, and then retrieve and display the output of the command.
Your program should take the following inputs:
- VM IP... | codefeedback |
You are tasked with creating a function that calculates the average score of a group of students. The scores are represented as an array of integers, where each integer represents the score of a student. Your function should return the average score rounded to the nearest whole number.
Create a function `calculateAver... | codefeedback |
You are tasked with creating a Python function that generates a JSON web token (JWT) for user authentication. The function should take in a user object, a token, and a JWT expiration delta, and return a JSON object containing the access token, token type, expiration time, and user data serialized using a custom seriali... | codefeedback |
You are tasked with implementing a serialization and deserialization algorithm for a binary tree. Serialization is the process of converting a data structure or object into a format that can be stored or transmitted, while deserialization is the reverse process. For this problem, you need to design an algorithm to seri... | codefeedback |
You are a security analyst tasked with identifying and addressing a potential SQL injection vulnerability in a web application. You have come across a code snippet from the application's backend that appears to be vulnerable to SQL injection. Your task is to analyze the code and identify the potential vulnerability, as... | codefeedback |
You are tasked with implementing a simple neural network training algorithm using Python. The neural network has a single hidden layer and uses the sigmoid activation function. Your goal is to complete the `train` method in the given code snippet to update the weights of the network using backpropagation and gradient d... | codefeedback |
You are tasked with creating a Python Flask API for a fictional online bookstore. The API should have endpoints for managing books, including adding new books, retrieving book details, updating book information, and deleting books. Additionally, the API should provide a search functionality to allow users to search for... | codefeedback |
You are tasked with implementing a function to parse an IPv6 header from a given byte slice. The IPv6 header is represented by the `Ipv6Header` struct, and the function should return the parsed header along with the unused parts of the input slice.
The `Ipv6Header` struct has the following fields:
```rust
struct Ipv6H... | codefeedback |
You are tasked with implementing a class method that handles event notification with a timeout. You are given a class with an `__init__` method that takes three parameters: `notify`, `event`, and `timeout`. The `notify` parameter is a function that will be called when the event occurs. The `event` parameter is a string... | codefeedback |
You are tasked with creating a Swift program to process and display information about famous individuals. The program should utilize optional binding and conditional statements to handle cases where certain information is missing.
You are given the following code snippet as a starting point:
```swift
var placeOfBirt... | codefeedback |
You are tasked with creating a custom validation constraint in a Symfony application. The goal is to implement a unique entity property constraint that ensures a specific property of an entity is unique within the database. The provided code snippet is a starting point for this custom constraint.
Your task is to compl... | codefeedback |
You are tasked with implementing a function that processes a list of results from a competition and returns the top three scores along with the corresponding letters. Each result is represented as a tuple containing a score and a letter. The function should return the top three scores and their corresponding letters, s... | codefeedback |
You are tasked with implementing a simplified version of a peer-to-peer network management system. The system consists of a `Peer` class and an `Admin` class. The `Peer` class represents a peer in the network, and the `Admin` class represents the administrator responsible for managing the network.
The `Peer` class has... | codefeedback |
You are given a directory path and a file extension. Your task is to write a Python program that counts the number of files with the given extension in the specified directory and all its subdirectories. You should consider only regular files, not directories or special files.
Your program should define a function `co... | codefeedback |
You are tasked with creating a parallel processing utility for a distributed computing system. The system consists of multiple machines communicating through a common communication interface. Your goal is to implement a function that will process a set of tasks in parallel and print the task names on the console. The t... | codefeedback |
You are tasked with implementing a function to calculate the total pixel difference in a sequence of images. Each image is represented as a 3D array, where the dimensions correspond to height, width, and color channels. The pixel difference between consecutive images is calculated by subtracting the corresponding pixel... | codefeedback |
You are tasked with implementing a Bayesian inference algorithm for a medical diagnosis system. The system uses a function `get_posterior(name)` to calculate the posterior probability of a patient having a certain medical condition given their symptoms and medical history. Additionally, the system has a command-line in... | codefeedback |
You are tasked with implementing a session-based alert system for a web application using Laravel Livewire. The code snippet provided is a part of a Blade template file and is responsible for displaying a warning alert if there is a 'warning' message in the session. The alert is dismissible and contains an icon, the wa... | codefeedback |
You are tasked with creating a Python function that checks whether a given numpy array has a specific shape and performs a transformation if the shape is not as expected.
Write a function called `transform_array` that takes in a numpy array `nump_array` and an integer `expected_shape`. The function should perform the ... | codefeedback |
You are tasked with creating a JavaScript function that interacts with a server to obtain a session ID and generate a token for accessing a video conferencing platform. The function should use XMLHttpRequest to send HTTP requests and handle the server's responses.
Write a function `generateToken(username, sessionUrl, ... | codefeedback |
You are tasked with creating a Python function that extracts the version number from a given module and returns it in a specific format. The module contains version information in the form of MAJOR, MINOR, PATCH, and VERSION variables. Your task is to implement a function that takes the module as input and returns the ... | codefeedback |
You are tasked with creating a Python web application that includes a WebSocket endpoint for real-time communication. Your goal is to implement a WebSocket chat application using FastAPI and Uvicorn.
You have been provided with a code snippet that attempts to start the FastAPI app and run the Uvicorn server. However, ... | codefeedback |
You are tasked with creating a PHP function that retrieves a specific blog post and displays its details on a web page. The function should take the blog post's slug as a parameter and return the corresponding view with the blog post details.
You are provided with the following code snippet as a starting point:
```ph... | codefeedback |
You are tasked with creating a program to convert a given Unicode character to its corresponding icon name in a specific font set. The font set contains a mapping of Unicode characters to icon names. Your program should take a Unicode character as input and return the corresponding icon name based on the provided font ... | codefeedback |
You are given a function `square_power` that takes in two parameters: `base` and `exponent`. The function should calculate the result of raising the base to the power of the exponent, and then return the square of that result.
Write a function `square_power` that implements this behavior.
Function signature: `fn squa... | codefeedback |
You are tasked with implementing a method to compare two instances of the `ContentManagementWorkspaceDocumentsTopicDocumentDataV2` class in Swift. The class represents document data within a content management workspace and contains various properties such as ID, name, creation date, modification date, workspace, creat... | codefeedback |
You are working on a data processing pipeline for a political election system. The pipeline takes input data in JSON format and performs various transformations to generate a CSV file. The input JSON data contains information about electoral districts (`dapil`) and their corresponding sub-districts (`wilayah`). Each el... | codefeedback |
You are tasked with creating a Python program to monitor and record audio volume levels at regular intervals. Your program should utilize multithreading to simultaneously capture audio and process the volume data. The code snippet provided gives a glimpse of the program's functionality, including creating a unique dire... | codefeedback |
You are tasked with creating a Python function that generates a BigQuery Machine Learning (BQML) prediction query and optionally sets up logging for error monitoring. The function should take in parameters for the prediction query, logging status, and error table schema, and return the complete BQML prediction query al... | codefeedback |
You are tasked with creating a program that processes and validates video aspect ratios. The program should take a string input representing the aspect ratio of a video and determine if it is supported or not. The aspect ratio is represented as a fraction in the form "width:height", where both width and height are posi... | codefeedback |
You are tasked with creating a script that automates the setup of a development environment for a software project. The script should perform several tasks, including setting up necessary directories, checking for root privileges, and printing the version of a specific command.
Given the provided code snippet as a sta... | codefeedback |
You are tasked with creating a class that manages intrusion events in a security system. The class should provide methods to retrieve and delete intrusion events from the system. You are given a code snippet that demonstrates the usage of these methods.
You need to implement a class called `IntrusionEventsManager` wit... | codefeedback |
You are tasked with creating a program that simulates a parallel job scheduler. The program should read a list of job files and execute them in parallel, with a specified number of jobs running concurrently. Each job file contains a command to be executed. Your task is to implement a function that takes the following i... | codefeedback |
You are tasked with implementing a function that processes a list of users and returns a specific result based on certain conditions. The function takes a list of user objects and a command type as input. The user objects have properties such as Id, Name, and Email. The function should perform the following steps:
1. E... | codefeedback |
You are tasked with implementing a custom control for a mobile application that allows users to input dates. The control should consist of a text entry field and a date picker dialog. The text entry field should be vertically aligned in the middle, and when focused, it should trigger the display of the date picker dial... | codefeedback |
You are given a string `str` containing only lowercase English letters. Your task is to write a function `duplicateChars` that takes in the string `str` and returns a new string where each character in the original string is duplicated. For example, if the input string is "hello", the output should be "hheelllloo".
Fu... | codefeedback |
You are tasked with implementing a simplified version of a peer-to-peer networking system in Rust. The provided code snippet is part of a larger networking library and represents a peer's method for establishing a connection and disconnecting from the network.
Your task is to create a Rust struct representing a peer a... | codefeedback |
You are tasked with creating a Python script that analyzes the required packages listed in a `requirements.txt` file and identifies any missing dependencies from the `packages` list. The `packages` list contains a hierarchy of package names, with some packages having submodules denoted by periods. The `requirements.txt... | codefeedback |
You are tasked with creating a script to ensure the existence of symbolic links for specific directories and to set up Git configuration on a Linux system. The script should handle the creation of symbolic links for specified directories and ensure that Git is installed and configured with specific settings.
Your task... | codefeedback |
You are tasked with implementing a function to decode an interleaved message using a reference encoder and a given interleaving sequence. The reference encoder encodes a message using a LDPC (Low-Density Parity-Check) code and a specific interleaving sequence. Your task is to decode the interleaved message using the sa... | codefeedback |
You are tasked with implementing a simplified version of a database query builder in PHP. Your task is to create a class that allows users to construct SQL queries using method chaining. The class should support the following operations:
- Adding a table to the query
- Setting column values for an update query
- Adding... | codefeedback |
You are tasked with creating a Rust module that manages a simple library system. The library system should have modules for managing games, web content, tables, and integration with external systems. Your task is to create a new module for managing books within the library system.
Your module should be named `books` a... | codefeedback |
You are tasked with creating a Java class that manages a repository of actors using Java Persistence API (JPA). The provided code snippet is a constructor for the `ActorsRepository` class, which is using dependency injection to receive a `JPAApi` instance and a `DatabaseExecutionContext` instance. The `ActorsRepository... | codefeedback |
You are working on a data analysis project in the field of high-energy physics. Your task is to write a program that creates and saves histograms to a ROOT file using the ROOT data analysis framework. The provided code snippet is part of the program and shows the initialization of the output file and the creation of a ... | codefeedback |
You are tasked with implementing a function that slices a 3D mesh with a given plane. The mesh is represented by its vertices and faces, and the slicing plane is defined by its normal vector and a point on the plane. The function should return the resulting vertices and faces of the sliced mesh.
You are given the foll... | codefeedback |
You are tasked with creating a script to automate the build and distribution process for a Haskell project using Cabal, a popular build system and package manager for Haskell.
Your script should perform the following steps:
1. Run the command `$CABAL build` to build the project.
2. Run the command `$CABAL sdist` to cr... | codefeedback |
You are tasked with implementing a parser for a simple programming language. The `parseImpl` function is responsible for parsing the input code and returning a boolean value indicating whether the parsing was successful or not. If the parsing fails, the function returns `false`. Your task is to design a parser for a sp... | codefeedback |
You are tasked with implementing a function that can handle multiple asynchronous requests and execute different callbacks based on the response or error of each request. The function `requestMulti` takes in an array of requests, a callback function for successful responses, and a callback function for errors. Your goa... | codefeedback |
You are tasked with implementing a custom `make_optional` function that creates an optional value from either a regular value or an `Optional` object. The `make_optional` function should be able to handle both regular values and `Optional` objects from the `com::sun::star::beans` namespace. Your task is to write the `m... | codefeedback |
You are working on a project that involves interfacing with a Java library using Rust. Your task is to implement a function that retrieves the supported SSL parameters from a Java SSL context. The Java library is accessed through the `__jni_bindgen` Rust crate, which provides bindings for interacting with Java code.
Y... | codefeedback |
You are tasked with creating a Python program to analyze facial recognition data using the `face_recognition` library. The program should read images of known and unknown individuals, compare them using facial recognition, and output the distance between the known and unknown faces.
Your program should take the follow... | codefeedback |
You are tasked with implementing a program to calculate the set A based on the given grammar G. The grammar G is defined as a tuple containing four elements: N (set of non-terminal symbols), T (set of terminal symbols), S (start symbol), and P (set of production rules). The set A is calculated as the union of the sets ... | codefeedback |
You are tasked with creating a Rust program that processes JSON data representing headers of various operations. The program should deserialize the JSON data into Rust structs and perform specific operations based on the deserialized data.
Given the following code snippet as a starting point:
```rust
#[derive(Serializ... | codefeedback |
You are working on a program that manages offers for selling goods in different cities. The code snippet provided is a part of a function that processes the chosen offers and calculates the profit from selling the goods. The `chosen_offers` list contains tuples with the following elements: `cityname`, `username`, `amou... | codefeedback |
You are tasked with implementing a Python class that manipulates and saves images. Your class should have methods to set the colorspace of the image and save the image to a specified filename. The class should also have a method to draw on the image.
You are given a code snippet that demonstrates the usage of the clas... | codefeedback |
You are working on a Swift library for handling database queries. The library provides a `QueryPredicateOperation` struct and a `Persistable` protocol for defining query predicates and values. The code snippet provided includes two methods `le` and `lt` for creating query predicates for less than or equal to and less t... | codefeedback |
You are tasked with simulating the movement of a raccoon on a grid. The raccoon can move in four directions: up, down, left, and right. The grid is represented as a 2D array, and the raccoon's initial position is at the top-left corner of the grid, with coordinates (0, 0). The raccoon's movements are represented by a s... | codefeedback |
You are tasked with implementing a rate limiter to restrict the number of attempts made by a specific IP address within a given time frame. Your task is to create a class `RateLimiter` with the following methods:
1. `void recordAttempt(String ipAddress)`: This method records an attempt made by the specified IP address... | codefeedback |
You are tasked with creating a program that simulates the behavior of the `nm` and `awk` commands in Unix-like systems. The `nm` command is used to display the symbol table of an object file, and the `awk` command is a powerful text processing tool. Your program should take an input file representing the output of the ... | codefeedback |
You are tasked with implementing a task repository system using Python and SQLAlchemy. The code snippet provided contains a test case for the repository functionality. Your task is to complete the implementation of the `RelationalTaskRepository` class and ensure that it meets the requirements specified in the test case... | codefeedback |
You are working on a software application that manages filters for tables. The application uses a `DialogFilterRow` class to represent individual filter rows, and a `ColumnTableFilter` class to represent the filter configuration for a table column. Your task is to implement a method that updates the filter configuratio... | codefeedback |
You are tasked with creating a Flask web application for a dating platform similar to Tinder. The code snippet provided initializes some essential components of the application. Your task is to implement a feature that allows users to upload and display images on their profiles.
You need to create a route that handle... | codefeedback |
You are tasked with implementing a Gerber file parser for a PCB (Printed Circuit Board) design software. Gerber files are used to describe the PCB layout, including the positions of traces, pads, and other features. Your task is to implement a class that can parse a Gerber file and extract relevant information.
You ar... | codefeedback |
You are tasked with implementing a function that processes an array of integers and returns the count of positive, negative, and zero elements in the array. However, there is a catch - the function must handle potential errors by throwing custom exceptions.
You are given the following code snippet as a starting point:... | codefeedback |
You are tasked with implementing a class to simulate the Towers of Hanoi game. The Towers of Hanoi is a classic mathematical puzzle that consists of three rods and a number of disks of different sizes, which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, ... | codefeedback |
You are working on a system administration tool that automates the setup of a chroot environment for a specific Linux distribution. The tool reads a configuration file containing mount points and then executes the necessary commands to set up the chroot environment. The configuration file follows the format:
```
<host... | codefeedback |
You are tasked with implementing a simple event listener class in C++. The class should be able to register different types of events and handle them in a specific order. Your task is to complete the implementation of the `EventListener` class by adding the necessary methods to register and handle events.
You are prov... | codefeedback |
You are given a code snippet in Swift that contains a test case for a function called `testNestedVariableBindings`. The function is testing the formatting of variable declarations in Swift code. The input to the test case is a multi-line string containing a variable declaration with nested variable bindings. Your task ... | codefeedback |
You are tasked with creating a Python program to simulate a simple network packet spoofing attack. The program should construct a spoofed packet with a spoofed source IP address, a destination IP address, source and destination ports, and a payload. The constructed packet should then be sent over the network using the ... | codefeedback |
You are tasked with implementing a Python decorator that measures the execution time of a function and prints the elapsed time in milliseconds. The decorator should be applied to any function and should not modify the behavior of the original function.
Your task is to complete the implementation of the `timer_decorato... | codefeedback |
You are tasked with implementing a C++ interface for a CPU architecture framework. The framework provides a namespace `arch` and an interface `CpuInterface` within it. Your goal is to create a concrete class that implements the `CpuInterface` and provides specific functionality for a CPU.
Your task is to create a clas... | codefeedback |
You are tasked with implementing a Python class that manages file operations. The class, `FileManager`, should have the following functionalities:
1. Opening a file for reading or writing.
2. Closing the file when it is no longer needed.
You need to implement the `FileManager` class with the following requirements:
- ... | codefeedback |
You are tasked with implementing a class reloading mechanism for a custom class loader in Java. The class loader is responsible for loading classes from a specified package, and it needs to support reloading classes when they have been modified.
Your task is to implement the `ReloadClassLoader` class, which should ext... | codefeedback |
You are working on a Vulkan graphics application and need to manage image memory barriers for efficient resource synchronization. Your task is to implement a function that takes in a set of image memory barriers and organizes them to ensure proper synchronization between different stages of the graphics pipeline.
You ... | codefeedback |
You are tasked with creating a Python program to scrape a website for song titles and then perform specific operations on the data obtained. You are given a class `WebPage` with a method `scrape()` that returns a list of song titles. Your task is to write a program that uses this class to scrape the website, process th... | codefeedback |
You are tasked with creating a custom React component called `CustomButton` that extends the functionality of the standard HTML button element. The `CustomButton` component should accept various props to customize its appearance and behavior. Your goal is to implement the `CustomButton` component and provide a usage ex... | codefeedback |
You are tasked with creating a program that can parse and extract license information from a given text. The license information is embedded within a comment block in the text and follows a specific format.
Your program should take a string as input and return the license information if found, or indicate if no licens... | codefeedback |
You are tasked with creating a Python program that utilizes the multiprocessing module to parallelize a specific task. Your program should take a list of integers as input and return the sum of the squares of these integers, calculated in parallel using a process pool.
Your program should consist of the following comp... | codefeedback |
You are tasked with creating a Python program that initializes environment settings and configuration based on command-line arguments. Your program should also handle logging configuration if specified in the environment settings.
You are provided with a code snippet that partially sets up the environment and configur... | codefeedback |
You are given a file `keylog.txt` containing a list of key sequences representing the order in which keys were pressed on a keypad. Each key sequence is a string of digits. Your task is to analyze the key sequences and determine the minimum number of unique digits required to represent all the key sequences.
Write a f... | codefeedback |
You are tasked with implementing a vehicle registration feature for a transportation service application. The application has a view model, `viewModelUnderTest`, which handles user input and submission. The view model has methods to set the first name, phone number, license plate, and rider capacity text fields. Upon s... | codefeedback |
You are tasked with implementing a function to calculate the envelope correlation of multichannel time series data. Envelope correlation is a measure of the temporal relationship between the amplitude envelopes of different signals. The input data consists of multichannel time series, and the output is a matrix represe... | codefeedback |
You are tasked with creating a program that benchmarks the performance of persistent kernels in a recurrent neural network (RNN) implementation. The code snippet provided is a compilation command for a C++ program that performs the benchmarking. The program uses the g++ compiler to compile the source file `benchmark-pe... | codefeedback |
You are tasked with creating a Python function that processes a given CSV file based on the provided parameters. The function should read the CSV file and perform specific operations based on the modes and test classes provided. The modes and test classes are used to filter and process the data in the CSV file.
You ar... | codefeedback |
You are tasked with implementing a simple disposable pattern in Swift. A disposable is an object that can be used to perform cleanup or release resources when it is no longer needed. The provided code snippet outlines a protocol `Disposable` and a class `SimpleDisposable` that conforms to this protocol.
Your task is t... | codefeedback |
You are tasked with implementing a Python class that performs residualization, a statistical technique used in regression analysis to remove the influence of certain variables on others. Your task is to create a `Residualizer` class that can be used to residualize a given dataset and a `ResidualizerEstimator` class tha... | codefeedback |
You are tasked with creating a Python class that implements a parallelized support vector machine (SVM) classifier using multiprocessing. Your task is to complete the implementation of the `ParallelSVM` class by filling in the missing parts of the `run_svc` method. The `run_svc` method is responsible for running the SV... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.