instruction_seed stringlengths 29 40.5k | source stringclasses 6
values |
|---|---|
You are tasked with implementing a class method that parses a custom HTTP request header and extracts the header fields and their values. The HTTP request header is represented as a string `self.reqhdrs`, where each header field is encoded as a series of characters. The format of the header is as follows:
- The header ... | magicoder |
You are tasked with creating a Python class that simulates a simple logging system. Your class should have the ability to display messages and log them with different levels of severity. The class should also be able to show the logged messages upon request. Your task is to implement the `Logger` class with the followi... | magicoder |
You are tasked with implementing a custom filter manager for a photo editing application. The manager should handle a collection of filter bundles, each containing a set of filters that can be applied to images. Your task is to implement the `FilterManager` class, which should provide methods for adding filter bundles,... | magicoder |
You are tasked with creating a script to process and export data from a SQLite database containing information about processed tomato production. The script should take a country name as input and export the total processed tomato production for that country to a CSV file.
You are provided with a code snippet that par... | magicoder |
You are tasked with creating a Bash script that processes input arguments and sets environment variables based on the input. The script should take two arguments and set them as environment variables for further use. Your task is to complete the script by adding the necessary code to achieve this functionality.
The gi... | magicoder |
You are tasked with creating a Java method that generates a SQL WHERE clause for a DELETE operation in a database. The method should take in the table column name and the value to be matched, and then construct the WHERE clause and its corresponding arguments for the DELETE operation.
Write a method `generateDeleteWhe... | magicoder |
You are tasked with implementing a Python class that interacts with Google BigQuery to perform various operations. The class should handle authentication, querying, and data manipulation using the BigQuery API. Your task is to complete the implementation of the `BigQueryService` class by adding methods for authenticati... | magicoder |
You are tasked with implementing a custom validation system for a MongoDB database using the Java MongoDB driver. The `ValidationOptions` class provides a way to configure validation rules for a collection in MongoDB. Your goal is to create a program that sets up validation options for a collection and then retrieves t... | magicoder |
You are working on a Python web application that interacts with an external API to retrieve data about different entities. The application uses a custom session object to make HTTP requests and handle responses. The session object has a method called `get_entity` that is used to retrieve information about a specific en... | magicoder |
You are tasked with creating a simple game using the Pygame library in Python. The game involves a player character and non-player characters (NPCs) that need to be drawn on the game window. The provided code snippet is a part of the game loop responsible for drawing the characters on the window.
You are given the fol... | magicoder |
You are tasked with creating a Python class that simulates a spectral synthesis wrapper for astronomical data analysis. The class should be able to retrieve and process spectral data based on input parameters such as effective temperature (teff), surface gravity (logg), and wavelength range (wstart and wend). Additiona... | magicoder |
You are tasked with implementing a simple RESTful API server for managing user data. The server should support creating, retrieving, and deleting user records using the HTTP methods PUT, GET, and DELETE respectively. Your task is to write the server-side code to handle these requests.
Your server should listen on `127... | magicoder |
You are working on a software system for an autonomous car. The system includes a module that monitors various conditions and flags related to the car's operation. One such flag is `CS.pause_long_on_gas_press`, which indicates whether the car should pause for an extended period when the gas pedal is pressed. Additional... | magicoder |
You are tasked with implementing a function that processes a mathematical expression and returns specific information about the expression. The expression is represented using a custom data structure called `Term`, which consists of a symbol and a list of subterms. Each subterm is also a `Term` object, allowing for nes... | magicoder |
You are tasked with creating a simple iOS app using SwiftUI. The app should display a list of items, and upon selecting an item, it should navigate to a new view that demonstrates the usage of ObservableObject in SwiftUI.
Your task is to complete the SwiftUI code by adding the necessary components to achieve the desir... | magicoder |
You are working on a script to set up a text-to-speech system on a Linux system. As part of the setup process, you need to create a symbolic link to a configuration file. The provided code snippet is a command that creates a symbolic link from a specific file to the `~/.festivalrc` file in the user's home directory.
Y... | magicoder |
You are tasked with implementing a function to create a boolean mask from a list of sequence lengths. The function should take in a list of sequence lengths and an optional maximum length, and return a boolean mask indicating which elements in the sequences are valid based on their lengths.
The function signature shou... | magicoder |
You are tasked with implementing a function to determine the number of bulls and cows in a game of guessing numbers. In this game, a "bull" is when a guessed digit is in the correct position, and a "cow" is when a guessed digit is in the incorrect position. You are given two strings, secret and guess, where each string... | magicoder |
You are working on a system that manages actors and their roles in various documents. The system uses a function to update the list of actors and return the updated list along with the document ID. However, the function contains a bug that needs to be fixed.
You are given the following Python code snippet:
```python
... | magicoder |
You are tasked with implementing a custom UITableViewHeaderFooterView subclass in Swift for a home tab section header in an iOS app. The header should display a title label and an image view. Additionally, it should support a tap gesture to expand or collapse the section it represents. Your task is to complete the impl... | magicoder |
You are working on a Django project that involves a model called `BulletPoint`. A new migration is being added to the project to modify the `BulletPoint` model. The migration is intended to add a new field to the `BulletPoint` model. Your task is to complete the migration by adding the necessary field to the `BulletPoi... | magicoder |
You are tasked with implementing a function to convert data from a Lua configuration table into a custom data structure. The provided code snippet is a part of a C++ program that defines a method `convert` within the `GodDB` class. The `convert` method takes a Lua `ConfigTable` object named `data` and a `std::string` n... | magicoder |
You are tasked with creating a Python class that manages configuration settings for a Flask web application. The class should include functionality for setting and retrieving configuration values, as well as a method for checking the expiration of a token.
Your task is to implement the `FlaskConfig` class with the fol... | magicoder |
You are tasked with implementing a custom smart pointer in Rust, similar to the built-in `Box` type. The smart pointer should have the ability to store a single character and provide methods to access and modify the stored value. Additionally, you need to handle the error related to the experimental box pattern syntax.... | magicoder |
You are tasked with implementing a simplified version of a user authentication system in Python. The system consists of a class `UserAuthenticator` with a method `_fail_auth` that handles failed authentication attempts. The method takes a message as input, sends an error message using the `_send_brio` method, and retur... | magicoder |
You are tasked with implementing a data collection system for a research project. The system has two types of data sources: real and fake. The provided code snippet is a part of the system's class, which includes a method for collecting data. The method takes a parameter `datatype` to determine whether to collect real ... | magicoder |
You are tasked with implementing a method to find the index of the next visible character in a text generator. The text generator contains a series of characters, some of which may not be visible due to their width being 0. The method should take an optional parameter `startVisibleCharIndex` (default value is 0) and re... | magicoder |
You are tasked with implementing a method to retrieve and display job listings based on their categories. You are provided with a partial code snippet from a Laravel application's controller. Your task is to complete the method `getJobsByCategory` within the `JobsController` class. The method should retrieve all jobs b... | magicoder |
You are tasked with implementing a basic tree data structure in Python. The tree will consist of nodes, each of which can have a parent and a single child. You need to create a class `TreeNode` with the following methods:
1. `__init__(self, value, parent)`: Initializes a node with a given value and parent. If the node ... | magicoder |
You are tasked with implementing a simplified version of an Entity-Component-System (ECS) framework in C++. In an ECS architecture, entities are composed of various components, and systems operate on entities based on their components. Your goal is to create a component container that stores and manages components of a... | magicoder |
You are working on a simulation program for a transportation network. The code snippet provided is a part of the program that sets up the network's endpoints and links between them. Each endpoint represents a location, and the links represent connections between these locations. The distance parameter in the `linkUp` f... | magicoder |
You are tasked with creating a Python class that manages the installation and version tracking of a software package. The class should handle the execution of installation commands, parsing the build date of the installed package, and retrieving the build date of the currently installed version.
Your task is to implem... | magicoder |
You are tasked with implementing a class that manages user preferences for a music streaming service. The class should allow users to set and retrieve their preferred genres and playlists. Additionally, it should provide a method to compare the user's preferences with another user's preferences.
You are provided with ... | magicoder |
You are tasked with implementing a function that processes a list of patient records and returns a filtered list based on certain criteria. Each patient record is represented as a dictionary with the following keys: "name", "age", "gender", and "diagnosis". The function should filter the patient records based on the fo... | magicoder |
You are tasked with implementing a function that calculates the total number of unique characters in a given string. A unique character is one that appears only once in the string. Your function should return the count of such unique characters.
Function Signature:
```python
def count_unique_characters(input_string: ... | magicoder |
You are tasked with implementing a song generator that takes musical notes and their corresponding start times and creates a song by inserting the notes into the song at the specified start times. The code snippet provided is a part of the song generation process. The `sig_gen.sin_constant` function is used to generate... | magicoder |
You are tasked with implementing a module system for a JavaScript application. The module system should allow for the export and import of constants and functions between different modules. The export statement is used to export functions, objects, or primitive values from a module, while the import statement is used t... | magicoder |
You are tasked with implementing a Python class that simulates a simple robot's autonomous driving behavior. The robot has a drive train with two gears: high gear and low gear. The robot should perform a sequence of actions, including shifting to high gear and then driving forward at a specified speed for a given durat... | magicoder |
You are given a code snippet representing a class with various properties. Each property is decorated with attributes such as `Ordinal` and `RED`. The properties have different data types and are related to inkCanvasWidgetReference, CUInt32, CFloat, and inkTextWidgetReference. Your task is to create a program that proc... | magicoder |
You are tasked with implementing a class that represents a smart card used for authentication and access control. The smart card has various features that can be enabled or disabled, and your goal is to implement the methods to check the status of these features.
You are provided with a partial code snippet for the `C... | magicoder |
You are tasked with implementing a Java class that manages filtering and clearing of form fields for a data query application. The class, `FormManager`, should provide methods for filtering data based on user input and clearing the form fields when needed. The class should also support event handling for filter actions... | magicoder |
You are given a string representing a block of ASCII art. The ASCII art contains a pattern of characters that form a specific shape or design. Your task is to write a program to identify the number of occurrences of a specific pattern within the given ASCII art block.
Write a function or method `countPatternOccurrence... | magicoder |
You are tasked with creating a Python function that processes file sizes and returns a human-readable representation of the size. The function should take a file size in bytes as input and return a string representing the size in a more readable format (e.g., kilobytes, megabytes, gigabytes, etc.).
You are provided wi... | magicoder |
You are tasked with creating a custom form validation library in Java for a web application. The library should allow developers to define validation rules for form fields and then validate user input against these rules. To achieve this, you need to implement a class called `FormValidator` that provides methods for ad... | magicoder |
You are tasked with implementing a function to calculate the mean squared error (MSE) between two sets of data. The MSE is a measure of the average squared difference between corresponding elements of the two sets. In this problem, you are given two sets of data, represented as vectors of double precision floating-poin... | magicoder |
You are tasked with implementing a utility function that constructs a service model object. The function takes two parameters, `serviceInstance` and `serviceBinding`, and returns the constructed service model object. The function should handle cases where either `serviceInstance` or `serviceBinding` is null by setting ... | magicoder |
You are tasked with implementing a simple inheritance and method invocation scenario in Python. Your goal is to create classes and methods that model a basic object-oriented structure.
You are given the following code snippet as a starting point:
```python
if __name__=='__main__':
martinho = Mutante(nome='Martinh... | magicoder |
You are tasked with creating a PHP class to handle invoice submissions and email confirmations. Your class should have methods to submit an invoice, send an email confirmation, and generate a URL for submitting another invoice. The class should also have properties to store the invoice title and the URL manager.
Your ... | magicoder |
You are tasked with implementing a weather information retrieval system using the Android Wear platform. The provided code snippet is a part of an Android application that communicates with a wearable device to request weather information. Your task is to complete the implementation by handling the weather information ... | magicoder |
You are working on a project that involves optimizing the performance of a computational task. The task involves performing a large number of floating-point operations, and you have a constraint on the maximum number of floating-point operations per second (FLOPS) that your system can handle. Additionally, you have a l... | magicoder |
You are tasked with implementing a function that processes a JSON response from a server and extracts specific information from it. The JSON response contains data about errors that occurred during a network request. Your task is to write a function that takes the JSON response as input and returns a list of error IDs ... | magicoder |
You are tasked with implementing a program that processes HTML table data to calculate the total number of items in a specific column. The input will be a string representing an HTML table, and the output should be the total count of items in the specified column.
You are given the following HTML table snippet as an e... | magicoder |
You are tasked with creating a Rust module that implements a finite module structure for a real projective space. The real projective space is a fundamental concept in algebraic topology and is represented by the module `RealProjectiveSpace` in the code snippet provided.
Your task is to define a Rust module that utili... | magicoder |
You are tasked with implementing a data validation function for a specific data structure. The data structure is represented by a Rust struct called `VerifyPacket`, which is used to store information related to a verification packet. The `VerifyPacket` struct has a field `fmt` of type `String` and a field `attStmt` of ... | magicoder |
You are tasked with creating a chatbot for managing addresses and statistics. The chatbot should be able to display addresses, provide statistics, and allow users to perform various actions on the addresses. You need to implement a function that processes the user's input and returns the appropriate response based on t... | magicoder |
You are tasked with implementing a system to manage shields in a game. The provided code snippet is a part of a game engine's system responsible for handling shield entities. The system processes entities with a `ShieldComponent` attached to them and updates their properties based on the elapsed time. When a shield's l... | magicoder |
You are tasked with implementing a Python module for simulating the n-body problem, which involves predicting the motion of a group of celestial objects interacting with each other through gravitational forces. The provided code snippet imports a module named `n_body`, which contains the necessary functions and classes... | magicoder |
You are tasked with implementing a Python class for controlling a robot's movement. The class, named `Go_straight`, is responsible for making the robot move straight for a specified duration. The class has an `__init__` method that initializes the left and right motors and a timer for moderating data taking.
You need ... | magicoder |
You are tasked with implementing a Python function that processes a list of directories and a configuration value. The function should perform specific assertions based on the input parameters. Your task is to complete the function by implementing the missing logic based on the given code snippet.
The function signatu... | magicoder |
You are tasked with implementing a Python module that manages a collection of mathematical functions. The module should include functions for calculating the factorial of a number, finding the greatest common divisor (GCD) of two numbers, and checking if a number is prime. Your task is to complete the implementation of... | magicoder |
You are tasked with creating a Python game using the Turtle module. The game involves a snake that moves around the screen, eating food to grow longer while avoiding collisions with itself and the screen boundaries. The provided code snippet sets up the game environment and imports necessary classes from other Python f... | magicoder |
You are tasked with implementing a custom evaluation metric for a machine learning model using MXNet and NumPy. The metric will be a variant of the Sigmoid Cross-Entropy Loss, and you need to create a class that extends the `mx.metric.EvalMetric` class provided by MXNet.
Your task is to implement the `SigmoidCELossMet... | magicoder |
You are tasked with creating a Python program that processes a text file containing numerical data. The program should read the file, perform a specific operation on the data, and then write the results to a new file. However, there are certain requirements and potential issues that need to be addressed.
Your program ... | magicoder |
You are given a list of time durations in the format "hh:mm:ss" (hours, minutes, seconds). Your task is to write a function that takes this list as input and returns the total duration in seconds.
Create a function `total_duration_in_seconds` that takes a list of time durations as input and returns the total duration ... | magicoder |
You are tasked with creating a command-line utility to sort tabular data from a file and save the sorted output to another file. Your program should accept two command-line arguments: `-i` or `--input` to specify the input tabular file to be sorted, and `-o` or `--out_file1` to specify the file where the sorted output ... | magicoder |
You are working on a project that involves processing and managing tensors in a computational graph. Tensors are represented as nodes in the graph, and operations are represented as edges connecting these nodes. Your task is to write a Python function that takes a list of operations (`ops`) and constructs a dictionary ... | magicoder |
You are tasked with implementing a simple event handling system in Rust. The system consists of an event transmitter (`event_tx`) and a `main` function that initializes a `Harness` and processes events.
The `event_tx` is a write-only channel that sends events to the `main` function. The `main` function processes the e... | magicoder |
You are given a list of integers representing the daily stock prices of a company. Your task is to write a function that calculates the maximum profit that can be obtained by buying and selling the stock on different days. The function should take the list of stock prices as input and return the maximum profit that can... | magicoder |
You are tasked with implementing a class that represents a financial account balance with threshold checks. The class should have properties for the balance and low threshold balance, and a method to check if the balance falls below the threshold.
You need to create a C# class `FinancialAccount` with the following req... | magicoder |
You are tasked with creating a script to automate the installation process of a software package. The script should handle the configuration, compilation, and installation steps. The configuration step involves setting specific options, the compilation step involves running the make command, and the installation step i... | magicoder |
You are tasked with creating a Python function that takes in the file path of an image and returns the dimensions (width and height) of the image. You are not allowed to use any external libraries or modules to accomplish this task. You must read the image file and extract its dimensions using only built-in Python func... | magicoder |
You are tasked with implementing a custom encoder and decoder for a domain object in Swift. The domain object has several properties that need to be encoded and decoded using the `Codable` protocol. Your task is to create the necessary custom encoder and decoder methods to handle the encoding and decoding of the domain... | magicoder |
You are tasked with creating a Django REST framework API for managing courses and subjects. The given code snippet is a part of the URL configuration for the API. The `router` is used to automatically generate URL patterns for the `CourseViewSet`, and two additional URL patterns are manually defined for listing and vie... | magicoder |
You are given a Python function that takes in a list of integers and a target integer. The function is intended to find the index of the first occurrence of the target integer in the list. However, the code snippet provided contains a line that needs to be completed to achieve the intended functionality.
The function ... | magicoder |
You are tasked with creating a script to automate the building and pushing of Docker images for different Node.js versions. The script should read the version from a `package.json` file, validate it as a semantic version (semver), transpile TypeScript code using `tsc`, and then build and push Docker images for specific... | magicoder |
You are tasked with simulating the flight trajectory of a disc golf disc using the given code snippet as a reference. The `Disc` class represents a disc model and its properties, and the `compute_trajectory` method calculates the disc's trajectory over time. Your goal is to create a Python function that takes the neces... | magicoder |
You are tasked with creating a Python class to manage configuration settings for an application using the AppMap recorder. The AppMap recorder is a tool used for recording interactions with an application to generate visual representations of the application's behavior.
Your task is to create a `ConfigManager` class t... | magicoder |
You are tasked with creating a Python function that processes a dataset containing GNSS (Global Navigation Satellite System) navigation messages and generates tables to report the number of these messages. The function takes in three arguments: `dset` (the dataset containing the data), `rpt` (a Report object for genera... | magicoder |
You are tasked with implementing a function to process and filter a collection of reports based on certain criteria. Each report has properties including `IsDeleted`, `Industry`, and `ReportDate`. The function should take in a collection of reports and return a new collection containing only the reports that meet the s... | magicoder |
You are tasked with implementing a NullResultConverter class in C# that adheres to a specific interface. The IConvertsJintEvaluationResult interface is used for converting the result of a Jint evaluation, and the NullResultConverter class should wrap an existing implementation of this interface, providing a null result... | magicoder |
You are tasked with implementing a LazyArray class that supports lazy evaluation of mathematical expressions. The LazyArray class should allow for the creation of lazy arrays and the composition of mathematical operations on these arrays without immediately evaluating the expressions. Additionally, the class should pro... | magicoder |
You are tasked with creating a Python function that generates a unique temporary file name within a specified directory. The function should take the directory path as input and return the full path of the temporary file.
Your task is to implement the `generate_temp_file` function, which takes a directory path as inpu... | magicoder |
You are tasked with implementing a custom data structure called `Field` in Python. The `Field` class has an attribute `table` which is a 2D list representing a game board. Additionally, the class has a method `copy_field` which creates a deep copy of the `Field` object. Your task is to implement the `Field` class and i... | magicoder |
You are tasked with implementing a simplified version of a time shift manager for a company's employees. The time shift manager is responsible for cloning and assigning recipients for time shift notifications. Each recipient is associated with a specific time shift and is responsible for receiving notifications related... | magicoder |
You are tasked with creating a simple web application using the Laravel framework. The application should have a route that displays a welcome page when accessed. Your task is to write the necessary code to achieve this functionality.
Create a new route in the web.php file that maps the root URL ("/") to a controller ... | magicoder |
You are tasked with implementing a custom CSS-in-JS component for a web application. The component, called `CustomHeading`, should render a heading with customizable styles based on the provided props. The component should accept the following props:
- `as`: The HTML tag for the heading (e.g., "h1", "h2", "h3", etc.).
... | magicoder |
You are tasked with creating a custom drawer component for a web application using the Naive UI library. The drawer component should have specific functionality and styling to meet the requirements of the application.
Your task is to implement a custom drawer component that extends the `DrawerProps` interface from the... | magicoder |
You are tasked with implementing a parallel evaluation system for a genetic algorithm using the NEAT (NeuroEvolution of Augmenting Topologies) library in Python. NEAT is a method for evolving artificial neural networks through genetic algorithms. The given code snippet demonstrates the setup and execution of the NEAT a... | magicoder |
You are working on a file management system and need to implement a function to create directories based on a given path. The function should handle both absolute and relative paths and create the necessary directories if they do not exist.
Write a Python function called `create_directories` that takes a string `base_... | magicoder |
You are tasked with implementing a function to calculate the centroid of a binary image using the OpenCV library in Python. The centroid is calculated using the moments of the binary image. The moments of an image are a set of scalars that provide a quantitative description of the image's spatial distribution. The func... | magicoder |
You are tasked with creating a Python function that manages the deletion of configuration files for a specific user's dataset. The function should take three parameters: `config` (string), `dataset` (string), and `username` (string). The `config` parameter specifies the configuration file to delete, and it can take the... | magicoder |
You are tasked with implementing a simple event handling system in Swift. Your goal is to create a class that allows other parts of the program to register callbacks to be triggered when a specific event occurs.
Create a class `EventEmitter` with the following specifications:
- It should have a method `on` that takes ... | magicoder |
You are working on a data processing pipeline for a web application, and you need to manage the flow of data between different stages of the pipeline. The pipeline consists of several stages, each with its own set of data. You have been provided with the following code snippet that defines constants for the different s... | magicoder |
You are tasked with implementing a WebSocket client in Swift. Your goal is to create a function that sends a message to the server and handles the response. The WebSocket client is represented by the `WebSocketClient` class, which has a method `sendMessage` for sending a message and a delegate method `didReceiveMessage... | magicoder |
You are tasked with creating a program that simulates a simple game of dice rolling. The program should prompt the user to roll a six-sided die and then display the result. However, if the user inputs an invalid command, the program should exit with an error code of 1.
Your task is to write a bash script that accompli... | magicoder |
You are tasked with implementing a Python function that generates a plot to visualize the cost and number of feasible solutions over generations in a genetic algorithm. The function should take in two lists as input: `itens` representing the cost of each generation, and `itens2` representing the number of feasible solu... | magicoder |
You are tasked with creating a class `Diem` that represents a date and provides a method `diff` to calculate the difference in days between two `Diem` objects. The `diff` method should take another `Diem` object as input and return the number of days between the two dates.
The input to the `diff` method will be two `D... | magicoder |
You are tasked with implementing a function that stitches together a grid of images to form a single large image. The function takes in a list of images, the dimensions of the grid, and the dimensions of each individual image. Your task is to write a function `stitch_images(images, grid_size, image_size)` that returns ... | magicoder |
You are tasked with implementing a command-line option parser in C++. The parser should support adding options of different types (string, integer, double) with short and long names, descriptions, and optional flags. Your task is to implement the `AddOption` method for adding different types of options to the parser.
... | magicoder |
You are tasked with implementing a unit test for a Gaussian distribution class using Python's unittest framework. The Gaussian distribution class is provided by the prml library, which is a machine learning library for Python. Your task is to write a test case to verify the correctness of the Gaussian distribution clas... | magicoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.