instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with creating a program that processes a given Blade template and extracts the content within the `@section('body')` directive. Blade is a templating engine used in the Laravel PHP framework. The content within the `@section('body')` directive represents the main body of a web page and is enclosed within...
codefeedback
You are tasked with creating a command-line interface (CLI) parser for a Python program. The provided code snippet demonstrates the initial steps of setting up the parser and handling the command-line arguments. Your task is to extend this functionality by implementing a function that processes the parsed arguments and...
codefeedback
You are tasked with creating a script that automates the process of starting a Node.js application using npm. Your script should handle any errors that may occur during the execution of the npm command and provide appropriate feedback to the user. Write a Node.js script that performs the following steps: 1. Executes t...
codefeedback
You are tasked with implementing a virtual machine (VM) compiler that translates a high-level programming language into bytecode for a custom VM. The VM supports a set of instructions and has a specific memory layout. Your goal is to write a function that takes a list of high-level instructions and generates the corres...
codefeedback
You are tasked with implementing a custom file reader class in Python. The class should be able to read a file and provide methods for reading the file content in different ways. Your task is to create a Python class called `CustomFileReader` with the following specifications: 1. The class should have a constructor th...
codefeedback
You are tasked with implementing a custom data processing class in Python for a machine learning project. The class should take a dictionary of features as input and return a dictionary of processed features as output. Your task is to complete the implementation of the `__call__` method in the class. You are given the...
codefeedback
You are tasked with implementing a file storage system that stores entities in separate files, while ensuring unique identifiers for each entity. You are provided with a C++ class `SeparateFileStorage` that inherits from `Storage` and `IDGenerator`. The class has private members `dirPath_`, `entityIDs_`, and `nextID_`,...
codefeedback
You are tasked with creating a script to automate the management of a specific process on a Linux system. The script should be able to identify and terminate a running process based on certain conditions. Your script should perform the following steps: 1. Use the `ps` command to list all running processes and filter t...
codefeedback
You are tasked with implementing an LRU (Least Recently Used) cache, which is a data structure that stores a fixed number of items and evicts the least recently used item when the cache reaches its limit. Your goal is to create a class `LRUCache` that supports the following operations: 1. `LRUCache(int capacity)`: Init...
codefeedback
You are tasked with implementing a thread-safe work queue in C++ using the given code snippet as a starting point. The provided code snippet contains a partial implementation of a class that manages a queue of work items. Your task is to complete the implementation of the class by adding the necessary member functions ...
codefeedback
You are working on a research project that involves running multiple trials of a Markov Chain Monte Carlo (MCMC) simulation. The goal is to estimate certain parameters using the MCMC method. You have a set of data points represented by the variable `Ms`, and you want to perform the MCMC simulation for different values ...
codefeedback
You are tasked with implementing a custom button class in Python. The class should have specific properties and handle the initialization of these properties. Your task is to complete the implementation of the `Button` class by filling in the missing parts of the code. The `Button` class has the following requirements...
codefeedback
You are tasked with creating a Python function that processes a list of tweets and returns the top N most frequently used words in the tweets. You should use the NLTK library to tokenize the tweets and remove stop words. The function should take two parameters: the list of tweets and the value of N, and should return a...
codefeedback
You are tasked with creating a class that represents an AWS CloudFormation resource for managing triggers in IoT Analytics datasets. Your task is to implement a method within the `Trigger` class that converts an instance of the class into a JSON representation using the Newtonsoft.Json library. The JSON representation ...
codefeedback
You are tasked with implementing a function to plot a 3D mesh using the matplotlib library in Python. The function `plot_mesh_general` takes a file path as input and is expected to read the topology data from the file, then create a 3D plot of the mesh using the obtained topology data. The `get_topology` function is a...
codefeedback
You are tasked with implementing a function that performs a topological sort on a directed graph represented as an adjacency list. The graph consists of nodes labeled from 0 to n-1, where n is the number of nodes. Your function should return a list of nodes in topological order. If the input graph is not a directed acy...
codefeedback
You are tasked with implementing a function to parse and process a series of 2D polygons from a given input file. The input file contains a list of vertices for each polygon, with each vertex represented by its x and y coordinates. The file format is as follows: - The first line contains an integer N, representing the ...
codefeedback
You are tasked with implementing a function to initialize and populate a 2D array based on the given code snippet. The function should take in the following parameters: - `atom` : a structure containing information about atom types - `nq` : a structure containing information about neighbor lists - `memory` : a memory m...
codefeedback
You are given a C# program that processes an array of integers and calculates the sum of specific values. Your task is to understand the given code and complete the missing part to achieve the desired output. The given code snippet is part of a C# program that processes an array of integers. The missing part of the co...
codefeedback
You are tasked with implementing a Python class that extends a base class and overrides a method to compute a specific expression. Your task is to complete the implementation of the `computeExpression` method in the `ExpressionBuiltinDir1` class. The `computeExpression` method takes a `trace_collection` parameter and s...
codefeedback
You are tasked with implementing a class that handles accepting invitations from a cloud service. The class `AcceptInvitationTask` is responsible for processing the acceptance of invitations and communicating with the cloud service. The `doInBackground` method is part of an asynchronous task and is used to perform back...
codefeedback
You are tasked with implementing a Python class that represents a locator for a geographical location. The locator should have attributes for latitude and longitude, and it should provide a method to calculate the distance between two locators using the Haversine formula. Your task is to complete the implementation of...
codefeedback
You are tasked with implementing a user authentication system using Python and the Marshmallow library for data serialization. Your goal is to create two classes, `CreateUserSchema` and `UpdateUserSchema`, which will be used to define the schema for creating and updating user data, respectively. The `CreateUserSchema`...
codefeedback
You are given a Python class `Particle` with the following attributes and methods: Attributes: - `n_levels()`: Returns the number of energy levels of the particle. - `t()`: Returns the time of the particle. - `z()`: Returns the position of the particle. You need to implement a method `check_energy_levels()` that init...
codefeedback
You are tasked with implementing a role-based access control system for a web application. The system should restrict access to certain URLs based on the roles of the users. You are given a code snippet that demonstrates how the access control system should be tested. The code snippet shows the usage of an `assert_res...
codefeedback
You are working on a Rust compiler and are tasked with implementing a new feature related to evaluating predicate obligations. In the code snippet provided, there are two methods defined within a Rust trait implementation. The methods are used to evaluate whether a given predicate obligation can be satisfied in a given...
codefeedback
You are tasked with implementing a simplified version of a key-reading module for a liquid crystal display (LCD) controller. The LCD controller is interfaced with a microcontroller, and the key-reading module is responsible for reading input from a keypad and transmitting the corresponding key information to the LCD co...
codefeedback
You are tasked with creating a Python function that simulates a simple game scenario. The game involves a player navigating through a maze using a virtual robot. The robot can move in four directions: up, down, left, and right. The maze is represented as a 2D grid, where the robot's current position is denoted by 'R', ...
codefeedback
You are tasked with creating a Python class for solving chemical equilibrium systems using the MINPACK solver. The MINPACK solver is initialized with specific parameters and settings. Your task is to implement the class and its methods to handle chemical equilibrium calculations. Your class should include the followin...
codefeedback
You are tasked with implementing a feature for a contact form management system. The system has a `ContactUsController` with a `destroy` method responsible for deleting a contact form entry from the database. The method uses the `ContactUs` model to perform the deletion and then redirects the user to the index page wit...
codefeedback
You are tasked with implementing a class that manages the storage and retrieval of events in a stream using PHP. The class, named `EventStreamManager`, has a constructor that takes two parameters: a `Client` object from the Predis library and a `Serializer` object. The `Client` object represents a connection to a Redis...
codefeedback
You are tasked with implementing a game-saving feature for a 2D adventure game. The game consists of a player character navigating through various zones, defeating enemies, collecting items, and interacting with objects such as chests. The goal is to create a function that saves the game state, including the player's p...
codefeedback
You are tasked with creating a SwiftUI application that tracks the number of commits made when editing a text field and displays the current text input along with the focus state of another text field. Your application should consist of the following components: 1. Two `TextField` views: - The first `TextField` sho...
codefeedback
You are given a binary tree represented by a class `TreeNode` with the following structure: ``` class TreeNode { int val; TreeNode left; TreeNode right; TreeNode(int x) { val = x; } } ``` The `val` field represents the value of the node, and the `left` and `right` fields represent the left and right chi...
codefeedback
You are working on a computer graphics project and need to implement a function that processes color and direction data using PyTorch. The function takes in two parameters: `color_directional` and `direction`. The `color_directional` parameter represents the color information for directional light, and the `direction` ...
codefeedback
You are tasked with creating a dependency resolution algorithm for a package manager. The package manager needs to resolve dependencies for targets within a package, considering both internal and external dependencies. Each target within a package can depend on other targets within the same package, as well as on prod...
codefeedback
You are tasked with implementing a function to measure the quality of seeds in an agricultural environment. The function should take into account the good and bad seeds present and produce a measurement based on specific criteria. You are given the following information: - `bad_seeds_01_env` is an object representing ...
codefeedback
You are working on a project that involves interacting with Xcode build settings and extracting specific information from the build configuration. Your task is to implement a function that parses the build settings output and extracts the debug directory for a given module. You are provided with a code snippet that de...
codefeedback
You are tasked with creating a custom annotation processor for a Java application. The application uses a framework that requires entities to be annotated with a specific table name for database mapping. Your goal is to implement a processor that will validate and process these annotations to ensure they adhere to the ...
codefeedback
You are tasked with creating a command-line utility that processes a series of command-line arguments to perform various operations on a given file. The utility should support the following options: - `-ander`: This option specifies a specific operation to be performed by the utility. - `-print-pts`: This option indic...
codefeedback
You are tasked with creating a program to manage the placement of windows on a computer screen. The screen is represented as a 2D grid, and each window is represented by a rectangular area on this grid. Your program should be able to handle the placement of windows, check for overlapping areas, and provide information ...
codefeedback
You are tasked with creating a Python function that simulates a simplified version of the `import` mechanism. Your function should take a module name, a module specification, and a loader as input, and return the imported module. The function signature should be: ```python def custom_import(name, spec, loader): # ...
codefeedback
You are tasked with creating a command-line utility that processes YAML files and performs specific operations based on user input. The utility should support setting, updating, and deleting YAML properties. Your task is to implement the logic for processing the user's commands and modifying the YAML file accordingly. ...
codefeedback
You are given a 2D matrix of integers and an integer k. Your task is to find the maximum sum of a submatrix that is less than or equal to k. You need to implement the function `max_sum_submatrix` that takes in the following parameters: - A reference to a 2D vector `matrix` of integers, representing the input matrix. -...
codefeedback
You are given a function `hamming(n)` that returns the nth number in the Hamming sequence. The Hamming sequence is a set of numbers in ascending order that only have 2, 3, or 5 as prime factors. The first few numbers in the Hamming sequence are 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, and so on. The given c...
codefeedback
You are working on a data visualization project and need to create a Python function to generate a composite spectral energy distribution (SED) plot. The SED plot should display the normalized flux ($\lambda$ F$_\lambda$) against the rest wavelength ($\AA$). You have been provided with a code snippet that sets the y-ax...
codefeedback
You are tasked with implementing a ViewModel class for a mobile app using the RxSwift framework. The ViewModel will be responsible for fetching and processing data from a remote source and providing it to the UI components. Your task is to complete the implementation of the ViewModel class by adding the necessary meth...
codefeedback
You are tasked with creating a program that simulates a simple terminal multiplexer. A terminal multiplexer is a software application that enables multiple terminals to be accessed and controlled from a single terminal. Your program should allow users to create, switch between, and manage multiple virtual terminals wit...
codefeedback
You are tasked with implementing a simplified version of the ChaCha encryption algorithm in Rust. The ChaCha algorithm is a symmetric encryption algorithm designed to provide high security and performance. Your task is to implement the core functionality of the ChaCha algorithm, including the key setup and encryption p...
codefeedback
You are working on a database migration script using Alembic, a popular database migration tool for SQLAlchemy. Your task is to write a migration script that modifies the database schema by dropping a column from a table and altering the data type of another column. Given the provided code snippet, you need to complet...
codefeedback
You are tasked with implementing a simple inter-process communication (IPC) mechanism using Python. Your goal is to create a program that utilizes the `os.pipe()` function to establish a unidirectional communication channel between a parent process and a child process. The parent process will write a message to the chi...
codefeedback
You are tasked with creating a Python program that will recursively search for all files with a specific file extension within a given directory and its subdirectories. Your program should measure the time taken to perform the search and display the total number of files found. You are provided with a code snippet tha...
codefeedback
You are tasked with implementing a Python function that simulates a simple HTTP client for making requests to a server. The client is expected to handle various HTTP status codes and raise appropriate exceptions based on the received status codes. Your goal is to create a function that can be used to test the behavior ...
codefeedback
You are tasked with implementing a class for handling dynamic link libraries (DLLs) in C++. The class, `dll::Handler`, is responsible for managing the loading and unloading of DLLs. The given code snippet shows a move assignment operator and a constructor for the `dll::Handler` class. Your task is to complete the impl...
codefeedback
You are tasked with creating a Python class that manages SSH keys for cloud services. Your class should be able to generate, update, and store SSH keys in a database. Additionally, it should provide a debugging feature to display verbose information during key management operations. Create a Python class `SSHKeyManage...
codefeedback
You are tasked with creating a memory management system for a file-backed memory mapping in Rust. Your goal is to implement a custom drop behavior for a wrapper struct that manages the memory mapping. The provided code snippet shows the implementation of the `Drop` trait for the `FileBackedMemoryDropWrapper` struct. Th...
codefeedback
You are tasked with implementing a Python class for training a signal convolutional neural network (SigCNN) using the given code snippet as a reference. The class should handle the initialization of hyperparameters, the initialization of the Weights and Biases (wandb) project, and the training of the SigCNN model. You...
codefeedback
You are tasked with creating a script to automate the deployment process for a Node.js application. The deployment process involves restarting the Nginx server, navigating to the application folder, installing dependencies using npm, and starting the Node.js application using pm2 with environment variables updated. Yo...
codefeedback
You are tasked with implementing an iterator pattern for a custom collection class in Java. The iterator pattern provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation. Your task is to create the necessary classes to support this pattern and demonstrate ...
codefeedback
You are working on a project that involves manipulating and querying graph data. Your task is to implement a method that sets variables based on a given map of values and a field name. The method should use reflection to access and modify the private fields of a Query object. You are given a partial code snippet that ...
codefeedback
You are tasked with creating a program to manage work shifts for a company. The company has two teams, one for the day shift and the other for the night shift. Each shift lasts for 12 hours. Your task is to implement a class `WorkSchedule` and its associated methods to facilitate the management of shifts. Your program...
codefeedback
You are tasked with creating a program that simulates a simple text-based adventure game. The game will involve the player making choices that lead to different outcomes. The player will navigate through a series of rooms, each with its own set of choices and consequences. The goal is to reach the final room and achiev...
codefeedback
You are tasked with creating a program to analyze and visualize user access data for a web application. The program should read a dataset containing user access information and generate a bar chart to display the number of users accessing the application on each day. The dataset is in the following format: ``` Date, U...
codefeedback
You are working on a firmware for a data acquisition system that includes multiple channels for reading analog signals. The system has a function `conv_settling_time` that calculates the settling time for a given channel. The settling time is the time required for the analog-to-digital converter to stabilize after a ne...
codefeedback
You are tasked with implementing a base64 encoding and decoding algorithm. Base64 encoding is a method of encoding binary data into ASCII text format. The encoding process involves taking a sequence of bytes and converting it into a sequence of printable ASCII characters. The decoding process reverses this operation, c...
codefeedback
You are tasked with creating a macro in Rust that takes a given input and generates a string representation of the input. The macro should be able to handle various types of input, including integers, floats, strings, and identifiers. Your task is to implement the `stringify` macro, which takes an input and returns it...
codefeedback
You are tasked with implementing a thread-safe singleton pattern in C#. The singleton pattern ensures that a class has only one instance and provides a global point of access to that instance. Your goal is to create a thread-safe implementation of a shared filter using the singleton pattern. You are provided with a co...
codefeedback
You are tasked with implementing a function to standardize a given dataset using the Z-score method. The Z-score standardization involves transforming the data such that it has a mean of 0 and a standard deviation of 1. You are provided with a Python code snippet that includes the declaration of a variable `data_std` a...
codefeedback
You are tasked with implementing a Python function that simulates a simple image processing operation. The function should take an input image file and create a new image file with a modified color palette. You are provided with a code snippet that closes two file handles and then calls a function named `CreatePalette...
codefeedback
You are tasked with implementing a custom database class in Python that supports reading and writing data. The class should handle exceptions and ensure data integrity. Your task is to complete the implementation of the `Database` class by filling in the missing methods. ```python class Database: def __init__(self...
codefeedback
You are tasked with simulating the behavior of a refractive interface when a collimated beam of light passes through it. A collimated beam is one in which the light rays are parallel, and a refractive interface is the boundary between two different mediums through which light can pass. The simulation should visualize t...
codefeedback
You are tasked with implementing a PHP trait that retrieves a license object from the Keygen.sh API. The trait, named `GetLicenseTrait`, is intended to be used within a larger PHP application for managing software licenses. Your goal is to complete the implementation of the `getLicense` method within this trait, which ...
codefeedback
You are tasked with implementing a Python decorator that ensures the successful execution of a function by handling potential exceptions. The decorator should catch specific exceptions and retry the function a specified number of times before re-raising the exception. Your task is to write the `ensure` decorator and ap...
codefeedback
You are tasked with creating a program that simulates the process of building a software project using the CMake build system. CMake is a popular tool for managing the build process of software using a compiler-independent method. In this problem, you will need to implement a simplified version of the CMake build proce...
codefeedback
You are tasked with implementing a multi-threaded arithmetic expression evaluator using the provided `pi` function and the auxiliary functions `set_print` and `set_num_threads`. The `pi` function takes an integer arithmetic expression as a string and returns the result as a string. The `set_print` function is used to e...
codefeedback
You are tasked with implementing a custom base58 encoding function in JavaScript. Base58 encoding is commonly used in cryptocurrency addresses and other applications where a compact human-readable representation of large numbers is required. The base58 encoding scheme is similar to base64 encoding but excludes characte...
codefeedback
You are tasked with implementing a class hierarchy for handling HTTP response sources. The provided code snippet is a part of a C++ program that defines a class `RedirectResponse` within the `HTTP::RespSource` namespace. The `RedirectResponse` class is used to represent HTTP redirect responses, with the target location...
codefeedback
You are tasked with implementing a simple version of the classic game Pong using Rust. Pong is a two-dimensional sports game that simulates table tennis. The game involves two paddles and a ball, with the goal of each player being to score points by successfully hitting the ball past the opponent's paddle. The game con...
codefeedback
You are tasked with simulating the behavior of a simple computer's CPU. The computer has a memory module and a CPU module. The CPU module contains registers and can execute instructions stored in memory. Your goal is to implement a method for the CPU to execute the BRK (Break) instruction. The BRK instruction is a one...
codefeedback
You are tasked with implementing a conditional generative adversarial network (CGAN) for generating images based on class labels. The provided code snippet is a part of the training process for the CGAN. The discriminator (`D`) is trained to distinguish between real and fake images, while the generator (`G`) is trained...
codefeedback
You are tasked with implementing a function that verifies the resharing dealing process in a distributed key generation (DKG) protocol. The DKG protocol is used to generate a shared public key among a group of participants, and the resharing dealing process involves updating the shared public key when new participants ...
codefeedback
You are tasked with implementing a simple online learning algorithm for a binary classification problem. The algorithm uses stochastic gradient descent to update the model parameters and minimize the loss function. However, the code snippet provided contains some commented-out lines and an incomplete implementation. Yo...
codefeedback
You are tasked with implementing a trait system for a role-playing game. Traits are characteristics that define a character's abilities and behavior. Each trait has a type and a value associated with it. Traits can be added, removed, and their values can be modified. Your task is to create a trait system using Swift an...
codefeedback
You are tasked with creating a program that detects a specific template image within a live video feed. The template image is loaded from a file, and the program continuously captures frames from the video feed to search for occurrences of the template. The program should terminate when the user presses the 'q' key. Y...
codefeedback
You are tasked with creating a script to automate the tagging and pushing of Docker images to a remote repository. The provided code snippet is a function `tag_and_push` written in Bash, which takes two parameters: `source` and `target`. The function tags the Docker image specified by `source` with the name `target` an...
codefeedback
You are tasked with implementing a function to serialize a given string into a specific format, ensuring that the serialized data does not exceed a specified length. The function should handle the conversion of the string into bytes using a specified encoding, and it should pad the serialized data if necessary to meet ...
codefeedback
You are given a set of coordinates representing points on a 2D plane. Your task is to find the minimum area of a rectangle that can be formed by selecting four distinct points from the given set of coordinates. You are to implement a function `min_rectangle_area(coordinates)` that takes in a list of tuples, where each...
codefeedback
You are tasked with implementing a simple command-line interpreter that reads commands from the standard input and executes them. Each command is a string of characters, and the interpreter should parse the command into individual arguments and execute the corresponding action. The command-line interpreter should conti...
codefeedback
You are tasked with implementing a smart contract for a blockchain-based token system. The contract should include a method for transferring tokens between addresses. The code snippet provided is a part of the transfer function, which is responsible for transferring a specified amount of tokens from the sender's addres...
codefeedback
You are tasked with implementing a Python function that processes a dictionary containing musical pitch intervals and returns a new dictionary with the intervals converted to semitones. The input dictionary will have keys representing musical chord types (e.g., "", "m") and values representing the pitch intervals for c...
codefeedback
You are given a set of retrieved documents represented by their document IDs. Your task is to write a function that takes this set of document IDs as input and returns the smallest positive integer that is not present in the set. For example, given the set of retrieved documents: ``` retrieved_documents = {100, 3022, ...
codefeedback
You are tasked with implementing a function that extracts the video ID from a given video.dtu.dk link. The video ID is the unique identifier for a specific video hosted on the video.dtu.dk platform. The function should take a video.dtu.dk link as input and return the extracted video ID. Additionally, the function shoul...
codefeedback
You are tasked with creating a script to automate the setup of a development environment using RVM (Ruby Version Manager). Your script should ensure that the temporary directory is set, create a new directory within it, switch to that directory, install Ruby version 2.3.4 using RVM, and then list the installed Ruby ver...
codefeedback
You are tasked with creating a Python function that interacts with a SQLite database. Your function should perform the following tasks: 1. Check if a database file exists at a given path. 2. If the database file exists, establish a connection to the database using the sqlite3 module. 3. If the database file does not ex...
codefeedback
You are tasked with creating a program that analyzes the dependencies of a Swift package and identifies any circular dependencies present. A circular dependency occurs when two or more packages depend on each other directly or indirectly, forming a loop in the dependency graph. Your task is to implement a function `fi...
codefeedback
You are given a Python code snippet that aims to create a square matrix and fill it with numbers in a specific pattern. Your task is to complete the code by implementing the logic for filling the square matrix with numbers in a spiral pattern. The input number `INPUT_NUMBER` will determine the size of the square matrix...
codefeedback
You are tasked with creating a Python function that securely stores an API key and provides a way to access it without exposing the key in the code. Your function should allow the key to be set once and then accessed as needed. Additionally, the function should prevent the key from being overwritten once it has been se...
codefeedback
You are tasked with implementing a custom validation feature for a Java Swing application. The application uses a `JLayer` component to display various `JComponent` instances, such as text fields, buttons, and labels. Your goal is to create a validation mechanism that visually indicates errors on specific components. ...
codefeedback
You are given a code snippet that represents a breadth-first search (BFS) algorithm. The code snippet uses an adjacency list representation of a graph and a queue data structure to perform the BFS traversal. The `dist` array is used to store the distance of each vertex from the source vertex, and the `Q` array is used ...
codefeedback
You are working on a bioinformatics project and need to implement a filtering algorithm for DNA sequence reads. The provided code snippet is part of a larger program that processes DNA sequence data. The `MapqFilter` class is responsible for tagging BSSeqPileupRead objects with a mapq fail flag based on their mapping q...
codefeedback