instruction_seed stringlengths 29 40.5k | source stringclasses 6
values |
|---|---|
You are tasked with creating a Python function that checks for the existence of a file and logs a warning message if the file does not exist. Your function should take the file path as an argument and return a boolean value indicating whether the file exists or not. Additionally, the function should log a warning messa... | magicoder |
You are tasked with implementing a function that determines whether a given string is a palindrome. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward, ignoring spaces, punctuation, and capitalization.
You need to write a function `isPalindrome` that takes ... | magicoder |
You are tasked with implementing a function that simulates the process of creating and managing ability buttons for a game UI. The function should take in an array of ability names and return a list of formatted strings representing the creation and setup of these ability buttons.
The function signature is:
```csharp
... | magicoder |
You are tasked with creating a Django migration to add a new field to a model. The model in question is `Categoria`, and the new field to be added is `slug`, which is of type `SlugField` with a maximum length of 200 characters and can be nullable.
Write a Django migration file that includes the necessary operations to... | magicoder |
You are working as a software developer for a cloud-based home automation system. Your team is responsible for managing the deployment and maintenance of various components of the system. One critical component is the PHP-FPM service used to handle PHP requests for the web interface. The deployment process involves run... | magicoder |
You are given a Python code snippet that is intended to calculate the sum of even numbers entered by the user. However, the code contains a logical error. Your task is to identify the error and fix the code to achieve the intended functionality.
The original code snippet is as follows:
```python
cont = 0
for n in rang... | magicoder |
You are tasked with implementing a Python class that simulates a message generator for a hardware testing environment. The class should be able to generate message packets with specific fields and values, and support the addition of multiple threads for concurrent message generation.
Your task is to complete the imple... | magicoder |
You are tasked with creating a script to automate the cross-compilation of a Go application for different operating systems. Your script should be able to build the application for both Windows (32-bit) and macOS platforms. The provided code snippet demonstrates a part of the script that accomplishes this task.
Your t... | magicoder |
You are tasked with implementing a custom serialization mechanism for a Python class. The goal is to create a `SerializableModel` class that allows objects to be serialized and deserialized using the `pickle` module. However, there are certain objects that should not be pickled, and an exception should be raised when a... | magicoder |
You are tasked with implementing a simplified version of the MD5 hashing algorithm. The MD5 algorithm takes as input a message of arbitrary length and produces a 128-bit "fingerprint" or "message digest" of the input. The algorithm consists of several logical functions, bitwise operations, and constant values.
Your ta... | magicoder |
You are working on a data processing application that requires determining whether a given value should be quoted when constructing a query. You are given a Python class method `should_quote_value` that takes in a value and returns a boolean indicating whether the value should be quoted. The method follows certain rule... | magicoder |
You are given a list of IP addresses and a target address. Your task is to write a function that finds the closest IP address to the target address based on the number of matching bits in the binary representation of the addresses.
You need to implement the following function:
```python
def closest_ip_address(ip_list... | magicoder |
You are tasked with debugging a JavaScript code snippet that is intended to display a chart using Google Charts API. The code snippet provided contains a bug that prevents the chart from being displayed. Your goal is to identify and fix the bug to ensure that the chart is rendered correctly.
The code snippet is as fol... | magicoder |
You are tasked with implementing a Python class method for a REST client that interacts with an API. The method, `show_endpoint`, is responsible for retrieving information about a specific endpoint identified by its `endpoint_id`. The method makes a GET request to the API and expects a successful response with a status... | magicoder |
You are tasked with implementing a Java class that represents a mathematical term. The class should have a coefficient and an identifier (id) for the term. Your task is to complete the implementation of the `toString` method, which should return a string representation of the term in the following format: "Term [coeffi... | magicoder |
You are working on a machine learning project and need to create a custom data loader for your dataset. You have been provided with a code snippet that imports various modules related to data handling and transformation. Your task is to implement a custom data loader using the provided modules and classes.
You are giv... | magicoder |
You are tasked with creating a program that extracts the copyright years from a given code snippet. The code snippet is a comment block that contains copyright information in the format "Copyright (c) year1, year2, year3, ...". Your program should parse the years and output them in ascending order.
Write a function `e... | magicoder |
You are tasked with creating a C++ program that utilizes the SObjectizer library to manage concurrent execution of multiple agents. The SObjectizer library provides a framework for building concurrent, event-driven, and distributed systems. Your goal is to create a cooperative (coop) within the SObjectizer environment ... | magicoder |
You are tasked with implementing a function that calculates the average USD value of a given array of backtest data points. Each data point is represented by an object with the following structure:
```typescript
interface IBacktestDataPointDto {
time: string;
usdValue: number;
}
```
Your function should take ... | magicoder |
You are tasked with creating a program to analyze VPN login data and generate a report of the login counts sorted by username. Additionally, you need to create a graphical representation of the login data.
You are given a log file containing VPN login records in the following format:
```
username,timestamp
user1,2022-... | magicoder |
You are tasked with implementing a function that processes a given string to extract and manipulate the title of a requirement. The input string will contain a title enclosed within single quotes, and the function should extract this title and perform a specific operation on it. If the input string contains the title o... | magicoder |
You are tasked with creating a Python program that simulates a simple terminal management system using the Tornado web framework. The program will handle WebSocket connections for terminal sessions and serve static files using Tornado's web application features.
Your task is to implement a class `TerminalManager` that... | magicoder |
You are tasked with implementing a function that simulates a simplified version of a file system error handling mechanism. The function should take in an error kind and a message, and return a string representing the error.
You are provided with a code snippet that demonstrates the creation of an IO error with the err... | magicoder |
You are tasked with implementing a retry mechanism for placing a limit order on a stock exchange. The given code snippet is a part of a trading system and demonstrates the logic for attempting to place a limit order and handling potential errors.
The relevant components in the code snippet are:
- `self.exchange`: An i... | magicoder |
You are tasked with implementing a system to manage invitations to a party. Each party attendee is represented by a `Party` object, which has a `role` and a `party_id`. The `role` represents the type of attendee (e.g., guest, host, performer), and the `party_id` is a unique identifier for the party. The `Party` class h... | magicoder |
You are tasked with implementing a function to process events from an Amazon Simple Queue Service (SQS) using Rust. The provided code snippet is a part of an AWS Lambda function that handles SQS events. The `handler` function takes an `SqsEvent` and a `Context` as input parameters and returns a `Result` containing `()`... | magicoder |
You are given a Python class representing a simple bank account. Your task is to implement a method that calculates the interest earned on the account balance over a specified period of time.
```python
class BankAccount:
def __init__(self, account_number, balance, interest_rate):
self.account_number = acco... | magicoder |
You are tasked with implementing a class that loads and processes properties from a given `EbPropSet` object. The `EbPropSet` class provides methods to retrieve properties of different types, such as strings and integers. Your task is to complete the implementation of the `load` method in the provided class, ensuring t... | magicoder |
You are tasked with implementing a route definition system for a web application framework. The route definition system should support different kinds of routes and provide a way to specify route configurations.
You need to create a TypeScript interface and a function that validates and processes route definitions bas... | magicoder |
You are tasked with creating a Python function to update player information in a database based on their team's performance in a game. The function receives a `team` object and a `player` object, and it updates the player's MMR (Match Making Rating), league, and games played in the database. The `team` object contains ... | magicoder |
You are tasked with implementing a simple logging utility in TypeScript. The given code snippet shows two functions, `success` and `fail`, which are used to log messages to the console. The `success` function logs a message in green color, while the `fail` function is incomplete. Your task is to complete the `fail` fun... | magicoder |
You are tasked with implementing a Java class that extends JPopupMenu to create a custom context menu for a text component. The context menu should provide options for editing the text within the component. Your task is to complete the implementation of the CodePanelPopupMenu class by adding specific menu items and the... | magicoder |
You are tasked with implementing a DynamicFunction class that can evaluate a given mathematical formula using a set of input data. The formula will consist of variables represented by letters (e.g., A, B, C) and basic arithmetic operations (+, -, *, /). The input data will be provided as a list of integers. Your task i... | magicoder |
You are tasked with implementing a weight calculation function for a Substrate runtime module. The module, called `UpfrontPool`, is responsible for managing a pool of players and their associated weights. The provided code snippet includes the definition of the `SubstrateWeight` struct, which is used to define weight f... | magicoder |
You are tasked with implementing a data augmentation technique for image processing using random rotation. Your goal is to create a Python class that takes in an image sample and applies a random rotation within a specified angle range to the image. The class should also handle the expansion of the image and provide op... | magicoder |
You are tasked with implementing a loading view in an Android application using RxJava. The `RxLoadingView` class provides a method `show` that takes a context and a string resource ID as parameters and returns an `Action0` object. The `Action0` interface represents an action that has no input and returns no result.
Y... | magicoder |
You are given a graph represented as an adjacency list and a start node. Your task is to implement a breadth-first search (BFS) algorithm to find the shortest path from the start node to a target node.
Write a function `shortest_path(graph, start, target)` that takes in the following parameters:
- `graph`: A dictionar... | magicoder |
You are tasked with implementing a simple Rust program to manage a hotel's room booking system. The program should allow users to create, book, and check the availability of rooms. The room availability is represented by a struct `Room` and a struct `Hotel` will manage the rooms.
The `Room` struct has the following fi... | magicoder |
You are working on a data processing module that involves handling different types of data sources. You have a class `DataProcessor` with a method `process_data` that is responsible for processing the data based on the source type. The method has the following structure:
```python
def process_data(self):
if self.s... | magicoder |
You are tasked with creating a script to automate the process of importing data into a MongoDB database. The script should take in the database name, collection name, and the file containing the data to be imported. The script should handle the following requirements:
- Connect to the MongoDB instance and import the da... | magicoder |
You are tasked with creating a Python function that extracts the version number from a given string. The version number is represented as a sequence of digits separated by dots, and it may be followed by an optional space and a single character suffix. Your function should return the extracted version number as a strin... | magicoder |
You are tasked with creating a program that searches for specific functions within shared libraries. The program will take command-line arguments to specify the directory to search in and whether to match imported or exported functions. The program will then process these arguments and perform the search based on the s... | magicoder |
You are tasked with implementing a function that merges two sets of extras for a given node in a system. The function should compare the existing extras with the new extras and update the node if there are any changes. Additionally, the function should update a progress bar with the count of non-Node entries.
You are ... | magicoder |
You are tasked with implementing a simple text-based game called "Rock, Paper, Scissors" in Python. The game will be played against the computer, and the winner will be determined based on the choices made by the player and the computer.
Your task is to write a Python program that simulates the game. The program shoul... | magicoder |
You are tasked with creating a Python function that takes in an access key ID and a secret access key, and generates an AWS credentials file in the format shown in the code snippet below. The function should handle the input validation and produce the credentials file as a string.
The format of the AWS credentials fil... | magicoder |
You are tasked with implementing a job scheduler that processes jobs at specific times. The scheduler is designed to execute jobs at their scheduled run times. You need to create a function that processes the jobs based on their run times and ensures that no jobs are missed.
You are given a code snippet from the exist... | magicoder |
You are tasked with implementing a simple text-based user interface for a media player application. The application has a `Player` class with two methods: `refresh` and `read_input`. The `refresh` method is used to update the display, and the `read_input` method is used to capture user input.
Your task is to create a ... | magicoder |
You are tasked with creating a PHP class that manages user data for a web application. The class should include methods for setting and getting user email and website information. Additionally, the class should enforce certain constraints on the email and website data.
Your task is to implement the `User` class with t... | magicoder |
You are tasked with creating a JavaScript function that dynamically enables or disables a button based on the state of a checkbox. The provided code snippet is a part of a larger web application, where the checkbox with the id "kullanimkosullari" is used to control the state of the button with the id "start-setup". Whe... | magicoder |
You are tasked with implementing a class that manages the status of a system. The class should have a method `setStatus` that allows setting the status of the system. Additionally, the class should have a method `getStatus` that returns the current status of the system. The status can only be one of the predefined valu... | magicoder |
You are tasked with creating a Node.js script to send data to Google Cloud IoT Core using the Google Cloud IoT Core Node.js client library. Your script should utilize environment variables for configuration and command-line arguments for specifying additional parameters.
The following environment variables are availab... | magicoder |
You are tasked with implementing a custom annotation view for a map-based application. The code snippet provided is a part of the implementation for displaying annotations on a map using MapKit framework in iOS. The `MKPinAnnotationView` class is used to represent a pin annotation on the map. The snippet checks if the ... | magicoder |
You are tasked with implementing a custom exception hierarchy for a public transportation application. The application interacts with various APIs to retrieve information about bus stops and buses. Your task is to create a set of custom exception classes that accurately represent different failure scenarios when intera... | magicoder |
You are tasked with implementing a class to manage time intervals. The class should have the following functionalities:
- Initialize the interval with a start time and an end time.
- Calculate the duration of the interval in minutes.
- Check if two intervals overlap with each other.
You are given a code snippet as a s... | magicoder |
You are tasked with creating a DateFormatter class in JavaScript. The class should have a constructor that takes a date object and an optional format string as arguments. If the format string is provided, the class should format the date according to the specified format. If no format string is provided, the class shou... | magicoder |
You are tasked with creating a Python function that parses and extracts information from a log message. The log message is in the format "email Sent! smtp server: {smtp} port: {port}", where {smtp} and {port} are placeholders for the SMTP server and port number used for sending an email. Your function should extract t... | magicoder |
You are tasked with implementing a simple messaging system using Java Spring framework. The provided code snippet is the beginning of an interface for a service responsible for receiving messages. Your task is to complete the interface by adding a method for receiving messages and then implement the interface in a clas... | magicoder |
You are tasked with implementing a function to reorder the elements of a given array based on a specific order defined by another array. The function should take in two arrays, `originalArray` and `orderArray`, and reorder the elements of `originalArray` according to the order specified in `orderArray`. If an element i... | magicoder |
You are tasked with implementing a function to parse and process POST request data in a Python web application. The function should handle cases where the request data is a dictionary with empty string values.
Write a Python function `parse_post_data(request_data: dict) -> dict` that takes a dictionary `request_data`... | magicoder |
You are tasked with implementing a parser for a custom programming language that supports theory terms, functions, and constants. The given code snippet is part of a larger parser implementation and contains a portion of the logic for parsing theory terms, functions, and constants. Your task is to complete the implemen... | magicoder |
You are given a list of integers representing the profits of a company over a series of days. Your task is to write a function that finds the maximum possible profit that can be achieved by buying and selling the company's stock at most once.
You need to implement the function `maximizeProfit(prices: [Int]) -> Int` w... | magicoder |
You are tasked with implementing a Java method that handles the execution of a remote procedure call (RPC) using the Byps framework. The given code snippet is part of a method named `execute` within a class that implements a remote interface. The method takes a remote object `__byps__remote` and an asynchronous result ... | magicoder |
You are tasked with implementing a function that processes a list of ranges and transforms them into a specific data structure. Each range is represented as a dictionary with 'start' and 'end' keys, and the function should create a new list of dictionaries with modified keys and values.
Write a function `transform_ran... | magicoder |
You are tasked with implementing a function to calculate the average loss and accuracy for a given set of training data. The function takes in a list of tuples, where each tuple contains the loss and accuracy for a single training iteration. Your goal is to process this data and return the average loss and accuracy.
Y... | magicoder |
You are working on a travel booking application that manages reservations for flights, car rentals, and hotel rooms. The code snippet provided is a part of the backend implementation for managing package reservations. The `hasMany` method is used to define a one-to-many relationship between the `Paquete_ReservaVuelo` m... | magicoder |
You are given a Python code snippet that seems to be attempting to manipulate a dictionary and call a function. However, the code contains some errors and inconsistencies. Your task is to analyze the code, identify the issues, and correct them to achieve the intended functionality.
The code snippet is as follows:
```... | magicoder |
You are given a Python program that appends the results of certain calculations to two separate lists `y_g` and `y_b`. However, the result of a calculation for the color red is not being appended to any list. Your task is to complete the program by adding the necessary code to append the `red_result` to a list `y_r`. A... | magicoder |
You are tasked with creating a PHP class that handles REST API requests and responses. Your class should be able to send HTTP requests to a specified endpoint, handle the response, and provide methods for accessing the response data.
Create a class named `RestApiClient` with the following requirements:
- The class sho... | magicoder |
You are tasked with implementing a Python function that performs data binning and smoothing using Extremely Randomized Trees (ExtraTrees) for a given dataset. The function should take into account the number of partitions for binning and the number of trees in the ExtraTrees ensemble for continuous smoothing.
You are ... | magicoder |
You are tasked with implementing a function to convert a given time in seconds to a formatted string representing the time in milliseconds. The function should take a floating-point number representing seconds as input and return a string representing the time in milliseconds. The formatted string should have the time ... | magicoder |
You are tasked with implementing a pagination algorithm for a web application that displays a list of orders. The provided code snippet is a part of the pagination logic and contains some incomplete parts. Your task is to complete the pagination logic based on the given code and requirements.
The code snippet is part ... | magicoder |
You are tasked with implementing a class to manage the volume control of a media player. The class should have the following functionalities:
1. `set_volume(volume_level)`: A method to set the volume level to the specified value.
2. `increase_volume()`: A method to increase the volume level by 1 unit.
3. `decrease_vol... | magicoder |
You are tasked with creating a Python script that utilizes the arcpy module to perform geoprocessing tasks on a set of input scenes. The script should prompt the user to input the scenes and then carry out specific geoprocessing operations on them.
Your task is to write a Python function that takes the input scenes an... | magicoder |
You are tasked with implementing a Python decorator that measures the execution time of a function and prints the duration in milliseconds. Your decorator should be able to handle functions with any number of arguments and keyword arguments.
Your decorator function should be named `measure_execution_time` and should t... | magicoder |
You are tasked with creating a program to calculate and display the Mandelbrot set. The Mandelbrot set is a set of complex numbers for which the function f(z) = z^2 + c does not diverge when iterated from z = 0. The program should generate an ASCII representation of the Mandelbrot set, with each character representing ... | magicoder |
You are tasked with implementing a class that manages IP addresses and their associated status. Your task is to create a Python class called `IPAddressManager` with the following requirements:
- The class should have a method called `set_status` that takes two parameters: `ip_address` (a string representing an IP addr... | magicoder |
You are tasked with implementing a Python function that calculates the absolute value of a given number. The absolute value of a number is its distance from zero on the number line, regardless of its sign. For example, the absolute value of -5 is 5, and the absolute value of 3 is 3.
You need to complete the implementa... | magicoder |
You are tasked with implementing a Python function that simulates a random walk in a 2D grid. The function should take in the maximum number of steps for the walk, the probability of overshooting the maximum number of steps, and a timeout value. Additionally, the function should raise a RunTimeError if the walk exceeds... | magicoder |
You are tasked with creating a program that simulates the behavior of the `mkdir` command in a Unix-like operating system. The `mkdir` command is used to create directories within the file system. Your program should take a list of directory names as input and create these directories within a specified path.
Write a ... | magicoder |
You are tasked with creating a Python function that parses a given property map and extracts the properties and their corresponding values from a provided JSON object. The property map is a dictionary that maps the property names in the JSON object to their corresponding names in the desired output. The JSON object con... | magicoder |
You are tasked with implementing a function to compare two sets of field values before and after a database operation. The fields are represented by integer constants, and the comparison involves adding 1 to the value of a specific field if it matches a certain condition. Your task is to write a function that performs ... | magicoder |
You are tasked with simulating a simplified bus tracking system. You are provided with two functions from an existing codebase: `post_bus` and `post_location`. The `post_bus` function is used to create a new bus for a given line, and the `post_location` function is used to update the location of a bus. The `post_locati... | magicoder |
You are tasked with creating a shell script that processes a given input file and generates a report based on the contents of the file. The input file contains a list of shell commands executed by different users, and your script needs to extract and analyze this information to produce the report.
The input file has t... | magicoder |
You are tasked with implementing a class that represents a contract in a software system. The contract has a name property that can be accessed and modified. Your goal is to create a method within the Contract class that allows for the validation of the contract name. The validation method should ensure that the contra... | magicoder |
You are tasked with creating a Python function that parses a Django URL configuration and extracts specific information from it. The URL configuration is represented as a list of tuples, where each tuple contains a regular expression pattern and a view function. The regular expression patterns may contain named groups ... | magicoder |
You are tasked with implementing a custom exception class for handling errors in a GraphQL server. The exception class should be designed to provide detailed information about the error, including the GraphQL query, the specific field causing the error, and the error message.
Your task is to create a custom exception ... | magicoder |
You are tasked with implementing a simple permission system for a user class in Python. The user class has the following methods and attributes:
```python
class User:
def __init__(self):
self.permissions = 0
def grant_permission(self, perm):
"""
Grants the specified permission to the u... | magicoder |
You are tasked with implementing a Python function that processes a list of annotations and extracts specific information from them. Each annotation is a string that contains a variable name and its corresponding value. The function should extract the values associated with a particular variable name and return them as... | magicoder |
You are given a code snippet that processes a string `code` and extracts a variable name from it. The code snippet is as follows:
```python
break
if (code[i] == " "):
comps.append(code[:i])
comps.append(code[i+1:])
break
val = 0
varname = comps[0]
```
Your task is to implement a function `extract_variabl... | magicoder |
You are tasked with creating a script to automate the versioning and building of a Docker image for a Django application. The provided code snippet is a part of the script, which is responsible for incrementing the build number, tagging the Docker images, and updating the build number in a file.
The script reads the c... | magicoder |
You are tasked with creating a Python module that simulates a simple text-based game. The game involves a player navigating through a series of rooms, each with its own set of challenges and rewards. To accomplish this, you will need to implement various classes and methods to manage the game's state and interactions.
... | magicoder |
You are tasked with creating a program to process and analyze cryptocurrency transaction data. The given code snippet represents a data structure containing information about a cryptocurrency wallet transaction. Your task is to extract and process this information to calculate the total number of transactions and the a... | magicoder |
You are tasked with implementing a simple JavaScript class that represents a basic bank account. The class should have methods for depositing funds, withdrawing funds, and checking the current balance. The constructor should initialize the account with a balance of 0.
Your task is to complete the implementation of the... | magicoder |
You are working on a simulation of particle movements within a mesh using the FEniCS library in Python. The code snippet provided is part of the simulation, and it involves checking for collisions between particles and the mesh cells. The variable `collisions` stores the total number of collisions, while `collisions1st... | magicoder |
You are tasked with implementing a file system error handling mechanism for an embedded system. The system uses the FileFS library to manage the file system. The provided code snippet is a part of the error handling logic for the file system initialization. The `FileFS.begin(true)` function is used to initialize the fi... | magicoder |
You are tasked with creating a Python class that simulates a simple database connection. The class should handle the opening and closing of the database connection, and it should also provide a method for executing SQL queries.
Your task is to implement the `Database` class with the following requirements:
- The class... | magicoder |
You are tasked with implementing a program that processes a list of transactions and calculates the total balance for a given account. Each transaction consists of a date, a description, and an amount. The program should be able to handle deposits (positive amounts) and withdrawals (negative amounts). Additionally, the... | magicoder |
You are tasked with implementing a function that processes an array of prefectures and returns a new array with the prefectures sorted in alphabetical order. The function should also remove any duplicate prefectures from the input array before sorting.
You are given the following code snippet as a starting point:
```... | magicoder |
You are tasked with implementing a simple command-line theme management system for a text-based application. The system should allow users to set a theme from a list of available themes and provide feedback on the success or failure of the theme change.
You are provided with a code snippet from the existing theme mana... | magicoder |
You are tasked with implementing a TypeScript class method that retrieves and organizes data related to Git repositories. Your goal is to complete the `getChildren` method of the `RepositoriesNode` class, which extends the `ExplorerNode` class. The `RepositoriesNode` class represents a node in a file explorer that cont... | magicoder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.