instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are working on a computer graphics project and need to implement a function to convert light sample weight to a solid angle measure. The function takes into account a few parameters such as the distance between two points, the normal vector, and the area of the light source. Your task is to implement the function t... | codefeedback |
You are tasked with creating a program that efficiently organizes and manages interrupt service routines (ISRs) for a microcontroller. The ISRs are represented as strings in the following format: "NVIC_<PERIPHERAL_NAME>_IRQ". The program should allow for registering, unregistering, and invoking ISRs, as well as providi... | codefeedback |
You are tasked with implementing a program to manage a sports tournament. The program should be able to update the points of the participating teams based on the match results. Each team is identified by a unique integer ID, and the program should be able to handle ties as well.
You are given a partial code snippet fo... | codefeedback |
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... | codefeedback |
You are tasked with creating a program to manage a list of items with their respective values. The program should prompt the user to input the number of items and then enter the value for each item. However, the program should validate the input to ensure that the value of each item is greater than 0. If the user enter... | codefeedback |
You are tasked with creating a Python module for image transformation workflows. The module should include classes for different types of transformation workflows, such as affine transformation, linear transformation, coordinate transformation, and general transformation. The code snippet provided imports these classes... | codefeedback |
You are tasked with creating a Python function that retrieves and processes data from a web page. Your function should utilize the `requests` library to fetch the content of a given URL and then parse the HTML to extract specific information. The function should return a structured representation of the data for furthe... | codefeedback |
You are tasked with implementing a Python class that manages audio files using the AVFoundation framework. The class, named `SoundAvplayer`, should provide methods for loading and unloading audio files, as well as playing and stopping the loaded audio. The class should also handle errors that may occur during the loadi... | codefeedback |
You are tasked with creating a Python web service that utilizes the aiohttp library to handle HTTP requests and manage user sessions. Your goal is to implement a simple web server that can handle user authentication and session management using the `aiohttp` and `servicelib` libraries.
Your task is to create a Python ... | codefeedback |
You are tasked with implementing a data structure to manage the state of sectors in a storage system. The system has two states for sectors: staged and sealed. The staged state contains sector IDs and their corresponding metadata, while the sealed state only contains sector IDs and their sealed metadata.
Your task is ... | codefeedback |
You are tasked with creating a Rust module for a simple task queue system. The task queue should support adding tasks, executing tasks in a first-in-first-out (FIFO) manner, and retrieving the result of the executed tasks. You need to implement the `TaskQueue` module with the following specifications:
1. The `Task` st... | codefeedback |
You are given a Python code snippet that appears to be part of a function to process a sequence of characters. Your task is to complete the function by implementing the missing part. The function is intended to process a sequence of characters and extract valid base characters from it.
The provided code snippet initia... | codefeedback |
You are tasked with creating a Python script to manage a database using the provided functions from the `pages.db.db` module. The module contains the following functions:
- `db_clean()`: This function cleans up the database by removing any redundant or obsolete data.
- `db_creation()`: This function initializes a new d... | codefeedback |
You are tasked with creating a program that analyzes the frequency of words in a given text file. Your program should read a text file and output the top N most frequently occurring words along with their respective frequencies. For the purpose of this problem, a word is defined as a sequence of alphanumeric characters... | codefeedback |
You are tasked with implementing a simple stack data structure in Python. A stack is a Last-In-First-Out (LIFO) data structure that supports two main operations: push, which adds an element to the top of the stack, and pop, which removes the top element from the stack. Additionally, you need to implement a method to ge... | codefeedback |
You are tasked with creating a program that processes a given HTML file and extracts the labels and input types from the form elements. The HTML file contains form elements with various attributes, and your program should be able to identify and extract the relevant information.
You need to write a function or method ... | 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 basic operations such as creating directories, creating files, listing the contents of a directory, and navigating through the file system.
Your task is to implem... | codefeedback |
You are tasked with creating a Python program that analyzes the memory usage of a given function and identifies the most memory-intensive parts of the code. To achieve this, you will need to utilize the `tracemalloc` module, which allows you to trace memory allocation in Python. The `tracemalloc` module provides a `tak... | codefeedback |
You are tasked with creating a program to manage a collection of books in a library. Each book has a unique ISBN (International Standard Book Number), a title, an author, and a quantity available. The program should allow users to perform various operations such as adding a new book, removing a book, updating the quant... | codefeedback |
You are tasked with creating a custom test case class for a PHP application using PHPUnit. Your task is to extend the `TestCase` class provided by PHPUnit and implement a custom test case method that checks the functionality of a specific class or method within your application.
Your custom test case class should have... | codefeedback |
You are tasked with creating a Python program that generates a colorful title for a given text. The program should take the input text and display it as a title with a colorful border around it. The colors for the border will be randomly selected from a predefined list of colors. The length of the border should be dete... | codefeedback |
You are given an array of UIImage objects `imgArray` and an array of strings `descArray`. Your task is to write a function that combines these arrays into a dictionary where the strings from `descArray` are the keys and the corresponding UIImage objects from `imgArray` are the values. If there are more strings than ima... | codefeedback |
You are tasked with implementing a simplified version of a publish-subscribe system using Python. The system consists of a Publisher class and a Subscriber class, which communicate through a shared connection. The Publisher publishes messages to a specific topic, and the Subscriber listens for messages on the same topi... | codefeedback |
You are tasked with implementing a function that performs a binary search on a sorted array to find the index of a given target value. However, there's a twist - the search algorithm has a time constraint and must terminate if it exceeds a specified timeout period. You are required to handle this constraint within your... | codefeedback |
You are tasked with creating a Python program to analyze a list of gamma distributed values representing gene fragment lengths. The program should calculate the average length of the gene fragments and identify the number of fragments that exceed a certain threshold length. Additionally, the program should determine th... | codefeedback |
You are given a Swift code snippet that contains a nested enum, struct, and class. Your task is to write a function that takes a generic type `T` conforming to a protocol `P` and returns a new instance of a specific type defined within the code snippet.
The code snippet is as follows:
```swift
if true {
enum b {
... | codefeedback |
You are tasked with implementing a custom middleware in a Django web application. The middleware should intercept incoming requests and set environment variables based on the values provided in the request. These environment variables will then be used by the Django application to customize its behavior for each reques... | codefeedback |
You are tasked with implementing a function that evaluates an abstract syntax tree (AST) and returns the result. The AST represents a sequence of expressions and reference sequences, and the evaluation involves recursively evaluating the expressions and handling reference sequences based on certain conditions.
You are... | codefeedback |
You are tasked with implementing a text formatting utility that applies different styles to a given text. The utility should support various styles such as bold, italic, underline, and color. You need to create a function that takes a text string and a style object as input and returns the formatted text according to t... | codefeedback |
You are tasked with implementing a function to project 3D points onto a 2D image plane using a pinhole camera model. The function should take as input the 3D points, camera rotation matrix, translation vector, and focal length, and return the corresponding 2D image coordinates of the projected points.
The pinhole came... | codefeedback |
You are tasked with implementing a voting system for identifying a ball in a computer vision application. The provided code snippet is part of a larger system that processes observations of a ball and updates its state based on certain conditions. Your task is to complete the implementation by writing the logic for the... | codefeedback |
You are tasked with implementing a function to process a series of image files using the QBetaKarttakuva library. The QBetaKarttakuva library provides functions for reading and manipulating image files in a proprietary format. Your task is to write a function that takes a list of image file paths as input, processes ea... | codefeedback |
You are tasked with creating a program that processes save files for a game called "Satisfactory." The save files are in a custom binary format and need to be parsed and analyzed. The save file format is represented by the `SaveFile` struct provided by the `satisfactory_save_file` crate. The `SaveFile` struct has metho... | codefeedback |
You are working for a data processing company that needs to clean and merge multiple datasets. Your task is to write a Python function that takes in several dataframes, performs a series of data cleaning and manipulation operations, and then returns the final merged dataframe.
The function should perform the following... | codefeedback |
You are tasked with creating a Java method that securely sets up environment variables for an Impala web server and starts an Impala cluster. The method should ensure that sensitive information, such as passwords, is handled securely. Your task is to implement the `setUpImpalaWebServer` method, which sets up the enviro... | codefeedback |
You are tasked with implementing a function to calculate the multi-modified Damerau-Levenshtein distance between a given string and an array of strings. The multi-modified Damerau-Levenshtein distance is a measure of the similarity between two strings, taking into account insertions, deletions, substitutions, and trans... | codefeedback |
You are tasked with implementing a simulation control system for a graphical user interface (GUI) application. The simulation control system will manage the timing and layout of various components within the GUI. The provided code snippet contains constants that will be used in the implementation.
The constants `SIMCO... | codefeedback |
You are working on a machine learning project and need to preprocess image data for training and testing. You have a set of image data in the form of a 3D numpy array and corresponding labels. Additionally, you have a test dataset with image names and labels stored in a CSV file. Your task is to create a function that ... | codefeedback |
You are tasked with implementing a memoization technique to optimize a recursive function. Memoization is a method used to store the results of expensive function calls and return the cached result when the same inputs occur again. The code snippet provided is a placeholder for the actual memoization logic.
Your task ... | codefeedback |
You are tasked with creating a program to simulate a simple database connection pool and data retrieval process. The program will involve generating random world IDs, querying a database, and returning the corresponding world data.
You are given a code snippet that represents part of the program. The `conn` variable r... | codefeedback |
You are tasked with implementing a function that translates Win32 error codes to ART (Application Response Time) equivalents. The function should take a Win32 error code as input and return the corresponding ART equivalent. Additionally, you need to handle the mapping of Win32 error codes to ART equivalents for a speci... | codefeedback |
You are tasked with implementing a Python class for calculating the Kernel Inception Distance (KID) to compare two sets of image intensity distributions. The KID is a statistical measure used to evaluate the similarity between two distributions. Your task is to create a class `KID` with the following functionalities:
-... | codefeedback |
You are tasked with creating a Python class that simulates a simple notification system. The class should be able to send notifications to different recipients and allow for customization of the notification message. Your task is to implement the `NotificationSystem` class with the following specifications:
- The clas... | codefeedback |
You are tasked with simulating a user management system using Python. The system should be able to perform actions such as inserting a new user, updating an existing user, adding an order for a user, and deleting a user. The actions are chosen randomly from a list of possible actions, and the corresponding functions ar... | codefeedback |
You are tasked with creating a custom form component in React that supports various layouts and validation functionalities. Your goal is to implement a `Form` component with the following features:
- The `Form` component should accept the following props:
- `layout` (optional): Specifies the layout of the form, defa... | codefeedback |
You are tasked with creating a migration script for a database table in a Laravel application. The table, named "cell", needs to have a composite index created on two columns: "meta_y_id" and "instance_id". Additionally, you need to ensure that the migration script includes the necessary code to reverse the index creat... | codefeedback |
You are tasked with implementing a Python function, `recursive_sum(arr)`, that calculates the sum of all elements in a nested list of integers. The function should handle both empty lists and lists containing integers or nested lists of integers. For example, given the input `[1, [2, [3, 4], 5], 6]`, the function shoul... | codefeedback |
You are tasked with creating a program to categorize and organize different types of electrical plugs based on their specifications. Each plug type is represented by a string in the format "standard-voltage-phase-connector-amperage", where:
- "standard" is the standardization organization (e.g., "iec" for International... | codefeedback |
You are tasked with implementing a custom pretty-printing module in Python. The module should provide two main functions: `pretty` and `pretty_print`. The `pretty` function should take an object as input and return a string representation of the object in a human-readable format. The `pretty_print` function should take... | codefeedback |
You are tasked with implementing a class that calculates the point of closest approach (POCA) between two tracks in a particle physics experiment. The class `TrkPocaBase` takes in two track parameters (`flt1` and `flt2`) and a precision value, and it should compute the POCA with the given precision.
The `TrkPocaBase` ... | codefeedback |
You are tasked with implementing a password change functionality for a user in a web application. The `UserController` class is responsible for handling user-related actions, and the `actionChangePwd` method is specifically designed to allow users to change their passwords. Your task is to complete the implementation o... | codefeedback |
You are tasked with implementing a function that calculates the total number of parameters in a convolutional neural network (CNN) layer. The function should take the input shape of the layer as a tuple and return the total number of parameters, considering the weights and biases.
The total number of parameters in a C... | codefeedback |
You are given an HTML code snippet that is intended to display a list item with a link to Instagram and an image. However, the code contains several errors and is not rendering as expected. Your task is to identify and correct the errors in the code to ensure that the list item and image are displayed correctly.
Given... | codefeedback |
You are working on a project that involves analyzing and extracting metrics from a machine learning model using TensorFlow. As part of this project, you need to implement a custom metric extractor that utilizes TensorFlow's model variables and logging capabilities.
Your task is to create a Python class called `CustomM... | codefeedback |
You are tasked with implementing a custom random number generator that uses a linear congruential generator (LCG) algorithm. The LCG algorithm generates a sequence of pseudo-randomized numbers using the formula: Xn+1 = (a * Xn + c) % m, where Xn is the current number, a is a multiplier, c is an increment, and m is the ... | codefeedback |
You are tasked with creating a simple iOS app that displays information about various locations. The app's main view is defined using SwiftUI, and it includes a ZStack containing a VStack and an HStack. Within the HStack, there is a VStack with alignment set to .leading, and within this VStack, there is a Text view dis... | codefeedback |
You are tasked with implementing a function to calculate the exact solution of a partial differential equation using the given code snippet as a reference. The function `exact_solution` takes in three parameters: `x` (position), `t` (time), and an optional parameter `q` with a default value of 1. The function uses a su... | codefeedback |
You are tasked with creating a Python function that generates a classification report for a given dataset. The dataset is represented as a pandas DataFrame and contains features and target values for a classification problem. The function should calculate and display a classification report including precision, recall,... | codefeedback |
You are tasked with implementing a function to convert the linearization of a kimchi circuit polynomial into a printable string. The linearization is based on a specific evaluation domain and involves generating a set of linearization columns and constraints expressions. Your task is to create a function that takes the... | codefeedback |
You are tasked with implementing a Python function that calculates the bounds of a given area based on the input parameters. The function should take four arguments: `width`, `height`, `margin`, and `action_metadata`. The `width` and `height` represent the dimensions of the area, while the `margin` indicates the margin... | codefeedback |
You are tasked with creating a Python class that manages a to-do list and contact list for a project management application. The class should have a method `solve` that takes in various parameters and performs operations based on the input. Your task is to implement the `solve` method of the class.
The class should ha... | codefeedback |
You are tasked with creating a PHP class method that processes an email body to hide hidden mail fields using regular expressions. Your task is to implement the `hide_hidden_mail_fields_regex_callback` method within the given PHP class.
The `hide_hidden_mail_fields_regex_callback` method should take a match as input a... | codefeedback |
You are tasked with implementing a Python class that represents a deck of playing cards and provides various methods for manipulating and interacting with the deck. The class should support shuffling the deck, dealing a specified number of cards, and returning the number of cards remaining in the deck.
Your task is to... | codefeedback |
You are tasked with implementing a Python function that handles SSH client connections using the `paramiko` library. The function should establish a secure SSH connection to a specified hostname using a given username and password. Additionally, it should handle potential exceptions related to host key verification and... | codefeedback |
You are tasked with creating a Python program to manage a playlist of audio files. Your program should be able to load, play, pause, resume, and stop audio files using the `pygame` library. The program should also allow the user to navigate through the playlist and play the next or previous audio file.
Your program sh... | codefeedback |
You are tasked with creating a Python package manager tool that can handle dependencies and provide warnings for missing dependencies. Your tool should be able to import modules from the package and handle potential ImportError exceptions.
Your task is to implement a function `import_package_module(package_name, modul... | codefeedback |
You are tasked with implementing a function to retrieve a list of categories from a database based on a given parent category ID, sorting order, limit, and offset. The provided code snippet is a part of a larger codebase for a C++ application that interacts with a database using the C++ Database Connectivity (CppDB) li... | codefeedback |
You are given a parallelized code snippet that performs a matrix-vector multiplication using OpenMP directives. Your task is to understand the code and identify potential issues related to parallel execution.
The code snippet is part of a larger program that performs matrix-vector multiplication using OpenMP for paral... | codefeedback |
You are tasked with creating a module registration system for a university. The system should allow students to observe and register for different modules offered by the university. Each module has a unique code and a maximum capacity of students it can accommodate. The system should also keep track of the number of st... | codefeedback |
You are tasked with creating a program that processes a list of GitHub repositories and calculates the total number of stars for each repository within a specified range. The program should also be able to filter repositories based on the number of stars and generate a report of repositories that fall within the specif... | codefeedback |
You are tasked with creating a web application for a university's student accommodation booking system. The code snippet provided is a part of the web application's view file written in PHP using the Yii framework.
Your task is to implement a function that generates the HTML code for a form to allow students to book a... | codefeedback |
You are tasked with implementing a timer event handler that manages a composite disposable object in a multi-threaded environment. The `timer` object has a method `setEventHandler` which takes a closure as a parameter. Inside the closure, you need to check if a `compositeDisposable` object is disposed. If it is dispose... | codefeedback |
You are tasked with creating a Python class that integrates with a specific context plugin system. The provided code snippet is a simplified example of such a class. Your task is to expand upon this snippet and create a class that can be used to version-up workfiles in a hypothetical content management system.
Your cl... | codefeedback |
You are tasked with implementing a memory manager for a custom memory pool in C++. The memory manager should support allocating and deallocating memory blocks of varying sizes from a pre-allocated memory region. The memory manager should also handle fragmentation and reuse of freed memory blocks to minimize memory wast... | codefeedback |
You are tasked with developing a JupyterHub configuration management system. Your system should be able to read a configuration file and apply the specified settings to the JupyterHub instance. The configuration file will contain settings for DockerSpawner, JupyterHub, and other related configurations. Your task is to ... | codefeedback |
You are given a singly linked list where each node contains an integer value. Write a function to reverse the linked list in place.
The linked list is represented by the following class:
```
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
```
You need to imple... | codefeedback |
You are tasked with implementing a function that processes a collection of frames to create an animated image. Each frame is represented by an object containing an image and a duration. The function should generate an animated image by repeating each frame's image a certain number of times based on its duration and ret... | codefeedback |
You are given a code snippet that calculates the variable `thetap` based on the values of `Lz`, `L`, `t`, `vt`, `p`, `thetaz`, and the numpy library functions. Your task is to implement a function that replicates the behavior of the code snippet and returns the value of `thetap` given the input values.
The code snippe... | codefeedback |
You are tasked with implementing a caching decorator in Python. A caching decorator is a higher-order function that can be used to cache the results of a function, thus avoiding redundant computations for the same input arguments. The provided code snippet serves as a starting point for creating the caching decorator.
... | codefeedback |
You are tasked with creating a Python program to extract the text content from a given URL and perform specific text processing tasks. The program should retrieve the HTML content from the URL, extract the text, and then perform word frequency analysis and text manipulation.
Your program should perform the following s... | codefeedback |
You are tasked with implementing a class to handle secondary location groups in a meteorological report parsing library. A secondary location group is a part of a weather report that provides additional information about a specific location. The class should support parsing, appending, and checking the result of append... | codefeedback |
You are tasked with creating a program that can analyze the copyright information in a given file and extract the year and organization name. The copyright information is typically found at the beginning of the file as a comment block. The format of the comment block is as follows:
```
# Copyright <year> <organizati... | codefeedback |
You are tasked with implementing a custom URI (Uniform Resource Identifier) class in Python. The URI class should support string representation, hashing, and equality comparison based on its attributes.
Your URI class should have the following attributes:
- `scheme`: The protocol or scheme of the URI (e.g., http, http... | codefeedback |
You are tasked with creating a Python function that generates convolutional neural network (CNN) layers based on a given convolution type. The function should take the convolution type as input and return the corresponding CNN layers.
You are provided with a code snippet that sets random seeds for NumPy and PyTorch, a... | codefeedback |
You are tasked with implementing a system for creating different types of documents using the abstract factory design pattern. The system should support the creation of two types of documents: `Letter` and `Resume`. Each document type has its own set of attributes and functionalities.
Your task is to implement the abs... | codefeedback |
You are tasked with creating a Python script that monitors a directory for any new or modified files and logs the changes to a specified log file. The script should utilize the `watchdog` library to achieve this functionality.
Your script should accept the following command-line arguments:
1. The directory to monitor.... | codefeedback |
You are tasked with implementing a Python class that represents a quantum circuit element. The quantum circuit element will be a part of a larger quantum circuit simulation, and it will have specific properties and methods to interact with other elements in the circuit.
Your task is to create a class called `QuantumEl... | codefeedback |
You are tasked with implementing a Python class for object detection using the Faster R-CNN (Region-based Convolutional Neural Network) model. The provided code snippet is a partial implementation of the class, and your task is to complete the implementation by adding the `infer` method.
The `__init__` method initiali... | codefeedback |
You are tasked with implementing a simple tokenizer and lexer for a custom programming language. The tokenizer should take a string of code as input and split it into tokens, while the lexer should analyze these tokens and categorize them into different types.
Your task is to complete the implementation of the `Tokeni... | codefeedback |
You are given a list of integers representing the heights of buildings in a city skyline. Your task is to write a function that calculates the total area of the skyline when viewed from one side. The skyline is formed by the buildings and the spaces between them. The width of each building is 1 unit.
Write a function ... | codefeedback |
You are tasked with implementing a snapshot reconciler for a JavaScript application. The reconciler is responsible for comparing a given value with a snapshot (sn) and updating the value based on any differences found. The reconciler function is registered with a specific priority and is called when a snapshot matches ... | codefeedback |
You are working on a version control system and need to resolve ambiguities between paths and other arguments. You have a script that creates a new file called "master" and another file with a name stored in the variable `$commit_id2`. These files are added to the version control system using the `got add` command and ... | codefeedback |
You are tasked with implementing a custom extension method for the `IEnumerable<T>` interface in C#. The method should return true if all elements in the collection satisfy a given condition, and false otherwise. The method signature should be as follows:
```csharp
public static bool AllSatisfy<T>(this IEnumerable<T> ... | codefeedback |
You are tasked with creating a Python class that validates alphanumeric strings using regular expressions. Your task is to implement a class `AlphanumericValidator` that provides a method `validate` to check if a given string contains only alphanumeric characters.
Your `AlphanumericValidator` class should have the fol... | codefeedback |
You are tasked with creating a CSS class generator function that takes in a set of parameters and outputs a CSS class string based on those parameters. The function should handle various CSS properties and their values to generate a valid CSS class string.
Your task is to implement the `generateCSSClass` function, whi... | codefeedback |
You are tasked with creating a program that processes a given software license agreement to extract specific permissions granted within the agreement. The license agreement is provided as a string, and the permissions are defined by the text following the "Permission is hereby granted" statement. Your program should ex... | codefeedback |
You are tasked with implementing a program that processes a video stream to detect and annotate objects using a pre-trained neural network model. The provided code snippet is a part of this program and uses the OpenCV library to perform object detection and annotation. The `cap.read()` function reads a frame from the v... | codefeedback |
You are tasked with implementing a custom integer caching mechanism in Java. The goal is to optimize memory usage by reusing integer objects within a specific range. The provided code snippet contains a partial implementation of the caching mechanism using a factory class and a custom integer class.
Your task is to co... | codefeedback |
You are tasked with implementing a Python function that calculates the partitioned norm of a given vector. The partitioned norm of a vector is a generalization of the Euclidean norm, where the vector is divided into multiple partitions, and the norm is calculated for each partition separately. The partitioned norm is t... | codefeedback |
You are tasked with implementing a multi-threaded file processing system using Rust's standard library. The system will involve managing a collection of file paths and tracking the progress of reading and processing these files concurrently.
You are provided with a code snippet that initializes two static lazy-initial... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.