instruction_seed stringlengths 29 40.5k | source stringclasses 6
values |
|---|---|
You are tasked with creating a web form validation system for a registration page. The form contains fields for username, email, and password. Your goal is to implement the server-side validation logic for the form using C# and ASP.NET Core. The validation rules are as follows:
1. Username must be at least 5 characters... | magicoder |
You are tasked with creating a Python function that handles the parsing of JSON data from an API response. The function should be able to handle potential errors during the JSON parsing process and implement a retry mechanism with a delay if parsing fails.
You are given the following code snippet as a reference:
```p... | magicoder |
You are tasked with implementing a function to send notifications using the Line Notify API. Line Notify is a web service provided by Line Corporation that allows you to send notifications to Line groups or chats. Your task is to complete the implementation of the `send_line_notify` function, which takes a message as i... | magicoder |
You are tasked with implementing a simplified version of a Transformer network for natural language processing. The Transformer network consists of an encoder and a decoder, each composed of multiple layers. The encoder processes the input sequence, while the decoder generates the output sequence. Your task is to imple... | magicoder |
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... | magicoder |
You are tasked with creating a Python program that fetches data from a given URL using the `aiohttp` library for asynchronous HTTP requests. Your program should be able to handle SSL/TLS connections and print the response text to the console.
Write a Python function `async def fetch_url(url: str)` that uses `aiohttp` ... | magicoder |
You are given two strings, `string1` and `string2`, along with match and mismatch scores, and a gap extend penalty. Your task is to implement a function to calculate the optimal alignment score and the aligned strings using the following scoring scheme:
- Match: +4
- Mismatch: -2
- Gap extend penalty: -2
The alignmen... | magicoder |
You are tasked with implementing a custom namespace resolver for a given C# codebase. The resolver should be able to identify and extract all the namespaces used in the code. A namespace in C# is a way to organize and provide a level of separation of code elements. It is declared using the `namespace` keyword followed ... | magicoder |
You are tasked with implementing a method to serialize a UDP packet object into a string representation. The UDP packet contains the following fields:
- `busId`: An array of bytes representing the bus ID.
- `senderId`: An array of bytes representing the sender ID.
- `canPackets`: A list of CAN packets.
Your task is to... | magicoder |
You are tasked with implementing a function that compares two DataFrames and checks if they are equal, with the option to ignore schema metadata such as comments. The function should handle cases where one or both DataFrames are None.
Write a Python function `compare_dataframes` that takes in four parameters:
1. `expe... | magicoder |
You are tasked with implementing a task runner utility that can execute a series of tasks in a specific order. Each task is represented by an object with properties `id`, `title`, `genFunc`, and `deployFunc`. The `id` is a unique identifier for the task, `title` is a descriptive title for the task, `genFunc` is a funct... | magicoder |
You are tasked with implementing a RateHandler class in Swift that manages the rating functionality for a mobile app. The RateHandler class should provide methods to handle user ratings and calculate the average rating for a specific item.
The RateHandler class should have the following functionalities:
1. A method to... | magicoder |
You are tasked with implementing a function to simulate the addition of noise to a given charge value. The function should take the original charge value in femtocoulombs (fC) and the noise level in femtocoulombs as input, and return the resulting charge value after adding the noise.
You are provided with the followin... | magicoder |
You are tasked with implementing a Python class for managing game pieces in a board game. The class should handle drawing the pieces on the game board and moving them to new positions. The provided code snippet shows two methods of the class: `draw_pieces` and `move_pieces`.
The `draw_pieces` method is responsible for... | magicoder |
You are tasked with creating a Bash script to download a specific JAR file from a remote repository. The script should take into account the version of the JAR file, resolving it if the version is "RELEASE" or "LATEST". The script should also handle the conversion of group and artifact paths to directory paths and cons... | magicoder |
You are tasked with implementing a Python class to manage page translations for a multilingual website. The class should handle the storage and manipulation of page translations, including the title, content, revision number, and flags indicating the translation status.
You are provided with a code snippet that outlin... | magicoder |
You are tasked with creating a messaging system for a social media platform. The system should allow users to send and receive messages, and also provide a feature to display the list of rooms (conversations) a user is a part of.
You are given a partial code snippet from the messaging system, which includes a method t... | magicoder |
You are tasked with implementing a function that processes a menu structure and returns a flattened list of menu items with their respective paths. The menu structure is represented as an array of objects, where each object contains information about a menu item and its children. Each menu item has a `title` and a `pat... | magicoder |
You are tasked with creating a Django model for a commenting system. The model should include a field for the status of the comment and a field for the body of the comment. The status field should be implemented using an EnumChoiceField, which is a custom field that restricts the choices to a predefined set of options ... | magicoder |
You are tasked with creating a Python function that processes a given workflow dictionary and extracts specific information from it. The workflow dictionary contains metadata about a workflow, including its name and the example it pertains to. Your function should extract the workflow name and print a message indicatin... | magicoder |
You are tasked with implementing a simple alert system using Python. The system should allow sending alerts to users via a messaging platform, such as Telegram. You are provided with a code snippet that includes a function for sending alerts and an error handling function. Your task is to extend this code by implementi... | magicoder |
You are working on a project to develop a Python package for disaggregation analysis, which involves breaking down data into more detailed components. As part of this project, you need to implement a function that performs ensemble disaggregation. The function should take input data and parameters, and then use the pro... | magicoder |
You are tasked with creating a program to manage DHCP options for a network configuration tool. The program should handle the creation, update, and deletion of DHCP options based on user input. The user can specify whether to delete or purge DHCP options, and whether to create, update, or delete options. Additionally, ... | magicoder |
You are given a Python code snippet that defines a function `f1`. The function `f1` takes no arguments and returns the integer `123`. However, the code snippet is incomplete and ends abruptly with a closing curly brace `}`. Your task is to complete the code snippet by providing the missing parts so that the function `f... | magicoder |
You are tasked with implementing a custom view for an image preview in a C# WPF application. The view is defined within the `AngelNode.View` namespace and is associated with the XAML file `ImagePreviewView.xaml`. Your goal is to create a user control that allows users to preview images with additional interactive featu... | magicoder |
You are tasked with implementing a function to calculate the factorial of a given non-negative integer. The factorial of a non-negative integer n is the product of all positive integers less than or equal to n. For example, the factorial of 5 (denoted as 5!) is 5 * 4 * 3 * 2 * 1 = 120.
Your task is to implement the `f... | magicoder |
You are working on a computer vision project and have a colored mask represented as a 3D NumPy array. The array has the shape (height, width, 3), where the last dimension represents the color channels (in the order of red, green, and blue). Your task is to write a function that takes this colored mask array as input an... | magicoder |
You are tasked with implementing a simple server management system. The system should allow for starting a server, serving requests indefinitely, and gracefully shutting down the server when requested. You are provided with a code snippet that partially implements this functionality using Python. Your task is to comple... | magicoder |
You are tasked with creating a program to analyze a given source code file and identify potential issues based on specific patterns and rules. The program should parse the source code file and generate a report containing various types of warnings and success messages based on the analysis.
Your task is to implement a... | magicoder |
You are tasked with implementing a class for parsing XML nodes based on the expected type of the Java object. Your task is to create a method that returns a parser for a specific XML element, given the expected type of the object.
You are given the following method signature:
```java
public NodeParser getParser(Class<... | magicoder |
You are tasked with creating a Python class that represents a login page for a web application. The class should inherit from a base page class and include methods to interact with the login page elements.
Your task is to complete the implementation of the `LoginPage` class by adding methods to interact with the login... | magicoder |
You are given a directed graph with n nodes numbered from 1 to n. The graph is represented using an adjacency list. Your task is to implement a depth-first search (DFS) algorithm to find the nodes in the graph that are reachable from a given starting node.
You are provided with the following code snippet, which contai... | magicoder |
You are given a PHP code snippet that contains conditional statements to determine whether a given number is even or odd and whether it is greater than or less than 100. Your task is to write a function that accomplishes the same logic as the code snippet.
Write a PHP function called `numberComparison` that takes an i... | magicoder |
You are tasked with implementing a function to process unspent transaction outputs (UTXOs) from a blockchain and store the data in a JSON file. The function `get_unspent` takes three parameters: `BLOCKCHAIN_DIR` (the directory of the blockchain data), `SNAPSHOT_START` (the start timestamp for the snapshot), and `SNAPSH... | magicoder |
You are tasked with implementing a Python class that simulates a match client for a multiplayer game. The match client will be responsible for managing player interactions and game state during a match. The class should include methods for adding players to the match, starting the match, and handling player actions dur... | magicoder |
You are tasked with implementing a memory layout analysis tool for C++ structures. Your program should be able to determine the size of a structure, including any inherited members and padding. For this problem, you will focus on analyzing the memory layout of the given C++ structure and its inheritance.
Given the fol... | magicoder |
You are tasked with creating a Python function that processes Blender objects and their animations to generate a directory structure for exporting glTF files. The function should take a list of Blender objects and a base directory as input and organize the exported glTF files based on the objects' animations.
The func... | magicoder |
You are tasked with implementing a simplified version of a command execution system in Rust. The system will involve defining a struct, implementing methods, and handling generic types and lifetimes.
You are given a code snippet that represents a method within a struct. The method takes a generic command `g_cmd` as in... | magicoder |
You are tasked with creating a script that automates the process of setting up a development environment for a Java project. The script should be able to detect the installed Java Development Kit (JDK) and set the `JAVA_HOME` environment variable accordingly. Additionally, it should provide a fallback option to set the... | magicoder |
You are tasked with creating a program that analyzes a given text file to count the occurrences of specific words. The program should read the text file, identify the specified words, and output the count of each word.
You are given a text file named "sample_text.txt" containing a passage of text. You need to create a... | magicoder |
You are given a JavaScript code snippet that appears to be incomplete. Your task is to complete the code by implementing a function that calculates the sum of all even numbers in an array.
The given code snippet is as follows:
```javascript
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
// Your task is to complete ... | magicoder |
You are given a Python code snippet that takes an integer input `bound` and iterates through a range from `bound` down to 1. Within the loop, it checks if the current number is divisible by an undefined variable `divisor`. If the number is divisible, it prints the number and then breaks out of the loop.
Your task is t... | magicoder |
You are tasked with creating a Python program that involves using the `oslo_config` library to define and parse configuration options for a network function virtualization platform. The program should allow users to specify a list of agents for the platform and provide a default value if no agents are specified.
Your ... | magicoder |
You are tasked with creating a Python class that represents a Collector and its associated Zone. The Collector class should have attributes for ID, UUID, name, and the Zone it belongs to. Additionally, you need to implement a method to retrieve a list of Collectors configured on the server using the provided code snipp... | magicoder |
You are tasked with implementing a function that can parse and extract image file paths from a given HTML code snippet. The HTML code snippet contains a portion of a web page that includes a JavaScript function and an unordered list (`<ul>`) with list items (`<li>`) representing image thumbnails.
Your task is to write... | magicoder |
You are given a list of integers representing the heights of buildings. Your task is to find the largest rectangular area that can be formed by the consecutive buildings. The width of each building is assumed to be 1, and the height of the rectangle is determined by the height of the shortest building within it.
Write... | magicoder |
You are tasked with implementing a Markdown scanner that checks for the presence of valid emphasis sequences in a given document. An emphasis sequence in Markdown is denoted by either asterisks (*) or underscores (_) surrounding a word or phrase. For example, `*emphasis*` or `_emphasis_` are valid emphasis sequences.
... | magicoder |
You are tasked with implementing a function to validate a message according to certain criteria. The function `validate_msg(msg)` should take a string `msg` as input and return `True` if the message meets the specified criteria, and `False` otherwise. The criteria for a valid message are as follows:
1. The message must... | magicoder |
You are tasked with implementing a simple web application using Python and the Pyramid web framework. The provided code snippet is a part of the application setup process. The `config.add_renderer('json', JSON(serializer=dumps))` line configures the application to render JSON responses using the `dumps` function for se... | magicoder |
You are tasked with creating a Python program that simulates a simple game of rock-paper-scissors against the computer. The program should display a menu for the user to choose their move, generate a random move for the computer, determine the winner, and keep track of the score. The game should continue until the user... | magicoder |
You are tasked with implementing a base class for a web automation framework. The base class, named `BasePage`, contains a private field `_context` of type `ScenarioContext` and a read-only property `PageTitle` of type `string`. The `PageTitle` property is overridden in a derived class to return the specific title of t... | magicoder |
You are working on a project that involves managing a large number of class names in a codebase. To ensure consistency and organization, you decide to create a tool that can alphabetically sort and display the class names in a user-friendly format. Your task is to write a Python function that takes a list of class name... | magicoder |
You are tasked with implementing a Python function that simulates a simple inventory management system for a small retail store. The system should allow adding, removing, and updating the quantity of products in the inventory. Additionally, it should be able to display the current inventory status.
You are provided wi... | magicoder |
You are tasked with implementing a custom `asDriver` function for a reactive programming framework. The `asDriver` function should convert a stream of events into a `Driver`, which is a special kind of observable sequence that represents a value or error that never fails. The `asDriver` function should take into accoun... | magicoder |
You are tasked with implementing a function to find the maximum depth of a binary tree. The binary tree is represented as a series of nested nodes, and the depth of a node is defined as the number of edges from the node to the tree's root node. The depth of the tree is the maximum depth of all the nodes in the tree.
Y... | magicoder |
You are tasked with implementing a function to parse and handle exceptions in a REST API. The function should take a string representing an exception message and return a formatted error response for the API. The input string may contain a syntax error, and your task is to identify and correct the error to produce the ... | magicoder |
You are tasked with creating a PHP class that can parse XML data and extract specific information from it. Your class should be able to handle XML data from a Sonos music system and extract details about the music library.
Your task is to create a class called `SonosXmlParser` with a method `getMusicLibrary` that take... | magicoder |
You are tasked with implementing a system to update the quality of various items in a store. The system has an interface with a method `UpdateQuality` that takes an `ExtendedItem` as a parameter. The `ExtendedItem` class represents an item in the store and has properties such as `Name`, `SellIn`, and `Quality`. The `Up... | magicoder |
You are tasked with implementing a function that processes a configuration object for a user interface layout. The configuration object contains a sublayout and a set of properties to be applied to the sublayout. The sublayout can be of different types, such as stack, grid, or flexbox, and the properties include settin... | magicoder |
You are given a list of log entries, where each entry is a string consisting of a unique identifier followed by some words. The identifier consists of only digits, and the words in the log are separated by spaces. The logs are to be sorted such that all the letter-logs come before the digit-logs. The letter-logs are or... | magicoder |
You are tasked with implementing a simple image search application using the MVP (Model-View-Presenter) architecture. The provided code snippet includes a `ImageSearchPresenter` class that conforms to the `ImageSearchPresenterProtocol`. Your goal is to extend this code to include the necessary components for fetching a... | magicoder |
You are given a list of strings representing items to be kept, and a dictionary `explib` that maps each item to its corresponding category. Your task is to write a function to summarize the count of items in each category and print the results in the format "category \t count".
The function should take in two paramete... | magicoder |
You are tasked with creating a program that processes a configuration file in a specific format and extracts key-value pairs from it. The configuration file is in the INI file format, which consists of sections enclosed in square brackets and key-value pairs within each section.
Your program should read the configurat... | magicoder |
You are tasked with creating a Python function that processes a given Bootstrap layout and extracts specific information from it. The layout is represented as a nested structure of Python dictionaries and lists, where each element corresponds to a Bootstrap component or container. Your goal is to extract the class name... | magicoder |
You are working on a data processing task and need to manipulate a CSV file using Python's pandas library. Your task is to write a Python function that reads a CSV file, transposes the data, and then saves the transposed data to a JSON file.
Write a function called `csv_to_json_transpose` that takes two input paramete... | magicoder |
You are tasked with implementing a generic constraint system for a UI framework. The framework provides two types, `ConstraintItem` and `ConstraintView`, both of which conform to the `ConstraintRelatableTarget` protocol. Your goal is to create a generic function that can compare and relate two instances of types confor... | magicoder |
You are tasked with implementing a Python class that represents a row element in a graphical user interface (GUI) framework. The row element is a subclass of the `Group` class and is used to organize and layout other GUI elements horizontally.
Your task is to complete the implementation of the `Row` class by adding a ... | magicoder |
You are tasked with implementing a simple event handling system for a mobile application. The application has three events that need to be handled: "applicationWillResignActive", "applicationDidEnterBackground", and "applicationWillEnterForeground". Each event corresponds to a specific function that needs to be execute... | magicoder |
You are given a list of elements, some of which may be nested lists. Your task is to write a Python function that counts the total number of elements in the list, including the elements within nested lists. You should implement a recursive approach to solve this problem.
Write a function `count_total_elements` that ta... | magicoder |
You are tasked with implementing a simple map type selection feature in a mobile application. The code snippet provided is a part of the implementation for storing and retrieving the selected map type using UserDefaults in Swift.
Your task is to complete the implementation by defining the enum `MapType` and ensuring t... | magicoder |
You are tasked with implementing a LineTracerWalker class that simulates a line-tracing robot. The class has a method `isLeftsideLine` that takes a boolean parameter `b` indicating whether the line is on the left side or the right side of the robot. The method sets the `minus` variable to -1 if `b` is true (indicating ... | magicoder |
You are working on a project that involves implementing an affine transformation function for feature tensors using PyTorch. The given code snippet is a part of a class that initializes certain parameters and defines a class method for applying the affine transform.
Your task is to implement the `affine_transform` met... | magicoder |
You are tasked with creating a class to represent a running race participant. The class should have a private property for the participant's name and a public property for the total time taken to complete the race. Additionally, you need to implement a method to calculate the average speed of the participant during the... | magicoder |
You are tasked with implementing a class hierarchy for a network server application. The provided code snippet outlines the interface for a `ListenStrategy` class and its derived class `SelectListenStrategy`. Your goal is to create the necessary classes and methods to manage the listening behavior of a network server u... | magicoder |
You are tasked with implementing a custom UIControl subclass in Swift that allows setting a value for a specific control state. The provided code snippet demonstrates the usage of an unsafe bit cast to invoke a method for setting a value for a control state. Your task is to create a method within the UIControl subclass... | magicoder |
You are tasked with implementing a function to manage scheduled updates for a live synchronization plugin in a content management system. The plugin, `LiveSyncPlugin`, is responsible for synchronizing content between different systems. The function, `scheduled_update`, is intended to check if the scheduled updates are ... | magicoder |
You are working on a time management software project called Kronos Heureka. The project involves handling dates and times using a custom Python module. The code snippet provided imports classes from the custom module for handling dates and times.
Your task is to create a Python class that represents a calendar event ... | magicoder |
You are tasked with implementing a simplified version of a C++ class that manages Vulkan instance creation. The class contains a member variable `m_instanceCreateInfo` of type `VkInstanceCreateInfo`, and another member variable `m_appInfo` of type `VkApplicationInfo`. Your goal is to write a method that sets the `pAppl... | magicoder |
You are tasked with creating a Python script that automates the process of building and distributing a Python package using the `setuptools` library. The script should perform the following tasks:
1. Create a `setup.py` file with the necessary metadata for the package.
2. Build a wheel distribution of the package using... | magicoder |
You are tasked with implementing a class that represents a nonterminal symbol in a context-free grammar. The class should include a property to access the nonterminal symbol.
You are given the following code snippet as a starting point:
```csharp
/// </summary>
public SymbolNonterminal Symbol {get{return (SymbolNonter... | magicoder |
You are tasked with creating a Python class that manages the scheduling of appointments for a medical clinic. The class should allow for the addition, removal, and rescheduling of appointments, as well as provide functionality to retrieve the schedule for a specific date.
Your task is to implement the `AppointmentMana... | magicoder |
You are tasked with implementing a custom annotation processor for a Java project. The annotation processor should generate code to validate the format of a specific field in a class. The validation format is specified using a regular expression provided as a parameter to the custom annotation.
Your task is to create ... | magicoder |
You are tasked with implementing a custom data structure that supports the following operations efficiently:
1. `add(x)`: Add the element `x` to the data structure.
2. `remove(x)`: Remove the element `x` from the data structure if it exists.
3. `contains(x)`: Check if the data structure contains the element `x`.
You ... | magicoder |
You are given a JSON object representing a set of data. Your task is to write a function that will extract a specific value from the JSON object based on a given key. The JSON object may contain nested structures, and the key may appear at different levels within the object.
Write a function `extractValue(json, key)` ... | magicoder |
You are tasked with implementing a custom testing framework for a Python API. The framework should be able to validate the behavior of the API's `apply` function when given different input and context.
Your task is to create a class `APITestCase` with the following requirements:
- The class should inherit from `unitte... | magicoder |
You are given a list of line styles used in a graphics library. Each line style is represented by a string, and the list contains various line styles. Your task is to write a function that takes this list as input and returns a dictionary containing the frequency of each line style in the list.
For example, given the ... | magicoder |
You are working on a project that involves processing multi-dimensional tensors. You need to implement a function that retrieves a value from a tensor at a given position. The tensor is represented as a multi-dimensional array, and the position is specified as an array of coordinates.
You are given the following code ... | magicoder |
You are tasked with implementing a feed simulation system for a social media app. The system should handle the display of images in a feed and simulate the loading of new images as the user scrolls through the feed. You are given a partial implementation of the `FeedViewController` class and the `simulateFeedImageViewN... | magicoder |
You are tasked with implementing a custom error type and handling it within a Rust function. The provided code snippet is a method signature and an error return statement from the `otspec` crate, which is used for working with OpenType font files. The method signature indicates that the function takes a reference to `s... | magicoder |
You are given an array of integers `nums` of length `n`. Your task is to create a new array `ans` of the same length, where `ans[i]` is the product of all elements in `nums` except `nums[i]`.
Write a function `productExceptSelf` that takes in an array of integers `nums` and returns the resulting array `ans`.
For exam... | magicoder |
You are tasked with implementing a Python class method that initializes the weights for a Long Short-Term Memory (LSTM) pooling cell. The LSTM pooling cell size is provided as an attribute of the class. Additionally, the class contains a method that applies softmax to the attention scores if a specific flag is set. You... | magicoder |
You are tasked with implementing a texture loading and drawing system for a simple 2D game. The game engine provides a set of functions for loading textures and drawing them on the screen. The texture loading function loads an image file and returns a unique identifier for the loaded texture. The drawing function takes... | magicoder |
You are tasked with implementing a class method for a data structure that represents a list of x-values and a corresponding list of y-values. The method should update the y-value at a given x-index by adding a specified value to it. The method should also handle cases where the x-value does not exist in the list, and i... | magicoder |
You are tasked with creating a Python program to manage and retrieve quotes in a group chat. The program should allow users to save quotes by replying to a message with `#quote` and recall saved quotes by using `#recall`. The program should also display the number of quotes saved for the group.
Your task is to impleme... | magicoder |
You are tasked with creating a Rust function that checks whether a given expression conforms to a specific pattern. The function should take into account the Rust compiler version and provide appropriate linting based on the version compatibility.
Write a function `check_expression` that takes the following parameters... | magicoder |
You are tasked with implementing a function to process telemetry data from different types of requests and dependencies. The telemetry data is received in the form of JavaScript objects with specific structures. Your task is to create a function that can extract and process the relevant data from these objects based on... | magicoder |
You are tasked with implementing a Python function that processes a given text file to extract and count the occurrences of specific license information. The text file contains license information in the form of comments, and your function should identify and count the occurrences of different license types.
You need ... | magicoder |
You are tasked with implementing a class hierarchy for a car control system. The system consists of a `SimpleCar`, `DistanceCar`, and `HeadingCar` classes. The `SimpleCar` class is a base class that takes a `control` parameter. The `DistanceCar` class is derived from `SimpleCar` and takes additional parameters `odomete... | magicoder |
You are tasked with implementing a class `TestRunner` that can execute test cases for a given function. The class should have a method `runTest` which takes a function and a list of test cases as input. Each test case is a tuple containing the input arguments for the function and the expected output. The `runTest` meth... | magicoder |
You are tasked with implementing a class to render EPICS (Experimental Physics and Industrial Control System) records based on the provided keyword arguments. EPICS is a set of open-source software tools, libraries, and applications developed collaboratively and used worldwide to create distributed soft real-time contr... | magicoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.