instruction_seed stringlengths 29 40.5k | source stringclasses 6
values |
|---|---|
You are tasked with implementing a simple banking system that supports depositing and withdrawing money in different currencies. Your task is to create a Java class `BankAccount` with the following specifications:
- The class should have three private instance variables: `depositingMoney`, `withdrawingMoney`, and `cur... | magicoder |
You are tasked with implementing a function to send SMS messages using the Twilio API in a Python application. The provided code snippet shows a partial implementation of the `send_sms` function, which takes a recipient's phone number (`to`) and the message body (`body`) as input parameters. The function is intended to... | magicoder |
You are tasked with implementing a Python function that subscribes to multiple MQTT topics in parallel using the `asyncio` library. The function should establish a connection to an MQTT broker, start the client, and then subscribe to two specified topics concurrently.
Your task is to complete the implementation of the... | magicoder |
You are tasked with creating a Python class that handles the subscription to a ROS topic and processes the received data. Your class should subscribe to the topic 'mavros/global_position/global' using the rospy library and handle the incoming NavSatFix messages by implementing the global_position_callback method.
Your... | magicoder |
You are tasked with implementing a simple text editor in Rust. The editor supports two types of operations: activation and editing. When activated, the editor returns the current text content as a message. When editing, the editor updates its content and returns a message indicating the change.
The provided code snipp... | magicoder |
You are tasked with implementing a function that extracts an access token from a response body. The response body is a JSON object containing various fields, and the access token is stored within the "access_token" field. Your goal is to write a function that takes the response body as input and returns the access toke... | magicoder |
You are tasked with creating a Python function that processes connection parameters for an IoT device using the `rospy` library. The function should retrieve and expand user-specified or default file paths for the certificate, key, and root CA files. The `rospy.get_param` function retrieves parameters from the ROS para... | magicoder |
You are tasked with implementing a simple platformer game in C#. The game features a player character that can jump and double jump. The player's movement is governed by gravity, and there is a maximum fall speed to prevent the player from falling too fast. Your goal is to implement the logic for the player's jumping a... | magicoder |
You are tasked with implementing a custom future polling mechanism in Rust. Futures are a fundamental concept in asynchronous programming, representing a value that may not yet be available. Your goal is to create a custom `Future` trait implementation with two methods: `expect_ok` and `expect_err`.
The `expect_ok` me... | magicoder |
You are tasked with creating a function that takes a list of elements and a target element as input and returns a list of indices where the target element is found in the input list. The function should be case-sensitive and should consider the exact match of the elements.
Write a function `find_element_indices` that ... | magicoder |
You are tasked with implementing a Python function that calculates the sum of the elements in a given list using TensorFlow. TensorFlow is an open-source machine learning library, commonly used for numerical computation and building machine learning models. Your function should take a list of integers as input and use ... | magicoder |
You are tasked with creating a Python function that reads a file and returns the number of occurrences of a specific word within that file. Your function should take two parameters: the file path and the target word. The function should then open the file, read its contents, and count the occurrences of the target word... | magicoder |
You are tasked with implementing a class that generates transition instructions for a 2D diamond animation. The class, `DiamondsTransition2D`, takes an integer parameter `diamondSize` in its constructor, representing the width of the diamonds. The constructor throws an `IllegalArgumentException` if the `diamondSize` is... | magicoder |
You are tasked with implementing a Python class that can read and process data from a CSV file into a Cassandra database. Your task is to create a class called `CassandraCsv` that provides methods for reading a CSV file and inserting its data into a Cassandra database table.
The `CassandraCsv` class should have the fo... | magicoder |
You are tasked with implementing a Python class that represents a table entity in a database. The class should have a method to return the blueprint of the table and a property to retrieve the name of the table.
Your task is to complete the implementation of the `TableEntity` class by adding the necessary methods and ... | magicoder |
You are working on a project that involves implementing a neural network using TensorFlow. As part of this project, you need to create a function that manipulates input data and performs certain operations based on the TensorFlow library. The function `digit` takes several parameters and performs operations on the inpu... | magicoder |
You are tasked with creating a Python script that automates the setup of a systemd service for a web application. The script should download a service file from a specified URL, place it in the appropriate directory, reload the systemd daemon, and enable the service.
Your Python script should take the following inputs... | magicoder |
You are tasked with implementing a class that manages a collection of unique IDs. The class should provide a method to add a new ID to the collection and a method to retrieve the newest ID that was added.
You are given a code snippet that partially defines the `addNewest` method of the class. The `addNewest` method ta... | magicoder |
You are tasked with implementing a function that compares two sets of options and returns a boolean value based on their equality. The options are represented as objects and the comparison should consider both the keys and values of the objects. You are given a code snippet that demonstrates the usage of a function `Ob... | magicoder |
You are tasked with creating a Rust module that interfaces with a CUDA library to perform parallel computations on a GPU. Your goal is to implement a function that calculates the sum of elements in an array using CUDA parallel processing. The provided code snippet includes the module structure and external crate declar... | magicoder |
You are working on a project that involves interacting with a database system called "Alfresco." The code snippet provided is a part of a script that is supposed to connect to the Alfresco database and perform some operations. However, the snippet seems to be incomplete and lacks the necessary connection and operation ... | magicoder |
You are tasked with implementing a Cumulative Moving Average (CMA) algorithm for time series data. The CMA is a method used to analyze data points by creating a series of averages of different subsets of the full data set. Your task is to write a Java method that takes a time series file as input, calculates the CMA fo... | magicoder |
You are working on a script to manage file downloads and clean up temporary files. The script snippet provided below is part of a larger script that handles the download process and cleanup. Your task is to complete the script by filling in the missing parts based on the given requirements.
Script Snippet:
```
exit 1
... | magicoder |
You are tasked with creating a Python class that interacts with a device over a UART connection. The class should have a method `sysinfo_copy` that retrieves system information from the device and processes it. The `sysinfo_copy` method sends a command to the device, waits for a prompt, captures the output, and then pr... | magicoder |
You are given a list of integers `c`. Your task is to write a function that returns the count of unique elements in the list `c` that are divisible by 3 and not divisible by 5.
Write a function `count_unique_divisible_by_three` that takes in a list of integers `c` and returns the count of unique elements in the list t... | magicoder |
You are tasked with implementing a function to validate and process user input for creating a new StoveBrandResource. The StoveBrandResource is a TypeScript interface representing a resource for a stove brand, and it contains the following properties:
- `title`: a required string representing the title of the stove bra... | magicoder |
You are tasked with creating a custom admin interface for managing hot search keywords in a web application. The provided code snippet is a part of a Python Django project using the Xadmin library for admin interface customization.
Your task is to implement a custom admin class for the HotSearchWords model, which shou... | magicoder |
You are tasked with implementing a simple shell script that processes user input and performs specific actions based on the input provided. The script should handle a specific set of commands and provide appropriate output for each command. Below is a partial code snippet of the shell script:
```bash
#!/bin/bash
read... | magicoder |
You are tasked with creating a Python program to automate the process of transferring images from one folder to another. The program should read images from a specified origin folder, process them, and save the processed images to a target folder. Your task is to complete the implementation of the `trans` function, whi... | magicoder |
You are tasked with creating a PHP function that generates a downloadable file from a given path and file name. The function should take the path and file name as input and return the appropriate HTTP headers and file content to allow the user to download the file. The file type should be set to "application/msword", a... | magicoder |
You are tasked with creating a Python program to process a file containing lines of comma-separated values representing names and ages. Each line in the file follows the format "name, age". Your program should read the file, extract the name and age from each line, and then print them in the following format: "Nome: [n... | magicoder |
You are tasked with creating a custom suggestion provider for a development tool. The tool allows users to specify a branch name for a version control system, and the suggestion provider should offer a list of valid branch names based on certain criteria. Your goal is to implement the suggestion provider class to gener... | magicoder |
You are tasked with creating a script to automate the testing of a Kubernetes cluster using the `podman` tool. The script should run a container with specific configurations and execute a test suite inside the container. Your task is to write a Bash script that accomplishes this automation.
The script should perform t... | magicoder |
You are tasked with creating a Python class that simulates a simple banking system. The class should have methods for depositing funds, withdrawing funds, and checking the account balance. Additionally, the class should be able to log all transactions to a file using a configured logger.
Your task is to implement the ... | magicoder |
You are tasked with implementing a Python class that manages machine learning models, datasets, evaluators, and trainers. Your task is to complete the implementation of the `ModelManager` class by adding the `get_trainer` method. The `ModelManager` class is responsible for setting evaluators, getting trainers, and mana... | magicoder |
You are working on a project that involves handling different capabilities for 3D objects in a graphics application. Each capability is associated with an enumerant and may have additional attributes. Your task is to create a data structure to efficiently store and retrieve these capabilities.
You need to implement a ... | magicoder |
You are tasked with implementing a change calculator for a vending machine. The vending machine accepts coins of various denominations and needs to return the optimal combination of coins as change for a given amount. The existing coins in the machine are represented as an associative array, where the keys are the coin... | magicoder |
You are tasked with creating a custom implementation of the `ToString` method for a class representing a geometric shape. The class has properties for the shape's name, color, and area. The `ToString` method should return a string representation of the shape in the format "Name: [name], Color: [color], Area: [area]".
... | magicoder |
You are tasked with implementing a Python function that processes quarantine actions for files based on a given quarantine profile. The function takes in three arguments: `quarantine_profile_id`, `file_id`, and `action`. The `quarantine_profile_id` represents the ID of the quarantine profile to be applied, `file_id` re... | magicoder |
You are working on a project that involves analyzing oceanographic data stored in NetCDF files. The code snippet provided is part of a data loading process, where the code reads in a NetCDF file, extracts the salinity and temperature fields, and then applies a mask based on the salinity data.
Your task is to write a P... | magicoder |
You are tasked with creating a program that can parse and extract information from a Python package's setup configuration file. The setup configuration file is typically named `setup.py` and contains metadata about the package such as its name, version, author, and other relevant details. Your program should be able to... | magicoder |
You are tasked with implementing a data structure to efficiently find the median of a stream of integers. You need to create a class `MedianFinder` with the following methods:
- `void addNum(int num)`: Add an integer number from the data stream to the data structure.
- `double findMedian()`: Return the median of all e... | magicoder |
You are working on a deep learning project and need to implement a logging mechanism to track the performance of your model during training. The provided code snippet is a part of the logging process and includes the following components:
1. `vutils.make_grid(im_noisy, normalize=True, scale_each=True)`: This function ... | magicoder |
You are tasked with implementing a simple event handling system in C. The system consists of a set of tasks that can receive and process events. Each task can be in one of two states: active or inactive. When a task is active, it can receive events and process them. When a task is inactive, it cannot receive events. Yo... | magicoder |
You are working on a deployment script for a web application that involves setting up a MySQL database and granting privileges to a user. The script needs to execute SQL commands to create a database and grant specific privileges to a user.
Write a Bash script that takes the following inputs:
- `$username`: MySQL user... | magicoder |
You are given a snippet of code that represents a simplified version of a conditional statement in a programming language. The snippet consists of three lines: `return 0`, `else`, and `return 1`. Your task is to write a function that simulates the behavior of this conditional statement and returns the appropriate value... | magicoder |
You are tasked with implementing a class that represents the status of a task. The class should have a method `isException()` that returns `true` if the task status is one of the exceptional states: `CANCELED`, `ABORTED`, or `FAILED`, and `false` otherwise. You need to implement the `TaskStatus` class and the `isExcept... | magicoder |
You are given a Python code snippet that is intended to append a value `x` to a list `li` if the list is not empty. If the list is empty, the code snippet initializes a new list `ret` with the value `x`. However, the code snippet is incomplete and contains indentation errors. Your task is to complete the code snippet b... | magicoder |
You are given a string `s` consisting of "0"s and "1"s. A binary string is a string containing only "0"s and "1"s. A binary string is called a binary substring if it contains equal number of consecutive "0"s and "1"s.
Write a function `countBinarySubstrings` to count the number of non-empty binary substrings that have... | magicoder |
You are tasked with creating a Python unit test for a Django application. The application has a settings module that contains various configurations. Your goal is to write a test case that ensures the settings module contains specific configurations as expected.
You are provided with a code snippet that includes the u... | magicoder |
You are tasked with implementing a class for a machine learning model. The class includes a method for initializing the weights of the model based on the type of features. The code snippet provided is a part of the initialization method, where it sets the weight to `None` for continuous features.
Your task is to compl... | magicoder |
You are working on a file management system and need to implement a function to retrieve the file path of a given file within a specified directory. The directory structure is mounted to a specific location, and you need to ensure compatibility across different operating systems.
Write a function `get_file_path(direct... | magicoder |
You are tasked with creating a program to optimize hyperparameters for a machine learning model using a genetic algorithm. The genetic algorithm will be used to find the best combination of hyperparameters for an XGBoost classifier.
You are given a Python code snippet that sets up an XGBoost classifier with various hy... | magicoder |
You are tasked with creating a calendar event management system for a facility. The system should be able to retrieve and display events from user track logs associated with the facility. Each user's track logs contain data, start time, and end time for events related to the "Calendar" module. Your task is to implement... | magicoder |
You are tasked with implementing a program to calculate statistics related to metatiles and states in a game. A metatile is a collection of smaller tiles, and each metatile can have a variable number of states. Your task is to calculate the total number of metatiles, the total number of states, the maximum number of st... | magicoder |
You are tasked with creating a custom logging handler in Python that will filter log records based on their severity level. Your task is to implement the `CustomHandler` class, which should inherit from the `logging.Handler` class and override the `emit` method to raise an `AssertionError` if the severity level of the ... | magicoder |
You are tasked with implementing a server management system that allows users to add servers to different groups. The code snippet provided is a part of a Python application that interacts with a database to add or update server information. The snippet includes a conditional block that checks if a group ID is provided... | magicoder |
You are tasked with implementing a class that manages date and time formats for a web application. The class should provide methods to set and retrieve the date format, time format, and timezone. The date and time formats should follow the PHP date() function format. Your task is to complete the implementation of the c... | magicoder |
You are tasked with implementing a custom error type for a file compression library in Rust. The error type should support various error cases related to file I/O, version compatibility, sync marker mismatch, end of file, and unsupported compression codecs. Your task is to define the custom error type and implement the... | magicoder |
You are working on a computer vision project that involves stereo image processing. Your task is to implement a function that performs stereo matching using the push broom algorithm. The push broom algorithm is commonly used in stereo vision to generate a 3D reconstruction of a scene from a pair of stereo images.
You ... | magicoder |
You are given a list of tuples `L`, where each tuple contains two elements: a string and an integer. Your task is to calculate a value `S` based on the following rules:
- Initialize two variables `T` and `S` to 0.
- For each tuple in the list `L`, add the first character of the string to `T`.
- Then, add the sum of `T`... | magicoder |
You are tasked with implementing a message processing system that receives and decodes messages. The system is designed to handle messages in a specific format and must parse the message header using a custom parser. However, the system should gracefully handle errors and continue processing messages even if a specific... | magicoder |
You are tasked with implementing a function to validate transaction pool statistics in a blockchain system. The provided code snippet is part of a blockchain node's codebase and contains a method for asserting transaction pool statistics.
The `assert_tx_pool_statics` method is responsible for validating the total size... | magicoder |
You are tasked with creating a Python function that processes a given dictionary of top 5 communication services and returns a list of their names. The dictionary contains the names of the communication services as keys and their corresponding rankings as values. Your task is to extract the names of the top 5 communica... | magicoder |
You are tasked with implementing a class that acts as an adapter for a LotusEmail object. The adapter class should provide methods to retrieve attachment names and sender information from the LotusEmail object. Your task is to complete the implementation of the adapter class by providing the missing methods.
You are g... | magicoder |
You are tasked with implementing a function to handle user authentication in a web application. The function should make an asynchronous call to a server endpoint to log in a user and handle the response accordingly.
You are provided with a code snippet that outlines the beginning of the `loginUserIn` function. The fu... | magicoder |
You are tasked with implementing a function that calculates the total number of unique paths to reach the bottom-right corner of a grid from the top-left corner. You can only move either down or to the right at any point in time. The grid is represented by a 2D array where 1 indicates an obstacle and 0 indicates an emp... | magicoder |
You are given a code snippet that reads input for two integers `n` and `k` until it encounters `-1 -1`. Your task is to write a program to implement a specific functionality based on the given code snippet.
You need to implement a program that takes input for `n` and `k` and performs a specific operation based on the ... | magicoder |
You are tasked with creating a unit test for a class that handles IoT hub messages. The class has a method that processes an incoming HTTPS message and sends a response back. The code snippet provided shows the setup for the unit test using the JMockit framework for mocking objects.
Your task is to write the unit test... | magicoder |
You are working on a project that involves processing audio and text data. The audio data is represented as a one-dimensional array `audio_lens` of length B, where each element represents the length of an audio clip in seconds. The text data is represented as a two-dimensional array `text` of shape (B, Umax), where B i... | magicoder |
You are tasked with implementing a set of interfaces for managing application data and history. The provided code snippet outlines the method signatures for creating various data objects and collections. Your goal is to create the necessary classes and interfaces to fulfill these method signatures.
You need to create ... | magicoder |
You are tasked with creating a program to analyze a series of messages and extract specific information from them. Each message is a string containing a sequence of sentences. Your task is to identify the longest sentence in each message and count the number of words in that sentence.
You are given a class `MessageAna... | magicoder |
You are tasked with implementing a firmware manager class in Swift. The firmware manager is responsible for handling firmware updates for a device. The firmware manager interacts with a backend service to download and manage firmware updates. Your task is to implement the `FirmwareManager` class and its associated meth... | magicoder |
You are given a code snippet that defines a macro `cb` which is used to handle different data types for a specific operation. Your task is to understand the code snippet and write a function that mimics the behavior of the macro using templates in C++.
The macro `cb` takes a data type `DType` as input and checks if th... | magicoder |
You are tasked with implementing a Python package for simple lazy regular expressions and string expressions manipulation. The package, named "slrp," provides modules for handling combinations, lazy evaluation, regular expressions, and string expressions. The code snippet provided initializes the package and imports ne... | magicoder |
You are tasked with creating a Python package for a new library called "demolib" that includes a command-line utility. The package should have the following structure:
1. The package should include a command-line utility named "rundemo" that executes the "run" function from the "main" module within the "demo" package.... | magicoder |
You are tasked with implementing a function that constructs a URL for retrieving information about group cities from an API. The function should take into account the API base URL, the specific API endpoint for getting group cities information, and the application ID.
Write a function `constructGroupCitiesURL` that ta... | magicoder |
You are working on a data recording system that stores variables at different timestamps. The system has a class with a method `initialize` that is responsible for administrative actions. The method `initialize` takes in a variable number of arguments and keyword arguments. The class also has attributes `last_recorded_... | magicoder |
You are working on a project that involves processing 3D point cloud data from RGB-D images using Python and the Open3D library. As part of the project, you need to manipulate the extrinsic camera transformation matrix and create a new point cloud from the transformed RGB-D image. Your task is to write a function that ... | magicoder |
You are tasked with implementing a dependency resolution algorithm for a software package manager. The package manager maintains a list of dependencies in the form of tuples, where each tuple consists of two strings representing the name of the package and its version. The dependencies are listed in a specific order, a... | magicoder |
You are working on a project management tool that needs to automate the process of patching Xcode project files. Your task is to create a function that takes in a project file URL, a project name, and a backup directory path, and then performs the following steps:
1. Read the Xcode project file from the given URL.
2. P... | magicoder |
You are tasked with implementing a user authentication system in Python. Your task is to create a class `User` with the following functionalities:
1. `UpdateUsername(username)`: A method to update the username of the user.
2. `UpdatePassword(password)`: A method to update the password of the user.
The `User` class sho... | magicoder |
You are tasked with creating a script to manage the execution of a workflow using Python and FastAPI. The script should start the workflow executor server and handle logging. The script should also ensure that the access log and error log are redirected to stdout for real-time monitoring.
Your task is to complete the ... | magicoder |
You are tasked with creating a script that automates the process of installing missing autotools files and performing any other one-time setup for a freshly cloned git repository. The script should also handle the case where `configure.ac` is modified, requiring the `autoreconf` command to be rerun to update the `confi... | magicoder |
You are tasked with implementing a simple event management system for a hypothetical event planning application. The system should support starting and closing events, advancing to the next phase of an event, and retrieving the type of event currently in progress.
You are provided with an interface `EventManagement` w... | magicoder |
You are tasked with simulating the durability of a weapon in a video game. The weapon has a certain durability value that decreases with each use. Your goal is to implement a class in C++ that represents this weapon and provides methods to interact with its durability.
You need to create a class called `Weapon` with t... | magicoder |
You are tasked with implementing a content caching algorithm for a Road Side Unit (RSU) in a vehicular network. The RSU has a cache with a maximum capacity of `max_cacheR` and is responsible for storing and serving content to vehicles passing through its coverage area. The algorithm aims to optimize content delivery by... | magicoder |
You are tasked with creating a Python program to process shape and COVID-19 data. The shape data is stored in a JSON format and contains information about different geographical features, while the COVID-19 data is stored in a CSV file. Your program needs to perform the following tasks:
1. Load the shape data from a f... | magicoder |
You are tasked with creating a program that parses a given HTML file and extracts the URLs of all anchor tags within a specific section of the file. The section of interest is defined by a specific class attribute in the HTML.
Write a function `extract_urls_from_html` that takes two parameters:
1. `html_content` (stri... | magicoder |
You are tasked with implementing a method to validate certain fields of a Java object. The method is part of a fluent assertion library used for testing. The method, `hasC_LandedCost_ID`, is intended to check if the `C_LandedCost_ID` field of the object matches the expected value. If the values do not match, an asserti... | magicoder |
You are tasked with creating a Python function that processes a given piece of text to extract and count the occurrences of each word. The function should take in a string of text and return a dictionary where the keys are the unique words in the text and the values are the counts of each word. Additionally, the functi... | magicoder |
You are tasked with creating a class that manages user information for a social media platform. The class, named `UserManager`, should have a method `get_user_id()` that returns the user ID of the currently logged-in user. The user ID is a unique identifier for each user in the platform.
You are provided with a code s... | magicoder |
You are given a list of strings representing various operations to be performed on a stack. Each operation can be one of the following:
1. "push n": Push the integer n onto the stack.
2. "pop": Pop the top element from the stack.
3. "inc i v": Add v to each of the first i elements of the stack.
Your task is to impleme... | magicoder |
You are tasked with simulating a loot generation system for a survival game. The loot is distributed in different categories such as vehicles, weapons, backpacks, and items. Each category has a specific distribution of items, and the loot generation system needs to randomly select items from these categories based on t... | magicoder |
You are tasked with implementing a function that performs authenticated encryption using a specific set of parameters. The function takes in a message, its length, additional data, and the length of the additional data. Your goal is to write a function that encrypts the message and authenticates the additional data usi... | magicoder |
You are tasked with creating a simple web application using Python and Flask. Your goal is to implement an endpoint that responds with a specific message when accessed. Below is a code snippet that sets up a basic Flask application with a single endpoint.
```python
from flask import Flask
app = Flask(__name__)
@app.... | magicoder |
You are tasked with creating a Python function that compares the results of two different parsing operations and performs specific operations based on the comparison. The function should take in a file postfix as an argument and use it to parse two sets of log files. The parsed results are then regrouped and stored in ... | magicoder |
You are working on a speech processing system that involves cleaning and processing raw text data to extract phonemes. The given code snippet is a part of this system and performs the following operations:
1. Retrieves the raw text data for a given utterance ID from a dictionary `raw_dict`.
2. Cleans the raw text using... | magicoder |
You are tasked with creating a Python program that monitors the CPU and memory usage of a given process over a specific time period. You will need to implement a function that takes the process ID, monitoring duration, and monitoring interval as input and returns a list of CPU and memory usage percentages at each inter... | magicoder |
You are tasked with implementing a simple iOS app feature that involves updating a banner message displayed on the screen. The provided code snippet is a part of an iOS app and includes an IBOutlet for a UILabel named `messageLabel` and a method `setBannerMessage(_:)` that sets the text of the `messageLabel` to the pro... | magicoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.