instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a simple RPC (Remote Procedure Call) framework in Java. The RPC framework should allow a client to remotely invoke methods on a server and receive the results. To achieve this, you need to create a proxy-based RPC client and a corresponding server that can handle the remote method invoc... | codefeedback |
You are tasked with implementing a Python script that handles tab completion for a custom command-line interface (CLI). The script should be able to provide completions for commands and arguments based on the user's input.
Your task is to complete the `handle_tab_complete` function, which is called when the user press... | codefeedback |
You are tasked with creating a Python program that processes a list of integers and performs specific operations on it. Your program should define a function `process_numbers` that takes a list of integers as input and returns a modified list based on the following rules:
1. If the number is even, add 10 to it.
2. If ... | codefeedback |
You are tasked with creating a Python program to read and process data from an Omron 2JCIE-BU01 environmental sensor. The sensor provides various environmental data such as temperature, humidity, light intensity, UV index, noise level, and acceleration.
Your program should perform the following tasks:
1. Connect to th... | codefeedback |
You are tasked with implementing a simple chat server using the `untwisted` library in Python. The `untwisted` library provides tools for asynchronous programming and event-driven networking.
Your task is to complete the implementation of the `ChatServer` class, which will handle incoming client connections and manage... | codefeedback |
You are tasked with implementing a custom data structure that combines the functionality of a stack and a queue. This data structure, named "StackQueue," should support the following operations:
1. `push(item)`: Add an item to the data structure.
2. `pop()`: Remove and return the most recently added item.
3. `peek()`: ... | codefeedback |
You are tasked with implementing a data structure that combines the functionality of a heap and a hash table. The data structure should support the following operations:
1. `insert(key, value)`: Insert a key-value pair into the data structure.
2. `remove(key)`: Remove the key-value pair with the specified key from the... | codefeedback |
You are tasked with implementing a configuration management system for a Windows Forms application. The system should allow the application to set various properties of the form, such as whether it can be maximized, minimized, resized, or displayed as a tool window. Additionally, the system should provide a way to set ... | codefeedback |
You are tasked with implementing a function that processes a complex data structure and returns a specific value based on certain conditions. The data structure consists of nested optional fields and requires careful unwrapping and manipulation to obtain the desired result.
You are given a Rust code snippet that demon... | codefeedback |
You are tasked with implementing a function that calculates the area of a polygon given its vertices. The vertices are represented as a list of (x, y) coordinates in the 2D plane. The area of a polygon can be calculated using the shoelace formula, which states that the area is half the absolute value of the difference ... | codefeedback |
You are tasked with simulating a simplified version of a producer-consumer problem using Python. The producer will continuously generate data and push it into a shared buffer, while the consumer will retrieve and process the data from the buffer. Your task is to implement the producer and consumer classes, ensuring tha... | codefeedback |
You are tasked with implementing a simplified version control system for a software project. The system will track dependencies between different components and manage the operations required to update these components.
You are given a Python code snippet representing a simplified version of a migration file in a Djan... | codefeedback |
You are tasked with implementing a file system data structure in Rust. The file system is represented using a struct `FileSystem` with various fields and methods. One of the methods in the `FileSystem` struct is shown below:
```rust
impl FileSystem {
fn read_file(&self, ino: u64) -> Result<Vec<u8>, Error> {
... | codefeedback |
You are tasked with implementing a program to solve the "Ticket Translation" problem. In this problem, you are given a set of rules for valid fields on a ticket, as well as a list of nearby tickets with their field values. Your goal is to determine the correct order of fields on the ticket.
The rules are represented a... | codefeedback |
You are tasked with implementing a simplified version of a library for handling system processes. The library, named `slib`, provides a function `spx()` that is used to execute a system process and return its exit status. Additionally, the library provides an `exit()` function to terminate the current process with a gi... | codefeedback |
You are tasked with implementing a function that converts a given OpenGL pixel format to its corresponding size in bytes. The pixel format is represented by a pair of values: the first value is an OpenGL constant representing the pixel format, and the second value is a custom `PixelType` object representing the number ... | codefeedback |
You are tasked with creating a React component that displays a forum. The forum component should be designed to render the forum interface and handle user interactions. Your task is to implement the `Forum` component with the following requirements:
1. The `Forum` component should render a list of discussion threads.
... | codefeedback |
You are tasked with creating a script to manage the startup of a local emulator for Google Cloud Datastore. The script should handle the configuration of the emulator based on certain conditions.
You are given a code snippet from an existing script that starts the emulator. The script checks the value of the `FULL_MEM... | codefeedback |
You are tasked with creating a Python class that generates and manages job configurations for different data processing tasks. The class should allow users to specify command arguments, SQL scripts, and properties for the job. Additionally, the class should provide a method to assert the equality of two job configurati... | codefeedback |
You are tasked with simulating a temperature sensor and a modem for sending temperature data to a server. The provided code snippet is a simplified version of a program that attempts to join a modem network and then continuously sends temperature data to a server using the modem. Your task is to implement the simulatio... | codefeedback |
You are tasked with creating a role-based access control system for a web application. Your goal is to implement a middleware function that will handle incoming requests and ensure that the user making the request has the necessary roles and permissions to access the requested resource.
You are provided with a code sn... | codefeedback |
You are given a snippet of code that appears to be incomplete. Your task is to complete the code by implementing a specific functionality. The code snippet is part of a Java program that aims to create a class representing a geometric shape. The class should have methods to calculate the area and perimeter of the shape... | codefeedback |
You are tasked with creating a script for a 2D game where clouds are dynamically resized based on their position and a size multiplier. The clouds are represented as GameObjects with associated sprites. The initial size of the cloud is modified by the `sizemultiplier` and the cloud's position. Additionally, the clouds ... | codefeedback |
You are tasked with implementing a simple stack data structure in Python. A stack is a Last-In-First-Out (LIFO) data structure that supports two main operations: push, which adds an element to the top of the stack, and pop, which removes the top element from the stack. Additionally, you need to implement a method to re... | codefeedback |
You are tasked with implementing a program that simulates a simple banking system. The program should allow users to create accounts, deposit and withdraw funds, and check their balance. Each account should have a unique account number and be associated with the user's name. The program should also be able to display a... | codefeedback |
You are working on a secret message encryption program. The program takes a message as input and encrypts it using a simple algorithm. The algorithm iterates through each character in the message in reverse order, increments its ASCII value by 1, and then concatenates the resulting characters to form the encrypted mess... | codefeedback |
You are tasked with creating a custom class in PHP that extends the `Illuminate\Database\Eloquent\Collection` class and adds functionality to filter and manipulate a collection of `Carbon` objects. The `Carbon` class is a popular date and time manipulation library in PHP.
Your task is to create a new class called `Cus... | codefeedback |
You are tasked with implementing a custom test case class for a unit testing framework. The class should include a method to calculate the average of an array of integers and a corresponding test method to verify the correctness of the average calculation.
Your task is to complete the implementation of the `CustomTest... | codefeedback |
You are tasked with creating a custom management command in a Django application. The command should accept two optional arguments: `--database` to specify the name of the database and `--plan` as a flag to indicate a specific action. The `--database` argument should default to `DEFAULT_DB_ALIAS` if not provided. Your ... | codefeedback |
You are tasked with implementing a function to encrypt a given message using a custom cryptographic algorithm. The algorithm is provided through a `crypto_wrapper` library, and the necessary configurations are defined in the `configurations.h` file. Additionally, some external constants are included from the `extern_co... | codefeedback |
You are given a function `longestPalindrome` that takes a string `s` as input and returns the longest palindromic substring within the string. A palindromic string is one that reads the same backward as forward. The function is implemented using the following code snippet:
```python
def longestPalindrome(s: str) -> st... | codefeedback |
You are tasked with implementing a Python metaclass that enforces a specific naming convention for class attributes. The metaclass should ensure that any attribute name starting with "attr_" must be in all uppercase letters. Any attempt to define an attribute violating this convention should raise a custom exception.
... | codefeedback |
You are tasked with implementing a Python function that calculates the total number of unique paths to reach the bottom-right corner of a grid from the top-left corner. You can only move either down or to the right at any point in time. The grid is represented as a 2D list where 1 indicates an obstacle and 0 indicates ... | codefeedback |
You are tasked with creating a script to automate the execution of smoketests for a software application. The script should iterate through a list of files, display their contents, and then indicate the completion of the smoketests. The script should also terminate immediately if any command within it fails.
You are p... | codefeedback |
You are tasked with implementing a Python class that simulates a multicast data transmission system. The provided code snippet serves as a starting point for your implementation. Your task is to complete the implementation of the `Multicast_transceiver` class and the `detuple` function based on the given code snippet a... | codefeedback |
You are tasked with creating a program that processes a list of Git repository URLs and performs specific operations on them. Each repository URL is in the format `https://github.com/{owner}/{repository_name}.git`. Your program needs to extract the owner's login and the repository name from the URL and then clone the r... | codefeedback |
You are given a series of assembly-like instructions that operate on different types of data. Each instruction is represented by a mnemonic followed by the source and destination operands. The operands are represented by their data type (e.g., r for register, a for array, f for float, etc.) and an index.
The mnemonics... | codefeedback |
You are tasked with implementing a program to simulate an actor's movement within a 2D grid. The actor should not be allowed to exit the boundaries of the grid. The grid is represented as a 2D array, and the actor's movement is controlled by a sequence of commands. Each command corresponds to a movement direction: "U" ... | codefeedback |
You are tasked with implementing a Python class to manage user profiles and their associated stories and favorite authors. The class should have methods to retrieve stories and favorite authors from a web page, as well as a method to generate a JSON dump of the user profile data.
You are provided with a code snippet t... | codefeedback |
You are working on a blog application that uses Spring Data JPA for data access. The code snippet provided is a part of the application's data access layer. The `ArticleRepository` interface extends the `JpaRepository` interface, which provides CRUD (Create, Read, Update, Delete) operations for the `Article` entity. Ad... | codefeedback |
You are tasked with creating a custom validation system for a web application. The system should handle various validation rules and provide custom error messages for specific cases. Your task is to implement a class that can handle these validation rules and error messages.
You are given a partial code snippet from a... | codefeedback |
You are tasked with implementing a Luhn algorithm validator for credit card numbers. The Luhn algorithm is used to validate a variety of identification numbers, such as credit card numbers, IMEI numbers, National Provider Identifier numbers, and Canadian Social Insurance Numbers. The algorithm is designed to prevent ac... | codefeedback |
You are tasked with creating a Swift function that calculates the area of a custom UIView shape and then applies a drop shadow effect to the view based on the calculated area.
You are given the following code snippet as a starting point:
```swift
extension UIView {
func dropShadow(scale: Bool = true) {
la... | codefeedback |
You are tasked with implementing a machine learning model class that includes a prediction method. The given code snippet is a part of the `predict` method of this class. The method takes a feature matrix `X` as input and returns the predictions based on whether the model is trained and whether it is a one-class classi... | codefeedback |
You are tasked with implementing a function to calculate the multi-class Area Under the Curve (AUC) for a given set of target labels and corresponding model output probabilities. The AUC is a widely used metric for evaluating the performance of classification models. In this problem, you will need to write a Python fun... | codefeedback |
You are tasked with implementing a class hierarchy for a role-playing game character system. The system should support different character classes, each with its own unique abilities and attributes. Your task is to design and implement the necessary classes and interfaces to support this system.
You are provided with ... | codefeedback |
You are tasked with implementing a function to parse a given `res_body` dictionary and extract specific information related to a job step. The `res_body` dictionary contains details about a job step, including its name, ID, type, action on failure, properties, and status. The properties further include information such... | codefeedback |
You are tasked with creating a Python function that renames files with a specific extension. Your function should take in a directory path, the current file extension, and the new file extension as input. It should then rename all files in the directory with the current file extension to the new file extension.
Your f... | codefeedback |
You are given a partial implementation of a graph data structure in C. The code snippet provided includes the definition of a graph vertex and some related data structures. Your task is to complete the implementation of a function that checks whether a given graph is cyclic or acyclic.
You need to implement the follow... | codefeedback |
You are tasked with implementing a circular buffer class in C++. A circular buffer is a data structure that uses a single, fixed-size buffer as if it were connected end-to-end. When the buffer is full and a new element is inserted, it overwrites the oldest element in the buffer. Your task is to complete the implementat... | codefeedback |
You are tasked with creating a function that simulates a simple vending machine. The vending machine will have a set of available items with corresponding prices. Users can insert coins into the machine and make a selection. The machine should dispense the selected item if the user has inserted enough money. If the use... | codefeedback |
You are tasked with implementing a custom type checker in Swift that mimics the behavior of the `as!` type cast operator. The `as!` operator performs a forced type cast, which attempts to convert an instance of a class or a value of a non-class type to a specified type. If the cast fails, a runtime error occurs. Your t... | codefeedback |
You are tasked with creating a Python class that can parse and instantiate FHIR (Fast Healthcare Interoperability Resources) resources from JSON files. FHIR is a standard for exchanging healthcare information electronically. Your task is to implement a class that can read a JSON file containing a FHIR resource, validat... | codefeedback |
You are tasked with implementing a Python context manager that logs the start and end of an activity using the `absl.logging` module. The context manager should handle any exceptions raised within the activity and log them as exceptions. Your task is to complete the implementation of the `log_activity` context manager ... | codefeedback |
You are working on a project that involves processing data from multiple cameras. The code snippet provided is a part of a larger program that processes camera calibration data. The snippet contains a class method that processes camera calibration information and performs some calculations using NumPy.
Your task is to... | codefeedback |
You are tasked with creating a program to parse and extract specific information from an API response. The response is in JSON format and contains two main sections: "meta" and "headers". The "meta" section includes a key-value pair with the key "total" and an integer value. The "headers" section includes several key-v... | codefeedback |
You are tasked with implementing a function to convert a hexadecimal string to an array of unsigned 8-bit integers (u8). The function should take a hexadecimal string as input and return a vector of u8 values representing the hexadecimal bytes.
You need to implement the following function:
```rust
/// Converts a hexad... | codefeedback |
You are tasked with implementing a simple user management system using Python. The system should allow for the creation of user profiles and the association of contexts with each user. A context is a specific setting or environment that can be linked to a user profile. Your task is to create a class `UserManagementSyst... | codefeedback |
You are tasked with creating a simplified version of a threading manager for executing functions in separate threads. Your goal is to implement a function that can run a given function in a new thread. You should also create a class that represents a simplified version of a social media platform, VK (Vkontakte), and im... | codefeedback |
You are tasked with creating a function that parses a given HTML string and extracts the URLs of all the images present in the string. The HTML string will contain image tags in the format `<img src='url' ...>` where `url` is the URL of the image. The function should return a list of all the image URLs present in the H... | codefeedback |
You are working on a project that involves managing a database schema using Alembic, a database migration tool for SQLAlchemy. Your task is to create a new migration script that adds a new table to the existing database schema. The table should store information about different services and their associated quotas.
Yo... | codefeedback |
You are tasked with implementing a custom serialization mechanism for a specific data structure. The data structure represents a binary tree node, where each node has a value and references to its left and right children. Your goal is to write a serialization and deserialization algorithm for this binary tree node stru... | codefeedback |
You are tasked with creating a program to analyze Verilog files and extract specific information from them. Your program needs to read Verilog files, identify LFSR (Linear Feedback Shift Register) modules, and extract the size of each LFSR module found in the files.
Your task is to implement a function that takes a li... | codefeedback |
You are tasked with creating a Python function that processes a given CSV file and returns the average value of a specific column. The CSV file contains data related to the sales of various products. The function should take the file path and the column name as input and return the average value of the specified column... | codefeedback |
You are given a Python function `where(condition, x, y)` that takes in three arguments:
- `condition`: a boolean array represented as a Chainer variable
- `x`: an array of values
- `y`: an array of values
The function `where` chooses elements from `x` or `y` depending on the values of the `condition`. If the `conditio... | codefeedback |
You are tasked with implementing a constraint system for validating input data in a web application. The system should support constraints for minimum and maximum length, as well as minimum value for numerical inputs. You are provided with a code snippet that outlines the constants for these constraints, but it seems t... | codefeedback |
You are tasked with implementing a clustering algorithm to group data points into homogeneous clusters based on local connectivity. The given code snippet initializes data points and provides some context about creating a graph capturing local connectivity. Your task is to complete the implementation by writing a funct... | codefeedback |
You are given a Python code snippet that uses a prime number sieve function to find a specific value based on prime numbers. Your task is to understand the code and implement a similar prime number sieve function to solve a related problem.
Write a Python function `find_special_value(limit)` that takes an integer `lim... | codefeedback |
You are tasked with implementing a function that creates a subgraph based on a set of intrinsics, rules, and subject types. The function should take in the intrinsics, rules, subject types, and other relevant parameters, and construct a subgraph based on these inputs. Additionally, the function should include a specifi... | codefeedback |
You are tasked with implementing a simulation of a repeller object in a 2D grid. The repeller object is represented by the following code snippet:
```csharp
public class Repeller
{
public Repeller(int repellerRadius, int repelPower)
{
this.RepellerRadius = repellerRadius;
this.RepelPower = repe... | codefeedback |
You are tasked with creating a Rust function that interacts with an HTTP API to retrieve air quality data for multiple cities. The function should utilize the `RParifClient` struct, which is designed for making multiple calls to the API. The function should take an API key and a list of INSEE city codes as input. The I... | codefeedback |
You are tasked with creating a Python program that reads a directory path from the user and then lists all the files and subdirectories within that directory. Additionally, the program should display the total size of all the files in the directory in bytes.
Your program should prompt the user to input a directory pat... | codefeedback |
You are tasked with creating a Python function to scrape and extract specific bio stats of a Dota 2 hero from the official Dota 2 website. The function should take the hero's name as input and return their bio stats.
The bio stats are located within the HTML of the hero's page on the Dota 2 website. The function shoul... | codefeedback |
You are tasked with creating a program that can efficiently install a list of software packages on a Linux system. The program should be able to handle both individual package installations and bulk installations.
Your task is to implement a function that takes a list of software packages as input and installs them us... | codefeedback |
You are tasked with creating a script to automate the testing of Docker images using Bats (Bash Automated Testing System). Your script should include the necessary setup and testing steps to ensure the successful building of a standard Docker image.
Given the provided code snippet as a starting point, you need to expa... | codefeedback |
You are given a C++ code snippet that defines two template structs: `index_impl` and `contains_impl`. The `index_impl` struct is used to find the index of a given type `T` within a template sequence `seq`. The `contains_impl` struct is used to determine if a given type `T` is present within a template sequence `seq`. Y... | codefeedback |
You are working on a project that involves running a series of commands to fit models and create trajectories. Each command in the `commands.txt` file consists of two parts: model fitting and trajectory creation. The commands need to be executed in sequence, but each command can be executed independently and in paralle... | codefeedback |
You are tasked with implementing a Python class that denies access based on the content of a specified key in the input arguments. Your task is to complete the implementation of the `args_key_is_empty_or_allowed` class by adding a method that checks if the specified key in the input arguments is either empty or contain... | codefeedback |
You are tasked with creating a program that simulates a simple banking system. The system should be able to create bank accounts, deposit and withdraw funds, and provide the account balance. Additionally, the program should be able to transfer funds between two accounts.
Create a class `BankAccount` with the following... | codefeedback |
You are tasked with implementing a Python class that manages file content and related information in a GitHub repository. The class should have the following attributes and methods:
Attributes:
- `file_commit_sha`: A string representing the commit SHA of the file.
- `content`: A string representing the content of the ... | codefeedback |
You are working on implementing a variant of the AdaGrad optimization algorithm for training a machine learning model. The given code snippet is a part of the update step in the algorithm. Your task is to complete the implementation of the AdaGrad optimizer by writing a function that takes in the current parameters, gr... | codefeedback |
You are working on a machine learning project and need to implement a custom loss function for a neural network. The loss function involves calculating the Hessian matrix of the network's output with respect to its parameters. You decide to use PyTorch to efficiently compute the Hessian matrix. The code snippet provide... | codefeedback |
You are tasked with implementing a C++ template metaprogramming problem to determine and print prime numbers. Your goal is to complete the implementation of the `PrimeNumberPrinter` class template, which will print all prime numbers up to a given number.
The provided code snippet contains a partial implementation of t... | codefeedback |
You are tasked with implementing a function that removes the last element from a singly linked list and returns the removed element. The linked list is represented using the following Node class:
```python
class Node:
def __init__(self, value):
self.value = value
self.next = None
```
You need to i... | codefeedback |
You are tasked with creating a Python program to simulate a network port scanning tool. The program should generate a specified number of random UDP port numbers within a given range and attempt to send a single UDP packet to each port using the `hping3` tool. The goal is to identify open ports by observing the respons... | codefeedback |
You are tasked with creating a custom test case class for a PHP application using the Orchestra Testbench library. The Orchestra Testbench library is commonly used for testing Laravel packages, and it provides a TestCase class that can be extended to create custom test cases. Your goal is to create a custom test case c... | codefeedback |
You are tasked with implementing a class method that processes data from a file and updates compound objects with specific properties. The provided code snippet is a part of a larger program and demonstrates the processing of data entries to attach a property called "dG" to compound objects. The `data` variable is an i... | codefeedback |
You are tasked with implementing a class for handling chat messages in a messaging application. The provided code snippet is a part of the CChat class, which contains member functions for initializing and converting chat messages to a string representation. Your task is to complete the implementation of the CChat class... | codefeedback |
You are tasked with creating a Python function that processes data from a music forum and generates a JSON file containing information about the forum topics and their corresponding responses. The function should take a list of topic dictionaries as input, where each dictionary represents a forum topic and contains the... | codefeedback |
You are tasked with creating a program that simulates a simple text-based adventure game. The game will involve navigating through different rooms, encountering obstacles, and making decisions that affect the outcome of the game.
Your task is to implement the `parse_input_arguments` function, which takes user input an... | codefeedback |
You are tasked with creating a script to automate the preprocessing and optimization of language model data using the SRILM toolkit. The script should handle the preparation of data, including text processing and vocabulary creation, as well as the optimization of language model parameters.
Your task is to write a Bas... | codefeedback |
You are tasked with implementing a program to extract and count the occurrences of specific namespaces in a given C++ header file. The namespaces are defined using the `namespace` keyword in C++. Your program should read the header file and output the count of each unique namespace present in the file.
For example, gi... | codefeedback |
You are tasked with implementing a function that validates a given subnet mask and returns the length of the prefix if the mask is valid. A subnet mask is a 32-bit number that consists of a series of contiguous 1s followed by a series of contiguous 0s. For example, 255.255.255.0 can be represented as 11111111.11111111.... | codefeedback |
You are tasked with creating a Swift function to handle authentication requests using OAuth 2.0. The function should construct an HTTP request, send it to the token endpoint, and handle the response. You are provided with a code snippet that sets up the request and initiates a data task to handle the response.
Your ta... | codefeedback |
You are tasked with creating a TypeScript interface for a set of Material Design Icons (MDI) used in a web application. The MDI icons are represented as React components and are imported from a library. Your goal is to define an interface that enforces the correct usage of these icons throughout the application.
Given... | codefeedback |
You are tasked with creating a program that analyzes the license information of software packages. The license information is provided in the form of a multi-line string, and your program needs to extract and display the license details.
The license information is structured as follows:
- The license text is enclosed ... | codefeedback |
You are tasked with implementing a binary search tree (BST) in Python. A binary search tree is a data structure that satisfies the binary search property: for each node `n`, all nodes in the left subtree of `n` have values less than `n`, and all nodes in the right subtree of `n` have values greater than `n`.
Your task... | codefeedback |
You are given a function `strRev` that takes a string `str` as input and reverses the order of words in the string. The function should return a new string with the words in reverse order, while maintaining the order of characters within each word. The input string `str` will consist of alphabets, spaces, and punctuati... | codefeedback |
You are tasked with creating a Python extension module that interfaces with the Festival speech synthesis system. Festival is a general multi-lingual speech synthesis system developed at the Centre for Speech Technology Research at the University of Edinburgh. The given code snippet is a part of a setup script for buil... | codefeedback |
You are tasked with creating a Python function that takes a list of integers as input and returns a dictionary containing the frequency of each unique integer in the input list.
The function should be named `calculate_frequency` and should take a single parameter:
- `input_list`: a list of integers (1 <= length <= 10^... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.