instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with creating a program that processes information about instances in a cloud environment and organizes it for display. The input consists of a list of instances, each with attributes such as public DNS name, region, instance type, IP address, and launch time. The program should group the instances based...
codefeedback
You are tasked with creating a validation function for "slug" strings used in a web application. A "slug" is a URL-friendly string typically used to uniquely identify resources. The validation function should ensure that the input string consists only of letters, numbers, underscores, or hyphens. Additionally, the func...
codefeedback
You are tasked with implementing a function to calculate the regularized incomplete beta function, which is commonly used in statistics and probability theory. The regularized incomplete beta function is defined as: \[ I_x(a, b) = \frac{1}{B(a, b)} \int_0^x t^{a-1}(1-t)^{b-1} dt \] Where \( B(a, b) \) is the beta fun...
codefeedback
You are tasked with creating a program that analyzes HTML code to identify and count the occurrences of specific HTML tags within the code. Your program should be able to handle nested tags and should output the count of each tag found. For example, given the following HTML code snippet: ```html <!DOCTYPE html> <html>...
codefeedback
You are tasked with implementing a file processing system that involves reading file sizes, skipping empty files and directories, and opening files with a password. Your task is to write a function that takes a file reader object, a password, and a list of file paths, and performs the following operations: 1. Iterate t...
codefeedback
You are tasked with implementing a caching system using the CacheMode class in Python. The CacheMode class should support two modes of caching: "LRU" (Least Recently Used) and "LFU" (Least Frequently Used). The caching system should be able to store key-value pairs and evict items based on the specified caching mode. ...
codefeedback
You are tasked with creating a program that simulates a simple file system. The file system will consist of directories and files, and you need to implement the functionality to navigate through directories, create new files, and display the contents of files. Your task is to implement a command-line interface program...
codefeedback
You are tasked with creating a function that extracts the last segment of a given import statement in a JavaScript file. The import statement follows the format `import <ComponentName> from '<path>'`, where `<ComponentName>` is the name of the component being imported and `<path>` is the file path. Your function should...
codefeedback
You are tasked with designing a LiteX-based system that includes an Ethernet interface with Etherbone support. LiteX is a Python-based SoC (System on Chip) builder that allows for the creation of customizable and complex digital designs. Etherbone is a network protocol for transporting Wishbone transactions over Ethern...
codefeedback
You are tasked with implementing a JavaScript function that parses a given string and returns an object containing the frequency of each word in the string. The function should ignore punctuation and treat uppercase and lowercase letters as equivalent. For example, "The cat in the hat" and "the cat, in the hat." should...
codefeedback
You are tasked with creating a Python class that simulates a simple user management system. The system should allow for the creation, retrieval, updating, and deletion of user records. The user records should include attributes such as username, email, and role. Additionally, the system should provide functionality for...
codefeedback
You are tasked with creating a PHP script that dynamically generates a navigation menu based on a given array of menu items. The navigation menu should be displayed using HTML and CSS, and the active menu item should be highlighted. You are provided with a PHP code snippet that includes the necessary header and naviga...
codefeedback
You are given a list of strings representing headers in Markdown format. Each string starts with a certain number of '#' symbols followed by a space and the header text. Your task is to write a function that parses these strings and returns the headers in a nested dictionary format, where the keys are the header texts ...
codefeedback
You are tasked with implementing a custom sorting algorithm for a list of objects based on two specific attributes. Each object has two attributes: `abbreviation`, a string representing an abbreviation, and `far_order`, an integer representing a numerical order. The goal is to sort the list of objects first by the `abb...
codefeedback
You are tasked with creating a program that generates a random color palette using the XKCD color survey data. The XKCD color survey collected data on color names and their corresponding RGB values. Your program should randomly select a set of unique colors from the XKCD color survey data and display the color palette....
codefeedback
You are tasked with creating a script that automates the process of building Docker images for different Python versions. The provided code snippet is a part of a Bash script that invokes another script to build a Docker image. The script takes in several arguments, including the Python version and additional parameter...
codefeedback
You are tasked with implementing a custom neural network architecture for image classification using PyTorch. The given code snippet is a part of the network definition and shows the construction of convolutional blocks using PyTorch's nn.Sequential module. Each block consists of a series of operations including convol...
codefeedback
You are tasked with implementing a caching mechanism for a Discord bot to efficiently retrieve member information from a guild. The `get_or_fetch_member` function is responsible for looking up a member in the cache and fetching it from the guild if not found. The function takes in a `guild` object representing the Disc...
codefeedback
You are tasked with implementing a function that copies a given state to a buffer, ensuring that the buffer does not exceed a maximum length. The function should handle the case where the given state is null. You are provided with a code snippet that initializes the view and calls the function to copy the state. You n...
codefeedback
You are tasked with creating a logging system for a software application. The application needs to log different types of errors to separate log files based on their severity. You have been provided with a Python code snippet that initializes a logger for logging errors related to the Sentry client. Your task is to ext...
codefeedback
You are tasked with implementing a Python function that calculates the lower incomplete gamma function, denoted as `lowergamma(a, x)`. The lower incomplete gamma function is defined as: \[ \gamma(a, x) = \int_0^x t^{a-1} e^{-t} dt \] Your task is to implement the `lowergamma` function and ensure that it satisfies cer...
codefeedback
You are tasked with creating a Python package using setuptools for distribution. Setuptools is a package development library that facilitates the creation and distribution of Python packages. Your goal is to create a simple Python package with a specific directory structure and necessary configuration files. Your pac...
codefeedback
You are tasked with creating a Python function that processes data from a performance analysis tool and generates plots for various configurations. The function takes in a list of data and configuration parameters and produces a plot based on the input. Your task is to implement the function `plot_configuration` that t...
codefeedback
You are tasked with creating a program that calculates the sum of the first n natural numbers and the sum of the squares of the first n natural numbers. The program should take an integer n as input and output the sum of the first n natural numbers and the sum of the squares of the first n natural numbers. For example...
codefeedback
You are tasked with implementing a method formatter for a specific RabbitMQ method in C#. The method formatter is responsible for serializing the method into a byte array for transmission over the network. Your goal is to complete the implementation of the `CloseMethodFormatter` class, which is used to format the `Clos...
codefeedback
You are working on a secure messaging application that requires the use of a secret key for encryption and decryption. The secret key is stored in a variable named `$appsecret`. Your task is to write a function that takes a message as input and encrypts it using the secret key. The encryption algorithm involves shiftin...
codefeedback
You are tasked with implementing a custom future polling mechanism in Rust. Futures are a fundamental concept in asynchronous programming, representing a value that may not yet be available. Your goal is to create a custom `Future` trait implementation with two methods: `expect_ok` and `expect_err`. The `expect_ok` me...
codefeedback
You are tasked with implementing a function to edit Modbus request and response packets in a PCAP file. Modbus is a communication protocol used for transmitting information between electronic devices. The provided code snippet demonstrates the setup for reading from a PCAP file, writing to a new PCAP file, and calling ...
codefeedback
You are working on a machine learning project and need to build a decision tree classifier using the scikit-learn library in Python. Your task is to create a program that loads a dataset, preprocesses it, trains a decision tree classifier, and evaluates its performance. Your program should perform the following steps:...
codefeedback
You are tasked with implementing a command-line interface (CLI) task for a system. The given code snippet is a part of the CLI task and represents the implementation of the `command_lsahci` function. The function is intended to handle the "lsahci" command, which is used to list the contents of a specific directory. The...
codefeedback
You are tasked with implementing a data validation function for a clinical trial database. The function should validate the data types of various fields in a trial record based on a provided schema. The schema is represented as a dictionary where the keys are field names and the values are the expected data types for t...
codefeedback
You are tasked with implementing a dynamic app factory for a home automation system using the NetDaemon framework. The dynamic app factory should be capable of creating and managing multiple instances of dynamic apps based on user-defined configurations. Your task is to create a class `DynamicAppFactory` that allows t...
codefeedback
You are tasked with implementing a custom provider system for a React application. The goal is to create a hierarchy of provider components that wrap the application, allowing different parts of the application to access shared data and functionality. Each provider should be able to accept optional props and provide de...
codefeedback
You are tasked with creating a program that interacts with the GitHub API to retrieve information about a specific repository. Your program should use the RestEase library to make an asynchronous HTTP request to the GitHub API and retrieve the number of stars for a given repository. You are provided with the following...
codefeedback
You are tasked with creating a Python program that sends an email with a PDF attachment using the `smtplib` library. Your program should read the PDF file from the specified location and send it as an attachment via a secure SMTP connection. You need to ensure that the email credentials are securely handled and that th...
codefeedback
You are tasked with implementing a simplified version of a mapping system for input devices in a user interface application. The system should allow users to assign input devices to specific groups and update the mappings accordingly. Your task is to implement the `bind` method and the associated functionalities. The ...
codefeedback
You are working on a computer vision project and need to preprocess a dataset of images for training a deep learning model. The preprocessing pipeline involves a series of operations to augment and manipulate the images. You have been provided with a code snippet that imports various image preprocessing operations from...
codefeedback
You are a software developer working on a user management system for a REST API. The system uses an error code map to handle different types of errors. The error code map is stored in a TypeScript file named `errorCodeMap.ts`. The file contains a mapping of error codes to their corresponding error messages. Each error ...
codefeedback
You are tasked with implementing a form validation function for a user sign-up screen in an iOS app. The provided code snippet includes outlets for various UI elements such as text fields, labels, buttons, and a text view. Your goal is to create a function that validates the user input when they attempt to sign up. The...
codefeedback
You are working on a Django web application that includes an admin interface for managing various models. One of the models in the application is named `Product`. You have been tasked with creating a custom admin interface for the `Product` model to include specific functionalities. Your task is to create a custom adm...
codefeedback
You are tasked with creating a Python program that utilizes the ChatterBot library to train a chatbot with a custom set of conversational data. The ChatterBot library is a machine learning, conversational dialog engine for creating chatbots. The code snippet provided is a partial import statement from the ChatterBot li...
codefeedback
You are tasked with creating a Python program that processes a CSV file containing information about employees and their salaries. The CSV file has the following format: ``` employee_id,employee_name,department,salary 1,John Doe,Engineering,75000 2,Jane Smith,Marketing,60000 3,Michael Johnson,Engineering,80000 4,Emily...
codefeedback
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...
codefeedback
You are working on a project that involves analyzing event logs to identify related activities. You have come across the Python code snippet below, which uses the `pm4pymdl` library to perform activity relation analysis. ```python from pm4pymdl.algo.mvp.gen_framework.rel_activities import classic, rel_activities_build...
codefeedback
You are tasked with creating a program to perform data visual analysis on a dataset containing audio information. The program should be able to visualize the original data and its adjusted, gender-isolated version using various techniques such as signal analysis, fast Fourier transform (FFT), filter bank (fbank), and M...
codefeedback
You are tasked with creating a multiplayer game server that manages team scores. The server is written in C# using the Unity game engine. The provided code snippet is a part of the server's functionality for updating team scores. The `CmdUpdateScore` method is a command that can be called by clients to update the score...
codefeedback
You are tasked with creating a program to parse and process HTML table data. The input will be a string representing an HTML table, and the output should be a list of dictionaries, where each dictionary represents a row in the table. Each dictionary should map the column headers to the corresponding cell values in that...
codefeedback
You are tasked with creating a class that manages financial data for a credit union. The given code snippet is part of a method within this class, which retrieves and processes various financial information for a specific member. Your task is to implement the missing methods and classes required to make this code snipp...
codefeedback
You are tasked with creating a Python function that parses a mesh vectorized connection and generates a C++ code snippet based on the connection information. The function `parse_mesh_vectorized_connection` takes in five parameters: - `connection`: a dictionary containing connection information, including 'In' and 'Out'...
codefeedback
You are tasked with creating a custom layout manager for a graphical user interface (GUI) application. The layout manager should arrange a series of widgets horizontally, with specific styling and spacing requirements. Your task is to implement the custom layout manager class and ensure that it correctly arranges the w...
codefeedback
You are tasked with implementing a C++ class that simulates a simple stack data structure. The stack should support the following operations: 1. `push(int val)`: Add an integer `val` to the top of the stack. 2. `pop()`: Remove the element at the top of the stack and return its value. If the stack is empty, return -1. 3...
codefeedback
You are tasked with implementing a Python function that processes a given string and returns a modified version of it. The function should take a string `ident` as input and apply a series of transformations to it. The transformations are defined by a generator `d` that yields functions to be applied to each part of th...
codefeedback
You are tasked with creating a script that simulates a simple file browsing interface in a Linux environment. The script should take a directory as input and display its contents in a user-friendly manner. The user should be able to navigate through the files and directories, and the script should provide visual feedba...
codefeedback
You are tasked with creating a Django REST API for managing email domains, aliases, and mailboxes. The given code snippet sets up the initial configuration for the API using Django, Django REST framework, and a router to handle the viewsets for the different resources. Your task is to implement the viewsets for the `D...
codefeedback
You are tasked with implementing a custom `then` function in Swift that allows for concise and readable configuration of UIKit elements. The `then` function should take a closure as its parameter, allowing the user to configure the properties of the object within the closure. The goal is to create a more fluent and exp...
codefeedback
You are tasked with implementing a Python function that processes and analyzes phase states from a file. The function should read phase states from a specified file, parse the data, and then print the index and corresponding phase groups to the console. You are given the following code snippet as a starting point: ``...
codefeedback
You are tasked with creating a custom authentication strategy for a Node.js application using TypeScript and Typegoose. Your goal is to implement a LocalStrategy class that will handle the validation of user credentials against a MongoDB database using Typegoose models. The provided code snippet is a TypeScript class ...
codefeedback
You are tasked with implementing a C++ program that manages audio IDs for a multimedia application. The provided code snippet shows a nested namespace structure with an enum class `AUDIO_ID` inside the `audio` namespace. Your task is to create a class that can store and retrieve audio IDs, and to implement methods for ...
codefeedback
You are tasked with creating a script to automate the process of checking the IP addresses associated with a given URL. The script should utilize a provided shell script called `goohost.sh` and incorporate error handling and user-friendly output. Your script should perform the following steps: 1. Pause execution for 1...
codefeedback
You are tasked with creating a Python script that automates the process of updating a version number in a file. Your script should read the current version number from a file called `version.txt` and then update this version number in another file called `app.py`. Additionally, the script should create a backup of the ...
codefeedback
You are tasked with creating a Java program that utilizes Java modules and sets specific runtime configurations. Your program should load a module from a given module path and execute a class within that module. Additionally, the program should handle illegal access warnings and set the Java library path. Write a Java...
codefeedback
You are tasked with implementing a custom data structure called `LinkedListWithDisconnect` that supports the following operations: `add`, `disconnect`, and `getLastComponent`. The `LinkedListWithDisconnect` should have the following behavior: - `add(component)`: Adds a new component to the end of the linked list. - `d...
codefeedback
You are tasked with implementing a simplified version of a REST request builder for a financial market data API. The provided code snippet is a part of a Java program that constructs a REST request for retrieving auction data from the IEX Cloud API. Your task is to create a similar request builder for a different type ...
codefeedback
You are tasked with implementing a Java class that represents a data transfer object for retrieving information about all paths between two measurable entities in a system. The class should be designed to conform to the XML representation standards and should contain specific attributes and methods for handling this da...
codefeedback
You are tasked with implementing a validation function for a form that contains several fields. Each field has a "required" attribute, which, if set to true, indicates that the field must be filled out before the form can be submitted. Your task is to write a function that takes the form data as input and checks whethe...
codefeedback
You are tasked with creating a program that formats a given date and time according to a specific format string. The format string consists of various placeholders that represent different components of the date and time. Your task is to implement a function that takes a date and time along with a format string and ret...
codefeedback
You are tasked with implementing a ray-plane intersection test for a 3D graphics engine. The given code snippet provides the interface for the ray-plane intersection functionality. Your goal is to write a function that takes a ray and a plane, and determines whether they intersect, as well as the point of intersection ...
codefeedback
You are tasked with creating a script to monitor and adjust the brightness of a display. The script should retrieve the current brightness level using the `xbacklight` command and then display it along with an emoji representing a sun and the brightness level. Additionally, the script should allow the user to set a new...
codefeedback
You are tasked with creating a program that extracts specific information from an HTML file and performs certain operations based on the extracted data. You are given an HTML snippet as follows: ``` <div class="container"> <div class="card" style="max-width: 18rem;"> <div class="card-body"> <br> <b>P...
codefeedback
You are given a Python code snippet that processes a list of categories and performs some operations based on the category information. Your task is to implement a function that simulates the behavior of the code snippet and returns the merged label array for each category. You are provided with the following informat...
codefeedback
You are tasked with designing a system to manage featured games in an online gaming platform. The platform uses a database to store information about games and their features. The code snippet provided is a simplified representation of a class `FeaturedGame` that is part of the system's data model. The class has a prop...
codefeedback
You are tasked with creating a Discord bot command that fetches and displays information about a YouTube video. The bot will take a YouTube video URL as input and retrieve the video's title, duration, and number of views. You are provided with a Python class snippet for the Discord bot command implementation. Your tas...
codefeedback
You are tasked with implementing a function that validates the structure of an HTML element based on a set of matchers. The matchers define the expected structure of the element's children. The function should return true if the element's children match the specified structure, and false otherwise. You are given the f...
codefeedback
You are tasked with implementing a parser for Abstract Syntax Notation One (ASN.1) encoded data. ASN.1 is a standard interface description language for defining data structures that can be serialized and deserialized in a cross-platform way. Your parser needs to handle a specific ASN.1 definition and extract informatio...
codefeedback
You are tasked with implementing a function that parses a code snippet and extracts relevant information to generate a function signature. The code snippet provided is a part of a larger program that defines a function `acosNode()` using a custom syntax. Your task is to write a program that can extract the necessary in...
codefeedback
You are given a CSS file containing a set of rules for styling elements on a webpage. Each rule is represented by a selector followed by a block of declarations enclosed in curly braces. Each declaration consists of a property and its corresponding value, separated by a colon. For example: ```css h1 { font-size: 24px...
codefeedback
You are tasked with implementing a function that simulates the behavior of a window snapping to edges based on a given preference. The function `snap_pref(win)` takes a single parameter `win`, which represents the window to be snapped. The function should make the window obey the `windows.sticky` preference, causing it...
codefeedback
You are tasked with implementing a custom data structure in C# that mimics the functionality of a dictionary but has the added feature of maintaining the insertion order of key-value pairs. You should create a class named `OrderedDictionary` that supports the following operations: 1. `Add(key, value)`: Adds a new key-v...
codefeedback
You are tasked with creating a Rust module that provides functionality for working with fonts and related components. The module should include various sub-modules and re-exports of specific items for ease of use. Your goal is to organize the module structure and re-exports according to the given code snippet. Your ta...
codefeedback
You are tasked with implementing a Python class for creating interactive maps. The class, named `Map`, should have the following functionalities: 1. Initialization: Upon initialization, the `Map` class should return a valid template for an interactive map. 2. Bounds: The class should have a method to set the bounds of ...
codefeedback
You are tasked with implementing a download progress indicator for a software update system. The system uses a status enum and a download progress variable to track the progress of the update. The download progress is set to 1 after the download finishes, regardless of the status phase. Your goal is to write a function...
codefeedback
You are working on a project that involves implementing finite state transducers (FSTs) for natural language processing tasks. As part of this project, you need to write a Python program that constructs an FST, performs operations on it, and then writes the FST to a file for further processing. Your task is to impleme...
codefeedback
You are working on a video uploading service that interacts with a cloud storage provider. The code snippet provided is a part of a Python script that handles the uploading of videos to a specified bucket in a cloud storage service. The script uses the `boto3` library, which is commonly used for interacting with Amazon...
codefeedback
You are tasked with creating a program that calculates the total cost of a customer's purchase, including tax and a possible discount. The program should prompt the user to input the item's price, the sales tax rate, and whether the customer is eligible for a discount. If the customer is eligible for a discount, the pr...
codefeedback
You are tasked with implementing a custom widget in a PyQt5 application. The widget should consist of a group box with a flat design, containing a vertical layout. Within this layout, there should be a QTextEdit widget for displaying text, and a separate QWidget for additional functionality. Your goal is to create a cl...
codefeedback
You are tasked with creating a GUI application for controlling a hardware device. The application includes a preset button, a duty scale, and an antenna preset combo box. The preset button triggers a specific action when pressed, the duty scale allows the user to set a value within a certain range, and the antenna pres...
codefeedback
You are tasked with implementing a class `Handler` that parses and processes a specific type of input string. The input string represents a command in the format `$F, <id>, "<start_time>", "<end_time>", "<duration>", "<status>"`, where: - `<id>` is the identifier of the command. - `<start_time>` is the start time in th...
codefeedback
You are given a text file containing a software license agreement. Your task is to write a program that reads the file and extracts the license text, excluding any additional information such as URLs or file paths. The extracted license text should be printed to the console. Write a Python program that takes the file ...
codefeedback
You are tasked with implementing a function to deserialize a lowercase hexadecimal string into a `Vec<u8>`. The function should take a deserializer as input and return a result containing the deserialized `Vec<u8>` or an error. Your task is to complete the implementation of the `hex_to_buffer` function, ensuring that ...
codefeedback
You are tasked with implementing a memory tracing mechanism for a multi-threaded reference-counted smart pointer in Rust. The provided code snippet includes a trait definition and an implementation for the `Trace` trait. Your goal is to extend this implementation to support tracing for a specific type. The `Trace` tra...
codefeedback
You are given a code snippet that includes the definitions of classes A, B, and C. Class A has a generic method f that takes an object of a type conforming to the protocol Nested and a key path of type WritableKeyPath. Class B is a generic class that attempts to conform to the Nested protocol but fails to do so. Class ...
codefeedback
You are tasked with implementing a queue data structure that supports the enqueue and dequeue operations for events. Each event has a unique identifier and a timestamp. Your task is to design and implement the dequeue operation, ensuring that the event with the earliest timestamp is removed from the queue. Additionally...
codefeedback
You are tasked with implementing a function to link shared paths in a file system. The file system is represented as a tree structure, where each node represents a directory and can have multiple children (subdirectories or files). Some directories may be shared among different paths in the file system. Your task is to...
codefeedback
You are tasked with implementing a Python function that processes patient queries based on different query engines. The function should handle different data sources and code systems based on the specified query engine. You need to implement the function `_process_patient_query(runner, data_source, code_system)` that t...
codefeedback
You are working on a security application that involves generating a key and hiding it within a Java class file. Your task is to write a Java program that accomplishes this. The key generation process involves compiling a Java class, converting it to a DEX file, and then hiding the key within the DEX file. The provided...
codefeedback
You are tasked with implementing a data structure to manage inherent values and provide methods to access and manipulate them. Inherents are identified by unique identifiers and are stored in a collection. Your goal is to create a Rust implementation for this data structure and its associated methods. Your task is to ...
codefeedback
You are tasked with implementing a 3D vector library in Rust. The library should provide functionality for creating, manipulating, and performing operations on 3D vectors. To get started, you need to create a module named `vector3d` and define the necessary structures and methods within it. Your task is to define the ...
codefeedback
You are tasked with implementing a function to send SMS messages using the Twilio API in a Python application. The provided code snippet shows a partial implementation of the `send_sms` function, which takes a recipient's phone number (`to`) and the message body (`body`) as input parameters. The function is intended to...
codefeedback
You are tasked with implementing a function that takes in a list of integers and returns the maximum sum of a contiguous subarray within the list. The function should be able to handle both positive and negative numbers. You are given the following code snippet as a starting point: ```python def max_subarray_sum(nums...
codefeedback
You are tasked with creating a program that analyzes a given text file to determine the frequency of each word in the file. Your program should read the text file, tokenize the words, and then count the occurrences of each word. Additionally, the program should ignore any words listed in a provided set of stop words. T...
codefeedback