instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with creating a PHP class that manages inventory for a retail store. The class should allow for adding, removing, and updating products in the inventory, as well as retrieving information about the products. Additionally, the class should be able to categorize products based on their type.
Your task is ... | codefeedback |
You are given a string `s` which has been encoded using the UTF-8 encoding. Your task is to write a function that decodes the string and returns the original string.
Write a function `decode_utf8(s: bytes) -> str` to decode the given UTF-8 encoded string and return the original string.
For example, if the input is `b... | codefeedback |
You are given a Python code snippet that processes and ranks results from a dataset. Your task is to implement a function that takes the input data and performs the same ranking and aggregation as described in the code snippet.
You are provided with the following information:
- `results_agg`: a DataFrame containing ag... | codefeedback |
You are tasked with implementing a custom dictionary class in Python that supports nested key access and retrieval. The class should have a `__getitem__` method that allows accessing nested keys using dot notation, and a `get` method that retrieves a value for a given key, with an optional default value if the key is n... | codefeedback |
You are tasked with implementing a command-line argument parser for a distributed training script. The script is used for training a machine learning model on multiple GPUs using the Apex library for mixed precision training. Your task is to parse the command-line arguments and extract the necessary configuration param... | codefeedback |
You are tasked with creating a Python function that automates the process of signing up for a GitHub account using Selenium WebDriver. The provided code snippet serves as a starting point for your task. Your function should take in the following parameters:
- `headless` (boolean): A flag indicating whether the browser ... | codefeedback |
You are tasked with creating a Python function that generates a new PDF file with specific details. The function should take in details about the content of the PDF, the name of the file, and the dimensions of the pages. You will need to use the PyPDF2 library to achieve this.
Write a function `new_pdf(details, name, ... | codefeedback |
You are tasked with implementing a class for querying the existence of a specific animation graph state in a game engine. The provided code snippet is a constructor for the `CMannequinAGExistanceQuery` class, which takes a pointer to an `IAnimationGraphState` object and initializes the member variable `m_pAnimationGrap... | codefeedback |
You are tasked with implementing a Python function that calculates the final value after applying a series of percentage increases and decreases to an initial value. The function `resumo` takes three parameters: `n` (initial value), `aumento` (list of percentage increases), and `reducao` (list of percentage decreases).... | codefeedback |
You are tasked with implementing a custom thread pool for executing tasks in a Java application. The thread pool should be capable of handling asynchronous tasks and logging the execution of each task using the Log4j framework. Additionally, the thread pool should be able to serialize the execution results of the tasks... | codefeedback |
You are tasked with implementing a Python class that manages contracts for a company. The class, `ContractManager`, should have a method `set_result_contract` that allows setting the result of a specific contract. The method should only allow setting the result if the contract exists. If the contract does not exist, it... | codefeedback |
You are tasked with implementing a method to cancel a media job using the COSClient API. The method `cancelMediaJob` takes a `COSClient` object as a parameter and should cancel the media job associated with it. The media job is represented by a task request object, and the cancellation process involves specific steps.
... | codefeedback |
You are tasked with implementing a custom dataset class for processing and loading frame-based data for machine learning applications. The dataset will be used to handle a DataFrame containing frame-level data and associated configurations. Your task is to complete the implementation of the `get_single_trial` method in... | codefeedback |
You are tasked with implementing a Python function that downloads a file from a given URL and saves it to the local file system. The function should handle the case where the download fails and return an appropriate error message. Use the following code snippet as a starting point:
```python
import requests
import os
... | codefeedback |
You are tasked with creating a Python program that reads data from a JSON file containing global epidemic statistics and performs specific operations on the data. The JSON file contains information about the number of cases, deaths, and recoveries for different countries. Your task is to write a program that reads this... | codefeedback |
You are tasked with implementing a priority queue using Python. A priority queue is a data structure that stores elements along with their associated priorities and allows for efficient retrieval of the element with the highest priority. In this problem, you will create a class `PriorityQueue` that supports the followi... | codefeedback |
You are tasked with creating a Python function that simulates a simplified file processing workflow. Your function will take an input file, process it using a Singularity container, and then save the output to a specified JSON file. You need to implement the function `process_file(input_file: str, json_file: str) -> No... | codefeedback |
You are tasked with implementing a function that processes a given set of style rules and returns a formatted CSS string. The input will be a JavaScript object representing the style rules, where each key-value pair corresponds to a CSS selector and its associated style properties. The keys are the CSS selectors, and t... | codefeedback |
You are tasked with implementing a function to parse and unescape HTML entities in a given string. HTML entities are special sequences of characters used in HTML to represent reserved characters, such as <, >, &, and ". For example, the HTML entity < represents the less-than symbol (<).
You are given a code snippet... | codefeedback |
You are tasked with creating a Java class that handles the configuration and generation of a RESTful API documentation. Your task is to complete the implementation of the `DocsResource` class, which is responsible for serving HTML documentation based on the provided configuration.
The `DocsResource` class has the foll... | codefeedback |
You are tasked with implementing a Python function that utilizes the VGG (Visual Geometry Group) model for image classification. The VGG model is a convolutional neural network that has achieved state-of-the-art performance in image recognition tasks. Your function should take an image file as input and return the top ... | codefeedback |
You are tasked with creating a Python script that simulates the behavior of the `os.environ` module and its `setdefault` method. The `os.environ` module is used to access and manipulate the environment variables of the operating system. The `setdefault` method sets the value of an environment variable if it does not al... | codefeedback |
You are tasked with creating a Python function that simulates the process of dropping all tables owned by a specific user in a PostgreSQL database. The function should take in the database connection object and the username of the table owner as input. It should then execute the necessary SQL commands to drop all table... | codefeedback |
You are tasked with implementing a program to manage and analyze data related to mathematical curves. The program should be able to store and retrieve curve data, as well as perform various operations on the curves.
You are given a partially completed Python code snippet that includes the initialization of data struct... | codefeedback |
You are tasked with implementing a custom exception handling mechanism for an Android application. The given code snippet is a part of an Android application class that extends `android.app.Application` and implements `Thread.UncaughtExceptionHandler`. The `onCreate` method is overridden to set up the custom exception ... | codefeedback |
You are given a list of passport data, where each passport is represented as a sequence of key-value pairs separated by spaces or newlines. Each key-value pair is represented as a string in the format "key:value". A passport is valid if it contains all seven required fields (byr, iyr, eyr, hgt, hcl, ecl, pid), and the ... | codefeedback |
You are tasked with implementing a font management system for a text editor application. The system should support adding custom fonts and providing access to specific fonts based on their style and size. Your task is to create a class that manages the fonts and provides methods to add fonts and retrieve them based on ... | codefeedback |
You are tasked with creating a release management script for a software project. The script should automate the process of updating version numbers, creating release notes, committing changes, tagging the release, and pushing the changes to the remote repository.
Your task is to write a shell script that performs the ... | codefeedback |
You are given a code snippet representing a mapping between a list of integers and their corresponding packed values. The packed values are represented in a specific format, either packed_U4 for unsigned 4-bit integers or packed_I4 for signed 4-bit integers. Each mapping consists of a list of integers, a list of corres... | codefeedback |
You are tasked with implementing a function to process and manipulate data from a file. The file contains pairs of values separated by whitespace, with each pair representing a specific data point. However, some lines in the file may not conform to this pattern and should be skipped. Additionally, a function `canon(var... | codefeedback |
You are tasked with implementing a method to retrieve and process a list of stream information. The stream information is obtained from a `Subject` object, and the list should contain a specified number of elements, sorted by timestamp in descending order. Each stream information contains a `Stream` property, which is ... | codefeedback |
You are tasked with creating a Python script to generate graphs based on different configurations. The script should iterate through various parameters and execute commands to generate graphs using the specified settings. Your task is to implement the Python script to automate the graph generation process based on the ... | codefeedback |
You are tasked with creating a Python script to securely generate and share a secret key between two parties using the BLS threshold signature scheme. The script should install the necessary dependencies and libraries before implementing the key generation and sharing process.
Your script should perform the following ... | codefeedback |
You are tasked with implementing a Python class that simulates a simple stack data structure. 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.
Your task is to implement the... | codefeedback |
You are tasked with implementing a function that calculates the average location of the selected vertices in edit mode for a 3D mesh object. The function should take the mesh object as input and return the average location as a tuple of three coordinates (x, y, z). However, there is a known issue with the existing code... | codefeedback |
You are tasked with creating a program that parses and extracts specific information from a JSON string representing a smart contract's ABI (Application Binary Interface). The ABI describes the methods and properties of the smart contract, including their names, types, and other metadata. Your program should be able to... | codefeedback |
You are tasked with implementing a right outer join function in Python. A right outer join combines rows from two data frames based on a common key, including all the rows from the right data frame and matching rows from the left data frame. If there is no match, the result will contain null values for the left data fr... | codefeedback |
You are tasked with implementing a custom slider component for an Android application. The slider should allow users to select a value within a specified range by dragging a thumb along a track. The slider should also display the selected value in a user-friendly manner.
Your task is to create a custom slider componen... | codefeedback |
You are tasked with creating a function that parses and validates FHIR (Fast Healthcare Interoperability Resources) consent data. FHIR is a standard for exchanging healthcare information electronically. The given code snippet is a part of a unit test for a SwiftFHIRConsent parsing and validation function. Your task is ... | codefeedback |
You are tasked with implementing a custom control in a Windows Forms application that displays daily values. The control should allow users to input and view daily data, and it should provide functionality to end the data input process. The code snippet provided is a part of the control's initialization and event handl... | codefeedback |
You are working on a data visualization project and need to create a program that generates a facet grid plot based on a given dataset. The dataset contains information about different classes and their corresponding scatter plot data. Your task is to write a Python function that takes the dataset and generates a facet... | codefeedback |
You are tasked with implementing a data buffering and insertion system for a database collection. The system should buffer incoming data items and commit them to the database collection once the buffer reaches a certain length. Additionally, the system should handle the insertion of individual items into the collection... | codefeedback |
You are tasked with creating a Python function that manages the congestion control algorithm used by the TCP protocol. The function should retrieve the current congestion control algorithm in use and allow for changing it to a specified algorithm.
You are provided with a code snippet that contains two functions: `get_... | codefeedback |
You are tasked with implementing a shipping cost calculator for an e-commerce platform. The given code snippet is a part of the shipping cost calculation logic. The `$shipping_content` array is used to store shipping information for different countries and services. If free shipping is available or a certain free shipp... | codefeedback |
You are tasked with creating a database schema for a messaging application. The application should support conversations between users, where each conversation can have multiple messages sent by different users. Additionally, each message should have a sender and a recipient, both of whom are users in the system.
Your... | codefeedback |
You are given a 2D vector representing a grid of integers. Each cell in the grid contains a non-negative integer value. The task is to find the minimum path sum from the top-left cell to the bottom-right cell, moving only right or down.
For example, given the following grid:
```
[
[1, 3, 1],
[1, 5, 1],
[4, 2, 1]... | codefeedback |
You are tasked with creating a Python program that simulates a simple UDP server for a chat application. The server will receive messages from multiple clients and broadcast them to all connected clients. You are given a code snippet that sets up the server socket and binds it to a specific address.
Your task is to co... | codefeedback |
You are tasked with implementing a Python method to parse a Bro log header section. The Bro log header section contains field names and their corresponding data types. The method should take a string representing the header section as input and return a dictionary mapping field names to their data types.
The format of... | codefeedback |
You are tasked with creating a program to implement the Find-S algorithm, a machine learning algorithm used for concept learning. The algorithm aims to find the most specific hypothesis that fits all the positive instances in the training data. In this problem, you are given a code snippet that partially implements the... | codefeedback |
You are tasked with simulating a live streaming recorder system. The provided code snippet is a part of a Python script that interacts with a live streaming recorder. The script continuously checks for the live status of a room and initiates recording if the room is live. The `you_live.Recorder.createRecorder` function... | codefeedback |
You are tasked with creating a Python function that generates a report containing a complete set of covering windows for a specific resource type. The function should utilize the boto3 library to interact with Amazon S3. The code snippet provided gives a glimpse of the existing codebase and the use of the `get_matching... | codefeedback |
You are tasked with implementing a generic TypeScript function that manipulates HTML elements and their properties. The function should take two generic type parameters and several props as input. Your goal is to complete the function implementation and ensure that it satisfies the given type constraints.
The provided... | codefeedback |
You are tasked with designing a modular music player application in Rust. The application will consist of several modules, each responsible for a specific aspect of the music player's functionality. The modules are as follows: `logical`, `physical`, `playback`, `playlist`, `prefs`, `reference`, `scan`, `db`, `ui`, and ... | codefeedback |
You are tasked with implementing a custom layer in a deep learning model using Keras and TensorFlow. The custom layer will combine a series of convolutional and normalization operations. Your goal is to write the code for this custom layer, ensuring that it adheres to the specified architecture and constraints.
You ar... | codefeedback |
You are tasked with implementing a validation rule system for a web application's form inputs. The system should allow for defining multiple validation rules for each form field, such as required, numeric, email, etc. Each rule can have various options, including custom error messages and conditional application based ... | codefeedback |
You are tasked with creating a program that can analyze the license information of a given GitHub repository. The program should be able to extract the license type and the year of copyright from the repository's license file.
Write a function `analyze_license_info` that takes in the repository name as a string and re... | codefeedback |
You are tasked with implementing a function that calculates the median of a given array of integers. The median of a set of numbers is the middle number when the numbers are ordered from least to greatest. If the set has an odd number of elements, the median is the middle number. If the set has an even number of elemen... | codefeedback |
You are tasked with implementing a Swift data structure to represent a shape composed of segments. Each segment is defined by its length and orientation. The shape is composed of four segments: top, right, bottom, and left. For simplicity, the bottom and left segments are never rotated.
You need to create a Swift stru... | codefeedback |
You are tasked with creating a Python script that organizes files in a specified directory based on their file extensions. Your script should take a source directory as input and then organize the files into separate subdirectories based on their file extensions. For example, all `.txt` files should be moved to a subdi... | codefeedback |
You are tasked with implementing a simple input handling system for a 2D game using Unity's Input System. The provided code snippet is a starting point for the input handling logic. Your task is to extend this code to handle player input and send it to the game's player character.
You need to create a method that will... | codefeedback |
You are tasked with creating a macOS application that involves managing the presentation options, toggling full screen mode, and hiding the cursor. Your goal is to implement a class that encapsulates these functionalities and provides a clean interface for managing the application's presentation behavior.
Your task is... | codefeedback |
You are working on a script to manage and organize various folders and files related to a machine learning project. The script contains a section with commented-out lines that specify different folder names and lists of features and models. Your task is to write a function that processes these comments and extracts the... | codefeedback |
You are tasked with creating a Python class that simulates a mock MySQL server connection for testing purposes. Your task is to implement the `MockMySQLServerConnection` class, which should inherit from the `MySQLConnection` class. The `MySQLConnection` class has a method `_execute` for executing queries and a method `... | codefeedback |
You are a security analyst investigating a potential security breach in a company's system. You have intercepted a suspicious HTTP request made by an unknown entity to a server. The intercepted request is as follows:
```
curl http://admin:xxxx@illusion.pwn2win.party:1337/
```
Your task is to analyze the intercepted r... | codefeedback |
You are tasked with implementing a class `DataProcessor` that processes data from a sensor and provides methods to manipulate and retrieve the processed data. The class should have the following functionalities:
1. A method `refresh()` that updates the processed data based on the latest sensor readings.
2. A method `g... | codefeedback |
You are tasked with implementing a class for image processing in C++. The class, `RandomCropDecodeResizeOp`, is responsible for performing random cropping, decoding, and resizing operations on images. The constructor of this class takes in the target height, target width, and a scale lower bound as parameters.
The `Ra... | codefeedback |
You are tasked with implementing a 3D grid data structure and a function to calculate the distance between two points in the grid. The grid is defined by its dimensions and the spacing between grid points in each direction. The function should take two points in 3D space and return the Euclidean distance between them i... | codefeedback |
You are working for a data science team that is developing an anomaly detection system for a financial institution. The team has decided to use Python and various libraries for this task. Your task is to create a Python function that preprocesses the data and applies an anomaly detection algorithm to identify potential... | codefeedback |
You are tasked with creating a Python script that automates the process of uploading a package to the Python Package Index (PyPI). The PyPI is a repository of software packages for the Python programming language. When uploading a package to PyPI, it is essential to follow the correct procedure to ensure that the packa... | codefeedback |
You are tasked with creating a function that calculates the aspect ratio of a given device screen based on its width and height. The function should take the width and height as input and return the aspect ratio in the form of a string in the format "width:height".
Write a function `calculateAspectRatio` that takes tw... | codefeedback |
You are tasked with implementing a Python class that calculates the volume of a 3D object using the Monte Carlo method. The class should utilize a given surface object to generate random points within the object's bounding box and determine the volume based on the ratio of points inside the object to the total points g... | codefeedback |
You are tasked with creating a script to automate the process of compiling NSIS (Nullsoft Scriptable Install System) scripts. NSIS is a professional open-source system to create Windows installers. The script should check for the presence of the `makensis` compiler and execute it with the appropriate arguments.
Write ... | codefeedback |
You are given a code snippet that attempts to find the first triangular number (a number that can be represented in the form of n(n+1)/2, where n is a positive integer) that has more than 500 divisors. However, the code snippet is incomplete and contains some errors. Your task is to complete the code and find the first... | codefeedback |
You are tasked with creating a program that simulates a user authentication system. The program should allow the creation of new user accounts and the ability to authenticate existing users. Each user account should have a username and a password. The program should also enforce certain password requirements for securi... | codefeedback |
You are tasked with implementing a Python class to manage requests in a web server log. The class should provide methods to add new requests, update their status, and retrieve requests based on various criteria.
You are given a code snippet representing the attributes of a request:
```python
'request_type',
'status',... | codefeedback |
You are tasked with creating a Python class to represent a transaction response in a payment processing system. The class should include error handling and validation for the transaction kind. Your task is to implement the `TransactionResponse` class with the following requirements:
- The class should have two attribu... | codefeedback |
You are tasked with implementing the Boyer-Moore string search algorithm to efficiently find occurrences of a given pattern within a text. The Boyer-Moore algorithm is known for its ability to perform pattern matching in linear time complexity in the best case and is widely used in practice due to its efficiency.
Your... | codefeedback |
You are tasked with creating a program that analyzes a given text file to count the occurrences of specific words. Your program should read the text file, identify the specified words, and output the count of each word. The words to be counted are provided as input to the program.
Your program should ignore case sensi... | codefeedback |
You are tasked with implementing a Python class for a multivariate Gaussian distribution. The class should provide methods for calculating the probability density function (PDF) and generating random samples from the distribution.
Your task is to complete the implementation of the `GaussianMultivariate` class by filli... | codefeedback |
You are tasked with creating a program that performs real-time face detection using a webcam feed. The provided code snippet initializes a face detection model and captures frames from the webcam, resizing and converting each frame for processing.
Your task is to complete the program by implementing the face detection... | codefeedback |
You are tasked with implementing a reinforcement learning algorithm to train an agent to navigate a grid-based environment. The environment is represented as a Markov Decision Process (MDP) with a set of states, actions, transition probabilities, and rewards. Your goal is to implement the update logic for the Q-learnin... | codefeedback |
You are tasked with creating a program that analyzes a given HTML file to identify and extract all the external JavaScript file URLs referenced within script tags. The program should be able to handle both inline script tags and external script tags with various attributes.
Write a function `extractScriptUrls(html)` t... | codefeedback |
You are tasked with creating a program that simulates a simple command-line interface for managing a list of tasks. The program should support adding tasks, marking tasks as completed, listing all tasks, and removing tasks. The tasks should be stored in memory and should persist for the duration of the program's execut... | codefeedback |
You are given a sequence of numbers that follows a specific pattern. The sequence starts with 1 and 1, and then each subsequent number is the sum of the two preceding numbers. The sequence goes as follows:
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...
Your task is to write a function to find the nth number in this sequence. ... | codefeedback |
You are tasked with implementing a function that processes an image represented as a 2D array of pixels. Each pixel is represented by a tuple of three integers (r, g, b), where r, g, and b are the red, green, and blue color components, respectively. The function should perform a specific image processing operation on t... | codefeedback |
You are working on a project that involves building a cross-platform native library using C++. The project utilizes the GTK+ 3.0 and WebKit2GTK 4.0 libraries for the graphical user interface and web content functionality. Additionally, it uses the libnotify library for desktop notifications. The provided code snippet s... | codefeedback |
You are tasked with implementing a job tracking system that allows users to manage their tasks and time spent on each task. The system should support commands to start, end, and switch between jobs. Your task is to implement the "pop" command, which ends the current job and continues the previous one.
You are provided... | codefeedback |
You are tasked with designing a safe and efficient implementation for a Context struct in Rust. The Context struct is responsible for managing the operating system context and providing methods to interact with it. However, it is crucial to ensure that only one instance of Context can exist at any given time, as having... | codefeedback |
You are tasked with implementing a signature verification function for a custom data structure called `CrdsValue`. The `CrdsValue` can represent different types of data, such as `ContactInfo` and `Vote`. Each `CrdsValue` is associated with a public key and a timestamp. The code snippet provided demonstrates the usage o... | codefeedback |
You are working on a genetics research project and need to implement a mapping system for converting genetic data between different representations. The project involves mapping GenotypePrimer objects to GenotypePrimerDTO objects and vice versa. The provided code snippet shows two methods within a GeneticsMapper class:... | codefeedback |
You are tasked with creating a program that generates a grid of squares, each with a randomly chosen gray value. The program should allow for the generation of a new set of squares with different gray values upon each redraw of the window.
Your task is to implement a Python program that accomplishes the following:
1. ... | codefeedback |
You are tasked with creating a Python function that retrieves the city ID from an API based on the city name provided. The function should make use of the `requests` library to send an HTTP GET request to a specific API endpoint and parse the JSON response to extract the city ID. The API endpoint for this problem is `h... | codefeedback |
You are tasked with implementing a CPU task scheduler that can efficiently assign tasks to available CPU cores. The CPU scheduler is represented as a dictionary `cpuLists`, where each key represents a CPU core and its associated value is a dictionary containing the list of tasks assigned to that core.
Your task is to ... | codefeedback |
You are tasked with implementing a custom data structure to store and manage geographical data for a mapping application. The data structure should be capable of efficiently storing and retrieving information about various geographical features such as cities, landmarks, and natural formations. To achieve this, you nee... | codefeedback |
You are tasked with implementing a program that simulates a simple text-based game. The game involves navigating through a maze represented by a 2D grid. The player starts at the top-left corner of the grid and must reach the bottom-right corner while avoiding obstacles represented by '#' symbols. The player can only m... | codefeedback |
You are tasked with implementing a simplified version of the Data Encryption Standard (DES) decryption algorithm. DES is a symmetric-key algorithm for the encryption of electronic data and was widely used in the past. The given code snippet is a part of the DES decryption process and includes some functions and variabl... | codefeedback |
You are tasked with creating a Python function that validates a software license key based on certain criteria. The license key is represented as a string containing alphanumeric characters and dashes. The function should check if the license key is valid according to the following rules:
1. The key must consist only o... | codefeedback |
You are tasked with implementing a function that takes an array of integers and returns the maximum sum of a subarray within the input array. A subarray is defined as a contiguous block of elements within the array. The function should return 0 if the input array is empty or contains only negative numbers.
Write a fun... | codefeedback |
You are tasked with implementing a genetic algorithm to evolve a population of genomes to solve a specific problem. The given code snippet is a part of a `GeneticAlgorithm` class, which contains a method `getPopulation()` that returns a reference to an array of `Genome` objects. The `Genome` class represents an individ... | codefeedback |
You are tasked with creating a C++ program to simulate a simple dice game. The game involves rolling a standard six-sided die and keeping track of the number of times each face (1 to 6) appears after a certain number of rolls.
Your program should use the `random_device` class from the C++ `<random>` library to generat... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.