instruction_seed stringlengths 29 40.5k | source stringclasses 6
values |
|---|---|
You are tasked with creating a multilingual support system for a website. The system should handle the translation of phrases and messages into different languages. You are given a set of phrase codes and their translations in a specific language. Your task is to implement a function that takes a phrase code and return... | magicoder |
You are tasked with creating a Python program that interacts with an SNMP (Simple Network Management Protocol) agent to retrieve and display information about various network devices. SNMP is commonly used to manage and monitor network devices such as routers, switches, and servers. In this problem, you will be require... | magicoder |
You are tasked with implementing a generic trait for working with binary data in Rust. The trait, named `Word`, is intended to provide methods for loading and storing binary data from a buffer. The `load` method is responsible for reading binary data from a buffer and converting it into the appropriate data type, while... | magicoder |
You are tasked with creating a script to manage virtual machine snapshots based on certain conditions. The script should take a team number as input and delete a snapshot of a virtual machine based on predefined quotas and warning thresholds.
The script should perform the following steps:
1. Check if the input team nu... | magicoder |
You are tasked with creating a file upload feature for a web application using PHP. Your goal is to implement a method that processes the uploaded file and saves it to the server. The web application uses the CodeIgniter framework, and you need to write the method within a controller class.
You are provided with the f... | magicoder |
You are tasked with implementing a custom exception class and handling the raised exception in a Python program.
Create a class called `OAuthProblem` that inherits from the built-in `Exception` class. The `OAuthProblem` class should have a constructor that accepts a single string parameter `message`. When an instance... | magicoder |
You are tasked with implementing a module dependency resolver for a programming language. The given code snippet represents a collection of module names within a Rust project. Your goal is to create a function that takes this collection of module names and returns a valid order in which the modules can be compiled, con... | magicoder |
You are tasked with creating a Python test case for a web application using the Django framework. The application includes a feature for adding new team members, and the test case is responsible for ensuring that only admin and owner users have permission to access the page for adding new team members.
You are provide... | magicoder |
You are tasked with creating a command-line tool that processes code coverage data and generates a report in the LCOV format. The tool should accept input in the form of a JSON file containing coverage information and produce an LCOV report file. The tool should also allow specifying the packages to report on and the o... | magicoder |
You are working on a file storage system that involves creating and saving space properties to a JSON file. Your task is to implement a Python class method that handles the creation and saving of space properties to a file. The code snippet provided gives a glimpse of the existing implementation.
You are given a Pytho... | magicoder |
You are tasked with implementing a Python class method for augmenting image samples. The method should take a sample object as input and perform a series of image augmentation operations on the image data within the sample. The sample object contains an image, sample ID, points, and a mask. Your task is to implement th... | magicoder |
You are tasked with creating a Python script that checks for the activation of a virtual environment (venv) before executing a given command. Your script should raise an IOError with a specific message if the script is not run from the root directory of a non-repository and should also check for the activation of a vir... | magicoder |
You are tasked with implementing a function that generates a CSS class name based on the provided layout and multi-file settings. The function should take two parameters: `layout` (a string representing the layout type) and `multi` (a boolean indicating whether multiple files can be uploaded). The generated class name ... | magicoder |
You are working on a cloud infrastructure management platform that uses Pulumi, an infrastructure as code tool, to provision and manage cloud resources. Your task is to implement a function that retrieves information about a protection container from the cloud provider.
The `get_protection_container` function takes se... | magicoder |
You are tasked with creating a Python function that processes a specific type of file and extracts relevant information from it. The file format is a custom format with the extension ".bbl". The function should take the object name as input and read the contents of the corresponding ".bbl" file. If the file exists, the... | magicoder |
You are tasked with implementing a function to flatten a JSON data structure in Python. The function should take a nested JSON object as input and return a flattened dictionary where the keys are the concatenated paths to reach the values. For example, given the input:
```python
{
"a": 1,
"b": {
"c": 2... | magicoder |
You are tasked with implementing a message sending system that supports multiple message types and recipients. The system should be able to send messages to different types of recipients, such as email addresses, phone numbers, and user IDs. Additionally, the system should support sending different types of messages, s... | magicoder |
You are tasked with implementing a function to summarize numerical variables in a given dataframe. The function should calculate various statistical measures for each numerical variable in the dataframe and return a summary table.
You are given the following code snippet as a starting point:
```python
def summarize(v... | magicoder |
You are tasked with implementing a simple environment initialization system for a rover simulation. The provided code snippet outlines a trait and a struct for initializing the positions of rovers in the environment. Your task is to extend this system by implementing the missing trait and struct, and then use it to ini... | magicoder |
You are tasked with implementing a motion path system for a 2D game. The motion path system should support various types of motion paths, such as linear, circular, and custom paths defined by a series of waypoints. Each motion path should be represented by a collection of points in 2D space. Your task is to design a cl... | magicoder |
You are tasked with implementing a simple entity component system for a game. An entity component system (ECS) is a design pattern used in game development to provide better flexibility and performance compared to traditional object-oriented approaches. In this problem, you will be working with Rust code to create enti... | magicoder |
You are given a code snippet that represents a nested loop structure. The code is written in C++ and involves the usage of the TMath library. Your task is to understand the code and write a function that accomplishes the same functionality as the given code snippet.
The code snippet provided is a part of a larger prog... | magicoder |
You are given the definition of a tree node and a Python function that appends the values of the nodes in a tree to a list. Your task is to implement a function that calculates the average value of the nodes at each level of the tree.
The tree node is defined as follows:
```python
class TreeNode:
def __init__(self... | magicoder |
You are tasked with implementing a Swift extension for the UIStoryboard class that provides a function to instantiate a view controller from a specific storyboard. The function should take the storyboard name and view controller identifier as parameters and return an instance of the specified view controller.
Your tas... | magicoder |
You are tasked with implementing a dependency resolution system for a custom build tool. The build tool is responsible for executing various tasks, and each task can have dependencies that need to be satisfied before the task can be executed. The provided code snippet is a part of the `create_dependencies` method of a ... | magicoder |
You are tasked with implementing a function to update a repository in a version control system. The function takes in the name of the repository and the root path where the repositories are stored. It should update the repository if it exists, or do nothing if the repository does not exist.
The code snippet provided g... | magicoder |
You are given a list of processed tweets, where each tweet has undergone a series of text processing steps. The code snippet provided demonstrates some of the processing steps applied to each tweet using regular expressions. Your task is to implement a function that takes the list of processed tweets as input and retur... | magicoder |
You are tasked with creating a program to manage modal views in a web application. The modal views are included using the `@include` directive in a Blade template, a templating engine used in Laravel framework for PHP. The modal views to be managed are `modal.reembolso.detalhes`, `modal.reembolso.checkin`, `modal.reemb... | magicoder |
You are tasked with creating a program to manage serial ports for a device. The program should include a method to find the port name of a Prolific USB-to-Serial adapter. The `SerialPortHelper` class contains a method `FindProlificPortName()` that needs to be implemented. The method should search for and return the por... | magicoder |
You are tasked with implementing a RESTful API endpoint for creating and deleting universities in a given city. The code snippet provided is a part of a Django-based API view for this purpose. Your task is to complete the implementation of the `UniversityView` class by adding the missing functionality for the `delete` ... | magicoder |
You are tasked with implementing a class that represents a cloud storage system. The class should have the following functionalities:
1. Initialize the cloud storage system with a given capacity in bytes and track the current usage in bytes.
2. Allow for uploading files to the cloud storage, which increases the curren... | magicoder |
You are tasked with creating a Python function that extracts and processes information from a call stack. The call stack is a data structure that stores information about the active subroutines of a computer program. Your function should take the call stack information and generate a string that represents the sequence... | magicoder |
You are given a list of directed edges in a graph, each represented by a tuple (a, b, c), where a and b are the nodes connected by the edge, and c is the weight of the edge. The graph may contain cycles and negative edge weights. Your task is to implement the Bellman-Ford algorithm to find the shortest path from a give... | magicoder |
You are tasked with creating a simple FPS (frames per second) tracking system for a game. Your goal is to implement a function that calculates and prints the average FPS over a given time period. The function will receive a series of frame counts at regular intervals and should output the average FPS at the end of the ... | magicoder |
You are tasked with creating a program that analyzes the access modifiers of methods in a given class. The program should take a class name as input and return a list of method access modifiers for each method in the class. The access modifiers to be considered are "IsFamily", "IsStatic", and "IsFamilyOrAssembly".
You... | magicoder |
You are tasked with implementing a custom monitoring and weight management system for a machine learning model. The provided code snippet is a part of a class method that is responsible for updating the best model weights based on the current performance.
The class `CustomModelMonitor` has the following attributes and... | magicoder |
You are tasked with implementing a class that manages validation attribute names for a model. The class has a method to set validation attribute names and another method to retrieve the model data used for validation.
You need to implement the `setValidationAttributeName` method that takes an attribute and its corresp... | magicoder |
You are tasked with implementing a custom content handler for managing email contact information in a content management system. The `EmailContactPartHandler` class is responsible for handling the storage and retrieval of email contact information. The class extends the `ContentHandler` and takes an `IRepository<EmailC... | magicoder |
You are given a code snippet that iterates over a range of numbers. Your task is to write a function that takes the same range and returns the sum of the squares of all the numbers within that range.
Write a Python function called `sum_of_squares_in_range` that takes two integers `start` and `end` as input and returns... | magicoder |
You are tasked with implementing a `LaserEncoder` class that encodes a list of documents using specific parameters. The `encode` method of the `LaserEncoder` class takes a list of documents and a dictionary of parameters as input. The parameters include `batch_size` and `traversal_paths`. The `batch_size` parameter spe... | magicoder |
You are tasked with creating a Python program that can recursively list all sub-packages and sub-modules within a given package. Your program should utilize the `pkgutil` module to achieve this functionality.
Write a function `list_subpackages_and_modules(package_name)` that takes a string `package_name` as input and ... | magicoder |
You are tasked with creating a Python class to manage user credentials. Your class should have the following functionalities:
1. A method to save a new credential, which should add the credential to a list of saved credentials.
2. A method to delete a credential from the list of saved credentials.
Your class should b... | magicoder |
You are working with a database system that uses SQL for data manipulation. Your task is to write a SQL query to retrieve specific information from the given tables.
Consider the following two SQL table creation statements:
Table T:
```
CREATE TABLE T (
A INT64,
B INT64,
C INT64,
) PRIMARY KEY(A)
```
Table U:
... | magicoder |
You are working on a computer vision project and need to implement object detection using the YOLO (You Only Look Once) algorithm. You have been provided with a code snippet that specifies the configuration file, weights file, image size, confidence threshold, and non-maximum suppression (NMS) threshold for the YOLO al... | magicoder |
You are tasked with creating a JavaScript function that takes a string of HTML content as input and extracts the text content within all `<code>` tags. The function should then return an array containing the extracted text content in the order they appear in the HTML string.
Your function should be named `extractCodeC... | magicoder |
You are tasked with creating a custom exception hierarchy for a Python application. The application is a weather monitoring system that processes data from various sensors. Your task is to define a set of custom exceptions to handle different error scenarios that may arise during the data processing.
You are provided ... | magicoder |
You are tasked with creating a script to benchmark the performance of Cython-compiled code. Cython is a superset of the Python programming language, designed to give C-like performance with code written in a Python-like syntax. Your script should compile and execute a Cython file, capturing the exit status of the compi... | magicoder |
You are tasked with creating a function that takes an array of objects representing categories and generates an HTML unordered list (ul) with the given categories as list items (li). Each category object has a `name` property representing the category name. The function should produce the HTML structure as shown in the... | magicoder |
You are tasked with implementing a function that manages memory allocation for a simulated assembly language program. The function should allocate memory for a specified number of data words and then place an ASCIIZ string constant at a specific memory location. The function should return the address of the ASCIIZ stri... | magicoder |
You are tasked with implementing a state machine to manage the sending of SMS messages in a messaging application. The state machine should handle the process of sending restored messages after a system failure. The state machine has a method `SendSMS` that takes a `restored_message` as a parameter and sends the messag... | magicoder |
You are tasked with implementing a Python generator function that processes data from a custom CID (Customer Identification) system. The CID system has various tag types defined in the `cidlineclasses` module. Your task is to create a generator function that validates the CID tag against the `cidlineclasses` and yields... | magicoder |
You are tasked with implementing a robot control system for a mining robot. The robot is equipped with sensors that provide distance and orientation information. Your goal is to use the provided thresholds to control the robot's movements.
You are given the following code snippet:
```python
""" float: Threshold for t... | magicoder |
You are tasked with creating a program that simulates a simple phone call hang-up mechanism. The program should take a sequence of instructions as input and output the final position of the phone hang-up icon.
The phone hang-up icon is represented by the given SVG path. The icon is initially positioned at the center o... | magicoder |
You are tasked with implementing a pagination algorithm for a user list displayed in a web application. The provided code snippet is a part of the pagination logic in a JavaScript application. The `data` object contains information about the user list, including the list of users, the total number of records, and the n... | magicoder |
You are tasked with implementing a simplified version of a cookie management system for HTTP requests. Your goal is to create a class that allows adding and retrieving cookies, as well as performing HTTP requests using libcurl.
You are provided with a partial code snippet that includes a `cookie` function for adding c... | magicoder |
You are tasked with implementing a function that processes a set of rules and messages. The function should take in a list of rules and a list of messages, and return a dictionary of rules and the list of messages. Each rule is represented as a key-value pair in the dictionary, where the key is the rule number and the ... | magicoder |
You are tasked with implementing a function that calculates the average pressure of a collection of points. Each point is represented as an array or object containing the x and y coordinates, and an optional pressure value. The pressure value, if present, indicates the pressure exerted at that point. Your function shou... | magicoder |
You are tasked with creating a simple iOS app that displays a list of items in a table view. Each item in the list should have a title and a description. Your task is to implement the necessary code to achieve this functionality.
You are provided with a basic iOS app template that includes an `AppDelegate` class. Your... | magicoder |
You are working on a database management system and need to implement a trait for determining the selectability of columns from a given from clause. The trait `Selectable` is used to determine how many times a table appears in a from clause, and a column can be selected if its table appears in the from clause exactly o... | magicoder |
You are tasked with implementing a class that manages a collection of books. The class should provide functionality to add books, remove books, and retrieve information about the books in the collection. Additionally, the class should have a method to return the total number of pages in all the books combined.
You are... | magicoder |
You are tasked with implementing a program that analyzes the frequency of words in a given text. Your program should take a string of text as input and output the frequency of each word in the text. For the purpose of this problem, a word is defined as a sequence of non-whitespace characters. The program should ignore ... | magicoder |
You are tasked with implementing a module dependency resolver for a given Angular application. The application consists of various modules, each with its own set of dependencies and exports. The module dependencies are defined in the Angular module metadata using the `imports` and `exports` properties.
Your task is to... | magicoder |
You are tasked with creating a program that processes a list of transactions and calculates the total balance for a given account. Each transaction is represented as a tuple containing the date, description, and amount. The amount can be positive for deposits and negative for withdrawals. Your program should take a lis... | magicoder |
You are tasked with implementing a Swift function that can determine the type of a given keypath. A keypath is a way to reference properties of a type in a type-safe manner. The function should take a keypath as input and return the type of the property it references.
Write a Swift function `getPropertyType` that take... | magicoder |
You are tasked with creating a program that calculates the frequency of each digit in a given number. The program should prompt the user to enter a number and then output the frequency of each digit from 0 to 9 in the given number.
Your task is to complete the implementation of the program by writing the necessary cod... | magicoder |
You are tasked with implementing a module system for a bare-metal embedded system using Rust. The system is designed to interface with various hardware components such as clocks, GPIO (General Purpose Input/Output), serial communication, timers, and watchdogs. The provided code snippet is a partial representation of th... | magicoder |
You are tasked with implementing a function that can parse and extract data from an HTML form. The function should take an HTML string representing a form and return a dictionary containing the form's input fields and their corresponding values.
The HTML form will be represented as a string with the following format:
... | magicoder |
You are tasked with creating a program that analyzes the frequency of words in a given text. Your program should take a string of text as input and output the frequency of each word in the text. For the purpose of this problem, a word is defined as a sequence of non-whitespace characters separated by whitespace or punc... | magicoder |
You are tasked with creating a Python program to process a list of texts and write them to a file. Additionally, the program should then open the file using the `gedit` text editor. Below is a detailed description of the requirements:
You are given a list `texts` containing strings. Your task is to write each string f... | magicoder |
You are tasked with creating a script to automate the setup process for a simulation tool called TASim. The setup process involves cloning the TASim repository from GitHub and running a setup script. Your script should handle potential errors and ensure that the setup process is executed successfully.
Your script shou... | magicoder |
You are working on a backend system for a sports management application. The code snippet provided is a part of a Python class that handles the creation of teams and organizations within the application. The class has methods for creating a program, generating login headers, creating a team, and is in the process of im... | magicoder |
You are tasked with implementing a function to parse outgoing citation web data and display it in a readable format. The function should take in a list of citation data and utilize a provided utility function to pretty print the parsed data.
You are given the following information:
- The function to be implemented is ... | magicoder |
You are tasked with creating a Java class that handles exceptions for a planogram application. The application is part of a repository named `ua.obzhora.planogram` and is located in the package `planograma.exception`. Your task is to create a custom exception class that handles SQL exceptions.
Create a class named `SQ... | magicoder |
You are tasked with creating a Python function that simulates the addition of a new entry to the `/etc/fstab` file in a Linux system. The `/etc/fstab` file is used to control how disk partitions are mounted and accessed by the system. The code snippet provided demonstrates the addition of a new entry for the `/boot` pa... | magicoder |
You are tasked with creating a Python function that encodes a given byte string using the zbase32 encoding scheme. Zbase32 is a base32 encoding designed to be human-readable and more efficient than the standard base32 encoding. The zbase32 module provides a function `zbase32.b32encode()` for this purpose.
Your task is... | magicoder |
You are tasked with implementing a custom concurrent operation in Swift. The operation should have the ability to perform a task asynchronously and then mark itself as finished once the task is completed. You need to create a subclass of `Operation` and override the necessary methods to achieve this behavior.
Your tas... | magicoder |
You are tasked with creating a program to manage a custom voice model for a speech synthesis service. The custom voice model contains words and their translations, and it has a limit of 20,000 entries. Your program should allow users to update the metadata of the voice model, including the name, description, and the wo... | magicoder |
You are tasked with creating a function that handles fetching data from a REST API and processing the response based on its content type. The function should take in the base URL, the specific URL endpoint, the HTTP method, request headers, a signal for aborting the request, and any additional request parameters. It sh... | magicoder |
You are tasked with creating a script to automate the configuration of monitors based on specific conditions. The script should handle the scenario where the primary monitor is not the built-in display (LVDS-1 or eDP1) and should turn off the built-in display, identify the primary and secondary monitors, and then set t... | magicoder |
You are tasked with creating a Python function that processes the output of a natural language generation model and writes the results to a file in a specific format. The function should take in the output of the model, extract relevant information, and then write the formatted output to a file.
The function should ta... | magicoder |
You are tasked with implementing a function to convert RGB color values to their corresponding hexadecimal representation. The function should take a tuple of three integers representing the red, green, and blue components of the color and return a string representing the hexadecimal color code.
You are given the foll... | magicoder |
You are tasked with implementing a custom method for the `UIScrollView` class in Swift. The method should calculate the total area of all subviews within the scroll view that are fully visible, taking into account the current content offset and the size of the scroll view.
You are given the following code snippet as a... | magicoder |
You are tasked with creating a Python script that interacts with a D-Bus service. The script should be able to claim a D-Bus service and handle instances. Your task is to implement the missing parts of the script to achieve the desired functionality.
You are provided with a code snippet that sets up argument parsing u... | magicoder |
You are tasked with implementing a function that sends a message to a client using a Promise-based approach. The function `send_message_to_client` takes two parameters: `client` (representing the client to whom the message will be sent) and `msg` (the message to be sent). The function returns a Promise that resolves wh... | magicoder |
You are tasked with implementing a Python class that simulates a neural network model. The class should support three different modes of operation: pre-training, fine-tuning, and testing. The class should also inherit from a superclass called `VGG` and initialize its attributes accordingly.
Your task is to complete th... | magicoder |
You are tasked with implementing a function to perform round trip sanity checks on incomplete gamma values. The incomplete gamma function, denoted as Γ(a, x), is a special function used in mathematics and statistics to calculate the integral of the gamma probability density function. The function takes two parameters, ... | magicoder |
You are tasked with creating a TypeScript interface for managing effects in a functional programming environment. The interface, `Effect<R, E, A>`, is defined with a method `runMain` that is annotated with a rewrite method directive. Your goal is to implement the `runMain` method in a way that adheres to the provided a... | magicoder |
You are tasked with creating a program that converts a given length in inches to centimeters. The conversion factor from inches to centimeters is 2.54. Write a Python function that takes a length in inches as input and returns the equivalent length in centimeters.
Your program should take a floating-point number as in... | magicoder |
You are working on a build optimization tool for a web development project. The provided code snippet is a part of the build process and includes the `preprocess` function, which is responsible for preprocessing the project's source files before the actual build. The function imports and utilizes various modules such a... | magicoder |
You are tasked with simulating the behavior of an AI agent in a game environment. The AI agent has an animator component and a finite state machine (FSM) to control its actions. The provided code snippet is a part of the AI agent's update function. The AI agent's behavior is determined by the following conditions:
1. I... | magicoder |
You are tasked with implementing a Django model method for the `Post` model. The method should return a summary of the post's content by truncating the `text` field to a specified length and appending an ellipsis if the text exceeds the specified length. The summary should prioritize breaking at the end of a sentence a... | magicoder |
You are tasked with implementing a custom linked list data structure in C++. The provided code snippet contains the beginning of a header file for a ListNode class, which is intended to be used as a node in the linked list. Your task is to complete the implementation of the ListNode class and create a method to insert ... | magicoder |
You are tasked with implementing a Python function to calculate the roots of a quadratic equation. The quadratic equation is of the form ax^2 + bx + c = 0, where a, b, and c are coefficients provided as input to the function. The roots of the quadratic equation can be calculated using the quadratic formula: x = (-b ± √... | magicoder |
You are tasked with implementing a function that calculates the range of relevant values within a given dataset. The dataset is represented as a 2D array `labels_relevant` containing relevant labels, and a 1D array `x_sample` containing sample values. Your goal is to find the difference between the maximum and minimum ... | magicoder |
You are tasked with implementing a function to analyze stress data collected over time. The function `smooth_curve` takes in the following parameters:
- `time`: A list of time values corresponding to the stress data points.
- `stress`: A list of stress values collected over time.
- `window_length`: An integer specifyin... | magicoder |
You are tasked with creating a Java class that represents a simplified version of a cryptocurrency exchange's market data response. The response contains information about contract contracts, including their status, data, error code, and error message. Your task is to implement the `ContractContractInfoResult` class, w... | magicoder |
You are tasked with creating a Python package that simulates a simple banking system. The package should include classes for bank accounts and provide functionality for deposits, withdrawals, and balance inquiries.
Your task is to implement the `BankAccount` class with the following specifications:
- The `BankAccount... | magicoder |
You are tasked with implementing a class for encoding LTLSpec properties using Python. The class should inherit from the `LTLTreeEncoder` class and have the following properties and methods:
Properties:
- `property_pad`: an integer representing the padding for properties
- `num_properties`: an integer representing the... | magicoder |
You are working on a project that involves processing raw data to extract features and then performing post-processing evaluation on the extracted features. The feature extraction process involves loading raw features from a module called `feature_extraction`, and the post-processing evaluation is done using a function... | magicoder |
You are tasked with implementing a Python class for a NoEnvInputTranslationVariationalAutoEncoder. The class inherits from a superclass and has specific parameters for its initialization.
Your task is to complete the implementation of the `NoEnvInputTranslationVariationalAutoEncoder` class by defining its `__init__` m... | magicoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.