instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with creating a program to manage a collection of websites. Each website is represented by a `Website` struct with the following properties: - `title`: a string representing the title of the website - `originalURL`: a URL object representing the original URL of the website - `resolvedURL`: a URL object r...
codefeedback
You are tasked with creating a script to handle the generation and validation of signed certificates for a secure communication system. The script should take a certificate name as input and perform the following steps: 1. Check if the certificate name is valid. 2. If the certificate name is valid, generate a signed c...
codefeedback
You are tasked with creating a shell script that reads environment variables from a file and performs specific operations based on the values of those variables. The script should be able to handle various scenarios and provide appropriate feedback to the user. Write a shell script named `env_processor.sh` that accomp...
codefeedback
You are tasked with implementing a function that parses a given JSON-like string and extracts specific information based on the provided keys. The JSON-like string contains key-value pairs, where the keys are enclosed in double quotes and followed by a colon, and the values can be strings, numbers, objects, or arrays. ...
codefeedback
You are tasked with implementing a version comparison function that takes two version strings as input and returns whether the first version is greater than, equal to, or less than the second version. A version string is a series of numbers separated by periods, such as "1.2.3". The function should follow the semantic ...
codefeedback
You are tasked with implementing a custom iterator class in JavaScript. The iterator should be able to iterate over a given array and provide the functionality to subscribe and unsubscribe from the iteration process. Your task is to complete the implementation of the `CustomIterator` class, which should have the follo...
codefeedback
You are tasked with creating a Python command-line tool for processing RINEX (Receiver Independent Exchange Format) navigation and observation files. The tool should support various functionalities such as file conversion, data visualization, and data filtering based on user-defined criteria. Your task is to implement...
codefeedback
You are tasked with implementing a method to read test coverage data from a file and calculate the total coverage percentage. The test coverage data is stored in a binary file in the following format: - The first 4 bytes represent an integer indicating the number of elements in the coverage array. - The subsequent byte...
codefeedback
You are tasked with creating a Python function that calculates the total number of possible connections between buses in an electrical network. The network is represented using the `pandapower` library, which provides functions for creating and managing power systems. You are given a code snippet that creates an empty...
codefeedback
You are given a code snippet that defines constants in a Rust program related to finite field arithmetic. Your task is to implement a function that performs a specific operation on elements of the finite field. You are provided with the following information: - `Fq` represents an element of a finite field. - `Fq3` rep...
codefeedback
You are tasked with implementing a Python function that calculates the area of a circle using numerical integration. The function should take the radius of the circle as an input and return the area. You are provided with the following code snippet as a reference for the integration process: ```python {"type":"eq","f...
codefeedback
You are tasked with creating a program that automates the process of generating unique usernames for a given service. The usernames should be retrieved from a secure vault using an API call and should follow a specific format. Your program should allow for a maximum number of retries and a sleep time between retries to...
codefeedback
You are tasked with implementing a function to perform round trip sanity checks on incomplete gamma values. The incomplete gamma function, denoted as Γ(a, x), is a special function used in mathematics and statistics to calculate the integral of the gamma probability density function. The function takes two parameters, ...
codefeedback
You are working on a project that involves processing and organizing datasets for a machine learning application. The given code snippet is part of a larger program that handles the storage and manipulation of datasets. The code snippet is responsible for updating and managing various data structures related to the dat...
codefeedback
You are tasked with implementing a sparse reshape operation for a neural network framework. The sparse reshape operation takes three inputs: `input_indices`, `input_shape`, and `new_shape`. The `input_indices` is a 2D array representing the indices of the sparse tensor, `input_shape` is a 1D array representing the orig...
codefeedback
You are tasked with creating a class to manage IT certification artifacts. The class, named `ITCC`, should have a method `generate_artifact` that takes in a certification name and returns the artifact in the format "Certification: [certification_name] Artifact". Additionally, the class should have a method `validate_ar...
codefeedback
You are tasked with implementing a ProviderFactory class that can dynamically create instances of different provider classes based on the provider name passed to it. The ProviderFactory class should have a method called provider, which takes a string parameter representing the provider name and returns an instance of t...
codefeedback
You are tasked with creating a web application form for users to input server details. The form should include fields for the server's IP address and port number. Additionally, the form should include validation to ensure that both fields are required and cannot be left empty. You are provided with a code snippet that ...
codefeedback
You are tasked with implementing a function that reads data from program memory in an embedded system using the AVR architecture. The AVR architecture, commonly used in microcontrollers, provides a special memory space called program memory, which stores the program code and read-only data. In AVR programming, the `avr...
codefeedback
You are tasked with implementing a configuration parser for a data transformation pipeline. The configuration file contains a set of rules for transforming input data into a desired output format. Each rule consists of a transformation function and its associated parameters. Your task is to write a Python function that...
codefeedback
You are tasked with implementing a custom transformer encoder for natural language processing using PyTorch. The transformer encoder will be used to process input sequences and generate contextualized representations for each token in the sequence. Your task is to create a class that inherits from the `TransformerTorch...
codefeedback
You are tasked with implementing a simple application framework for a model-view-controller (MVC) architecture. The provided code snippet is a part of the application's entry point, where the `App::start` function is called with four arguments: the application name, the model initialization function `model::init`, the ...
codefeedback
You are tasked with implementing a function that calculates the total number of occurrences of a specific word in a given string. The function should be case-insensitive and should consider only whole word matches. A word is defined as a sequence of alphanumeric characters, delimited by non-alphanumeric characters or t...
codefeedback
You are tasked with creating a script to automate the packaging of a software application for the Debian package manager. The script should take various parameters and generate a Debian package (.deb) with the specified metadata and dependencies. Your task is to write a Python function that takes the necessary paramet...
codefeedback
You are tasked with implementing a custom activity type provider and bookmark provider for a workflow management system. The system uses the `elsaOptions` and `services` objects to configure various activities and services. The `AddActivitiesFrom` method is used to add activities to the `elsaOptions`, while the `AddCon...
codefeedback
You are tasked with creating a function to remove a player from a space-themed game database. The function should also have an option to remove any associated planets. The game's database contains information about various resources, such as ore, organics, goods, and energy. The function should set the production of th...
codefeedback
You are tasked with creating a Python script to manage the submission of Gaussian jobs for a set of molecular conformers. The script should handle the generation of input files for Gaussian, submission of jobs to a high-performance computing (HPC) cluster using SLURM, and potential restarts for failed jobs. Your task i...
codefeedback
You are tasked with implementing a Python function that processes a list of arguments and performs specific operations based on the type and content of each argument. The function should handle various data types and callable objects, and return the result of the operations as a list. You are given a partial code snip...
codefeedback
You are tasked with implementing a function to load and compile a shader from a file using the given `Shader` struct and associated methods. The `Shader` struct has a method `new` that takes a reference to the OpenGL context (`gl::Gl`), a mutable reference to a file stream (`T: Read`), and the type of shader to create ...
codefeedback
You are tasked with implementing a method to generate an SQL query for adding a new record to a table called `UserFeedback`. The table has the following schema: - `FeedbackID`: An unsigned integer of 11 digits, serves as the primary key and auto-increments. - `UserID`: An unsigned integer of 11 digits, not null. - `Fe...
codefeedback
You are tasked with implementing a custom exception class for handling labeling operations on read replica nodes in a database system. The provided code snippet is a Java class definition for the exception `ReadReplicaNodeLabelingOperationException`. This exception is thrown when a labeling operation on a read replica ...
codefeedback
You are tasked with creating a Java program that simulates a simple library management system. The system should allow users to add books, remove books, and display the list of available books. Additionally, users should be able to search for a book by its title or author. To implement this system, you need to define a...
codefeedback
You are tasked with creating a Python script to evaluate a machine learning model and generate an output CSV file. The script will take command-line arguments for the model file to be evaluated and the name of the output CSV file. The model file is usually of the form "model_X.pth", where X is a placeholder for the mod...
codefeedback
You are given a script and a corresponding voice recording. The script is represented as a list of strings `script_table`, where each element represents a segment of the script. Similarly, the voice recording is represented as a list of strings `voice_table`, where each element represents a segment of the voice recordi...
codefeedback
You are tasked with creating a script to calculate the checksum of multiple files and then sort the checksums in ascending order. You are given a code snippet as a starting point: ```bash for FILE in ${FILES[@]}; do echo $(checksum_file $FILE) >> $RESULT_FILE done # Now sort the file so that it is sort $RESULT_FILE -...
codefeedback
You are working on a project involving a device that utilizes a radio frequency (RF) module for communication. The code snippet provided is part of the firmware for this device. The snippet includes a function call, a configuration setting, and a debug print statement. Your task is to understand the context and purpose...
codefeedback
You are tasked with creating a program to validate and process mapping data for a software update. The mapping data consists of three JSON objects: `var1`, `var2`, and `var3`. The program should load a JSON file containing the mapping differences between two versions of the software and then perform validation and proc...
codefeedback
You are given an array `arr` of length 2, where `arr[0]` represents a constant multiplier and `arr[1]` represents a threshold value. Additionally, you are given a positive integer `i`. Your task is to write a function or program that calculates the result based on the following logic: 1. Calculate the sum as the produ...
codefeedback
You are tasked with creating a script to automate the process of building and updating a software package. The script should perform the following steps: 1. Extract the contents of the `net-tools-CVS_20101030.tar.gz` file into a directory named `net-tools-CVS_20101030`. 2. Apply a patch named `net-tools-CVS_20101030-r...
codefeedback
You are tasked with creating a program that processes HTML table data. Your program should read an HTML table from a file and extract specific information from it. The table will contain rows and columns, and you need to extract the content of a specific cell based on its row and column index. You are given a sample H...
codefeedback
You are tasked with creating a Python function that simulates a simple game of dice. The game involves rolling two dice and summing the values obtained. The function should take an integer `n` as input and simulate rolling the dice `n` times. It should then return the frequency of each possible sum from 2 to 12 as a di...
codefeedback
You are tasked with implementing a program to encrypt and decrypt messages using the Affine cipher. The Affine cipher is a type of monoalphabetic substitution cipher, where each letter in an alphabet is mapped to its numeric equivalent, encrypted using a simple mathematical function, and then converted back to a letter...
codefeedback
You are tasked with implementing a function that parses and processes a given CSS code snippet to extract and count the unique CSS properties used within it. Each property is defined as a key-value pair within the CSS code. The function should return a dictionary mapping each unique property to the number of times it a...
codefeedback
You are working on a static analysis tool that performs abstract interpretation on programs to infer properties about their behavior. In this context, you are given a code snippet that defines operations on linear expressions and intervals. Your task is to implement a specific operation for the static analysis tool. Y...
codefeedback
You are tasked with implementing a user management system for a web application. The system should allow for the retrieval and removal of user information from a session-based user database. The user information is stored as a dictionary in the session under the key 'user_db', with the user ID as the key and a dictiona...
codefeedback
You are tasked with implementing a function to process and analyze text data. The function will take in three parameters: `data`, `text`, and `height`. The `data` parameter represents an image, and the `text` parameter represents the text to be analyzed. The `height` parameter represents the height of the glyphs used i...
codefeedback
You are tasked with implementing a function that processes audio data and performs specific operations on it. The function takes in a list of WavData objects, a list of DsData objects, a directory path for the audio files, optional custom hyperparameters, and a callback function for saving processed data. The function ...
codefeedback
You are tasked with implementing a side effect detector in Java. A side effect is any modification of state that is observable outside the called function other than its return value. Your goal is to create a class `NoopSideEffectDetector` that implements the `SideEffectDetector` interface. The `SideEffectDetector` int...
codefeedback
You are tasked with implementing a class that performs a full sort operation on a given tensor. The class should take in a tensor containing indices, a tensor containing values, and an axis along which to perform the sorting operation. Your task is to implement the `FullSortResult` class with the following specificatio...
codefeedback
You are given a dataset `dt` containing information about black holes, including their masses and times. The dataset has the following columns: `GWtime`, `BWorldtime`, `Mass_0`, and `Mass_1`. Additionally, there are boolean index arrays `idxb0` and `idxb1` representing the indices of black holes, and boolean index arra...
codefeedback
You are tasked with implementing a generic method for writing a value to a stack in a memory-efficient and performant manner. The method should utilize unsafe code to achieve this functionality. Your task is to write the implementation for the `WriteToStack` method, which takes a generic type `T` and a value of type `T...
codefeedback
You are tasked with implementing a simple command-line argument parser in C++ to handle the input arguments for a server gateway application. The gateway application is responsible for routing incoming requests to the appropriate server functions. The code snippet provided is the entry point of the application, where t...
codefeedback
You are tasked with implementing a binary tree data structure in Python. Your task is to create a method that populates a list with the IDs of all the leaf nodes in the binary tree. You are given the following code snippet as a starting point: ```python class TreeNode: def __init__(self, value): self.valu...
codefeedback
You are tasked with creating a program that performs a basic search of xkcd comics based on user input. The program should take a search string as input and then fetch and display the relevant xkcd comic links. Your task is to implement a function `search_xkcd_comics(search_string)` that takes a search string as input...
codefeedback
You are tasked with implementing a custom data structure that simulates a queue with additional functionality. The queue should support the standard enqueue and dequeue operations, as well as a method to get the minimum element currently in the queue. The minimum method should run in constant time, O(1). You need to i...
codefeedback
You are tasked with implementing a function to calculate the dimensions and position of objects placed on a road. The function takes a list of objects, the road area, and a vector to store the calculated object dimensions. The function returns a boolean indicating success or failure. If successful and only one object d...
codefeedback
You are tasked with creating a Python function that processes a given image using TensorFlow and Keras. The function should load a pre-trained deep learning model, perform image preprocessing, make predictions on the image, and return the top predicted classes along with their probabilities. You are provided with the ...
codefeedback
You are tasked with implementing a class to manage a set of data streams. The class, named `StreamManager`, should provide methods for acquiring and releasing streams, as well as retrieving pending items from the streams. The `StreamManager` class has the following methods: 1. `acquire(max_streams)`: A method to acqui...
codefeedback
You are working on a game development project where you need to implement a function to determine the color tint for different types of blocks based on their properties. The function takes in the block ID and the y-coordinate as input and returns the corresponding color tint for the block. The color tint is represented...
codefeedback
You are tasked with implementing a camera struct in C++ that supports both perspective and orthographic projections. The camera should have methods to initialize the perspective and orthographic projections, reset the camera, and modify the viewport size, zoom, and aspect ratio. Your task is to complete the implementa...
codefeedback
You are tasked with implementing a Python function that serves as a wrapper script for command-line R visualizations. The function takes in several parameters, including `whichway`, `name`, `id`, `target_onto`, `width`, `height`, `tabfile`, `feature_cluster_size`, and `sample_cluster_size`. Your goal is to create a fun...
codefeedback
You are tasked with creating a Rust function that interacts with the Wasmtime runtime to execute WebAssembly (Wasm) code. Your goal is to implement a function that takes a list of arguments, runs the Wasmtime runtime with those arguments, and returns the output of the execution. You are provided with a code snippet th...
codefeedback
You are tasked with creating a text-based adventure game using Python. The game will involve combat encounters, shields with different durability, and various events such as encountering a wizard or stumbling into a trap. Your task is to implement a class called `Player` that represents the game's protagonist. The `Pl...
codefeedback
You are tasked with implementing a simulated annealing algorithm for optimizing a given search space. Simulated annealing is a probabilistic technique used for finding an approximate solution to an optimization problem. In this problem, you will need to complete the implementation of the `SimulatedAnnealingOptimizer` c...
codefeedback
You are tasked with implementing a method in the `RemotesQueue` class that manages pending connections. The `RemotesQueue` class has a property `pendingConnections` which is a dictionary mapping connection IDs to `PendingConnection` objects. Each `PendingConnection` object has a `readyPromise` property, which is a prom...
codefeedback
You are tasked with implementing a custom attribute class in C# that can be used to store line numbers and program counter values for a given method. The attribute should be able to be applied to methods within a class and store the line number and program counter value for each method. Additionally, you need to create...
codefeedback
You are working on a software packaging system called Mininix, which involves creating a function to handle the installation of source code. The `mininix_step_make_install` function is responsible for copying the contents of the `source` directory to the appropriate location within the Mininix system. However, the code...
codefeedback
You are tasked with implementing a stream encryption function using the XOR operation. The function `stream_encrypt_xor` takes three parameters: `input`, `nonce`, and `key`, and returns the encrypted data as a vector of unsigned 8-bit integers (bytes). The `input` parameter is a slice of bytes representing the data to...
codefeedback
You are tasked with implementing a color picker component in a graphical user interface (GUI) application. The color picker should allow users to select a color using sliders and up/down controls for different color channels (e.g., red, green, blue). Additionally, the color picker should raise an event whenever the sel...
codefeedback
You are working for a retail company that sells various products. Your task is to write a Python function to analyze the sales data stored in a pandas DataFrame. The DataFrame, named `df`, contains the following columns: `ProductID`, `ProductName`, `Quantity`, and `UnitPrice`. The `Quantity` column represents the numbe...
codefeedback
You are tasked with simulating the response of a control system to a given plant model. The plant model is defined by the parameters L, R, and M, and the control system will be designed to regulate the output of this plant. The control system will be a proportional-integral-derivative (PID) controller, and you are requ...
codefeedback
You are working on a blogging platform and need to implement a feature to allow users to create, view, and edit their posts. The platform uses Django and Django REST framework for the backend. You have been provided with a code snippet from the backend codebase that includes imports related to the blog functionality. Y...
codefeedback
You are tasked with creating a Python function that simulates a simple game of dice. The game involves rolling two dice and summing the values. The function should take the number of rounds to play as input and return the frequency of each possible sum from 2 to 12 after the specified number of rounds. The function si...
codefeedback
You are tasked with creating a script to automate the installation of Go packages and their dependencies. The script should parse a given input file containing package names and execute the necessary `go get` and `go install` commands to fetch and build the packages and their dependencies. The input file will contain ...
codefeedback
You are given a string `S` consisting of lowercase English letters. Your task is to find all non-overlapping substrings in `S` that consist of at least three identical consecutive characters. For each such substring found, you need to output the starting and ending indices of the substring within the original string `S...
codefeedback
You are tasked with creating a Python program that processes and sends email messages using the `EmailMessage` class from the `email.message` module. Your program should read a list of recipient email addresses from a file, construct an email message with a specified subject and body, and then send the email to each re...
codefeedback
You are tasked with creating a Python class that dynamically generates a serializer for Kubernetes objects. The serializer should inherit from a base serializer class and include specific fields based on the Kubernetes object being serialized. Your task is to implement the `KubernetesMetadataObjBaseSerializer` class a...
codefeedback
You are tasked with creating a custom command-line prompt for a developer's environment. The prompt should display the current Git branch and status, the current directory, and the time in a specific format. Additionally, the prompt should include a custom theme provided by the "pure" package. Your task is to write a ...
codefeedback
You are tasked with implementing a custom iterator for a collection of items. The iterator should support removing elements from the collection while iterating through it. Additionally, the iterator should skip over elements based on a specified condition. Your task is to create a class `CustomIterator` that implement...
codefeedback
You are tasked with creating a custom pagination class for a Django REST framework viewset. The goal is to implement a pagination class that allows for large result sets to be paginated efficiently. The provided code snippet includes a `QuizFilter` class for filtering quizzes and a `QuizViewSet` class for handling quiz...
codefeedback
You are tasked with implementing a route definition system for a web application framework. The route definition system should support different kinds of routes and provide a way to specify route configurations. You need to create a TypeScript interface and a function that validates and processes route definitions bas...
codefeedback
You are tasked with creating a program to manage a leaderboard for an online gaming platform. The program should allow users to add their username and experience points (XP) to the leaderboard and display the top players based on their XP. You are given the following code snippet as a starting point: ```python print(...
codefeedback
You are given a network represented by a collection of places and transitions. Each place in the network has a set of tokens, and transitions represent the flow of tokens between places. Your task is to implement a function that identifies pairs of places in the network that have similar characteristics. You are given...
codefeedback
You are tasked with implementing a memory manipulation function in C++ that involves interpreting a data buffer as an array of bytes and performing a specific operation on it. The function should take a data buffer, its size, and a data definition as input, and then allocate a new data buffer based on the provided data...
codefeedback
You are tasked with creating a Python program that utilizes the `instabot` library to automate posting images to Instagram at scheduled intervals. The program should be able to upload images from a specified directory to a designated Instagram account using the `instabot` library and the `schedule` library for scheduli...
codefeedback
You are tasked with implementing a function that takes an integer value and generates the corresponding IL (Intermediate Language) code to load that value onto the evaluation stack using the `System.Reflection.Emit` namespace in C#. The IL code should handle both small integer values within the range of -128 to 127 and...
codefeedback
You are tasked with creating a script that automates the process of setting up a Python environment and running a specific Python script. Your script should handle the loading of necessary modules, setting environment variables, and executing the Python script with the specified arguments. Write a shell script that ac...
codefeedback
You are tasked with creating a Django REST framework API view for a project management system. The API view should handle various operations related to projects, including listing, creating, updating, and deleting projects. The view should also support filtering, searching, and ordering of projects. Additionally, the A...
codefeedback
You are given the definition of a binary tree node and a function to check if the given binary tree is a complete tree. Binary Tree Node Definition: ```python class TreeNode: def __init__(self, value=0, left=None, right=None): self.value = value self.left = left self.right = right ``` Func...
codefeedback
You are working on a software project that involves creating and managing attribute definitions using the SMTK (Simulation Modeling Toolkit) library. The provided code snippet demonstrates the creation of attribute definitions using the SMTK API. Your task is to implement a function that can validate and manipulate the...
codefeedback
You are working on a signal processing application that involves categorizing signal amplitudes based on their frequencies. You have been given a list of frequency-amplitude pairs and need to categorize the amplitudes into different buckets based on the frequency ranges. The frequency ranges and corresponding buckets a...
codefeedback
You are tasked with creating a Rust function that processes image data and applies a specific image transformation using the glium library. The function should take in the image data and return the resulting transformed image. The function signature should be: ```rust fn apply_image_transformation(image_data: &[u8]) -...
codefeedback
You are tasked with creating a function to render and send email invitations to users. The function should handle the scenario where an invitation notification has already been sent and should not send duplicate notifications. You are provided with a code snippet that includes a test case for the function. The test ca...
codefeedback
You are tasked with creating a Python class that simulates a simple quiz application. The class should allow the user to add questions, take the quiz, and view the quiz results. Each question will have a prompt and an answer. The quiz will be scored based on the number of correct answers. Your task is to implement the...
codefeedback
You are tasked with implementing a method to parse a given file and return its content as a string. Additionally, you need to create a method to retrieve a resource as a URL. You are provided with a partial code snippet from a `FileUtils` class, which includes an incomplete `readFileAsString` method and an incomplete `...
codefeedback
You are tasked with implementing a learning rate scheduler for a deep learning model training process. The learning rate scheduler should adjust the learning rate of the optimizer during training to improve model convergence and performance. You are provided with a code snippet that initializes a deep learning model, l...
codefeedback
You are tasked with creating a Python class that represents a media graph for a cloud infrastructure using Pulumi, a popular infrastructure as code tool. The media graph class should be able to manage various resources such as account name, description, media graph name, resource group name, sinks, and sources. Your ta...
codefeedback
You are tasked with implementing a simplified version of a class for handling HTTP requests using the libcurl library. The provided code snippet outlines the basic structure of the class and its member functions. Your task is to complete the class implementation by adding the necessary member variables and implementing...
codefeedback
You are tasked with implementing a parameter parsing system for a command-line interface. The system should be able to parse different types of parameters, such as flags, options, and positional parameters. Each parameter has a name, a type, and an optional default value. Your task is to create a class `Parameter` wit...
codefeedback
You are tasked with creating a custom tabbed widget in a PyQt application. The given code snippet is a part of a larger PyQt application and is responsible for setting up a tabbed interface with a specific size policy for the log output widget. Your task is to complete the implementation of the tabbed widget by adding ...
codefeedback