instruction_seed stringlengths 29 40.5k | source stringclasses 6
values |
|---|---|
You are working on a Python project that involves managing different categories of books. The code snippet provided defines a class with some constants and a method to retrieve the name of a category based on its index. Your task is to implement a BookCategory class that utilizes the given code snippet and provides add... | magicoder |
You are tasked with creating a script to automate end-to-end testing for a web application using Selenium. The provided code snippet contains a series of environment variable assignments that are crucial for configuring the testing environment. Your task is to write a Python script that utilizes these environment varia... | magicoder |
You are tasked with creating a Python program that simulates a simple web application using the Flask framework. Your program should include a route that handles a GET request and returns a specific response. Additionally, you need to ensure that the application can handle multiple requests concurrently by utilizing th... | magicoder |
You are tasked with implementing a JavaScript class that manages alerts for a web application. The class, named `AlertManager`, should have the following functionalities:
1. A constructor that initializes the `size` property to "none".
2. An `alert()` method that displays an alert with the message "Lorem ipsum".
3. An... | magicoder |
You are tasked with implementing a simple network communication protocol using Python. Your goal is to create a class that can send and receive data over a network socket. The class should be able to handle exceptions and encode the received data using base64 before writing it to the standard output.
You are provided ... | magicoder |
You are tasked with creating a simple iOS application that allows users to post content and browse through existing content. The application has two buttons, "postBtn" and "browseBtn", and two corresponding action functions, "postFunc" and "browseFunc". Your task is to implement the functionality for these buttons such... | magicoder |
You are tasked with creating a Python function that processes a list of classifiers and returns a dictionary containing the count of each unique category. Each classifier is a string representing a category in the format "Category :: Subcategory". The function should ignore the subcategories and only consider the main ... | magicoder |
You are tasked with implementing a doubly linked list in C++. A doubly linked list is a data structure that consists of a sequence of elements, where each element has a reference to the previous and next elements in the sequence. Your task is to create a class that represents a doubly linked list and implement various ... | magicoder |
You are given a list of integers representing the scores of a game. The game has a special rule: if the current score is the same as the previous score, the current score is discounted and not added to the total score. Write a function to calculate the total score of the game according to this rule.
Function Signature... | magicoder |
You are tasked with implementing a Python function that processes a given input sequence using a specific recurrent neural network (RNN) architecture. The RNN is defined using TensorFlow, and the function should prepare the input data and construct the RNN model as per the provided code snippet.
Your task is to comple... | magicoder |
You are tasked with creating a shell script that automates the setup and configuration of a development environment. The script should execute a series of commands to set up a specific programming language, run a configuration check, and potentially create a database. Your task is to complete the shell script by fillin... | magicoder |
You are tasked with creating a function that generates a secure URL for accessing a backend server. The function should take in the backend URL and return a secure URL with the "https" protocol.
You are given the following code snippet as a starting point:
```javascript
const config = {
backendURL: 'bhayanak-streame... | magicoder |
You are tasked with implementing a function that processes a list of issues from an issue tracker system and returns a summary of the issues based on their status. The issue tracker system provides a list of issues, each containing a title and a status. The function should return a summary that includes the count of is... | magicoder |
You are tasked with designing a multi-threaded experiment processing system. The system is responsible for processing various tasks related to feature generation, matrix building, and model training/testing. Your goal is to implement the multi-threaded processing logic for the given experiment tasks.
You are provided ... | magicoder |
You are working on a project that involves analyzing text data within a SQL Server environment. Your task is to create a Python script that connects to a local SQL Server database, installs the "textblob" package using the `sqlmlutils` library, and then performs sentiment analysis on a specific table within the databas... | magicoder |
You are tasked with implementing a function to parse a list of driving environments. The function should take a string as input and return a list of integers representing the driving environments. The input string may contain comma-separated integers or a single integer. If the input is a single integer, it should be r... | magicoder |
You are tasked with implementing a function to handle error responses in a time model configuration system. The system provides a method that responds with specific error codes in case of failure. Your task is to create a function that interprets these error codes and provides appropriate actions for each error type.
... | magicoder |
You are tasked with implementing a method to insert data into a database table using the provided code snippet as a reference. The code snippet is a part of a C# extension method that extends the functionality of the `IDbConnection` interface. The `Insert` method takes in the database connection, data to be inserted, t... | magicoder |
You are tasked with implementing a Python function that processes a string of comma-separated integers and returns a list containing the integers in descending order. Additionally, you need to write a unit test for this function using the `unittest` framework.
Write a function `listpicle` that takes no arguments and d... | magicoder |
You are tasked with implementing an asynchronous file reading function in Python. Your function should open a file in binary mode, read its contents asynchronously, and then close the file. Additionally, you need to write a test case using the `pytest` framework to verify the functionality of your asynchronous file rea... | magicoder |
You are tasked with creating a custom viewset for a contact management system using Django Rest Framework. The viewset should allow users to create new contacts. The `Contact` model and `ContactSerializer` are already provided. Your task is to implement the `ContactViewSet` class, which should inherit from `mixins.Crea... | magicoder |
You are tasked with implementing a custom exception class in PHP. Your task is to create a class called `CustomException` that extends the built-in `Exception` class. The `CustomException` class should have the following properties and methods:
Properties:
- `code`: An integer representing the exception code. It shoul... | magicoder |
You are tasked with creating a Python class that handles the comparison of data objects. Your class should include methods for setting and retrieving the results of the comparison at both the object level and the data level. The class should also have appropriate type annotations for the properties.
Your task is to im... | magicoder |
You are tasked with implementing a Python class that represents a fan controller for a smart home system. The fan controller should support different modes such as "low", "medium", "high", and "auto". Additionally, the class should provide methods to set the fan mode, get the current fan mode, and retrieve a string rep... | magicoder |
You are tasked with implementing a script to train a machine learning model using a command-line interface. The script takes various parameters and options, and it is essential to understand and manipulate these settings for optimal model training.
The provided code snippet is a part of the command used to launch the ... | magicoder |
You are tasked with creating a program that analyzes a given text file to count the occurrences of specific words. The program should read the text file, tokenize the words, and then count the occurrences of each word. Additionally, the program should ignore any words that are included in a provided list of common stop... | magicoder |
You are tasked with implementing a simple form validation function for a web application. The function should validate the input from a client ID field and return a boolean value indicating whether the input is valid or not. The client ID field is represented by an HTML input element with the following attributes and e... | magicoder |
You are tasked with implementing a class that manages server lock status. The class has a method to set the end start date and a method to get the server lock status.
You need to implement the `setEndStartDate` method that takes a parameter `$endStartDate` and sets it to the class property `$endStartDate`. Additionall... | magicoder |
You are tasked with creating a Django model for tracking service request history. The model should store information about service requests, including the contact details of the requester and the operator handling the request. Your task is to extend the given code snippet to include additional fields and constraints.
... | magicoder |
You are tasked with implementing a Python class for modeling a global eccentricity distribution based on the Kipping (2013) study. The provided code snippet serves as a starting point for the implementation. Your task is to complete the implementation of the `Kipping13Global` class by adding a method to calculate the p... | magicoder |
You are tasked with implementing a custom data structure called `StackWithMax` that supports the following operations efficiently:
1. `push(val)`: Add an element to the top of the stack.
2. `pop()`: Remove the element from the top of the stack and return its value.
3. `max()`: Return the maximum value in the stack.
Y... | magicoder |
You are tasked with implementing a floating-point vector class in C++. The class should support basic vector operations and provide methods to access the individual components of the vector. Additionally, you need to write a unit test for the `getX` method of the vector class to ensure its correctness.
Your task is to... | magicoder |
You are tasked with implementing a data preprocessing algorithm for a machine learning project. The algorithm involves reading a list of file paths from a file, processing the data, and then writing the processed data to a new file. The specific steps of the algorithm are as follows:
1. Read a list of file paths from ... | magicoder |
You are tasked with implementing a Python class that can unwrap echo packets received from a communication channel. The echo packets are wrapped using a custom protocol called EchoPacketWrapper. Your task is to complete the implementation of the echo_packet_unwrapper class, which inherits from the gr.basic_block class ... | magicoder |
You are working on a software project that involves creating a graphical user interface (GUI) using PyQt. As part of the project, you need to add a custom plot widget to the GUI. The custom plot widget is an instance of the `PlotWidget` class, which is a subclass of `QWidget`. The GUI layout is managed using a `QGridLa... | magicoder |
You are tasked with implementing a function to generate acronyms from a given string. An acronym is formed by taking the first letter of each word in the string and converting it to uppercase. For example, "World Health Organization" would be abbreviated as "WHO".
You are to write a function `generateAcronym` that tak... | magicoder |
You are tasked with creating a Python program to process and analyze a database of order items. The database contains a table named `OrderItems` with the following schema:
```
OrderItems(order_num INT, order_item INT, prod_id TEXT, quantity INT, item_price FLOAT)
```
The given code snippet shows a series of SQL `INSE... | magicoder |
You are tasked with creating a Flutter plugin for macOS that integrates with the bitsdojo_window package to customize the window appearance and behavior. The bitsdojo_window package provides functionalities for customizing the window frame, title bar, and other window-related features in a Flutter desktop application.
... | magicoder |
You are tasked with implementing a simplified version of a callback system for handling HTTP commands in a C++ application. The provided code snippet is a part of a larger system that processes HTTP requests and sends the corresponding responses to a callback function.
Your task is to create a class that manages the H... | magicoder |
You are tasked with implementing a Swift structure to represent musical clefs. A clef is a symbol at the beginning of a musical staff that indicates the pitch of the notes. The given code snippet provides a partial implementation of the `Clef` structure. Your task is to complete the implementation by adding the necessa... | magicoder |
You are tasked with creating a Python function that processes a list of integers and returns the sum of all even numbers in the list. However, the function should also handle potential errors gracefully. Your task is to implement the function `sum_even_numbers` which takes a list of integers as input and returns the su... | magicoder |
You are tasked with creating a Bash script to automate the process of adding new nodes to a cluster. The script should handle the status of the Ansible command used to add the node and provide appropriate feedback based on the command's success or failure.
Your script should include the following components:
- A varia... | magicoder |
You are given a function `reverseFraction` that takes in two parameters: `x` (a floating-point number) and `n` (an integer). The function is intended to reverse the fraction `x` and then multiply the result by `-n`. However, the given code snippet is incorrect and needs to be fixed.
Your task is to correct the code sn... | magicoder |
You are tasked with implementing a class for a Binary-Binary Restricted Boltzmann Machine (RBM) in Python. An RBM is a type of neural network used for unsupervised learning. The Binary-Binary RBM consists of visible and hidden layers, both of which contain binary units. The RBM has the following characteristics:
- The ... | magicoder |
You are tasked with implementing a Python class that manages different types of package builders for a software distribution system. The class should allow adding new builder types and retrieving the appropriate builder based on a given format.
You are provided with a partial code snippet that initializes a dictionary... | magicoder |
You are tasked with creating a function that calculates the bandwidth utilization based on the input parameters. The function should take three arguments: `run_time` (in seconds), `size` (in bytes), and `bandwidth` (in bits per second). The function should return the bandwidth utilization as a percentage.
The bandwidt... | magicoder |
You are tasked with implementing a random number generator plugin for a game development framework. The `RngPlugin` struct is provided, which contains a field `seed` of type `Option<Seed>`. The `Seed` enum has variants `String` and `Integer`, representing different types of seeds for the random number generator.
Your ... | magicoder |
You are tasked with creating a Python program to automate the process of scraping and processing lecture links from a specific webpage. The program should use the Selenium library to interact with a web browser and extract the lecture links from the page. Additionally, the program should print the processing status for... | magicoder |
You are tasked with creating a Python function that tests the connection to a web application using the `http_client` library. The `http_client` library provides a set of functions for making HTTP requests and handling responses. Your goal is to implement the `test_connect_to_app` function, which takes the `http_client... | magicoder |
You are tasked with implementing a Java class for managing expenses within a personal finance application. The class `ExpenseManagementCommunsDTO` is used to represent expense data and is annotated with various annotations for serialization and deserialization purposes. Your task is to complete the implementation of th... | magicoder |
You are tasked with implementing a TypeScript type definition for a component's props. The component is an icon button that can be in a disabled state, and it may display a tooltip when disabled. Your goal is to define the type `IconButtonProps` that accurately represents the props for this icon button component.
The ... | magicoder |
You are tasked with creating a script to automate the process of building Docker images for different versions of a digital sky application. The script should take a version number as a command-line argument and use it to tag the Docker image and select the appropriate Dockerfile for building.
Write a shell script nam... | magicoder |
You are tasked with implementing a simple class in Swift that represents a geometric shape. The class should have a method to calculate the area of the shape. You need to create a subclass for a specific shape and implement the area calculation method for that shape.
You are provided with the following code snippet as... | magicoder |
You are given a snippet of code from an Android RecyclerView adapter. The code is responsible for handling data changes and notifying the RecyclerView about the changes to update the UI. The `notifyItemRangeChanged` method is used to inform the RecyclerView about specific item range changes.
Your task is to implement ... | magicoder |
You are tasked with implementing a custom queue data structure in Python. The queue should support the following operations:
1. `append(item)`: Add an item to the end of the queue.
2. `pop()`: Remove and return the item at the front of the queue.
3. `ShowQueue(queue, direct)`: A function that takes a queue and a direct... | magicoder |
You are tasked with creating a Python function that processes a list of integers and returns a modified list based on specific criteria. Your function should take a list of integers as input and perform the following operations:
1. Remove any duplicate integers from the list.
2. Sort the list in ascending order.
3. If ... | magicoder |
You are tasked with creating a Python function that parses shield image URLs from a given reStructuredText file and returns a list of these URLs. The shield image URLs are denoted by the `.. image::` directive followed by the URL within the reStructuredText file.
Write a function `parse_shield_urls(file_content: str) ... | magicoder |
You are tasked with creating a Rust program that reads the contents of a file into a string and then performs a specific operation on the data. Your program should take a file path as input and perform the following steps:
1. Open the file located at the given path.
2. Read the contents of the file into a string.
3. Pe... | magicoder |
You are working on a file management system that stores information about downloaded files in a database. The given code snippet is a method that inserts a new record into the database table. The table has the following columns:
- download_date (timestamp of the download)
- filename (name of the file)
- file_type (type... | magicoder |
You are tasked with implementing a Python function that performs a specific operation on a given set of elements. The function should take a list of elements as input and return a modified set based on the input elements. Additionally, you need to write unit tests for this function using the `unittest` framework to ens... | magicoder |
You are given a snippet of code that manipulates an index variable based on the size of a source array and an offset index. Your task is to implement a function that simulates the behavior of the given code snippet.
You need to write a function `calculateNewIndex` that takes three parameters:
1. `source`: an array of ... | magicoder |
You are tasked with implementing a function that processes linting errors from a JavaScript linting tool and formats them for display. The linting errors are stored in a list called `error_lines`, and the linting tool's output is stored in a variable called `eslint_output`. The code snippet provided is a part of the fu... | magicoder |
You are tasked with creating a Python program that utilizes command-line arguments to process data from a file using different functions. The program should accept two command-line arguments: the input file and the function to apply to the data. The available functions are predefined and can be chosen from a list of po... | magicoder |
You are tasked with implementing a function that applies Bit Error Rate (BER) to a given input binary string. The BER is a measure of the number of bits that have been altered due to noise, interference, or other imperfections in a communication channel. Your function should simulate this by randomly flipping a specifi... | magicoder |
You are working on a backend system for a quiz application. The system uses Django and Django REST framework for creating APIs. You are tasked with creating a serializer for the `Question` model and its related `Answer` model. The `Question` model has a field called `tutor`, and you need to ensure that this field is re... | magicoder |
You are tasked with implementing a syntax checker for a custom programming language. The language uses single quotes to denote character literals, and the syntax checker needs to ensure that the characters within the single quotes are valid. The syntax checker should also handle the case where a single quote is used as... | magicoder |
You are tasked with implementing a cache management system for a web application. The cache is designed to store frequently accessed data to improve performance. The cache has a total cost limit, which is the maximum amount of memory it can consume. The cost of an item in the cache is determined by its size in bytes. W... | magicoder |
You are tasked with implementing a custom exception class in C++. Your task is to create a class called `CustomException` that inherits from the standard `std::exception` class. The `CustomException` class should have a constructor that takes a `const char*` message as a parameter and stores it internally. Additionally... | magicoder |
You are tasked with implementing a simple security module in Rust to manage certificates and security requirements. The provided code snippet defines some basic structures and type aliases for the security module. Your task is to create a function that takes a reference to a security code and a reference to a security ... | magicoder |
You are tasked with implementing a memory management function for an ARMv4 processor. The function `SetTranslationTableBaseRegister` is responsible for writing the Translation Table Base Register, and it takes a pointer to an unsigned 32-bit integer as its parameter. The function `ResetControlRegisterBits` is used to r... | magicoder |
You are tasked with implementing a text encoding function that supports both Unix-based and Windows-based systems. The function should take a string as input and return the encoded representation of the text based on the underlying operating system. For Unix-based systems, the encoding should be done using UTF-8, while... | magicoder |
You are tasked with implementing a Python class that simulates a simple key-value store with the ability to set, get, and delete key-value pairs. The key-value store should also support lazy loading of hooks, which are functions that can be triggered when certain keys are accessed.
Your task is to complete the impleme... | magicoder |
You are tasked with creating a function to handle update alerts for a mobile application. The function `createAlert` takes two parameters: `type`, which is an enum of type `UpdateAlertType`, and `vc`, which is an optional `UIViewController`. The function should return an `UIAlertController` instance or `nil` based on t... | magicoder |
You are tasked with creating a Python class to manage the configuration of various hardware pins for a microcontroller. The class should allow users to set and retrieve pin configurations for different hardware components.
You are given the following code snippet as a reference for the pin configurations:
```python
T... | magicoder |
You are working on a system that manages devices and their commands. The system uses a token for authentication and interacts with a backend API to retrieve files and process device commands. Your task is to implement a function that processes the commands for each device obtained from a file.
You are given the follow... | magicoder |
You are tasked with implementing a custom exception hierarchy for handling authentication errors in a Python application. The provided code snippet includes a base exception class `KrbError` and two subclasses `BasicAuthError` and `GSSError`. Your task is to extend this exception hierarchy by adding a new subclass and ... | magicoder |
You are tasked with creating a Rust library that can be used in both web and non-web environments. The provided code snippet shows a conditional compilation attribute `#[cfg(feature = "web_console")]` being used to conditionally include a module `web` when the feature `web_console` is enabled.
Your task is to implemen... | magicoder |
You are tasked with creating a Django model for a blogging platform. The model should include fields for the body of the blog post, the date of publication, and the author of the post. The body of the blog post should be a text field that allows for blank entries, the date should default to the current time, and the au... | magicoder |
You are tasked with creating a Python script to automate the process of building Anaconda packages. Anaconda is a popular distribution of the Python and R programming languages for scientific computing, data science, and machine learning. Building Anaconda packages involves creating a package that can be easily install... | magicoder |
You are tasked with creating a program that processes a given text file containing Chinese language articles. The program should read the input file, tokenize the Chinese text using the Jieba library, and then write the tokenized output to a new file. The Jieba library is a popular Chinese text segmentation tool used f... | magicoder |
You are tasked with implementing a simple text-based game in Java. The game involves a player navigating through a grid-based world, collecting items, and avoiding obstacles. The player can move up, down, left, or right within the grid. The grid is represented by a 2D array, where each cell can contain one of the follo... | magicoder |
You are tasked with implementing a C++ template meta-programming problem that involves determining whether a given type is a pointer type. Your goal is to create a meta-function called `is_pointer` that takes a type as a template parameter and evaluates to `true` if the type is a pointer, and `false` otherwise.
Your t... | magicoder |
You are given a function `sort_words_by_value` that takes a list of words as input and returns a new list of words sorted based on their numerical values. The numerical value of a word is calculated by summing the values of its characters, where 'a' has a value of 1, 'b' has a value of 2, and so on.
The function `get_... | magicoder |
You are given a Python code snippet that prints the public keys of a card and a door. Your task is to write a program that calculates the encryption key based on these public keys.
The code snippet provided is as follows:
```python
print('--------------------------')
print('Card public key: %d' % cardPublicKey)
print... | magicoder |
You are tasked with creating a Python script that interacts with the KEGG (Kyoto Encyclopedia of Genes and Genomes) API to retrieve information about a specific pathway and save the results in a JSON file. The KEGG API provides access to a wealth of biological data, including pathways, genes, and compounds.
Your scrip... | magicoder |
You are tasked with implementing a shell script that processes command-line arguments related to address types. The script should handle two specific options: `-at` and `-w`. The `-at` option requires an argument specifying the address type, while the `-w` option does not require any additional arguments. If the `-at` ... | magicoder |
You are tasked with implementing a function to approximate the value of π using the Leibniz formula for π. The Leibniz formula is given by the series:
π/4 = 1 - 1/3 + 1/5 - 1/7 + 1/9 - ...
Your task is to write a Python function that takes an integer n as input and returns the approximation of π using the first n ter... | magicoder |
You are tasked with implementing a neural network for handwritten digit recognition using the given specifications. The network architecture consists of a single hidden layer with 30 neurons, an input layer with 784 neurons, and an output layer with 10 neurons. The activation function for both the hidden and output lay... | magicoder |
You are tasked with implementing a PID controller for a system. A PID controller is a control loop feedback mechanism widely used in industrial control systems. It calculates an error value as the difference between a desired setpoint (SP) and a measured process variable (PV). The controller attempts to minimize the er... | magicoder |
You are tasked with implementing a Java method to calculate the HMAC-SM3 signature for a given key and data. The HMAC-SM3 algorithm uses the SM3 cryptographic hash function and the HMAC (Hash-based Message Authentication Code) construction to produce a secure message authentication code.
You are provided with the foll... | magicoder |
You are tasked with implementing a task assignment system in Python. The system should keep track of the number of tasks assigned to each person and allow for the reassignment of tasks to different individuals. You are provided with a partial implementation of the task assignment system, which includes a class `TaskMan... | magicoder |
You are tasked with creating a Python class to represent a 3-axis accelerometer sensor. The class should have a method to read the current acceleration values and a method to print these values in a specific format.
Create a Python class `Accelerometer` with the following specifications:
- The class should have a cons... | magicoder |
You are tasked with creating a Java class that processes data from a Kafka topic using the Gobblin framework. The Gobblin framework is a distributed data integration framework for simplifying the process of ingesting and processing large volumes of data. Your task is to implement a class that consumes messages from a K... | magicoder |
You are tasked with implementing a class that represents a collection of models. Each model has a unique identifier and a name. Your task is to complete the implementation of the `ModelCollection` class by adding a method that returns the names of all the models in the collection.
You are provided with a partial imple... | magicoder |
You are tasked with implementing a logging system for a chatbot application using C#. The chatbot application is built using the Microsoft Bot Framework and is responsible for processing incoming activities. The application uses the `Microsoft.Bot.Schema` and `Microsoft.Extensions.Logging` namespaces.
Your task is to ... | magicoder |
You are tasked with implementing a function that processes a collection of parent-child relationships and returns a mapping of each parent to its corresponding children. Each relationship is represented as a tuple containing a parent and a child.
You need to implement the function `process_relationships` that takes a ... | magicoder |
You are tasked with implementing a Python function that processes a configuration dictionary for a web service. The dictionary contains various settings and parameters, and your function needs to extract specific information and perform certain operations based on the configuration.
The configuration dictionary is str... | magicoder |
You are tasked with implementing a command-line utility that provides help information for various commands. The utility should support a simple help system where users can request information about specific commands.
You are given a code snippet that demonstrates the usage of the `util` object and the help system. Th... | magicoder |
You are tasked with implementing a data processing pipeline for analyzing particle physics data. The pipeline involves applying a series of selection criteria to the data and then performing specific calculations on the selected events. Your task is to write a Python function that processes the data using the given cod... | magicoder |
You are tasked with creating a Python program that simulates a simple banking system. The program should have the ability to create new bank accounts, perform deposits and withdrawals, and display the account balance. Additionally, the program should include a unit test suite to verify the functionality of the banking ... | magicoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.