instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with creating a web application that allows users to edit their profile information. The application is built using the Laravel framework, and you need to implement the functionality for editing a user's profile.
You are provided with a snippet of code from the UserController in the Laravel application:... | codefeedback |
You are given a program snippet that processes cities and their connections. The program uses a breadth-first search (BFS) algorithm to determine the number of connected components in a network of cities. Your task is to implement a function that performs the BFS and returns the number of connected components in the ne... | codefeedback |
You are tasked with implementing a custom logging mechanism for an asynchronous HTTP client in C#. The provided code snippet is a part of a custom `HttpClient` class that extends the `HttpClient` provided by the .NET framework. The `SendAsync` method is overridden to log the details of the HTTP request before forwardin... | codefeedback |
You are tasked with implementing a simple server management system for a fake calculator application. The system should allow starting and stopping the server, and it should handle transitions between the foreground and background states of the application.
Your task is to create a Swift class `CalculatorFakeServer` t... | codefeedback |
You are tasked with implementing a class hierarchy for managing events in a software system. The base class `Event` is provided, and you need to create a subclass `ProductPermanentlyDeleted` that extends the `Event` class. Additionally, the `ProductPermanentlyDeleted` class should utilize the `SerializesModels` trait. ... | codefeedback |
You are tasked with implementing a function to calculate the volume of a time series data. The function `get_vol_TS` takes no parameters and returns a vector of doubles representing the volume of the time series data.
The time series data is represented as a vector of doubles, where each element represents the value o... | codefeedback |
You are tasked with implementing a simplified version of a task management system in a React application. The system consists of tasks represented by components, and each task has associated buttons for marking it as done and displaying more options. The provided code snippet is a part of the `Task` component, which re... | codefeedback |
You are tasked with implementing a vector model for natural language processing. The vector model is a mathematical representation of text documents, where each document is represented as a vector in a high-dimensional space. The vector model is commonly used for tasks such as information retrieval, document classifica... | codefeedback |
You are tasked with simulating the behavior of charged particles in a 3D mesh. The mesh is represented as a 3D grid, and each cell in the grid can hold charge density. The particles are represented by their position, charge, and weight. Your goal is to implement a function that distributes the charge of the particles o... | codefeedback |
You are tasked with implementing a generic factory method that initializes a scenario class based on a given class name. The factory method should handle the scenario where the class initialization fails and provide an appropriate error message.
Write a function `initializeScenario` that takes a class name as a parame... | codefeedback |
You are tasked with implementing a vector library in Rust. The library should provide functionality for creating, manipulating, and performing operations on vectors. You need to implement the following operations for 3D vectors:
1. Addition of two vectors
2. Subtraction of two vectors
3. Dot product of two vectors
4. C... | codefeedback |
You are tasked with creating a program to analyze and modify HTML code. Your program should be able to identify and modify the style attribute of HTML elements based on specific criteria.
Write a function called `modifyHTMLStyle` that takes in three parameters:
1. `htmlCode` (string): A string representing the HTML c... | codefeedback |
You are tasked with implementing a generic Functor class in C++ that can wrap any callable type, including function pointers, member functions, and lambdas. The Functor class should be able to store the callable object and its arguments, and then invoke the stored callable with the stored arguments when called.
Your t... | codefeedback |
You are tasked with creating a Python function that processes system monitoring data and generates a specific type of visualization. The function will take in a list of dictionaries, each containing system monitoring data, and return a dictionary with formatted timestamps and corresponding memory usage percentages. The... | codefeedback |
You are given a Python code snippet that manipulates a 3x3 matrix and performs various operations on its elements. Your task is to understand the code and implement a function to perform similar operations on a given 3x3 matrix.
You need to write a Python function `matrix_operations(matrix)` that takes a 3x3 matrix (a... | codefeedback |
You are tasked with creating a program that validates the naming conventions of identifiers in a given source code file. The program should check for two specific naming conventions: the use of unions and the use of snake_case for identifiers.
Your task is to implement a function or method that takes a file path as in... | codefeedback |
You are given a code snippet from a C++ program that defines a class `EBCoarToCoarRedist` with a method `define`. The method takes three arguments: `a_eblgFine` of type `EBLevelGrid`, `a_eblgCoar` of type `EBLevelGrid`, and `a_nref` of type `int`. Your task is to implement a similar method in the `EBCoarToCoarRedist` c... | codefeedback |
You are tasked with implementing a function that extracts the URLs from a given JavaScript code snippet. The URLs are embedded within the `Link` components and are represented by the `to` attribute. Your function should return an array of all the extracted URLs.
Write a function `extractURLsFromCode` that takes a stri... | codefeedback |
You are tasked with implementing a function that processes a list of addons for a software application. The function should take a list of addons as input and return a modified version of the list. If the input list is not empty, the function should convert the addons to a list if they are not already in that format. I... | codefeedback |
You are working on a project that involves visualizing 3D meshes with associated texture values using the Visbrain library in Python. Your task is to create a program that generates and visualizes a spherical source mesh and a target mesh with interpolated texture values. The program should use the Visbrain library to ... | codefeedback |
You are tasked with creating a Python class that represents a simple bank account. The class should have methods to deposit funds, withdraw funds, and check the current balance. Additionally, the class should keep track of the total number of transactions (deposits and withdrawals) made on the account.
Your task is to... | codefeedback |
You are tasked with creating a web service that accepts code snippets from users, saves them to a file, and then compiles and executes the code. Your task is to implement the function `compile_and_execute` that takes a JSON object containing the code snippet and compiles and executes it. The function should return the ... | codefeedback |
You are tasked with implementing a Swift extension for the UIColor class that allows converting a hexadecimal color representation to a UIColor object. The extension should provide a convenient way to create UIColor instances using hexadecimal color codes commonly used in web and graphic design.
Your task is to comple... | codefeedback |
You are working on a Django web application and need to configure the middleware for handling various aspects of the HTTP request-response cycle. The middleware components play a crucial role in processing requests and responses, performing tasks such as session management, CSRF protection, authentication, and more.
G... | codefeedback |
You are tasked with creating a Python module that reads a configuration file and provides a function to retrieve specific configuration values. The configuration file is in a simple key-value format, where each line contains a key and its corresponding value separated by an equal sign (=). The module should be able to ... | codefeedback |
You are tasked with creating a PHP class that represents a shopping cart. The class should have the ability to add items, remove items, calculate the total cost of the items in the cart, and apply discounts. Additionally, the class should be able to serialize the cart to a JSON format and unserialize it back to a PHP o... | codefeedback |
You are given an array representing the level order traversal of a binary tree. The array contains integers and `None` values. Your task is to construct the binary tree from the given array and return the root node of the constructed binary tree.
The array follows the level order traversal of the binary tree, where `N... | codefeedback |
You are tasked with creating a Python function that lists sources based on certain criteria from a database. The function `list_sources` is provided with the following parameters: `group_id`, `recursive`, `auto_download_media`, `persist_thumbnails`, `error`, and `db`. The function is decorated with `@with_db`, indicati... | codefeedback |
You are given a code snippet from a Rust program that deals with bitwise operations and type conversions. Your task is to write a function that replicates the behavior of the given code snippet.
The function should take three parameters: `res` of type `u64`, `src` of type `u32`, and `dst` of type `u32`. The function ... | codefeedback |
You are tasked with creating a command-line utility for copying files with specific options. The utility should accept command-line arguments for the source file, target location, and an optional flag to override the target file if it already exists.
Your task is to implement a C# program that parses command-line argu... | codefeedback |
You are working on a machine learning library called RegressorDevice, which provides functionalities for regression analysis. The code snippet provided is a part of the RegressorDevice module. The snippet includes a function that is used to train a regression model and make predictions. The function takes in a datafram... | codefeedback |
You are tasked with implementing a function to validate whether a given string is a valid GUID (Globally Unique Identifier) according to the specified format. A GUID is a 32-character hexadecimal string, typically formatted with hyphens in the pattern "8-4-4-4-12" (e.g., "550e8400-e29b-41d4-a716-446655440000"). The fun... | codefeedback |
You are tasked with creating a program that can parse and extract license information from a given code snippet. The license information is typically found within comments and follows a specific format. The program should be able to identify the license type and version, and extract any additional relevant information.... | codefeedback |
You are tasked with creating a validation function for a user registration form in a web application. The form includes fields for a person's name, email, phone number, password, passport URL, and boolean flags for admin and politician status. The validation rules for each field are as follows:
- Person name: Should on... | codefeedback |
You are given a Python code snippet that processes climate data using xarray, a popular library for working with labeled multi-dimensional arrays. Your task is to implement a function that calculates the weighted area average of a given input dataset over a specified geographical region.
The function `wgt_areaave` tak... | codefeedback |
You are tasked with implementing a Python function that synchronizes a list of files to a specified node. The function should create a temporary directory, copy the files from the list to the temporary directory, and then sync the contents of the temporary directory to the specified node. Additionally, the function sho... | codefeedback |
You are tasked with implementing a Swift extension for UITextField that provides a method to validate the input based on the type of text being entered. The extension should include a method that returns a boolean value indicating whether the input text is valid according to the specified type. The validation rules for... | codefeedback |
You are tasked with creating a web application for managing project tasks. The application allows users to input the completion date and the value of a task. Upon submission, the application should store the task details in a database. You are required to implement the backend functionality to handle the form submissio... | codefeedback |
You are given a positive integer `n`. Your task is to write a function `solution` that takes the binary representation of `n` as input and returns the length of the longest consecutive sequence of ones in the binary representation.
For example, if `n` is 156, its binary representation is 10011100. The longest consecut... | codefeedback |
You are tasked with implementing a function `long_write` that takes an integer as input and returns a byte string representing the input integer in a specific format. The format is as follows:
- For positive integers, the byte string should represent the integer in little-endian byte order.
- For negative integers, the... | codefeedback |
You are tasked with implementing a function to process and write the results of a cryptographic operation. The function `write_result` takes four parameters:
1. `cfg`: A reference to a configuration object of type `Cfg`.
2. `result`: A slice of unsigned 8-bit integers representing the result of the cryptographic operat... | codefeedback |
You are tasked with creating a program that simulates a simple banking system. The program should allow users to create accounts, deposit and withdraw funds, and check their balance. To achieve this, you need to implement a class for bank accounts and a user interface to interact with the accounts.
Create a class `Ban... | codefeedback |
You are tasked with creating a Python class that simulates a Cloud Object Storage (COS) wrapper. The class should handle the instantiation of the wrapper and provide methods for interacting with the COS. Additionally, you need to implement a function that monitors the status of a training run and skips preparation step... | codefeedback |
You are tasked with creating a Python class for handling credits in a game. The class should be able to display credits at the bottom of the screen, with the ability to scroll the credits horizontally. You need to implement the `write` method of the class, which takes care of rendering the credits.
The `write` method ... | codefeedback |
You are tasked with implementing a custom data structure that can store various types of data, including primitive types, arrays, and objects. The data structure should be able to handle different data types and provide methods for adding, retrieving, and removing elements. To achieve this, you will need to create a cl... | codefeedback |
You are tasked with implementing a custom photo browser component in Swift. The photo browser should be a subclass of `UICollectionView` and conform to the `UICollectionViewDelegate` and `UICollectionViewDataSource` protocols. Your task is to complete the implementation of the `PhotoBrowser` class by adding the necessa... | codefeedback |
You are tasked with implementing a function that processes contact data and sends it to an API for storage. The function should take an email address, a set of attributes, and a list ID as input, and then construct a data object to be sent to the API. The function should handle the case where the list ID is provided as... | codefeedback |
You are tasked with creating a Python function that calculates the number of weeks between a given date and a fixed start date, excluding weekends. The start date is defined as "2021-01-04". The function should take a date in the format "YYYY-MM-DD" as input and return the number of weeks (rounded down to the nearest i... | codefeedback |
You are working on a software project that involves XML serialization. Your task is to implement a method for serializing objects to XML using a given context. The context provides settings for serialization, such as whether to include XML declarations and whether to format the output for readability. Additionally, the... | codefeedback |
You are tasked with simulating the behavior of the VSHUFPD instruction from the x86 instruction set architecture. This instruction shuffles the elements of two XMM registers based on the control byte provided as an immediate operand. The control byte specifies which elements from the source registers are to be shuffled... | codefeedback |
You are tasked with creating a Python class that represents a deck of playing cards. The class should have methods to shuffle the deck, deal a specified number of cards, and reset the deck to its original order.
Your task is to implement the `Deck` class with the following specifications:
- The `Deck` class should hav... | codefeedback |
You are tasked with implementing a cache manager class that can handle multiple cache providers. The cache manager should be able to store and retrieve data from different cache providers, such as an array cache and a filesystem cache. Your goal is to write a method that adds a new cache provider to the cache manager a... | codefeedback |
You are tasked with designing a Rust library for a cryptocurrency wallet system. The library will consist of several modules, each serving a specific purpose. The provided code snippet outlines the initial structure of the library, with modules for stake management, test mode control, transaction handling, data types, ... | codefeedback |
You are tasked with creating a Python function that processes a list of Python package information and returns a dictionary containing the package names and their corresponding dependencies. The package information is provided in the form of a list of strings, where each string represents a package and its associated d... | codefeedback |
You are tasked with creating a Python function to scrape images from a website and extract the URL of the featured image. The function should utilize the BeautifulSoup library to parse the HTML content of the website and retrieve the required image URL.
Write a function `scrape_featured_image_url()` that accomplishes ... | codefeedback |
You are tasked with implementing a class that manages resources for a scene management system. The class, named `SceneManager`, should handle the allocation and release of resources for different scenes in a game or application. The provided code snippet shows the end of a method within the `SceneManager` class, where ... | codefeedback |
You are tasked with implementing a lemmatization function for a natural language processing application. Lemmatization is the process of reducing words to their base or root form, typically used to normalize words for analysis or processing. Your task is to create a Python function that takes a word and its part-of-spe... | codefeedback |
You are tasked with implementing a function that processes a set of CSS properties and values to generate a new set of styles based on a predefined set of spacing properties. The function should filter out any undefined values, convert string values to numeric values, and apply a specific transformation to the numeric ... | codefeedback |
You are tasked with implementing a function that converts a Swift object into a JSON representation. The provided code snippet shows the beginning of a Swift function named `toJson` that is intended to accomplish this task. Your goal is to complete the implementation of the `toJson` function to handle various types of ... | codefeedback |
You are tasked with implementing a HashProxy class in Python. The HashProxy class is designed to act as a proxy for a dictionary, providing a way to access and modify the dictionary's key-value pairs while also keeping track of the changes made to the dictionary. Your goal is to implement the HashProxy class with speci... | codefeedback |
You are tasked with implementing a generic trait and its corresponding implementation in Rust. The trait, `GridIndex`, is intended to be used for indexing elements in a grid-like structure. The provided code snippet includes a trait definition and an attempted implementation.
Your task is to complete the implementatio... | codefeedback |
You are tasked with implementing a simple rendering engine using the C++ programming language. The engine should support multiple rendering APIs, such as Vulkan, DirectX, and OpenGL. The provided code snippet is a part of the rendering engine's namespace "Morpheus" and defines a static member variable within the "Rende... | codefeedback |
You are working on a software system that handles online key-value pairs of different data types. The system uses a Variant class to store and retrieve these key-value pairs. The Variant class has a method GetValue() to retrieve the value of the key as a specific data type. Your task is to implement a function that con... | codefeedback |
You are tasked with implementing a Python class that utilizes Newton's method to solve for the root of a given function. Newton's method is an iterative method for finding successively better approximations to the roots (or zeroes) of a real-valued function. The class should have methods for setting function arguments,... | codefeedback |
You are tasked with implementing a class method for a control system interface. The method should handle the appending of commands to a deque data structure based on certain conditions. The method should also handle the formatting of parameters for the command to be appended. The class has a constant `MAX_OUTPUTS` repr... | codefeedback |
You are tasked with implementing a Rust program that involves error handling and asynchronous traits. The program includes a code snippet that defines an enum `UseCaseError` and implements a conversion from this enum to another error type `NettuError`. Additionally, it declares an asynchronous trait `UseCase` for a spe... | codefeedback |
You are tasked with implementing a custom view in Swift that displays an image and a label. The view should have a specific layout defined by constraints. Your goal is to create a class that inherits from UIView and sets up the necessary UI components and constraints to achieve the desired layout.
Your task is to comp... | codefeedback |
You are tasked with implementing a custom parser for CSS values in Rust. The provided code snippet is a part of a Rust program that defines a `CustomIdent` struct and its implementation for parsing CSS custom identifiers. Your task is to complete the implementation of the `parse` function for the `CustomIdent` struct, ... | codefeedback |
You are tasked with implementing a function that validates email addresses based on certain criteria. The function should take an email address as input and return a boolean value indicating whether the email address is valid or not.
The criteria for a valid email address are as follows:
1. The email address must con... | codefeedback |
You are tasked with implementing a custom preprocessor for a notebook grading system. The preprocessor should modify specific cells within a Jupyter notebook before it is graded. The provided code snippet is a partial implementation of the custom preprocessor, which inherits from `NbgraderOverwriteCells` and overrides ... | codefeedback |
You are tasked with creating a Python unit test for a command-line interface (CLI) method that reads data from a file. The method, `take_action`, is part of a larger CLI application and is responsible for reading columns and data from a file specified by the `plugin_name`. The code snippet provided is a partial unit te... | codefeedback |
You are tasked with implementing a matrix attention module for a natural language processing (NLP) system. The module will take two sets of vectors, apply a specified attention mechanism, and produce an attention-weighted combination of the vectors. The attention mechanisms available for use are Dot Product, Bilinear, ... | codefeedback |
You are tasked with implementing a custom data structure called `Stack` in Swift. A stack is a Last-In-First-Out (LIFO) data structure that allows for two main operations: pushing an element onto the stack and popping an element off the stack. Additionally, the stack should support a computed property that returns a ne... | codefeedback |
You are tasked with implementing a simple module system for a web server framework in Rust. The provided code snippet is a partial representation of the module structure for the framework. Your goal is to create a module system that allows for easy organization and access to various components of the web server framewo... | codefeedback |
You are tasked with implementing a function that calculates the total area covered by a set of rectangles in a 2D plane. Each rectangle is represented by its top-left and bottom-right coordinates. The total area is the sum of the individual areas of the rectangles, excluding any overlapping regions.
You are given the ... | codefeedback |
You are tasked with creating a script that automates the training of a neural network model with varying hidden layer sizes. The script should export an environment variable `SC_SUFFIX` with a specific naming convention and then call a Python script `pl_train_module.py` with the appropriate parameters. The `SC_HIDDEN_S... | codefeedback |
You are tasked with creating a Python class that manages worker processes for processing and archiving music files. The provided code snippet is part of a larger system and demonstrates the creation of a worker for processing music files. Your task is to implement the `ProcessorWorker` class and its associated methods ... | codefeedback |
You are tasked with implementing a plugin system for a remote configuration adapter in Swift. The `FirebaseRemoteConfigAdapter` class is provided as a starting point, which implements the `RemoteConfigAdapter` protocol. The `RemoteConfigAdapter` protocol is not explicitly defined, but it is assumed to have methods and ... | codefeedback |
You are tasked with implementing a program to generate a finite state machine (FSM) representation in the DOT language. The DOT language is commonly used to describe graphs and networks, and in this case, it will be used to represent the transitions and states of the FSM.
Your task is to write a function that takes a ... | codefeedback |
You are given a Python function that processes image data using PyTorch tensors. The function takes in three input tensors: `idx`, `cls`, and `no_classes`. It constructs class vectors for each image and then performs some operations on these vectors. Your task is to understand the given code snippet and implement a sim... | codefeedback |
You are tasked with implementing a custom string manipulation function in Rust. The function should take a `self` reference to a struct and return a string representation of the struct's `name` field. If the `name` field is `Some`, the function should return the string representation of the `name`. If the `name` field ... | codefeedback |
You are tasked with implementing a generic serialization and deserialization mechanism for a struct in Rust. The given code snippet provides the skeleton for the serialization and deserialization functions. Your task is to complete the implementation of these functions to support the serialization and deserialization o... | codefeedback |
You are tasked with implementing a custom `SetChange` class that represents a change to a set of elements. The `SetChange` class should override the `equals` method to compare two `SetChange` objects for equality based on their contents. The `equals` method should return `true` if the two `SetChange` objects have the s... | codefeedback |
You are tasked with implementing a resource management system for a game engine. The system should handle the management of resources such as textures, models, and audio files. The code snippet provided checks whether the necessary components for resource management are available: `pResourceManager`, `pGraphicsContext`... | codefeedback |
You are tasked with implementing a custom memory allocator in Rust. Your allocator should be able to allocate and deallocate memory for a specific data structure. To achieve this, you need to create a struct that encapsulates the allocator and implement the necessary trait for memory allocation. The provided code snipp... | codefeedback |
You are tasked with creating a Python function that processes a given dictionary and string to generate a specific output. The dictionary contains information about a programming language, and the string represents a banner message. Your function should extract certain details from the dictionary and use them to constr... | codefeedback |
You are tasked with implementing a black box data structure that supports the following operations:
1. `insert(value)`: Insert a new value into the black box.
2. `delete(value)`: Delete a value from the black box.
3. `get_min()`: Retrieve the minimum value from the black box.
4. `get_max()`: Retrieve the maximum value... | codefeedback |
You are tasked with creating a Python function to process data from a web page using Selenium. The web page contains a list of movie review titles and their corresponding review dates. Your function should take a Selenium WebDriver object and a dictionary containing XPath expressions for the review dates and titles as ... | codefeedback |
You are tasked with implementing a custom assertion function in Swift for unit testing. The function should take an expression, evaluate it, compare the result with an expected value, and return a custom result object based on the comparison.
You are given the following code snippet as a starting point:
```swift
let ... | codefeedback |
You are tasked with creating a script to automate the testing of a C# project using NUnit. The script should execute the NUnit console runner to run the tests contained in a specific test assembly file. The script should be designed to be run from the command line and should include error handling for various scenarios... | codefeedback |
You are tasked with creating a program that simulates a simple text-based adventure game. The game will involve the player navigating through different rooms, encountering obstacles, and making decisions that affect the outcome of the game. To start, you need to implement a class for the game's rooms.
Create a class c... | codefeedback |
You are working on a test suite for a car rental application. The application has an endpoint for retrieving car information, including the car's rating. You are tasked with writing a test case to ensure that the default rate value for a particular car is correctly set. The test case should make an HTTP GET request to ... | codefeedback |
You are tasked with implementing a program to parse and analyze a custom layout format used in a GUI application. The layout is defined using a series of method calls and chained method invocations. Each method call represents a component or a layout constraint in the GUI.
The layout is constructed using the `javax.sw... | codefeedback |
You are tasked with creating a custom UITableView in an iOS app that displays a list of activities fetched from a JSON file. The app should utilize the UITableViewDataSource and UITableViewDelegate protocols to populate the table view and handle user interactions. Additionally, the app should make a network request to ... | codefeedback |
You are working on a web application using the Wagtail CMS framework. Your task is to create a custom form model that allows users to submit their contact information. The form should include fields for name, email, and message. Additionally, you need to implement a custom form builder to define the form fields and the... | codefeedback |
You are tasked with creating a program that parses and extracts relevant information from a copyright header in a source code file. The copyright header follows a specific format and contains details such as the author's name, last modification date, modified by, and copyright notice. Your program should be able to ext... | codefeedback |
You are tasked with creating a program that validates a given duration against a predefined list of allowed duration values. A duration is represented in the format of "PnYnMnDTnHnMnS", where:
- P indicates the period
- nY represents the number of years
- nM represents the number of months
- nD represents the number of... | codefeedback |
You are tasked with implementing a function to determine the number of combinations of a specific pattern within a given string. The pattern consists of a sequence of characters, where each character can be either '0' or '1'. The function should take a string `expression` as input and return the count of combinations o... | codefeedback |
You are tasked with creating a Python program that utilizes the `subprocess` module to execute a command-line interface (CLI) tool for code modification. The CLI tool is part of the `libcst` library, which provides a concrete syntax tree (CST) parser and generator for Python. Your program should be able to execute the ... | codefeedback |
You are tasked with implementing a trie data structure in a programming language of your choice. A trie is a tree-like data structure used to store a dynamic set of strings, where the keys are usually strings and the values are often associated with the entire key. Each node in the trie represents a single character of... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.