instruction_seed stringlengths 29 40.5k | source stringclasses 6
values |
|---|---|
You are tasked with creating a Python class to represent musical instruments. The class should have the following attributes and methods:
Attributes:
- name (str): name of the instrument.
Methods:
- play(): a method that prints a message indicating the instrument being played.
Your task is to create the Instrument c... | magicoder |
You are tasked with creating a class to manage attendees for an event using PHP. The class should include functionality to add, remove, and retrieve attendee information. Additionally, it should be able to check if a specific attendee is already registered for the event.
Create a PHP class named `EventManager` with th... | magicoder |
You are tasked with creating a Python program that reads a JSON file containing Bitcoin transaction values and performs various operations related to Bitcoin addresses and programs. The program should utilize the `get_public_key_hash`, `get_p2pkh_program`, `get_p2wpkh_program`, and `get_p2wpkh_address` functions to pro... | magicoder |
You are tasked with creating a custom React hook that manages the visibility state of a component. The hook should provide functions to show and hide the component, as well as a boolean value indicating the current visibility state.
Your task is to complete the implementation of the custom hook `useVisibility` by fill... | magicoder |
You are tasked with implementing a simple environment class in Python that can store key-value pairs and provide methods for adding, retrieving, and deleting entries. The environment should also support the ability to check if a key exists and to retrieve all keys or values.
Your task is to complete the implementation... | magicoder |
You are tasked with implementing a dynamic casting mechanism for a custom map class in C++. The map class is represented by the `Map` class, and it has a pointer to its type stored in `MapPtr`. The code snippet provided initializes a `MapPtr` by dynamically casting the type pointer of a given object `pPtr`.
Your task ... | magicoder |
You are tasked with implementing a custom Gated Recurrent Unit (GRU) neural network layer for a natural language processing (NLP) application. The GRU is a type of recurrent neural network (RNN) that is capable of capturing long-range dependencies in sequential data. Your task is to create a Python class that represent... | magicoder |
You are tasked with implementing a function that simulates a window state change in a user interface. The function takes in a window object and an old window show state, and then updates the window to reflect the new state. The window show state is an enumeration representing different states in which a window can be d... | magicoder |
You are tasked with creating a program that simulates the functionality of the `export` command in a Unix-like shell. The `export` command is used to set environment variables in the current shell session. When a variable is exported, it becomes available to any child processes that are spawned from the current shell. ... | magicoder |
You are tasked with creating a script that automates the process of connecting to a remote server via SSH. Your script should take two command-line arguments: the first argument is the username for the remote server, and the second argument is the IP address or hostname of the remote server. Your script should then est... | magicoder |
You are tasked with implementing a class `Tester` that has a method `test` which takes a function as an argument and returns the result of executing that function. Additionally, you need to create a program that utilizes the `Tester` class to test various functions.
Your task is to implement the `Tester` class and wri... | magicoder |
You are tasked with creating a web application for user authentication using Django. You need to implement a registration form and a login form with specific requirements.
Your task is to create a Django form for user registration and another form for user login. The registration form should inherit from `UserCreation... | magicoder |
You are tasked with creating a custom error handling system for a meditation app. The app needs to define a set of error domains and error codes to handle various types of errors that may occur during meditation sessions. Each error domain should have a unique string identifier, and each error code within a domain shou... | magicoder |
You are tasked with implementing a `flash()` method for a custom UITableViewCell subclass in Swift. The `flash()` method should animate a brief visual change to indicate selection. The `flash()` method should change the cell's background color to a different color for a short duration and then revert it back to the ori... | magicoder |
You are tasked with creating a web application that allows users to manage announcements. The code snippet provided is a part of the user interface for deleting an announcement. The snippet includes an HTML-like syntax with a custom tag `<x:heroicon-o-trash>` representing an icon for the "Delete announcement" action. A... | magicoder |
You are tasked with implementing a class that represents a parameter with constraints in a TypeScript application. The `Parameter` interface is defined with the following properties:
- `name`: a string representing the name of the parameter
- `constraints`: an array of `Constraint` objects representing the constraints ... | magicoder |
You are tasked with implementing a function that processes a set of playing cards and determines the highest poker hand that can be formed from the given cards. The function should take a list of playing cards as input and return the highest poker hand that can be formed.
Each playing card is represented as a string w... | magicoder |
You are tasked with creating a class that represents a Discord user. The class should have three properties: `IsManaged`, `IsMentionable`, and `GuildId`. The `IsManaged` property should indicate whether the user is managed by an integration, `IsMentionable` should indicate whether the user can be mentioned, and `GuildI... | magicoder |
You are tasked with creating a Python function that processes textual data using the Stanford NLP library. The function should take a pandas DataFrame `statute_df` as input, which contains a column named "Content" with textual content to be processed. The function should iterate through each row of the DataFrame, extra... | magicoder |
You are working on a project that involves loading and decoding parameters for a machine learning model. Your task is to write a Python function that processes the loaded parameters and performs specific actions based on certain conditions.
You are given a list `DECODER_ONLY_PARAMS` containing parameter names. For ea... | magicoder |
You are tasked with implementing a simplified version of a signal handling system in C++. The provided code snippet outlines the structure of the system, including a `SignalMaster` class responsible for managing signals and a `Signal` enum representing different types of signals. Your task is to complete the implementa... | magicoder |
You are tasked with implementing a class that represents a generator in a custom data processing library. The class should support multiplication operations with other generators. The provided code snippet shows two methods, `mul_generators` and `rmul_generators`, which are used to multiply two generators together. The... | magicoder |
You are tasked with creating a command-line utility that processes a series of commands. The utility should support the following commands:
- `add <number>`: Add the specified number to the current total.
- `subtract <number>`: Subtract the specified number from the current total.
- `multiply <number>`: Multiply the cu... | magicoder |
You are tasked with creating a script that analyzes the compilation status of a software project. The script should take the compilation status as input and provide an appropriate exit code and message based on the status.
Write a Bash script that takes a single argument representing the compilation status. The possib... | magicoder |
You are given a list of `file_data`, where each element represents a timestamp in the format "YYYY-MM-DD HH:MM:SS". Additionally, there is a function `get_time_members(data)` that takes a timestamp string as input and returns its individual time components (year, month, day, hour). The code snippet provided iterates th... | magicoder |
You are working on a Django web application that manages information about passengers and drivers. The code snippet provided includes two Django model classes: `Passenger` and `Driver`. Each class has a method `get_absolute_url` that returns the URL for the detail view of the respective object.
Your task is to impleme... | magicoder |
You are working on a system that handles frequency inversion for a signal processing application. The code snippet provided is a part of a method in a class that manipulates an array representing the frequency inversion. The method `setUIntElement` is used to set a specific element in the array to a given value. The pa... | magicoder |
You are tasked with implementing a movie rental system. The system should handle the inventory of movies and the rental process. Each movie has a title, stock quantity, and rental price. When a customer wants to rent a movie, the system should check if the movie is available in stock. If the movie is available, the sys... | magicoder |
You are working on a machine learning project and need to evaluate the accuracy and loss of a trained model using TensorFlow. The code snippet provided is a part of a larger TensorFlow session and graph setup. Your task is to write a Python function that takes the session and graph as input and returns the accuracy and... | magicoder |
You are tasked with implementing a custom trait in Rust that represents interrupt numbers for a microcontroller. The trait, `InterruptNumber`, has a single method `number` that returns an unsigned 16-bit integer representing the interrupt number. Additionally, there is a deprecated implementation for the old `bare_meta... | magicoder |
You are tasked with implementing a Python class that simulates a simple banking system. The class should support basic operations such as creating a new account, depositing funds, withdrawing funds, and checking the account balance. Additionally, the class should enforce basic validation rules for account creation and ... | magicoder |
You are tasked with implementing a lock management system using Python's asyncio library. Your goal is to create a class that can acquire and release locks to ensure exclusive access to a shared resource. The provided code snippet outlines the beginning of a `LockOps` class, which is a subclass of `CoordinatorOp`. Your... | magicoder |
You are tasked with creating a file management system for a restaurant. The system should allow the restaurant staff to save and manage files related to different tables in the restaurant. Each table will have its own set of files, and the staff should be able to save files with custom names for easy identification.
Y... | magicoder |
You are tasked with creating a unit test for a Python class called `Planner`. The `Planner` class is responsible for managing a set of `Link` objects, which represent connections to other components in a larger system. The test is intended to verify that the `Planner` class correctly handles the lifecycle events of its... | magicoder |
You are working for a cloud computing company that provides a Key-Value Cache Service (KCS) to its clients. The KCS allows clients to manage their cache instances and associated security groups through a set of API operations. Your task is to implement a function that simulates the behavior of these API operations.
Yo... | magicoder |
You are tasked with implementing a simple inventory system for a game using C#. The inventory system should allow adding, removing, and checking the availability of items. You are provided with a basic `Inventory` class and a `Structure` class that contains an instance of the `Inventory` class. Your task is to implemen... | magicoder |
You are tasked with implementing a Rust structure that represents a mathematical concept. The structure should contain specific fields and methods to perform operations related to the concept. Your task is to complete the implementation of the structure and its associated methods.
You are given a code snippet that ini... | magicoder |
You are tasked with implementing a Python class method that processes a model dictionary and populates certain attributes based on the data within the dictionary. The method should extract specific values from the model dictionary and use them to populate the `model_output` attribute and initialize the `inner_param` at... | magicoder |
You are tasked with optimizing a Python script that processes log messages. The script currently uses the `re` module to extract specific information from log messages, but it has been observed that using `re`'s `each_with_index` method is slower than a while loop for this particular task. Your goal is to refactor the ... | magicoder |
You are tasked with implementing a simple message processing system using Kafka consumer in Python. Your goal is to create a program that consumes messages from a Kafka topic and prints them, ensuring that each message is printed only once and any new messages are printed as they arrive.
You are given the following co... | magicoder |
You are tasked with implementing a Python program to read a file containing JSONL (JSON Lines) data and write a modified version of the data to a new file. The input file contains a list of JSON objects, each representing a data record, and the program should modify the data before writing it to the output file.
Your ... | magicoder |
You are tasked with implementing a function to parse and extract color information from a given code snippet. The code snippet contains a comment that describes a color in either RGB or named format. Your task is to write a function that extracts the color information and returns it in a standardized format.
Write a f... | magicoder |
You are tasked with implementing a function that removes the static offset from a given HTML element's position. The static offset is defined as setting the `bottom` and `right` styles to `auto`. Your function should take an HTML element as input and modify its styles to remove the static offset, ensuring that the elem... | magicoder |
You are working on a web application that involves managing a list of items. The application uses CSS modules to style the user interface. You have been provided with the following code snippet from the CSS module file:
```javascript
export const item__add: string;
export const item__add_disabled: string;
```
Your ta... | magicoder |
You are tasked with creating a TypeScript interface for a network event log structure. The log contains various fields related to network events, and your job is to define an interface that enforces the correct data types for each field.
You are given the following fields:
- `EventTV`: A string representing the timest... | magicoder |
You are tasked with implementing a modified version of the DGCNN (Dynamic Graph Convolutional Neural Network) model in PyTorch for a specific task and dataset. The provided code snippet shows the beginning of the custom DGCNN class, which inherits from nn.Module and has an __init__ method. Your task is to complete the ... | magicoder |
You are tasked with implementing a function that extracts and formats data from a given array of objects. The objects represent products, and each object contains information about the product's name, category, and price. Your function should filter the products based on a specified category and format the price of eac... | magicoder |
You are tasked with implementing a logging system for a web application. The system should support different log modes, including 'live', 'interactive', and 'grouped'. Each log mode has specific behavior and requirements. Your task is to create a TypeScript type definition for the `LogMode` type that accurately represe... | magicoder |
You are tasked with implementing a hierarchy of geometric shapes using object-oriented programming principles. Your goal is to create a class hierarchy that allows you to work with points and areas in a geometric context.
You are provided with a base class `HierarchyPlace` that serves as the foundation for the hierar... | magicoder |
You are tasked with creating a Python function that generates a JSON web token (JWT) for user authentication. The function should take in a user object, a token, and a JWT expiration delta, and return a JSON object containing the access token, token type, expiration time, and user data serialized using a custom seriali... | magicoder |
You are tasked with implementing a message publishing system for a simplified order cancellation mechanism. The system should utilize a key-value store, such as Redis, to publish cancellation messages to a specific channel when an order expires.
You are given a code snippet that extracts the order ID from an expire ke... | magicoder |
You are tasked with creating a Python program that calculates the number of days between two given dates. Your program should take two dates as input and output the number of days between them, inclusive of the start date and end date. You should consider leap years and ensure that the program handles invalid inputs gr... | magicoder |
You are tasked with implementing a function to generate candidates for a machine learning model based on given parameter constraints. The function should take into account linear constraints extracted from a search space and use a model to generate the candidates.
You are given a code snippet that extracts linear cons... | magicoder |
You are tasked with creating a script to interact with the Azure Search service using the Azure Search REST API. The script will be responsible for sending a request to the Azure Search service to retrieve documents from a specific index.
The provided code snippet is a part of the script and contains the following var... | magicoder |
You are working on a Python application that interacts with a MySQL database using the `pymysql` library. The code snippet provided is a part of a database access class. The `update` method is used to update records in a specified table. The method takes three parameters: `table_name` (the name of the table to update),... | magicoder |
You are working on a project that involves fetching and integrating external libraries. As part of this process, you need to automate the fetching of these libraries from their respective repositories. Your task is to write a script that automates the fetching of the "libb64" and "tinyxml2" libraries from their GitHub ... | magicoder |
You are tasked with implementing a time formatting function for a mobile application. The function should take the current context and a given hour and minute as input and return the formatted time as a string. The formatting should consider whether the device is set to a 24-hour or 12-hour time format.
You are provid... | magicoder |
You are tasked with creating a Python function that generates DNS records for a given domain. The function should take in the domain name as a parameter and return a formatted DNS record string. The DNS record should include the domain name, an IP address, and a random sorting value.
Your task is to implement the `gen... | magicoder |
You are tasked with creating a Python program that processes a given file to extract information about GitHub repositories and their stars. The file contains lines of code, and each line may or may not contain information about GitHub repositories and their stars. The format of the lines is as follows:
```
<gh_stars>mi... | magicoder |
You are given a Python class `Grafo` that represents a graph. The class has a method `insertAresta` to insert an edge (represented by `Aresta` objects) into the graph, and a method `ciclico` to determine whether the graph contains a cycle. An edge is represented by the `Aresta` class, which takes two vertices as its pa... | magicoder |
You are tasked with implementing a simple suggestion system for a search engine. The suggestion system should take a query string and return a list of suggested words based on the input query. To achieve this, you need to implement a class `Suggester` with a method `suggest` that takes the query string as input and ret... | magicoder |
You are tasked with implementing a JavaScript function that manages a checkout system for a library. The function should prevent users from checking out the same book multiple times and should return a Promise that resolves when the checkout is successful. Below is a code snippet that partially implements the checkout ... | magicoder |
You are tasked with creating a Python class that dynamically generates an argument parser for a machine learning model configuration. The class should allow users to add different types of arguments with default values and then parse the input arguments to obtain the configuration settings.
Your task is to implement t... | magicoder |
You are tasked with creating a Django web application that includes a URL pattern for the home page. Your goal is to define a URL path for the home page and link it to the corresponding view. Additionally, you need to ensure that the app name is correctly specified.
Write a function `create_home_url` that takes in the... | magicoder |
You are tasked with creating a custom PHP class that represents a user entity in a web application. The class should include properties and methods to manage user data. Your task is to implement the class with the following requirements:
1. The class should be named "User" and should have a constructor that initialize... | magicoder |
You are tasked with implementing a Python function that rounds a given floating-point number to a specified number of decimal places. The function should take two parameters: the floating-point number to be rounded (`num`) and the number of decimal places to round to (`decimal_places`). The function should return the r... | magicoder |
You are tasked with creating a Django web application for managing file uploads. The application should allow users to upload various types of files, such as images, documents, and videos. To achieve this, you need to define a model for the uploaded files and register it with the Django admin interface.
Define a Djang... | magicoder |
You are tasked with implementing a function that processes user input for a zoom feature in a graphics application. The function should take three parameters: `width`, `height`, and `zoom`. The `width` and `height` parameters represent the dimensions of the graphics, and the `zoom` parameter represents the level of zoo... | magicoder |
You are tasked with implementing a stack data structure using a linked list. The stack should support the standard push and pop operations, along with a method to retrieve the minimum element in constant time. You need to design the stack to have O(1) time complexity for all operations.
You are given the following Nod... | magicoder |
You are tasked with creating a Python function that securely stores sensitive information, such as passwords and API keys, using a custom encryption scheme. The function should take in the sensitive information as input and return the encrypted string. Additionally, you need to implement a decryption function that take... | magicoder |
You are tasked with creating a command-line utility for managing a hypothetical service. The utility should accept different commands such as start, stop, restart, install, and uninstall. The usage of the utility should be displayed when an invalid command is provided. Your task is to implement the logic for parsing th... | magicoder |
You are tasked with implementing a user account management system using Python. The code snippet provided defines an empty dictionary `user_account` and a function `total_users()` that is intended to return the total number of registered users. However, the function is incorrectly referencing a non-existent variable `r... | magicoder |
You are required to implement a Python function `fact(n)` that calculates the factorial of a given non-negative integer `n`. 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 3 (denoted as 3!) is calculated as 3 * 2 * 1 = 6.
The... | magicoder |
You are tasked with implementing a simple 2D graphics rendering system. The system uses a coordinate system where the origin (0, 0) is at the top-left corner of the window, and the x-axis increases to the right while the y-axis increases downwards. The rendering system has a method `blit` that takes the x and y coordin... | magicoder |
You are working on a game development project and need to implement a function to calculate the distance of a player from a beach ellipse. The ellipse is defined by its center coordinates (cx, cy), and the half-width (rw) and half-height (rh) of the ellipse. The player's position is given by the coordinates (x, y). You... | magicoder |
You are tasked with creating a custom form for the administration of video clips in a web application. The form should include specific fields and validation rules to ensure the accurate and secure management of video clip data.
Your task is to implement a custom form class, `ClipAdminForm`, that inherits from `forms.... | magicoder |
You are tasked with implementing a function to process iCloud records based on a given predicate. The function should filter the iCloud records based on the provided predicate and return the filtered records.
You are given the following code snippet as a starting point for your implementation:
```swift
private func ch... | magicoder |
You are tasked with implementing a simple Python program that simulates a basic chatbot. The chatbot should greet the user and ask for their name. Once the user provides their name, the chatbot should respond with a personalized greeting. The chatbot should then ask the user how their day is going and provide a respons... | magicoder |
You are working on a data catalog system that stores information about variables used in scientific datasets. The system uses a relational database with two tables: `Variable` and `Alias`. The `Variable` table stores information about variables, while the `Alias` table stores aliases for these variables. Each variable ... | magicoder |
You are tasked with implementing a Python function that processes a given string to extract specific information based on certain conditions. The function should take a string as input and perform the following operations:
1. Check if the input string contains the substring "iwrite".
2. If "iwrite" is found, extract t... | magicoder |
You are working as a DevOps engineer at a software development company. Your team is responsible for setting up the development environment for various applications using OpenShift Container Platform. You need to automate the process of setting up a new build and application deployment for different development project... | magicoder |
You are tasked with implementing a function that validates a form action attribute in an HTML document. The function should check if the form action attribute is either an empty string or None, and return True if it is, and False otherwise.
The function signature is:
```python
def validate_form_action(form_action: str... | magicoder |
You are tasked with creating a web application for managing vehicle information. The application uses a popular PHP framework that utilizes Blade templating for the front-end. You need to implement a feature to display a form for adding new vehicles on a web page. The form should be included within the main content sec... | magicoder |
You are tasked with implementing a Python class that simulates a simple banking system. The class, `BankAccount`, should have methods to deposit funds, withdraw funds, and check the balance. Additionally, the class should keep track of the total number of transactions performed on all bank accounts.
You are provided w... | magicoder |
You are working on a security application that requires handling encrypted key strings. The application uses a keyfile to store and retrieve encrypted keys. The keyfile contains a list of encrypted key strings, each of which is associated with a unique identifier. Your task is to implement a function that takes a keyfi... | magicoder |
You are tasked with creating a React component that displays a list of items fetched from an API and allows the user to filter the items based on a specific criterion. The component should also include a search functionality to filter items based on a search query. You are provided with a basic structure of the compone... | magicoder |
You are tasked with creating a script to merge multiple PDF files into a single PDF document. The script should take input from a file containing a list of file paths and a folder name, and then use the `wkhtmltopdf` and `pdftk` commands to merge the PDF files.
Your script should perform the following steps:
1. Read e... | magicoder |
You are tasked with implementing a data stream sink for a TLS socket in Swift. The provided code snippet is a part of a TLS socket library and shows the extension method `sink` for the `TLSSocket` class. Your goal is to create a `TLSSocketSink` class that will handle writing data to the TLS socket on a specific event l... | magicoder |
You are tasked with simulating a simple queuing system for a customer service center. The system receives incoming customer requests and processes them based on a predefined time step. Your goal is to implement a Python function that simulates the queuing system and calculates the average number of customers in the que... | magicoder |
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... | magicoder |
You are tasked with creating a program to manage and display a collection of catalog items. The catalog items are stored in an array `$All_Cetalogues`, where each item is an associative array with keys `id` and `url`. The program should generate HTML to display each catalog item in a grid layout, with an option to dele... | magicoder |
You are tasked with creating a Python function that retrieves the current version of a library. Your function should return a string representing the version number. The version number is expected to match the value specified in the library's setup.py file.
Write a function called `get_library_version` that takes no a... | magicoder |
You are tasked with creating a web form for a product management system. The form should allow users to input and update product details. The provided code snippet is a part of the HTML form for adding or editing product information. The form uses the Laravel Blade templating engine to populate input fields with existi... | magicoder |
You are tasked with implementing a Swift function to encode data for a specific API request. The provided code snippet is part of a larger Swift application that interacts with an API. Your task is to complete the implementation of the `encodeBody` function, which is responsible for encoding the request body data befor... | magicoder |
You are given a string of comma-separated numbers representing ASCII values. Your task is to decode the string and convert it into the corresponding characters. Each number represents the ASCII value of a character. The string may contain non-printable characters as well.
Write a function or program that takes the inp... | magicoder |
You are tasked with implementing a simplified version of a Shopify client in PHP. The client interacts with the Shopify API to perform various operations. Your goal is to create a class that can set the shop name, access token, and make API calls to the Shopify server.
You are provided with a code snippet that tests t... | magicoder |
You are tasked with implementing a Python class that represents a convolutional neural network (CNN) layer. The provided code snippet is a part of the constructor method of the CNN layer class. Your task is to complete the implementation of the constructor method by adding the necessary code to handle the initializatio... | magicoder |
You are tasked with implementing a function that processes user permissions based on a given code snippet. The code snippet is part of a larger web application and is written in Python using the webapp2 framework. The function `get` is a method of a class and takes a parameter `blockable_id`. It retrieves a blockable e... | magicoder |
You are tasked with implementing a cacheable response trait for a given struct in Rust. The `impl_macro` function takes a `syn::DeriveInput` as input and generates the implementation code for the `CacheableResponse` trait for the given struct.
Your task is to complete the implementation of the `impl_macro` function to... | magicoder |
You are tasked with implementing a tip timing system for a game. The game has a `TicketSpawn` component, and the tip timing functionality is handled within a script. The `Update` method calls the `TipTiming` method, which checks if the `tipTime` variable is greater than 0. Your task is to complete the `TipTiming` metho... | magicoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.