instruction_seed stringlengths 29 40.5k | source stringclasses 6
values |
|---|---|
You are tasked with creating a Python function that prepares URLs for image files and checks for the existence of a specified file path. The function should utilize the `subprocess` module to move a temporary file to a specified location and then verify the existence of a file at a given path using the `os` module.
Yo... | magicoder |
You are tasked with implementing a network traffic monitoring system. The system should maintain a dictionary of traffic destinations and the corresponding source and receiver pairs. The code snippet provided is a part of the system's message processing logic. The snippet handles the reception of a message payload and ... | magicoder |
You are tasked with creating a form validation function for a web application. The application has a form with two input fields: "address" and "email". The form is structured using HTML and includes classes and attributes for styling and functionality. Your goal is to write a JavaScript function that validates the inpu... | magicoder |
You are tasked with implementing a simple event handling system for a virtual gun controller in a game. The provided code snippet is a part of a class that handles incoming events from the gun controller. The `HandleMissive` method is called whenever a new input event is received from the gun controller. Your task is t... | magicoder |
You are tasked with implementing a Python class that parses and reassembles TCP data from the output of a network traffic extraction tool. The class should be able to process the output of the `pcap-extract-traffic.sh` script and extract the raw binary data contained in the traffic for further processing.
Your task is... | magicoder |
You are tasked with creating a Python middleware system for a web application. Middleware is a crucial component in web frameworks, allowing for the interception of incoming requests and outgoing responses. The provided code snippet is a part of the middleware setup for the application.
Your task is to implement a Pyt... | magicoder |
You are tasked with implementing a function to filter phone numbers based on a given country code. The function should take a vector of phone numbers and a country code as input, and return a new vector containing only the phone numbers that match the given country code.
You are given the following code snippet as a s... | magicoder |
You are tasked with creating a PHP function that retrieves a specific blog post and displays its details on a web page. The function should take the blog post's slug as a parameter and return the corresponding view with the blog post details.
You are provided with the following code snippet as a starting point:
```ph... | magicoder |
You are tasked with implementing a neural network class in Python for a specific architecture. The network has a single hidden layer and an output layer. The hidden layer uses the Rectified Linear Unit (ReLU) activation function, while the output layer uses the linear activation function. The number of neurons in the o... | magicoder |
You are given a list of integers, where each integer represents a student's score in a test. The scores range from 0 to 100. Your task is to write a Python function that takes this list of scores as input and returns the count of scores that are greater than or equal to 60.
Function Signature: `def count_passing_score... | magicoder |
You are tasked with implementing a class that represents a network device's capabilities and status. The class should contain methods to check specific capabilities and states based on the device's configuration.
You are provided with a partial code snippet for the class, which includes three methods: `isFecEnabled()`... | magicoder |
You are tasked with creating a Python class that simulates an asynchronous HTTP response. The class should be able to handle different status codes and provide a method to retrieve the status code and message.
Create a class `AsyncHttpResponse` with the following requirements:
- The class should have a constructor tha... | magicoder |
You are tasked with creating a Python class that handles authentication for an IServ server. The class should have a method to set the username and password, as well as a method to generate the login URL based on the server URL provided. The login URL should be in the format "https://schoolsite.<wildcard>/iserv/app/log... | magicoder |
You are given a list of file paths representing images in a web application. Each file path starts with "/static/img/" followed by the image name and its extension. Your task is to write a function to categorize these images based on their file extensions and count the occurrences of each category.
Write a function `c... | magicoder |
You are tasked with designing a class that manages the registration of applications within a system. The class, `AppRegistrationManager`, should handle the loading and registration of applications, utilizing various services and repositories. Your goal is to implement the constructor and a method for registering an app... | magicoder |
You are given a dictionary `uniforms` containing the names of students as keys and their corresponding uniform numbers as values. Each uniform number is represented as a string. Your task is to write a program that calculates the sum of the uniform numbers of two specific students and prints the result.
The given code... | magicoder |
You are tasked with creating a Python function that manages the saving and loading of model weights for deep learning models. The function should take in two arguments: `from_model` and `to_model`. The `from_model` represents the source model from which the weights will be saved, and the `to_model` represents the targe... | magicoder |
You are tasked with creating a Django migration for a new model in a web application. The model represents a simple product with a name, price, and description. Your task is to write the migration file that will create the corresponding database table for this model.
The model definition is as follows:
```python
from ... | magicoder |
You are tasked with creating a program to analyze and manipulate data related to word synsets. The program should read in data from a JSON file containing word synsets, create dataframes from the noun and verb synsets, and then perform a specific operation on a given dataframe.
The JSON file `words_synsets.json` conta... | magicoder |
You are tasked with creating a Python function that processes data from an API response and returns specific information based on the given input. The function will take a UPC (Universal Product Code) as input and use it to make a request to a hypothetical API endpoint. The response from the API will be in JSON format,... | magicoder |
You are tasked with creating a Python function that processes a configuration dictionary for a mobile application build system. The dictionary contains settings for building the mobile application, including resource and distribution URLs, and the build type. Your function should extract and process this information to... | magicoder |
You are tasked with creating a function that compares two results, each of which can be either a success with received data or a failure with an error. The function should assert whether the received data or error matches the expected data or error, and if not, it should provide a detailed message indicating the mismat... | magicoder |
You are tasked with implementing a Timer class in C# that allows for tracking the elapsed time and checking if a specified time duration has passed. The class should have the following properties and constructor:
Properties:
- `passedTime`: Returns the elapsed time in seconds.
- `timer`: Returns the specified time dur... | magicoder |
You are given a Python code snippet that implements the merge sort algorithm. Your task is to complete the implementation of the `merge` function, which is responsible for merging two sorted subarrays within the `merge_sort_call` function. The `merge` function takes an array `a`, start index `sp`, mid index `mp`, and e... | magicoder |
You are tasked with implementing a Python class that manages the state of an application and its version. The class should have the following requirements:
1. The class should be named `Application`.
2. It should have two attributes:
- `application_state`: A dictionary representing the state of the application.
... | magicoder |
You are given a Python class method snippet that is part of a larger program. Your task is to understand the functionality of the method and then implement a similar functionality in a different programming language.
The method is part of a class and is used to process some data. The method takes in a parameter `by` a... | magicoder |
You are tasked with implementing a simple memory management system for a microcontroller. The system consists of a class with a method to read a single byte from a specific memory address. The memory is represented as a list of bytes, and the class has a method `read_byte(self, address)` that takes an integer `address`... | magicoder |
You are tasked with implementing a function that can efficiently determine the number of occurrences of a given word in a large text document. The function should be able to handle case-insensitive matching and should return the count of occurrences of the word in the text.
You are given the following code snippet as ... | magicoder |
You are tasked with implementing a program that processes a series of input lines and extracts specific information based on certain patterns. The program should read input lines from a source, and when a line contains the pattern "DEV-MUC3-", it should extract the document identifier following this pattern and store i... | magicoder |
You are working as a DevOps engineer for a company that is deploying a microservices-based application on Kubernetes. As part of the deployment process, you need to automate the cleanup of certain resources using Kubernetes command-line tool (`kubectl`). The resources to be deleted include a role, a role binding, and a... | magicoder |
You are tasked with creating a Python package that processes and stitches together a series of images to create a panoramic view. The package, named "panorama," is authored by "romainx" and is currently at version "0.2.0." The package contains a module named "panorama" with functionalities for image processing and stit... | magicoder |
You are tasked with implementing a Python class that manages data forwarding entries in a software-defined networking (SDN) controller. The provided code snippet is a partial implementation of a RESTful API endpoint using Flask and Flask-RESTful for adding and deleting data forwarding entries in the SDN controller. You... | magicoder |
You are working on a system that logs and processes keyboard events. The system has a method that receives an array of keyboard events and logs the number of items in the array. You need to implement a function that checks if the system is initialized and then processes the keyboard events accordingly.
You are given t... | magicoder |
You are tasked with implementing a Python class for a deep learning model trainer. The class is responsible for training a neural network model using various hyperparameters and settings. Your task is to complete the implementation of the `ModelTrainer` class by adding the `train_model` method, which will handle the tr... | magicoder |
You are tasked with implementing a class to manage time intervals for data aggregation. The class should provide functionality to convert time intervals to their respective durations in minutes. You are given a partial code snippet to define an enumeration class `RES` representing different time intervals. Your task is... | magicoder |
You are tasked with implementing a function that applies specific attributes to a substring within a given mutable attributed string. The function should take in the mutable attributed string, a dictionary of attributes, and the substring to which the attributes should be applied. The function should then return the mo... | magicoder |
You are tasked with creating a program to manage key bindings for a game using Python and the Pygame library. The key bindings are defined by a pattern, and the program should generate the corresponding text based on the configured key bindings.
You need to implement a class `KeyBindingManager` with the following meth... | magicoder |
You are tasked with implementing a class that manages segment IDs for a video streaming service. The class should provide a method to retrieve the last segment IDs for each video. The segment IDs are represented as a map, where the keys are video IDs and the values are the corresponding last segment IDs.
You need to i... | magicoder |
You are tasked with creating a Python function to perform linear interpolation on a set of data points. Linear interpolation is a method of estimating values between two known data points. Given two lists `time` and `temp`, where `time` represents time in minutes and `temp` represents the corresponding temperature in d... | magicoder |
You are tasked with implementing a function that calculates the average color of a given image. The image is represented as a 2D array of pixels, where each pixel is represented as a 3-element array containing the red, green, and blue color values. The average color is calculated by taking the mean of the red, green, a... | magicoder |
You are tasked with creating a Python class for rendering in-game text. The class should have a method `renderFont` that takes a string as input and returns the rendered text using a specified font.
The class should be named `TextRenderer` and should have the following attributes and methods:
- Attribute: `font_text` ... | magicoder |
You are working on a project to develop a simulation software for internal lighting systems. As part of this project, you need to implement a class for simulating internal load lights. The code snippet provided is a part of the implementation of this class. Your task is to complete the implementation of the `SimInterna... | magicoder |
You are tasked with implementing a fade effect for a Unity game. The provided code snippet includes a script with a method for fading a UI image. The `Fade` method takes a boolean parameter to determine whether the image should fade in or out. The `timeFade` variable represents the duration of the fade effect, and the ... | magicoder |
You are tasked with implementing a class that represents a graphical object with an anchor point. The anchor point is used to position the object within a graphical user interface. The anchor point can be one of four types: TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, or BOTTOM_RIGHT. Your task is to create a class that encapsula... | magicoder |
You are given four integers a, b, k, and l. You need to determine the minimum cost to buy k items of size l.
The cost of buying k items of size l can be calculated using the following formula:
min(k % l * a + k / l * b, k / l * b + b)
Write a function to calculate the minimum cost to buy k items of size l.
Function ... | magicoder |
You are tasked with creating a validation function for awarding office codes in a financial assistance system. The awarding office code must be exactly six characters long. You need to implement a Python function that takes a list of awarding office codes and returns the number of codes that do not meet the length requ... | magicoder |
You are tasked with implementing a custom writer discrimination module using PyTorch. The module should be designed as a subclass of `nn.Module` and should utilize a pre-trained ResNet-18 model as its base. Additionally, the module should have the capability to replace the model's head and freeze the network's layers. ... | magicoder |
You are tasked with implementing a nonlinear step function for a simulation framework. The function `nonlinear_step` takes in several parameters and performs a nonlinear step operation on a given matrix. The function signature is as follows:
```cpp
void nonlinear_step(std::shared_ptr<const DefaultExecutor> exec, int n... | magicoder |
You are tasked with implementing a function that parses a given Rust code snippet and extracts the names of the structs defined within it. The code snippet will contain Rust struct definitions, and your function should return a list of the names of these structs.
Write a function `extract_struct_names` that takes a Ru... | magicoder |
You are tasked with implementing a subscription management system for a newsletter service. The system should allow subscribers to be added to newsletters and provide functionality to check if a subscriber is already subscribed to a particular newsletter.
You are given the following class definitions:
```csharp
publi... | magicoder |
You are tasked with implementing a Python class that simulates a simple environment for rendering. The class contains a method `_render` that handles the rendering of the environment. The method takes two parameters: `mode` (default value: 'human') and `close` (default value: False). When the `close` parameter is True,... | magicoder |
You are tasked with creating a Python class that utilizes PyTorch and PyTorch Lightning to build a simple neural network for image classification. Your class should inherit from PyTorch Lightning's `LightningModule` and implement the necessary methods to define the neural network architecture, loss function, and optimi... | magicoder |
You are tasked with implementing a simple to-do list application in Python. The application should have the ability to add, remove, and retrieve items from the to-do list. You need to create a class `TodoList` with the following methods:
1. `__init__(self)`: Initializes an empty list to store the to-do items.
2. `add_i... | magicoder |
You are tasked with implementing a custom Python class that extends a base class and includes specific functionality. Your task is to complete the implementation of the `SimpleBaseAwsLink` class by adding a method that manipulates a dictionary and returns a modified version of it.
The `SimpleBaseAwsLink` class extends... | magicoder |
You are tasked with implementing a shell script that processes a series of commands based on a given code snippet. The code snippet contains a sequence of commands and file references, and your goal is to understand and execute these commands in the correct order.
The code snippet provided is as follows:
```
. ${0%03-... | magicoder |
You are tasked with implementing a function to parse search results from a file and verify the correctness of the parsed data. The search results are expected to contain information about duplicate repositories in GitHub and Bitbucket. The function should parse the results and return the count of duplicate repositories... | magicoder |
You are tasked with creating a simple routing system for a web application using PHP. The routing system should be able to handle different HTTP request methods and map them to specific controller methods. Your task is to implement a basic routing system using the given code snippet as a reference.
Your routing system... | magicoder |
You are tasked with implementing a class `StringGenerator` that can create strings based on certain criteria. The class should have the following methods:
1. `new_str_with_value(self, value: int) -> str`: This method should generate a string of length 5 containing random digits between 0 and the given `value` (inclusi... | magicoder |
You are tasked with creating a Python function that generates an analysis index in Elasticsearch. The function should take in a list of fields and their data types, and then create an index with the specified fields in Elasticsearch. The function should handle potential errors and return the result of the index creatio... | magicoder |
You are tasked with implementing a simple curve evaluation system. The `Curve` struct has a method `evaluate` that takes a time parameter and returns the value of the curve at that time. The curve is defined by a mathematical function, and you need to implement the evaluation logic for this function.
You are given the... | magicoder |
You are tasked with creating a Python function that retrieves information about Star Wars characters from the Star Wars API (SWAPI). The function should take a character's name as input and return their details, including their name, birth year, gender, and list of films they appeared in. You will need to use the reque... | magicoder |
You are tasked with implementing a class to represent an address. The address should include fields for street, city, state, and postal code. Additionally, the class should have methods to set and get each of these fields.
Your task is to complete the implementation of the `Address` class by adding the necessary field... | magicoder |
You are tasked with creating a Python class that generates random ASCII strings of a specified length. Your class should be able to initialize a Jinja2 environment and add a global function that can be used within Jinja2 templates to generate random ASCII strings.
Your task is to complete the implementation of the `ra... | magicoder |
You are tasked with creating a Python program that calculates the total of a given number based on a specific rule. The program should prompt the user to input a number between 0 and 9. If the input is within this range, the program should calculate the total based on the following rule:
- If the input number is even, ... | magicoder |
You are tasked with implementing a configuration class in Python that allows for the storage and retrieval of key-value pairs. The class should support setting, getting, and deleting key-value pairs, as well as providing a method to return all key-value pairs as a dictionary. Additionally, the class should have a metho... | magicoder |
You are tasked with implementing a simple Functional Reactive Programming (FRP) framework in Rust. The provided code snippet outlines the basic structure of the FRP framework, including a function signature for `label()` and a constructor function `new()` that takes references to an `Application` and a `Logger`. Your t... | magicoder |
You are tasked with implementing a Python function that processes medical imaging data. The function should take in three parameters representing the coordinates of a point in 3D space and return the corresponding image ID from a DICOM file. Additionally, the function should read the DICOM file associated with the extr... | magicoder |
You are tasked with implementing a PHP trait that provides functionality for handling model events in a web application. The trait, named `EModel`, should include methods for registering and triggering events associated with the model.
Your task is to complete the implementation of the `EModel` trait by adding the fol... | magicoder |
You are tasked with implementing a Python function that converts a given dictionary of tennis tournament rounds into a new dictionary with abbreviated round names. The input dictionary contains full round names as keys and the corresponding abbreviated names as values. Your function should take this input dictionary an... | magicoder |
You are tasked with creating a Python function that calculates the factorial of a given non-negative integer. The factorial of a non-negative integer n is the product of all positive integers less than or equal to n. For example, the factorial of 5 (denoted as 5!) is calculated as 5 x 4 x 3 x 2 x 1 = 120.
Your task is... | magicoder |
You are given a code snippet in Rust that involves the use of the `pipe` function and tuple and array operations. Your task is to understand the code and write a function that achieves the same result as the code snippet.
The `pipe` function is used to chain multiple functions together, passing the result of each func... | magicoder |
You are tasked with creating a Python function that simulates a simple game of rock-paper-scissors. The function should take two arguments: the player's choice and the computer's choice. The function should then determine the winner based on the standard rules of rock-paper-scissors and return the result as a string.
... | magicoder |
You are tasked with implementing a pattern recognition system that can detect and respond to specific patterns in a stream of data. The system is designed to call a method `OnStopPattern` whenever a particular pattern is identified. Your task is to design a class that can manage this pattern recognition system and hand... | magicoder |
You are tasked with implementing a cache management system for a mobile application. The cache should support inserting, deleting, and retrieving items efficiently. Your task is to design and implement a cache system that satisfies the following requirements:
1. The cache should be able to store key-value pairs, where... | magicoder |
You are tasked with implementing a simple parser for a custom language called "Lari". The language is defined using the `rowan` crate, which provides functionality for creating and manipulating syntax trees. The code snippet provided is a partial implementation of the `rowan::Language` trait for the `Lari` language.
Y... | magicoder |
You are tasked with implementing a configuration parser for a simulation tool used in electronic design. The configuration file contains various settings that control the behavior of the simulation tool. Your task is to write a Python function that parses the configuration file and extracts the relevant settings.
The ... | magicoder |
You are tasked with implementing a function that returns the first non-None argument from a given list of arguments. If all the arguments are None, the function should return None. You need to write a Python function `find_first_non_none` that takes a variable number of arguments and returns the first non-None argument... | magicoder |
You are tasked with implementing a thread-safe scheduler class in C++ that manages a schedule of tasks. The class should provide methods to set and clear tasks at specific indices in the schedule, as well as a method to check if all tasks are completed.
You are given a code snippet that includes a `std::mutex` and a `... | magicoder |
You are tasked with implementing a simple factory pattern in C++ to create instances of different Lua objects. The Lua objects are defined by a base class `LuaObject` and two derived classes `LuaNumber` and `LuaString`. Your goal is to create a `LuaFactory` class that can produce instances of these Lua objects based on... | magicoder |
You are tasked with creating a Python function that parses a list of URL patterns and returns a dictionary containing the endpoints and their corresponding view classes. Each URL pattern is represented as a tuple containing the URL path, the view class, and the name of the endpoint.
You need to implement the function ... | magicoder |
You are tasked with implementing a GeoFirestore class that stores and retrieves geo location data at a Firestore document. The GeoFirestore class should provide methods for adding, updating, and retrieving geo location data, as well as querying for nearby locations.
Your task is to implement the following methods in t... | magicoder |
You are tasked with creating a Django model for a new online platform that hosts educational audio content. The model should represent the audio content and its associated metadata. The model should include fields for the name of the content, the subject it pertains to, a description, the creator's name, the maximum nu... | magicoder |
You are tasked with implementing a function to check the header of a file. The header is considered valid if the first elements of the first two lines are of different lengths. If the header is invalid, an error message should be logged, and an exception should be raised.
You are given a code snippet that partially im... | magicoder |
You are working on a recommendation system for a book-sharing platform. The system aims to suggest books to users based on their wishlists and the wishlists of other users. You have been given a snippet of code that processes the wishlists of users and calculates suggestion scores for books. Your task is to complete th... | magicoder |
You are tasked with implementing a function to handle email delivery using the Mailgun API. The function should check if the Mailgun API key is set in the settings and then proceed to deliver the messages. If the API key is not set, it should raise a `MailerConfigError` exception. Your task is to write a Python functio... | magicoder |
You are given a Python code snippet that defines two classes, A and B, each with an `__eq__` method. The `__eq__` method is used to determine equality between instances of the class. The `__eq__` method in class A always returns True, while the `__eq__` method in class B is incomplete. Your task is to complete the `__e... | magicoder |
You are tasked with implementing a function to calculate the average of a list of numbers. However, due to potential floating-point precision issues, you need to ensure that the calculated average is within a certain tolerance of the expected result.
Write a function `calculate_average` that takes a list of numbers an... | magicoder |
You are tasked with implementing a generic expression interface for a simple expression tree in C#. The interface should define three properties and a generic method.
The properties are:
1. `Cast` of type `BaseType`, representing the base type of the expression.
2. `DataType` of type `DataType`, representing the data ... | magicoder |
You are tasked with implementing a priority queue data structure using a max-heap. A priority queue is a data structure that maintains a set of elements, each associated with a priority. The max-heap property states that the priority of a parent node is always greater than or equal to the priorities of its children. Yo... | magicoder |
You are tasked with implementing a function that processes the result of an operation and handles potential errors. The function should take a Result type as input and print the error if the result is a failure, or perform a specific action if the result is a success.
You are given the following code snippet as a star... | magicoder |
You are tasked with creating a Python class that processes test data using a model and stores the results in a specific format. Your class should have a method to run the model on the test data and store the results in a dictionary.
You need to implement the `ModelProcessor` class with the following specifications:
- ... | magicoder |
You are tasked with implementing a custom translation function in PHP. The function should take a key, an array of replacements, and an optional locale as parameters. If the key is provided, the function should return the translated string with any replacements applied. If the key is not provided, the function should r... | magicoder |
You are tasked with implementing a custom progress bar for a long-running calculation. The progress bar should display the progress of the calculation and update in real-time as the calculation proceeds. You are given a `progress_bar` function that takes the following parameters:
- `range_val`: The range of the calcula... | magicoder |
You are tasked with implementing a member registration feature for a web application. The application uses Angular framework for the front-end and communicates with a backend server to store member information. The provided code snippet is a part of the Angular component responsible for member registration.
Your task ... | magicoder |
You are working on a Django web application for managing issues and contributors. The code snippet provided is a part of a Django migration file that modifies the database schema. The migration file contains operations to add fields to the `Issue` and `Contributor` models.
Your task is to write a Django model definiti... | magicoder |
You are tasked with implementing a simplified version of a dependency injection container in C#. The container should be able to register and resolve services based on their types. Additionally, the container should support advanced features such as code generation for transactions.
Your task is to create a class `Ser... | magicoder |
You are tasked with creating a TypeScript function that takes in a React component and returns a new component with additional functionality. The input component is of type `FC<BannerProps>`, which is a functional component that accepts `BannerProps` as its props. Your task is to implement a function that takes this co... | magicoder |
You are tasked with creating a sentiment analysis program to evaluate a series of text snippets and determine if they indicate signs of depression. The sentiment analysis is based on the VADER (Valence Aware Dictionary and sEntiment Reasoner) lexicon, which provides a score for the sentiment of each text snippet. The p... | magicoder |
You are given a list of integers representing a puzzle input. Your task is to calculate the sum of the products of adjacent pairs of integers in the list. If the last integer is reached, the "next" integer will be the first integer in the list. Write a function to compute this sum.
For example, given the input list [2... | magicoder |
You are tasked with creating a Python function that performs relative import transformations on a given string based on a provided package. Relative imports are a way of importing modules in Python by specifying the relative location of the module with respect to the current module. The function should take a package n... | magicoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.