instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a function to process XML data received as a POST request and extract specific information from it. The XML data represents a notification for a successful recharge transaction and contains details about the transaction. Your task is to parse the XML data and extract the following infor... | codefeedback |
You are tasked with creating a function that determines the frequency of each word in a given string. The function should take a string as input and return a dictionary where the keys are the unique words in the input string, and the values are the frequencies of those words.
For example, given the input string "the c... | codefeedback |
You are tasked with creating a Python function that processes a dataset stored in a specified directory and performs image processing operations using the "scipy" library. Your function should traverse the directory, locate image files, and apply a specific image processing operation to each image found. If the "scipy"... | codefeedback |
You are tasked with implementing a file locking mechanism in PHP to ensure that a file is not accessed by multiple processes simultaneously. You need to write a function that locks a file, updates a counter stored in the file, and returns a unique code based on the current date and the updated counter. If the file cann... | codefeedback |
You are tasked with implementing a class that represents a non-deterministic finite automaton (NFA) in a programming language of your choice. The given code snippet provides a partial implementation of the NFA class, including methods for setting the NFA bit, getting the accept state, and potentially other methods not ... | codefeedback |
You are tasked with creating a function that calculates the distance between two geographical coordinates using the Haversine formula. The Haversine formula is used to calculate the distance between two points on the Earth given their latitude and longitude in decimal degrees. The formula is as follows:
```
a = sin²(Δ... | codefeedback |
You are tasked with implementing a Python function that converts a PostgreSQL array-string to a Python list. The PostgreSQL array-string is represented as a comma-separated string enclosed in curly braces. The function should handle the conversion for one-dimensional arrays only. If the input is not a string or Unicode... | codefeedback |
You are tasked with implementing a Python class method for deserializing an event stream from a byte stream. The event stream is represented by the `EventStream` class, and the deserialization method should be implemented as the `from_bytes` class method. The deserialization process involves loading data from a CBOR-en... | codefeedback |
You are tasked with implementing a face recognition system that involves initializing a face recognition database by reading information from a face register file. The provided code snippet is a part of the initialization process, where the system checks if the face register file exists and creates it if it doesn't. Yo... | codefeedback |
You are tasked with creating a Python program that simulates a simple command-line tool for performing mathematical operations. The program should accept command-line arguments to specify the operation to be performed and the operands involved. The supported operations are addition, subtraction, multiplication, and div... | codefeedback |
You are tasked with implementing a function to parse and extract information from a Rust macro. The macro is defined using the `macro_rules!` syntax and contains a specific pattern that needs to be identified and processed.
You are given a code snippet from a Rust build script that includes a function `rustc_minor_ver... | codefeedback |
You are tasked with creating a Rust function that interacts with Java through JNI (Java Native Interface). Your function will receive two parameters: `body` and `witness_set`, both of type `JRPtr` (Java Rust Pointer). The goal is to implement the logic inside the Rust function to handle these parameters and return a re... | codefeedback |
You are tasked with implementing a simplified version of a message queue system using Python's `queue` module. The system should support adding messages to the queue, retrieving messages from the queue, and handling the case when the queue is empty.
You are provided with a partial implementation of the `queue_get` fun... | codefeedback |
You are tasked with creating a Python function that selects the best compression algorithm based on a given input data size and compression ratio. The function should take in the input data size and compression ratio, and then determine the most suitable compression algorithm from a predefined list of available codecs.... | codefeedback |
You are tasked with implementing a command-line tool for managing abbreviations in a text editor. The tool will support the creation, removal, and listing of abbreviations. Abbreviations are short forms of commands that expand into their full form when used in the text editor.
Your task is to implement the `unabbrevia... | codefeedback |
You are tasked with implementing a function that processes user data using the AptoSDK framework. The AptoSDK is a software development kit for building financial applications, and it provides various functionalities for managing user data and transactions. In this problem, you need to create a function that takes user... | codefeedback |
You are tasked with implementing a program to analyze the enrichment of clipped reads in a set of samples at a given genomic coordinate. A clipped read is a sequence that has been partially removed during the sequencing process, often due to low-quality bases or adapter contamination. The goal is to determine the propo... | codefeedback |
You are working on a recipe recommendation system that takes a dataset of recipes and provides recommendations based on certain criteria. The code snippet provided is a part of this system and involves reading a CSV file containing recipe data, processing the data to generate recommendations, and then printing the reco... | codefeedback |
You are tasked with implementing a function that converts a Python data structure into a dictionary. The function should handle nested structures and convert them into nested dictionaries. The function should be named `struct_to_dict` and should take a single argument `struct` representing the input data structure. The... | codefeedback |
You are tasked with creating a Go package that provides a shared library for interfacing with the InterPlanetary File System (IPFS). The provided code snippet demonstrates the compilation and installation process for the shared library. Your goal is to write a Go program that utilizes this shared library to interact wi... | codefeedback |
You are tasked with implementing a simulation of a universe using a 2D grid. The universe is represented by a boolean grid where each cell can be either alive (True) or dead (False). You need to implement a function `add_beacon` that adds a beacon pattern to the universe grid. The beacon pattern consists of two blocks ... | codefeedback |
You are tasked with creating a Rust module that handles various aspects of working with Uniform Resource Identifiers (URIs). The module should include functionality for parsing, manipulating, and representing URIs. Your task is to implement the `uri` module, which will contain the following components:
1. `doc` module... | codefeedback |
You are tasked with implementing a generic repository pattern for a data access layer in a C# application. The repository pattern is a common design pattern used to abstract the data access logic from the rest of the application. In this scenario, you are required to create a generic repository interface and a concrete... | codefeedback |
You are tasked with creating a Python function that sends a POST request to a specified URL with a file payload. The function should take the URL and the file path as input and return the response from the server.
You are provided with the following code snippet for inspiration:
```python
import io
import json
import... | codefeedback |
You are tasked with implementing a DropdownFactory class that can create and manage instances of different Dropdown classes. The DropdownFactory class should have the following features:
1. It should be able to create instances of Dropdown classes based on the provided class type.
2. It should maintain a map of created... | codefeedback |
You are tasked with implementing a custom exception class and handling its usage within a testing framework. Your goal is to create a custom exception class, write a test case to verify the exception message, and handle the exception within a testing framework.
Create a custom exception class called `UnknownSelectorEx... | codefeedback |
You are tasked with implementing a compile-time comparison trait in C++. The trait should compare the value of a given type with the value of another type and return a boolean value indicating whether the first value is greater than the second value.
Your task is to complete the implementation of the `greater_than` tr... | codefeedback |
You are tasked with implementing a custom modal input component in React. The component should display a modal window with an input field and two buttons: "Save" and "Cancel". The input field should be pre-populated with a JSON string representation of a given value, and the user should be able to edit this value. The ... | codefeedback |
You are tasked with implementing a Python function that simulates a simple notification system. The function should be able to produce different types of notifications, such as success notifications and warning notifications. The function should also have the ability to play sound files synchronously or asynchronously,... | codefeedback |
You are tasked with creating a script to automate the installation of the LPeg library for Lua. The LPeg library is stored in a tar.gz archive file named `lpeg-1.0.1.tar.gz`, and its download URL is `http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-1.0.1.tar.gz`. The installation process involves extracting the contents of... | codefeedback |
You are working on a computer vision project and are tasked with implementing a custom image classification model using a pre-trained ResNet architecture. The ResNet model consists of several layers, including convolutional layers, batch normalization, ReLU activation, and max pooling. Additionally, the model has four ... | codefeedback |
You are tasked with creating a Bash script to download a specific JAR file from a remote repository. The script should take into account the version of the JAR file, resolving it if the version is "RELEASE" or "LATEST". The script should also handle the conversion of group and artifact paths to directory paths and cons... | codefeedback |
You are tasked with implementing a function that processes XML nodes based on certain conditions. The function takes in a list of XML nodes and two boolean flags, `stop_on_next` and `tagid_required`. Each XML node is represented as an object with attributes such as `tag_type` and `attributes`. The function should retur... | codefeedback |
You are tasked with creating a class to monitor and validate network latency data. Your class should have a property `average_latency` that allows setting and getting the average latency value. Additionally, the class should have a method `validate` to ensure that the average latency value meets certain criteria.
Your... | codefeedback |
You are tasked with implementing a session management system for a server that handles connections and disconnections. The provided code snippet is part of a Swift application and contains a few methods related to session management. Your task is to design and implement the `SessionManager` class that encapsulates the ... | codefeedback |
You are tasked with implementing a TypeScript class that manages Google Drive operations using OAuth2 authentication. The class should handle the authentication process and provide methods for interacting with Google Drive resources. However, the class should also ensure that certain sensitive properties are hidden fro... | codefeedback |
You are tasked with implementing a benchmarking utility for a software system. The utility should measure the performance of various functions and provide detailed results for analysis. Your task is to design and implement the benchmarking utility using the provided code snippet as a starting point.
You are given the ... | codefeedback |
You are working on a ticket management system for an application. The code snippet provided is a part of a base class that is used for managing tickets and application settings. The class uses dependency injection to access the `ITicketManager` and `IApplicationSettings` interfaces. The `Ticket.Culture` property is use... | codefeedback |
You are tasked with implementing a custom error handling mechanism in a C# application. The `SetErrorHandler` method is used to register a callback function that will be invoked whenever an error occurs in the application. Your goal is to create a class that allows users to register an error handling callback and provi... | codefeedback |
You are given a Python function that takes a list of arrays and a random seed as input. The function shuffles the arrays using the provided seed and returns the shuffled arrays. Your task is to implement a Python program that can accurately predict the shuffled arrays given the original arrays and the random seed.
Fun... | codefeedback |
You are tasked with creating a Python function that interacts with a database table to manage a simple key-value cache system. The cache table has the following structure:
Table Name: cache
Columns:
- id (BigInteger, not nullable): Unique identifier for each cache entry
- key (Unicode, nullable): The key for the cache... | codefeedback |
You are tasked with creating a program that processes images using a pre-trained machine learning model. The program should take an input image, display it using a function called `imshow`, and then pass the image through the model to obtain an output.
Your task is to implement a function called `process_image` that t... | codefeedback |
You are tasked with creating a TypeScript class that manages a collection of records using TypeORM. Your class should provide methods to add, retrieve, update, and delete records from a database using TypeORMModule. Additionally, you need to create a service and a resolver to handle the business logic and GraphQL queri... | codefeedback |
You are tasked with implementing a function that takes in an array of strings representing CSS class names and returns a new string representing the concatenation of these class names with a specific prefix. The function should also ensure that the resulting string does not contain any duplicate class names.
You are g... | codefeedback |
You are given a field represented as a 2D grid of characters. Each cell in the grid can be either a tree ('#') or open space ('.'). Starting from the top-left corner of the grid, you need to count the number of trees encountered while moving in specific patterns. The patterns are defined by slopes, which represent the ... | codefeedback |
You are tasked with implementing a data streaming system for a wearable device that includes various sensors such as accelerometer, user accelerometer, gyroscope, magnetometer, and a special "magic" sensor. The system uses channels to handle the streaming of data from these sensors. However, the given code snippet show... | codefeedback |
You are tasked with implementing a utility function to parse and validate memory limits and optimization passes for a compiler tool. The function should handle parsing memory limits as positive integers and optimization passes as comma-separated strings. The function should return the parsed values or appropriate error... | codefeedback |
You are tasked with creating a Python module that interacts with a database and performs various operations on the data. The module should import functions from other modules and use them to achieve its objectives.
Your task is to implement a function `process_data` in the `data_processor.py` module, which will perfor... | codefeedback |
You are tasked with creating a web application for a company that manages standards and manual procedures. The application needs to display a form with dropdown menus for selecting a standard and a manual procedure. The standards and manual procedures are fetched from a database and need to be populated dynamically in ... | codefeedback |
You are given a Python code snippet that contains an inefficient implementation of a depth-first search algorithm. Your task is to reimplement the depth-first search algorithm using a more elegant and efficient recursive approach.
Your goal is to create a Python function that takes in a graph represented as an adjacen... | codefeedback |
You are tasked with creating a Python program that interacts with the Dialogflow API to build a simple chatbot. The chatbot will respond to user input with predefined phrases based on certain keywords. Your task is to implement the logic for processing user input and generating appropriate responses.
Your program shou... | codefeedback |
You are tasked with creating a Python function that utilizes the NumPy library to perform a specific mathematical operation. The function should take in two NumPy arrays, C and V, and a NumPy array of integers, nums. The function should calculate the result based on the following formula:
result = (C * V) / nums
Wher... | codefeedback |
You are tasked with implementing a testing framework for a user interface library. The library includes a `MenuItem` interface, which represents a menu item in a graphical user interface. The `MenuItem` interface extends the `Component` interface and provides two methods: `labelShouldHave(String text)` and `click()`. T... | codefeedback |
You are tasked with implementing a function to perform 3D convolutional soft argmax operation using the given input tensor and parameters. The soft argmax operation is a differentiable approximation of the argmax function, which is commonly used in machine learning for localization tasks. The input tensor represents a ... | codefeedback |
You are tasked with designing a Java class to represent an online purchase order. The class should encapsulate the necessary attributes and provide methods to manipulate and retrieve the order details. Use the given code snippet as a starting point and expand upon it to create the complete class.
Your class should inc... | codefeedback |
You are tasked with implementing a function to generate a boot sector for a FAT32 file system. The boot sector is a crucial part of the file system, containing essential information for the system to boot and access the file system. The provided code snippet is a partial implementation of this function in Python.
Your... | codefeedback |
You are tasked with creating a program that simulates a simple text-based adventure game. The game will involve the player navigating through different rooms, encountering obstacles, and making decisions that affect the outcome of the game.
Your program should include the following features:
- The game should start wi... | codefeedback |
You are tasked with creating a Python script to analyze and visualize the performance data of a system using the Phoronix Test Suite (PTS). The Phoronix Test Suite is a comprehensive testing and benchmarking platform available for various operating systems.
Your script should perform the following tasks:
1. Retrieve t... | codefeedback |
You are tasked with creating a script that processes a directory containing executable files. Your script should iterate through each file in the directory, check if it is a regular file, readable, and executable, and if so, execute the file.
Write a shell script that accomplishes the following:
1. Accepts a directory... | codefeedback |
You are tasked with implementing a service management system for a company that provides various services to its customers. The system should include classes for managing customer information, drafting service details, generating invoices, and calculating taxes. The provided code snippet includes the names of the class... | codefeedback |
You are tasked with creating a simple web application using PHP and Laravel framework. Your task is to implement a feature that allows users to manage components and subcomponents. The given code snippet is a part of the routing configuration in a Laravel application.
The code snippet defines several routes for the we... | codefeedback |
You are tasked with creating a program that analyzes a given text and counts the occurrences of each unique word. For the purpose of this problem, a word is defined as a sequence of characters separated by spaces. Punctuation marks should be disregarded, and the comparison of words should be case-insensitive. The progr... | codefeedback |
You are tasked with creating a Python function that generates a training dataset for a machine learning model. The function should take in parameters for the number of data points, batch size, and repeat size, and should yield batches of input data and corresponding labels. The input data should be random images, and t... | codefeedback |
You are tasked with implementing a function that takes a string as input and returns the count of each unique character in the string. The function should ignore whitespace and be case-insensitive. For example, given the input "Hello, World!", the function should return a dictionary with the counts of each character: {... | codefeedback |
You are tasked with creating a Python function that interacts with a database and a GitHub API. Your function will handle the retrieval and storage of GitHub release data. You will also need to implement a function to load a personal access token from a JSON file.
You are provided with the following code snippet as a ... | codefeedback |
You are tasked with implementing a Python class that utilizes the AlexNet model for feature extraction. The AlexNet model is imported from a module called `extractors`. Your task is to create a class called `FeatureExtractor` that has a method `extract_features` which takes an image as input and returns the extracted f... | codefeedback |
You are tasked with implementing a function that processes a list of tuples representing product data and returns a dictionary containing the count of unique values for each category. Each tuple contains the product name and its associated categories. The function should ignore duplicate product names and count the uni... | codefeedback |
You are given a code snippet that describes the computation of parameters for the generalized gamma distribution and the computation of percentiles at different percentages. Your task is to implement a Python function that takes in the input parameters and computes the percentiles for the given generalized gamma distri... | codefeedback |
You are working on a software development project that involves packaging and managing dependencies using NuGet, a popular package manager for .NET. As part of the project, you need to automate the process of packing and cleaning up old NuGet packages. The provided code snippet is a part of the automation script.
The ... | codefeedback |
You are tasked with creating a Python function that retrieves a specific setting from a Django configuration and performs a transformation on it. The Django configuration is represented by a dictionary containing various settings. Your function should take the name of the setting as a parameter and return the transform... | codefeedback |
You are tasked with creating a Python function that processes a list of URL paths and extracts the view names associated with each path. The view name is the part of the URL path that comes after the last forward slash ("/") and before any query parameters or file extensions. Your function should return a dictionary wh... | codefeedback |
You are tasked with creating a program to process and display information about a trading card game. The program should handle legalities and rulings for a specific card. The card object has attributes `legalities` and `rulings`, which are lists of dictionaries containing information about the legal status of the card ... | codefeedback |
You are tasked with implementing a movie recommendation system using the provided code snippet as a starting point. The system should retrieve now playing movies and display them to the user. Additionally, the system should allow users to search for specific movies and display detailed information about the selected mo... | codefeedback |
You are tasked with implementing a function that determines whether a debugger is attached to a running process. The function will take no parameters and return a boolean value indicating the presence of a debugger.
You are provided with a code snippet that demonstrates the use of system calls and low-level memory ope... | codefeedback |
You are tasked with creating a program to parse and process HTML table data. The program should extract specific information from the table and perform calculations based on the extracted data.
You are given an HTML table snippet as follows:
```html
</thead>
<tbody>
<tr>
... | codefeedback |
You are given a string `S` containing only lowercase letters. Your task is to write a function that repeatedly removes adjacent, duplicate characters from the string until no adjacent duplicates remain. The function should return the modified string.
For example, if the input string is "abbaca", the function should re... | codefeedback |
You are tasked with creating a Python script to automate the deployment process for an AWS Lambda function using API Gateway. The deployment process involves installing the required Python packages, zipping the necessary files, and uploading the zip file to AWS Lambda.
Your script should perform the following steps:
1... | codefeedback |
You are tasked with creating a Rust program that interacts with the X Window System using the x11 and xft libraries. Your program needs to open a display, retrieve the default screen, and then draw a simple text string on the screen using Xft.
Your task is to complete the following Rust function:
```rust
fn draw_text... | codefeedback |
You are tasked with implementing a function to generate a unique identifier for a new ElectionLog entry in a Django application. The provided code snippet shows the model for ElectionLog, which includes a field for the unique identifier. Your task is to create a function that generates a new unique identifier following... | codefeedback |
You are tasked with implementing a Python function that processes a table of data and performs specific operations on it. The table is represented as a list of tuples, where each tuple contains information about a person. The information includes the person's name, alias, points, and awake status. The table is generate... | codefeedback |
You are tasked with creating a program that can parse and extract the domain name from a given URL. The domain name is the sequence of characters between the "http://" or "https://" and the next "/" in the URL. For example, in the URL "http://www.example.com/page1", the domain name is "www.example.com".
Write a functi... | codefeedback |
You are tasked with implementing a function that processes a table of product ratings and returns the average rating for each product. The table is represented as a list of dictionaries, where each dictionary contains the product name, date, and rating. Your function should calculate the average rating for each product... | codefeedback |
You are given a Python code snippet that involves the manipulation of a 3D array `q` based on the dimensions of arrays `G`, `x`, and `P`. Your task is to write a function that takes in the arrays `G`, `x`, `P`, and `q_raw` as input and returns the modified 3D array `q` based on the operations performed in the given cod... | codefeedback |
You are tasked with creating a Python program that processes a given directory and its subdirectories to find all image files and then convert them to a different format using the `subprocess` module. Your program should take the input directory path, the output directory path, and the desired image format as command-l... | codefeedback |
You are tasked with creating a program to send email notifications to users based on certain conditions. Your program should utilize the `System.Net.Mail` namespace in C# to send emails. You need to implement a method that takes in the recipient's email address, subject, and body of the email, and sends the email using... | codefeedback |
You are tasked with creating a Python function that processes a collection of files and extracts specific information from each file. The function should utilize regular expressions to extract data from the files and store the extracted information in a structured format.
You are provided with a code snippet that iter... | codefeedback |
You are working on a project to process data from a scientific instrument that captures images using various filters and settings. The instrument produces an XML file containing information about the filters used, including the number of exposures, integrations, groups, filter name, mask, and readout pattern. Your task... | codefeedback |
You are tasked with creating a Python class that processes and stores contact information. The class should have methods for adding new contacts, retrieving contacts by email address, and displaying all contacts in a user-friendly format.
Create a class `ContactManager` with the following methods:
1. `add_contact(emai... | codefeedback |
You are tasked with implementing a function to determine the number of occurrences of a given substring within a larger string. The function should take two string inputs: the larger string and the substring to search for. The function should return the count of occurrences of the substring within the larger string.
F... | codefeedback |
You are tasked with implementing a job scheduling system using Rust. The `jobs` module contains the necessary structures and functions for managing jobs. Your task is to complete the implementation of the `jobs` module by defining a job scheduling algorithm.
The `jobs` module contains the following structures:
```rust... | codefeedback |
You are tasked with creating a program that reads data from a CSV file, performs some operations on the data, and then writes the modified data back to a new CSV file. The given code snippet is a part of the program that writes the modified data to the new CSV file.
Your task is to implement the function `modify_and_w... | codefeedback |
You are working on a bioinformatics project that involves processing DNA sequences using a specialized data structure called a label hash. The label hash is used to efficiently store and query k-mers, which are substrings of length k within a DNA sequence. In this project, you need to implement a function to process DN... | codefeedback |
You are tasked with creating a Python function that simulates the behavior of a process manager for a simplified version of the Linux operating system. The process manager will be responsible for managing the lifecycle of processes, including starting, terminating, and monitoring them.
Your task is to implement a Pyth... | codefeedback |
You are tasked with designing a Java class that models a simple library system. The library contains books, and each book has a unique ISBN (International Standard Book Number). Your task is to create a class `Library` that manages the books in the library. The `Library` class should have the following functionalities:... | codefeedback |
You are tasked with implementing a background task handler for a watchOS app. The provided code snippet shows a function `handle(_ backgroundTasks: Set<WKRefreshBackgroundTask>)` which is responsible for handling background tasks. Your goal is to extend this function to handle different types of background tasks and ex... | codefeedback |
You are tasked with implementing a simplified version of a key-value store in Python. Your task is to create a class `KeyValueStore` with the following functionalities:
1. `__init__`: Initialize an empty key-value store.
2. `set`: Add a key-value pair to the store. If the key already exists, update its value.
3. `get`... | codefeedback |
You are given a string representing a text document. Your task is to write a function that counts the frequency of each word in the document and returns a dictionary where the keys are the unique words and the values are the frequencies of those words.
Your function should ignore punctuation and be case-insensitive, ... | codefeedback |
You are tasked with implementing a reinforcement learning algorithm using a neural network for Q-learning. The given code snippet is part of the Q-learning algorithm and involves processing Q-values for a batch of observations.
You are provided with the following variables:
- `q`: A tensor representing Q-values for th... | codefeedback |
You are tasked with creating a program that simulates a simple banking system. The program should allow users to create accounts, deposit and withdraw funds, and check their balance. Each account should have a unique account number, and the program should be able to handle multiple accounts.
Your task is to implement ... | codefeedback |
You are tasked with implementing a function to determine whether a given binary tree is a valid binary search tree (BST). A BST is a binary tree where each node has a key, and for any node, all keys in its left subtree are less than the node's key, and all keys in its right subtree are greater than the node's key.
You... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.