instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with implementing a Python decorator that performs access control checks for a web application. The decorator should ensure that the user is logged in and has the necessary permissions to access a specific view function. You will need to create the decorator and apply it to the given `keyword_csv` functi...
codefeedback
You are tasked with creating a Django admin interface for managing various models in a web application. The provided code snippet is a part of a Django project and demonstrates the registration of models with corresponding admin classes. Your task is to extend this functionality by creating a custom admin class for a n...
codefeedback
You are tasked with implementing a function to calculate the cross product of two three-dimensional vectors. The cross product of two vectors in three-dimensional space results in a vector that is perpendicular to both input vectors. The formula for the cross product is defined as follows: Given two vectors A = (a1, a...
codefeedback
You are tasked with implementing a function that takes in an array of integers and returns a new array where each element is the product of all the elements in the original array except the element at the current index. You need to implement the following function: ```java public int[] calculateProduct(int[] nums) { ...
codefeedback
You are tasked with creating a Python function that processes a neural network checkpoint and extracts information about the masks used in the network's generator. The function should take in a checkpoint dictionary and return the number of masks with specific properties. The function signature should be: ```python de...
codefeedback
You are tasked with implementing a program that simulates a simple game of rock-paper-scissors. The game should allow a user to input their choice (rock, paper, or scissors) and then randomly generate a choice for the computer. The program should then determine the winner based on the standard rules of rock-paper-sciss...
codefeedback
You are tasked with implementing a custom debugging plugin for a web application using Python and Flask. The code snippet provided initializes a session and a database for the Flask application, and then there is a comment indicating the instantiation of a debugging plugin. Your task is to create a debugging plugin cl...
codefeedback
You are working on a location-based service application that requires analyzing access points within a given area. The access points are defined by their type, position, and characteristics. Your task is to write a function that filters and processes the access points based on certain criteria. You are given the follo...
codefeedback
You are tasked with implementing a function that searches for a specific pattern within a given memory range. The function should take the starting and ending addresses of the memory range, and a pattern to search for. The pattern is represented as an unsigned 64-bit integer. The function should return the address of t...
codefeedback
You are tasked with implementing a simplified version of a dependency injection container in C#. The container should be able to register and resolve services based on their types. Additionally, the container should support advanced features such as code generation for transactions. Your task is to create a class `Ser...
codefeedback
You are tasked with creating a reinforcement learning environment for a multi-agent system. The environment consists of parallel agents that interact with the environment simultaneously. Each agent has its own observation space and action space. The environment provides a `reset()` function to initialize the agents and...
codefeedback
You are tasked with creating a Python function that processes a given text to extract winning numbers for a series of draws from a lottery report. The lottery report is in Russian, and the winning numbers are labeled with the phrase "ВЫИГРЫШНЫЕ НОМЕРА" (which translates to "WINNING NUMBERS" in English). Your function s...
codefeedback
You are tasked with creating a React higher-order component (HOC) that measures the time taken for a component to render and logs the duration to the console. Your HOC should wrap any given component and measure the time it takes for the component to render when it is mounted. Your task is to implement the `withRender...
codefeedback
You are tasked with implementing a function to fill a collection in a database with a specified number of elements. The database is represented by the `DB` struct, which has a method `new` for creating a new instance. The function `fill_coll` takes the database name, collection name, database client, and the number of ...
codefeedback
You are tasked with implementing a function to calculate the value of a polynomial at a given abscissa for a given polynomial order. The polynomial is defined by the following recurrence relation: \[ P_n(x) = \begin{cases} 1 & \text{if } n = 0 \\ x & \text{if } n = 1 \\ 2xP_{n-1}(x) - P_{n-2}(x) & \...
codefeedback
You are tasked with implementing a progress monitoring system for a multi-threaded application. The system should allow multiple listeners to be notified when a task starts and completes. The provided code snippet is a part of the progress monitoring system and includes the method `fireTaskCompleted()` which is respons...
codefeedback
You are tasked with implementing a file-serving mechanism that first attempts to retrieve a file from the filesystem and, if not found, tries to serve it from a database. You are given a code snippet that outlines the initial logic for this process. Your task is to complete the implementation by writing the `django_ser...
codefeedback
You are tasked with creating a Python script to calculate the sum of memory usage for a given process on a Linux-based system. The script will take the process name as input and use system commands to retrieve the memory usage information. Your task is to implement the Python script `memsum.py` that takes the process n...
codefeedback
You are tasked with creating a script to automate the correction of certain formatting issues in reStructuredText (RST) files generated by pandoc. Your script should perform the following tasks: 1. Replace occurrences of ".. code::" with ".. code-block::". 2. Update links from "../assets/" to "_static/". 3. Convert ins...
codefeedback
You are tasked with creating a backup script that zips a directory and uploads it to a remote storage using rclone. Your script should handle both zipping the directory and uploading it to the remote storage based on the value of the `ZIP` variable. The script should perform the following actions: 1. If the `ZIP` vari...
codefeedback
You are tasked with implementing a C++ class that simulates a simple bank account. The class should support basic operations such as depositing funds, withdrawing funds, and checking the current balance. Additionally, the class should keep track of the total number of transactions performed on the account. Your task i...
codefeedback
You are tasked with implementing a class that represents a simple stack data structure. The stack should support the following operations: 1. `push(val)`: Add an element to the top of the stack. 2. `pop()`: Remove the element from the top of the stack and return its value. 3. `peek()`: Return the value of the element a...
codefeedback
You are tasked with implementing a function to process weekly transactions data. The provided code snippet initializes variables for the data source, week number, week year, and a flag for the first load. Your task is to create a function that processes the weekly transactions and returns a summary of the data. You ar...
codefeedback
You are tasked with implementing a function that extracts and returns the largest number embedded within a given string. The function should take a string as input and return the largest integer present in the string. If no integers are found, the function should return 0. The function signature is: ```python def get_...
codefeedback
You are given a list of faces representing a 3D mesh and the number of points in the mesh. Each face is represented by a list of three vertices. Your task is to write a function to populate a neighbor list for each point in the mesh. The neighbor list for a point contains the indices of the points that are directly con...
codefeedback
You are given a code snippet that seems to be incomplete. Your task is to complete the code by implementing a function that calculates the Fibonacci sequence. The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. The code snippet provided...
codefeedback
You are tasked with creating a Rust function to verify a transaction for a blockchain application. The function should take in transaction data and additional information, and then perform various checks to ensure the validity of the transaction. Your task is to implement the verification logic based on the given code ...
codefeedback
You are tasked with implementing a class method for a game statistics tracker in Python. The method should reset various statistics to their initial values when called. The provided code snippet is a part of a larger class and shows the initialization of certain attributes. Your task is to complete the method `reset_st...
codefeedback
You are tasked with implementing a feature for a web application that involves making a network request to retrieve user data from an API. The provided code snippet is a part of the existing codebase and contains relevant information for this task. The code snippet includes a configuration for making a GET request to t...
codefeedback
You are tasked with creating a Swift data structure that enforces certain access control rules. Your task is to define a struct with a property that can be read from anywhere in the module, but can only be modified from within the same module. Additionally, you need to handle the situation where the property is modifie...
codefeedback
You are tasked with implementing a scoring system for a sports event. The scoring system involves updating a dictionary of scores based on scoring events and calculating the total number of ways to achieve each score. Your task is to write a function that takes in a list of scoring events and returns a list of total wa...
codefeedback
You are tasked with implementing a function to process a list of property updates for a person object. Each property update is represented as a tuple containing the operation type, property key, and value. The function should apply these updates to the person object and return the updated person object. The person obj...
codefeedback
You are tasked with implementing a rail fence cipher encryption algorithm. The rail fence cipher is a transposition cipher that rearranges the plaintext letters by writing them in a zigzag pattern down and up the rails of a fence. The number of "rails" used for the zigzag pattern is determined by the key provided. For ...
codefeedback
You are tasked with implementing a method within the `IndexedTransformer` class that will transform a given time series data using the provided `TimeSeriesTransformer` and return the transformed data in indexed format. The `IndexedTransformer` class has been initialized with a `TimeSeriesTransformer`, a padding value, ...
codefeedback
You are tasked with implementing a function `stable_uniq(L)` that takes a list `L` as input and returns a new list containing the unique elements of `L` in the order they first appeared. The function should maintain the stability of the original order of elements, meaning that if an element appears multiple times in `L...
codefeedback
You are given an array of integers `nums`, where each element is either 0 or 1. Your task is to find the maximum number of consecutive 1s in the array. Write a function `findMaxConsecutiveOnes` that takes in the array `nums` and returns the maximum number of consecutive 1s in the array. For example, given the input a...
codefeedback
You are tasked with implementing a function that calculates the total cost of a customer's purchase, factoring in any applicable discounts. The function should take in a list of items purchased, their individual prices, and any available discount codes. The discount codes can be applied to specific items or the entire ...
codefeedback
You are given a class `Node` representing a node in a trie data structure. The trie is used to store a collection of strings, and each node represents a single character. The class `Node` has the following structure: ```python class Node: def __init__(self): self.children = {} # Dictionary to store child ...
codefeedback
You are tasked with implementing a class that represents a graphical user interface (GUI) control. The class should have properties for the X and Y coordinates of the control, as well as methods to retrieve its width and height. Additionally, the Y coordinate should be aligned to a grid based on a provided canvas. You...
codefeedback
You are tasked with implementing a function that performs a serialisation roundtrip and checks the integrity of the data before and after the roundtrip. The function should take in a dictionary of example metadata and a temporary directory path. The function should generate a document by performing a serialisation roun...
codefeedback
You are tasked with implementing a simplified version of a messaging system using the MQTT protocol. MQTT (Message Queuing Telemetry Transport) is a lightweight messaging protocol commonly used for IoT (Internet of Things) devices and applications. Your goal is to create a Python class that encapsulates the functionali...
codefeedback
You are tasked with implementing a Python class that represents a financial instrument in a trading system. The class should handle various operations related to the instrument, such as retrieving historical data, calculating indicators, and executing trading strategies. Your task is to create the `FinancialInstrument`...
codefeedback
You are tasked with implementing a message validation system for a communication protocol. The system should be able to read and validate messages based on predefined message definitions and validators. You are given a `MessageReader` class that takes the following parameters: 1. `transportState`: An instance of the `...
codefeedback
You are tasked with implementing a custom serializer class for a Python web API framework. The class should have methods for serializing and deserializing data based on a specified schema. The provided code snippet is a part of the serializer class and shows the implementation of the `_deserialize` method. Your task i...
codefeedback
You are tasked with implementing a function to decode a sequence of characters recognized by a neural network. The function takes in the recognized characters and a set of characters that the neural network can recognize, excluding a special CTC-blank character. The function should return the decoded text based on the ...
codefeedback
You are tasked with creating a Python package management system that can resolve dependencies and import modules correctly. Your system should be able to handle circular dependencies and ensure that modules are imported only once to avoid conflicts. Given the code snippet provided, you need to implement a function tha...
codefeedback
You are tasked with implementing a custom logging system in Python. The provided code snippet shows a part of the logging functionality, where the `debug` function is meant to log messages at the debug level using a custom logger named 'mylogger'. The `debug` function takes a message as input and logs it using the `log...
codefeedback
You are tasked with creating a Python package management system that can parse and process package metadata. The metadata is provided in the form of a Python code snippet, as shown below: ```python pkgname = "python-sphinx-removed-in" pkgver = "0.2.1" pkgrel = 0 build_style = "python_module" hostmakedepends = ["python...
codefeedback
You are given a code snippet that reads pairs of integers into a vector and then initializes a 2D array. Your task is to complete the code by populating the 2D array with the values from the vector. Additionally, you need to implement a function to calculate the sum of all elements in the array that are located on the ...
codefeedback
You are given a C++ code snippet that involves some operations on time and data structures. Your task is to create a program that can efficiently find the time difference between the start and end times of a process and perform a specific operation on the data structures. Your program should perform the following task...
codefeedback
You are tasked with implementing a data preprocessing method for a machine learning pipeline. The method should transform any zero values in a given parameter to `None`, while leaving all other values unchanged. Additionally, you need to create a class method that returns the maximum number of features to be used in th...
codefeedback
You are tasked with creating a Python class that represents a GcsFolderDestination for exporting data to a Cloud Storage directory. Your task is to implement the class with the required attribute and ensure that it meets the specified requirements. Your task is to complete the implementation of the `GcsFolderDestinati...
codefeedback
You are tasked with creating a script that interacts with a web service to obtain a session path. The script should be able to extract the session path from the response of a POST request to a specific URL. Additionally, the script should determine the directory in which it is located. Your task is to write a Bash scri...
codefeedback
You are tasked with implementing a function that processes the output of a language model and applies certain post-processing steps based on specific conditions. The function takes in several input parameters and performs various operations on them. Your task is to complete the function by implementing the necessary lo...
codefeedback
You are tasked with implementing a web browser component in a Swift-based iOS application. The given code snippet contains two methods within a custom web view class. The `reload` method is responsible for reloading the web view with the original request, while the `setupProgress` method sets up a progress view to disp...
codefeedback
You are tasked with implementing a function that performs a specific type of data augmentation for a machine learning model training process. The function takes in a list of choices, a dictionary of parameters, and a dictionary of image indexes per class. The function is responsible for shuffling the choices, duplicati...
codefeedback
You are tasked with creating a Python function that reads a file containing a series of floating-point numbers and calculates the average of these numbers. Your function should take the file name as input and return the average of the numbers as output. Assume that the file contains one floating-point number per line. ...
codefeedback
You are tasked with creating a program that processes a list of user information and generates a report based on the data. Each user's information is represented by a string in the format "username: date", where "username" is the user's name and "date" is the date in the format "YY/MM/DD". The program should output the...
codefeedback
You are tasked with creating a Java program to manage a list of users in a customer management system. The program should include a class to represent a user and a graphical user interface (GUI) to display and interact with the user data. The user class should have attributes for the user's name, email, and age. The GU...
codefeedback
You are tasked with implementing a role-based access control system for a cloud-based image repository. The system should allow users to perform various actions such as pulling images from projects, pushing images to projects, and managing robot accounts. Each action should be associated with specific permissions and s...
codefeedback
You are tasked with creating a script that automates the setup of a cross-compilation environment for ARM64 architecture. The script should take a target directory and a configuration file as input, and then perform several operations using the `multistrap` tool and `find` commands to set up symbolic links in the targe...
codefeedback
You are tasked with creating a simple program to manage categories in an e-commerce platform. The program should allow users to create, retrieve, update, and delete categories. To achieve this, you need to implement a Category class with the following properties and methods: Properties: - `id` (number): A unique ident...
codefeedback
You are tasked with creating a script to automate the setup of a development environment for a web application. The script should check for the presence of a `.env` file, create one from a provided `.env.example` file if it does not exist, and then start the Supervisor process manager using the configuration file `supe...
codefeedback
You are given a list of tuples, where each tuple represents a pair of coordinates in a 2D plane. Your task is to write a function that calculates the distance between each pair of coordinates and returns a list of distances. The distance between two points \((x_1, y_1)\) and \((x_2, y_2)\) in a 2D plane can be calcula...
codefeedback
You are tasked with implementing a function that creates a symbolic link from a source file or directory to a destination directory. If the destination is a directory, the function should create the symbolic link inside that directory. If the destination is a file, the function should create the symbolic link with the ...
codefeedback
You are tasked with creating a Python function that takes in a list of time series data and their corresponding class labels, and returns a dictionary containing a random sample of time series data for each unique class label. The function should be able to handle any number of unique class labels and time series data....
codefeedback
You are tasked with creating a Python script to automate the process of downloading gene reference data from the Ensembl database. The Ensembl database provides a REST API that allows users to query and retrieve gene information in various formats. Your script should utilize the Ensembl REST API to download gene refere...
codefeedback
You are tasked with implementing a nonlinearity function for image processing. The function should support two different methods for applying gamma correction to an input image. The first method involves applying gamma correction by a specific value. The second method involves applying gamma correction using a lookup ...
codefeedback
You are tasked with implementing a class `SecretNumber` that generates a random secret number within a specified range and allows users to guess the number. The class should provide methods to check if a guess is correct and to retrieve the range of the secret number. Additionally, the class should keep track of the nu...
codefeedback
You are tasked with implementing a data preprocessing function for a machine learning model. The function takes in three lists of numpy arrays: `payoff_matrix_split`, `col_prob_split`, and `col_action_split`. It then selects specific indices from these lists and concatenates the arrays at those indices. The concatenate...
codefeedback
You are tasked with creating a function that processes configuration data for building an iOS application using the NativeScript framework. The function should extract specific information from a given configuration and use it to construct a command for building the iOS application release version. The function should...
codefeedback
You are working on a computer vision project that involves processing object detection predictions. You have a list of predictions for a particular image, where each prediction is represented by a bounding box, a confidence score, and a label. Additionally, you have a set of weights and parameters for fusing these pred...
codefeedback
You are tasked with implementing a plugin system for a presentation software. The software has a `Presenter` class with a private static property `didImportPlugins` that tracks whether the plugins have been imported. Your goal is to create a method to import plugins and ensure that the `didImportPlugins` property is se...
codefeedback
You are tasked with implementing a custom segmented control in a Swift iOS application. The segmented control should display a list of options and update the content of the table view based on the selected option. The provided code snippet is a starting point for the implementation. Your task is to complete the impleme...
codefeedback
You are tasked with creating a Python function that processes a list of tweets and extracts media URLs from tweets that contain a specific hashtag. The function should take in two parameters: a list of tweets and a hashtag. Each tweet is represented as a dictionary with keys "text" for the tweet content and "entities" ...
codefeedback
You are tasked with creating a Python function that takes a list of URLs and returns a dictionary containing the domain names as keys and the unique URLs associated with each domain as values. The domain name should be extracted from the URL and should not include the protocol (e.g., 'http://' or 'https://'). Create a...
codefeedback
You are tasked with implementing a custom SwipableView class in Swift that supports dragging and executing actions based on the position changes. The SwipableView class has a method beganDragging(_:) that should be called when the user starts dragging the view. Additionally, an action should be executed when the positi...
codefeedback
You are tasked with implementing a Python class that simulates a simple bank account. The class should have methods for depositing funds, withdrawing funds, and checking the current balance. Additionally, the class should have a method for transferring funds to another bank account. Your task is to complete the implem...
codefeedback
You are tasked with implementing a function that processes a given string containing a series of commands and returns the final position of a robot. The robot starts at position (0, 0) on a 2D grid and can move in four directions: up, down, left, and right. Each command is represented by a single character: 'U' for up,...
codefeedback
You are tasked with implementing a file organization system using Python. The goal is to create a program that can organize files in a specified directory based on their types (e.g., images, documents, videos, etc.) into separate subdirectories. You are provided with a Python library, `Library`, which offers the follo...
codefeedback
You are tasked with implementing a simplified version of the WalkSAT algorithm, a local search algorithm used to find satisfying assignments for propositional logic formulas. The algorithm randomly selects an unsatisfied clause and then flips the value of a variable in that clause to try to satisfy it. This process is ...
codefeedback
You are given a Python code snippet that involves manipulation of NumPy arrays. Your task is to implement a function that performs similar operations on NumPy arrays. You need to write a Python function called `process_arrays` that takes two NumPy arrays `z1` and `z2` as input and performs the following operations: 1....
codefeedback
You are tasked with implementing a function that processes and overlays keypoint data onto an image using the OpenCV library. The function takes in the following parameters: - `left_display`: A 2D array representing the left display image. - `overlay`: A 2D array representing the overlay image. - `cv_kp`: A tuple conta...
codefeedback
You are tasked with creating a Python function that compares the contents of two directories and ensures that they are identical, except for specific files that should be ignored. Your function should take in two directory paths and a list of filenames to ignore, and then perform the comparison. If any differences are ...
codefeedback
You are tasked with implementing a Rust module that provides utility functions for working with hashmaps and unwinding results. The module should expose three public functions: `clone_to_hashmap`, `into_hashmap`, and `clone_unwind`. Additionally, the module should expose two public traits: `IntoHashmap` and `Unwinds`. ...
codefeedback
You are tasked with implementing a program to calculate the alpha shape of a set of weighted points in a 2D space. An alpha shape is a geometric shape that encloses a set of points, and it is determined by a parameter alpha. The alpha shape is defined as the intersection of all convex shapes containing the input points...
codefeedback
You are tasked with implementing a custom view class in Swift that displays a progress indicator with a GIF animation and a message label. The provided code snippet is the beginning of a custom view class called `NewProgressView`. This class has two outlets: `gifView` for displaying the GIF animation and `messageLbl` f...
codefeedback
You are tasked with creating a script to automate the execution of machine learning models with different configurations. The script should iterate through a list of models, repetitions, and k-fold values, and submit jobs to a job scheduler for each combination of these parameters. Additionally, the script should keep ...
codefeedback
You are tasked with creating a program to manage high scores for a video game. The program should prompt the user to input a new high score and then update the list of high scores accordingly. The high scores should be stored in descending order, and the program should display the updated list of high scores after each...
codefeedback
You are tasked with creating a script to automate the installation process of MPItrampoline, a tool for intercepting and redirecting MPI calls. The script should perform the following steps: 1. Create a directory specified by the variable `$path`. 2. Navigate to the created directory. 3. Create a subdirectory named `l...
codefeedback
You are tasked with creating a dynamic table in a web application using JavaScript. The table should display information about different departments in a company. Each row in the table represents a department and contains three columns: department name, number of employees, and average salary. However, the data for the...
codefeedback
You are given a Python function `solve(x)` that takes an integer `x` as input. The function is intended to convert the integer `x` into a reversed integer and return the result. However, there are some issues with the given code snippet, and you are tasked with fixing the code to ensure it works as intended. Your task...
codefeedback
You are tasked with implementing a simple data structure to represent a destination in a travel application. The destination has a name and a value associated with it. Your goal is to create a class that represents this destination and write test cases to ensure its correctness. Create a class `Destination` with the f...
codefeedback
You are tasked with creating a Bash script that sets up a development environment for a JavaScript project. The script should set the language environment to UTF-8 and customize the command prompt to indicate the current environment. Your task is to write a Bash script that accomplishes these requirements. Your Bash s...
codefeedback
You are tasked with implementing a feature for a social media platform that allows users to like comments on articles. The code snippet provided is a part of the existing JavaScript code that handles the like functionality. Your task is to complete the implementation by writing the JavaScript function that sends an AJA...
codefeedback
You are tasked with designing a system to manage product receiving in a warehouse. The system involves the use of Java and a relational database. The code snippet provided is a method from a service class that adds a new receive entry to the system. The method takes a `ReceiveVO` object as a parameter, which contains i...
codefeedback
You are tasked with implementing a simple audio processing system. The system has an Audio Manager class, AKManager, which can be configured to apply different audio effects to the input audio signal. The available audio effects are represented by different classes, such as flanger, reverb, and chorus. The AKManager ha...
codefeedback
You are tasked with implementing a function that calculates the area of a rectangle based on the width and height provided. However, the twist is that the function should be able to handle both metric and imperial units. The function should accept the width and height along with their respective units (either "m" for m...
codefeedback
You are tasked with creating a Python program that simulates a simple API routing system. The program should allow the user to register and login, and it should handle routing requests to the appropriate endpoints based on the provided URL paths. Your task is to implement the `APIRouter` class, which will manage the r...
codefeedback
You are tasked with creating a program that manages a menu system for a graphical user interface (GUI) application. The code snippet provided is a part of the menu creation process in a Windows Forms application using C#. The `optionToolStripMenuItem` represents a top-level menu item, and `menuItemImageBackground` is a...
codefeedback