instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are working on a data processing pipeline for a child welfare organization. The organization collects data on children and households, and you need to manipulate and process this data for reporting and analysis. The provided code snippet contains lists of properties and fields related to children and households.
Y... | codefeedback |
You are tasked with creating a custom event handling system in C++ using Qt. Your goal is to implement a custom event type and handle it within a Qt application.
Your task is to create a class `CustomEvent` that inherits from `QEvent` and represents a custom event type `CMScrolled`. The `CustomEvent` class should have... | codefeedback |
You are tasked with creating a password validation function that checks whether a given password meets specific criteria. The function should ensure that the password contains at least one character from each of the following categories: lower-case characters (a-z), upper-case characters (A-Z), digits (0-9), and non-al... | codefeedback |
You are tasked with implementing a 3D wavelet transform and its adjoint operator using Python. The wavelet transform is a mathematical tool used for signal processing and data compression. The code snippet provided is a unit test for the adjoint operator of the 3D wavelet transform. Your task is to write a Python funct... | codefeedback |
You are tasked with implementing a program to calculate and visualize the distances between vertices of a sphere. The vertices are represented by their indices, and the distances are to be displayed in a heatmap.
Write a function `calculate_vertex_distances(n)` that takes an integer `n` as input and returns a 2D array... | codefeedback |
You are tasked with implementing a Quartiles struct that can calculate the quartiles of a given dataset. Quartiles are values that divide a dataset into four equal parts. The first quartile (Q1) is the value that separates the lowest 25% of the data from the rest, the second quartile (Q2) is the median of the data, and... | codefeedback |
You are tasked with implementing a class that manages the configuration for a SQL-based scale-out solution. The provided code snippet is the beginning of a class named `SqlScaleoutConfiguration`, which inherits from `ScaleoutConfiguration`. The `SqlScaleoutConfiguration` class is intended to manage the configuration se... | codefeedback |
You are tasked with implementing a report generation system that supports multiple output formats. The system should be able to generate reports in LaTeX, Markdown, JSON, and HTML formats. To achieve this, you need to create classes for each report builder type: LatexReportBuilder, MarkdownReportBuilder, JsonReportBuil... | codefeedback |
You are tasked with implementing a custom Gaussian Distribution Network (GDN) using PyTorch. The GDN will be used to model a Gaussian distribution with a given mean and standard deviation. You are provided with a skeleton code that imports the necessary modules and initializes the parameters using a utility function. Y... | codefeedback |
You are tasked with creating a PHP class that converts a given text file into an image using a specific library. The class should take the input from a text file, convert it into an image, and save the image as a PNG file.
Your task is to implement the `CharToImage` class, which will utilize the `PngIn` and `PngOut` c... | codefeedback |
You are tasked with creating a Python function that validates a given phone number based on certain criteria. The phone number is represented as a string and must adhere to the following rules:
1. The phone number must consist of only digits (0-9) and may contain optional hyphens (-) and parentheses ().
2. If the phone... | codefeedback |
You are tasked with automating the deployment process for a web application using Docker and SSH. Your goal is to create a script that builds a Docker image, pushes it to a private registry, and then deploys the application to a remote server using SSH.
The deployment process involves the following steps:
1. Build a D... | codefeedback |
You are tasked with creating a Python function that processes Jewish dates and performs error handling for invalid dates. The function should take a string representing a Jewish date in the format "DD/MM/YYYY" and return the corresponding JewishDate object. If the input date is invalid, the function should raise a cust... | codefeedback |
You are tasked with creating a Python test case for an API testing framework using the pytest library. The framework utilizes the Screenplay Pattern, a design pattern for writing high-level acceptance tests in a human-readable format. The provided code snippet is a part of the test setup using the pytest framework and ... | codefeedback |
You are tasked with creating a Python function that processes data from a file and extracts specific parameters for further analysis. The file contains information about a forecast, and the function needs to extract certain parameters related to power cuts and Levy distributions. The parameters are stored in a specific... | codefeedback |
You are tasked with creating a script to automate the setup process for a development environment. The script should install necessary tools and dependencies based on the target platform. Your task is to write a Python function that takes in the target platform as a parameter and generates the appropriate shell command... | codefeedback |
You are tasked with creating a Discord bot command that processes user messages and interacts with a JSON configuration file. The bot should delete messages that start with a specific character and repost them in a designated channel, based on the server's configuration.
You are given a Python code snippet that partia... | codefeedback |
You are tasked with implementing a Python function that performs a binary search on a sorted list of integers and measures the time taken to execute the search. Your function should take in the sorted list and the number to be searched for as input, and return the time taken to perform the binary search.
Your task is ... | codefeedback |
You are tasked with implementing a Python class that calculates the weighted moving average of a given list of numbers. The weighted moving average (WMA) is a method for smoothing time series data, where each value in the series is multiplied by a weight, and then the weighted sum is divided by the sum of the weights. ... | codefeedback |
You are given a text file containing a software license agreement. Your task is to write a Python program to extract and count the occurrences of unique words in the license agreement.
Your program should perform the following steps:
1. Read the text file "license.txt" containing the license agreement.
2. Tokenize th... | codefeedback |
You are given a grid of size m x n. You are initially located at the top-left corner and need to reach the bottom-right corner. In the grid, there are some obstacles. You can move either down or right at any point in time, but you cannot move diagonally. The grid is represented by a binary matrix where 0 represents an ... | codefeedback |
You are tasked with creating a simple TCP client-server application using the Boost.Asio library in C++. The server will listen for incoming connections and respond to client requests, while the client will establish a connection to the server and send a message.
Your task is to implement the server side of the applic... | codefeedback |
You are tasked with creating a network simulation using the ns-3 network simulator. The given code snippet is a part of the setup for a point-to-point communication link in the simulation. The `PointToPointHelper` class is used to configure the attributes of the point-to-point link. The `SetDeviceAttribute` method is u... | codefeedback |
You are tasked with creating a Python function that converts a PostgreSQL query result to a dictionary format. The function should take in three parameters: `result` (a list of tuples representing the query result), `columns` (a list of column names), and `single_object` (a boolean indicating whether the result should ... | codefeedback |
You are tasked with creating a Rust library for a simple physics simulation. The library should include modules for velocity and movement calculations. The `velocity` module should handle operations related to velocity, such as calculating speed and direction. The `movement` module should handle operations related to m... | codefeedback |
You are working on a project that involves building a deep learning model using TensorFlow and Keras. Your task is to create a custom deep learning model for image classification using the given code snippet as a starting point. The code snippet defines a function that constructs a model with specific layers and config... | codefeedback |
You are given an array of integers, where each element represents the price of a stock on a particular day. You need to design an algorithm to find the maximum profit that can be obtained by buying and selling a single stock at the right time. If no profit can be made, return 0.
For example, given the array `prices = ... | codefeedback |
You are tasked with implementing a function that takes a string as input and returns the string with each word reversed. A word is defined as a sequence of non-space characters. The input string may contain punctuation and special characters, but these should not be reversed with the words. The function should preserve... | codefeedback |
You are tasked with implementing a custom neural network layer in Python. The layer will be a simplified version of a Long Short-Term Memory (LSTM) layer, a type of recurrent neural network layer commonly used for processing sequential data. Your implementation should include the following components:
1. An `__init__`... | codefeedback |
You are tasked with implementing a message processing system that can handle different types of messages. The system should be able to match incoming messages to their respective message types and execute the appropriate actions based on the message type.
You are given a code snippet that demonstrates a part of the me... | codefeedback |
You are tasked with implementing a custom error type in Rust that includes a span representing the location of the error. The error type should be able to store an associated span and provide a way to access this span when the error is encountered.
Your task is to define a new error type called `SpannedError` and impl... | codefeedback |
You are tasked with creating a function to validate the edge conditions of a path generated by a motion planning algorithm. The function should check if the start and end positions and orientations of the path match the expected values within a certain tolerance.
You are given a code snippet that includes a function ... | codefeedback |
You are tasked with creating a Django management command that exports a user's information as a set of environment variables. The command should take a user ID as an argument and retrieve the user's information from the database. If the user exists, the command should export the user's information as environment variab... | codefeedback |
You are tasked with implementing a visibility check for objects in a 3D scene using Python. The scene contains multiple objects represented by their names and positions. Your goal is to determine whether each object in the scene has a minimum number of visible pixels, based on their positions and the camera's viewpoint... | codefeedback |
You are tasked with creating a script to automate the setup and execution of a cryptocurrency mining process using Docker. The script should read configuration from a file, check for the presence of Docker, and then run a Docker container with the specified parameters.
The configuration file, `hellminer.conf`, contain... | codefeedback |
You are tasked with implementing a Python function that simulates a simple image segmentation algorithm based on the Mumford-Shah model. The Mumford-Shah model is a widely used method for image segmentation, which aims to partition an image into regions with relatively homogeneous intensity while minimizing the length ... | codefeedback |
You are tasked with implementing a custom date extension in Swift that calculates the number of days remaining in the current week. You are given a code snippet that includes part of a Swift date extension, and you need to complete the extension by adding a computed property to calculate the remaining days in the curre... | codefeedback |
You are given a dictionary containing tuples as keys and floating-point numbers as values. Each tuple represents a unique combination of three integers. The integers within the tuple have specific meanings: the first integer represents a category, the second integer represents a subcategory, and the third integer repre... | codefeedback |
You are tasked with implementing a shell script function that processes command-line arguments to set the value of certain variables based on the provided options. The script should handle the following options:
- `-n`: Sets the value of `NB_EXE` to "jupyter-notebook".
- `-d`: Appends "/stdnotes" to the value of `NB_D... | codefeedback |
You are tasked with implementing a function that processes a collection of museum objects and their associated images. The function should retrieve the museum objects from a database, calculate the count of public images associated with each object, and then return a paginated list of the museum objects along with thei... | codefeedback |
You are tasked with creating a Swift class that represents a blogger's profile view. The class should have properties and methods to manage the display of the blogger's information. The blogger's profile view consists of a cover photo, a circular blogger image, a name label, and a handle label. Your task is to implemen... | codefeedback |
You are working on a project to simulate electrical circuits using Python. You have been provided with a code snippet that imports various electrical components from the `andes.models.dc.rlc` module. The components imported include resistors (R), inductors (L), and capacitors (C), as well as different combinations of t... | codefeedback |
You are tasked with implementing a class for a progress bar widget in a graphical user interface (GUI) application. The progress bar consists of a rectangular shape and a label displaying a value and additional text. The progress bar should be able to update its value and appearance based on a given percentage.
Your t... | codefeedback |
You are tasked with implementing a custom filtering mechanism for a collection of objects. The filtering logic is based on a given code snippet that represents a part of the filtering process. Your goal is to complete the filtering logic by implementing the missing parts and ensuring that the filtering criteria are met... | codefeedback |
You are tasked with implementing a function to calculate the surface area of a 3D model represented by a collection of faces. Each face is defined by three vertices and their corresponding vertex normals. The surface area of the 3D model is the sum of the surface areas of all its faces.
You are given a struct `Face` r... | codefeedback |
You are working on a time series analysis project and need to implement a Singular Spectrum Analysis (SSA) algorithm to reconstruct the original time series data. The SSA algorithm decomposes the time series into several components and then reconstructs the original time series using a subset of these components.
You ... | codefeedback |
You are tasked with creating a Python function that processes a file containing tab-separated values and extracts specific information from each line. The function should read the file, parse each line, and then return a list of tuples containing the extracted data.
The function signature should be:
```python
def extr... | codefeedback |
You are tasked with implementing a file checker for a BitTorrent client. The provided code snippet is part of a larger program responsible for checking the integrity of downloaded files. The `info` dictionary contains metadata about the torrent, including the piece length, pieces, file information, and the torrent name... | codefeedback |
You are given a Python code snippet that represents a graph using a list of dictionaries. Each dictionary represents a node in the graph, with keys as the neighboring nodes and values as the edge weights. The code also includes some operations on the graph.
Your task is to write a Python function that takes the graph ... | codefeedback |
You are given a partially completed implementation of a binary tree node class in Java. The class `Node` represents a node in a binary tree and has an integer value and references to its left and right children. However, the `toString` method of the `Node` class is incomplete and needs to be implemented. The `toString`... | codefeedback |
You are tasked with implementing a simple exception handling mechanism for a hypothetical embedded system. The system has a list of exception messages and a UART module for communication. Your goal is to write a function that sends an exception report over UART when an exception occurs.
You are given a code snippet th... | codefeedback |
You are tasked with implementing a custom view controller transition in a Swift iOS app. The provided code snippet is part of a custom transition manager class that will handle the transition animation between two view controllers. The `init` method initializes the transition manager with a specified style and directio... | codefeedback |
You are tasked with implementing a custom exception class for a user authentication system. The exception class should be designed to handle the scenario where a user attempts to activate their account, but it is already activated. Your task is to complete the implementation of the `UserAlreadyActivatedException` class... | codefeedback |
You are tasked with creating a Python class that manages a user stream and stores user activity in a Redis database. Your class should have the following functionalities:
1. Initialize the class with a subreddit name, a logger, an event, and a Redis client.
2. Implement a method `userstream` that yields tuples contain... | codefeedback |
You are given a code snippet that represents a function to find the maximum element in a stack. The stack is implemented using a linked list. Your task is to complete the implementation of the `MaxStack` class by adding the `get_max` method that returns the maximum element in the stack in O(1) time complexity.
```pyth... | codefeedback |
You are tasked with writing a script to automate the installation of Apache Giraph and Zookeeper on a Unix-based system. The script should download the necessary files, extract them to a specified directory, and create symbolic links for easy access. Your script should be able to handle errors and provide informative o... | codefeedback |
You are tasked with implementing a function that processes a given type of field in a document. The function should handle different field types and perform specific actions based on the type of field provided. The code snippet provided is a part of the function and contains a conditional statement to determine the fie... | codefeedback |
You are tasked with implementing a date selection widget in a graphical user interface (GUI) using wxWidgets, a C++ library for creating cross-platform applications. The provided code snippet is a part of a larger program that creates a date selection control. The snippet checks if the flag `wxCAL_SEQUENTIAL_MONTH_SELE... | codefeedback |
You are tasked with creating a Python function that processes a configuration file and user input to update a specific setting. The function should take in the path to the configuration file and prompt the user to input a new value for a setting. The function should then update the setting in the configuration file bas... | codefeedback |
You are tasked with creating a script to securely manage and display sensitive client credentials for a multi-client application. The script should prompt the user to input the client credentials and then display them in a secure manner. The script should also include error handling to ensure that the credentials are e... | codefeedback |
You are tasked with implementing a function to process and send messages in a chatbot application. The chatbot has the ability to retrieve and send poems based on user commands. The provided code snippet is a part of the chatbot's functionality. The `reply` variable is constructed based on the input data, and then it i... | codefeedback |
You are working on a game development project and need to implement a spell system for the game. The game has a set of spells that can be unlocked and used by the player. Each spell has a specific status effect that can be applied, and the player can also handle damage from various sources. Additionally, the game has a... | codefeedback |
You are tasked with creating a Python function that simulates the process of sending an HTTP POST request to a given URL with specific headers and payload. The function should handle the request and return the response received.
You are provided with a code snippet that sets up the URL, headers, and payload for the HT... | codefeedback |
You are given a list of airline tickets represented as pairs of departure and arrival airports. Your task is to reconstruct the itinerary in the correct order. It is guaranteed that the input represents a valid itinerary. The starting airport is "JFK".
For example, given the following list of tickets:
```
tickets = [[... | codefeedback |
You are tasked with implementing a text processing algorithm that involves tokenization, encoding, and embedding generation. The algorithm processes a given block of text and produces a list of embeddings for the tokens in the text. The provided code snippet is a part of the implementation and includes a method `_encod... | codefeedback |
You are tasked with implementing a pitch detection algorithm using the HannedFftDetector structure provided in the code snippet. The HannedFftDetector is a struct that implements the PitchDetector trait and has an fft_space field of type Option<FftSpace>. Your task is to complete the implementation of the HannedFftDete... | codefeedback |
You are working on a project that involves crafting adversarial examples for a machine learning model. Adversarial examples are inputs intentionally designed to cause a machine learning model to make a mistake. One common method for generating adversarial examples is the Fast Gradient Sign Method (FGSM). You are tasked... | codefeedback |
You are tasked with creating a Python program that simulates fetching data from multiple URLs concurrently using asynchronous programming. You will need to utilize the `aiohttp` library for making asynchronous HTTP requests.
Your program should include the following components:
1. Define an asynchronous function `fetc... | codefeedback |
You are tasked with implementing a generic data source and data source builder framework in Swift. The provided code snippet outlines the basic structure of the framework using generic types and protocols. Your goal is to extend this framework by creating a concrete implementation of a data source and a data source bui... | codefeedback |
You are working on a telemetry data processing system for an unmanned aerial vehicle (UAV). The system receives telemetry logs from different sources and needs to extract wind velocity data based on the source and type of log. The wind velocity data is stored in different formats depending on the log type and source.
... | codefeedback |
You are tasked with implementing a Python class method that processes a sequence of ranks and updates the ranks of nodes in a tree data structure. The tree is represented using an instance of the `HereditaryStratumOrderedStoreTree` class. The method `do_getrank_DelRanks` takes in an iterator of ranks and updates the ra... | codefeedback |
You are tasked with implementing a function that searches for a specific value within a lookup table. The lookup table is provided as a stream of strings, and the function should return `True` if the value is found in the table and `False` otherwise. The function should ignore leading and trailing whitespace in the loo... | codefeedback |
You are given a code snippet from a Swift function. Your task is to identify the missing parts of the function and complete the implementation. The function is intended to take a request object, process it, and return a result. However, the code snippet provided is incomplete, and you need to fill in the missing parts ... | codefeedback |
You are given a robot that moves on a grid. The robot starts at position (x, y) and moves according to the following rules:
- It moves one step forward in the direction it is facing.
- It turns 90 degrees to the left.
- It moves one step forward in the new direction.
The robot follows the code snippet provided below t... | codefeedback |
You are tasked with implementing a Python class that simulates a file system using the HDF5 file format. The class, named `File`, should support various file operations and modes, such as creating groups within the file and opening the file in different modes like read, write, and append.
Your task is to implement the... | codefeedback |
You are tasked with implementing a simplified version of an asynchronous MQTT client in Rust. The client is responsible for connecting to an MQTT broker and handling incoming and outgoing messages.
Your task is to complete the implementation of the `connect` method in the `AsyncClient` struct. The method should establ... | codefeedback |
You are tasked with creating a program that extracts data from an HTML file and counts the occurrences of specific HTML tags within the file. The HTML file contains a series of nested elements, and you need to count the occurrences of a given tag within the file.
Write a function `countTagOccurrences(html, tag)` that ... | codefeedback |
You are tasked with implementing a program that can analyze the frequency of words in a given text. Your program should take a string of text as input and return a dictionary containing the frequency of each word in the text. For the purpose of this problem, a word is defined as a sequence of characters separated by sp... | codefeedback |
You are tasked with creating a function that parses an HTML form and extracts the input fields along with their attributes. The function should take an HTML string as input and return a dictionary where the keys are the input field names and the values are dictionaries containing the attributes of each input field.
Fo... | codefeedback |
You are working on a project that involves building a command-handling system for a fabric-based event-sourcing architecture. The code snippet provided is a TypeScript module that imports and exports various components related to this system. Your task is to create a TypeScript class that implements a command handler f... | codefeedback |
You are tasked with implementing a simplified version of a Glob pattern matcher in Rust. A Glob pattern is a type of pattern matching that is commonly used in Unix-like operating systems to match filenames. In this problem, you will create a Rust program that can match strings against a list of Glob patterns.
Your tas... | codefeedback |
You are tasked with implementing a custom event system in a game development project. The game has various events that need to be handled, such as player damage, player effects, player authentication, player class changes, item pickups, item drops, and room cleaning activations. To achieve this, you need to create a fl... | codefeedback |
You are tasked with implementing a module system for a programming language. The module system should support the creation and usage of three distinct data types: map, list, and tuple. Each data type should be encapsulated within its own module for organization and encapsulation purposes.
Your task is to design and im... | codefeedback |
You are tasked with writing a program to extract all the URLs from a given HTML code snippet. The URLs should be extracted from the `href` attribute of anchor (`<a>`) tags and should include both absolute and relative URLs.
Write a function `extract_urls(html_code: str) -> List[str]` that takes a string `html_code` re... | codefeedback |
You are tasked with creating a function to perform a geolocation lookup using the MaxMind GeoIP2 database. The function should handle the initialization of the GeoIP2 engine, loading the GeoIP2 database, and performing a lookup for a given IP address.
Write a function `geoip2_lookup` that takes an IP address as a para... | codefeedback |
You are tasked with creating a program that simulates a file system operation. Your program should implement a function that takes a directory path as input and performs the following operations:
1. Delete a specific file named "yawik.config.global.php" located in the "config/autoload" subdirectory within the given dir... | codefeedback |
You are tasked with implementing a signal handling mechanism in a Python application. The application uses a custom signal, `register_global_settings`, to allow various components to register their global settings. Your goal is to create a class that can handle the registration of these global settings and provide a me... | codefeedback |
You are tasked with implementing a genetic algorithm for evolving neural network weights and biases. The given code snippet is a part of the mutation process in the genetic algorithm. The `self.network` object represents the neural network, and the mutation is applied to the weights and biases of the network.
Your tas... | codefeedback |
You are tasked with creating a script to automate the installation of npm, grunt, and the configuration of bower for root installation in a Docker container. Your script should handle the installation of npm, grunt, and the necessary configuration for bower to allow root installation.
Given the code snippet provided, ... | codefeedback |
You are tasked with implementing a strategy for a prisoner's dilemma game. In this game, two players can choose to either cooperate or defect. The payoff matrix is as follows:
- If both players cooperate, each receives a moderate reward (R).
- If one player defects while the other cooperates, the defector receives a hi... | codefeedback |
You are tasked with implementing a simple user profile class in Python. The class should have the following attributes and methods:
Attributes:
- `username`: a string representing the username of the user
- `email`: a string representing the email address of the user
- `age`: an integer representing the age of the use... | codefeedback |
You are tasked with implementing a Python function to perform the secant method for finding the root of a given function. The secant method is an iterative numerical root-finding algorithm that uses a succession of roots of secant lines to better approximate a root of a function. The function should take the following ... | codefeedback |
You are tasked with creating a TypeScript class that extends a base class and implements a specific theme for a slider track component in a UI framework. The base class and related imports are provided in the code snippet below:
```typescript
* SPDX-License-Identifier: Apache-2.0
*/
import { DBaseStateSet } from ".... | codefeedback |
You are tasked with implementing a simple caching mechanism using Rust. Your goal is to create a generic cache that can store key-value pairs and evict the least recently used (LRU) item when the cache reaches its maximum capacity. You should implement the `LRUCache` struct with the following methods:
- `new(capacity: ... | codefeedback |
You are tasked with creating a Python function that simulates the behavior of a web browser interacting with multiple windows. The function should take a list of links as input and perform a series of actions on each link. The goal is to handle the opening and closing of new windows based on the provided links.
Your t... | codefeedback |
You are working on a data processing pipeline for a drug discovery project. The pipeline involves merging and processing two dataframes, `part1` and `part2`, and then exporting the resulting dataframe to a tab-separated file. The code snippet provided is a part of this pipeline and involves the following steps:
1. Logg... | codefeedback |
You are tasked with implementing a function that converts world coordinates to viewport coordinates in a 3D environment. The function should handle both Unity's RectTransformUtility.WorldToScreenPoint and Camera.WorldToViewportPoint methods.
You are given the following code snippet as a starting point:
```csharp
poi... | codefeedback |
You are tasked with creating a function that retrieves a list of players from an anime website using asynchronous JavaScript. The function `getPlayers` takes two parameters: `q` (a query string) and `n` (a number). It makes an asynchronous call to an API endpoint using the `api.get` method, which returns a response obj... | codefeedback |
You are tasked with implementing a class that manages the state of a job execution in a distributed computing environment. The class, `AppMaster`, is responsible for coordinating the execution of a job and handling any errors that may occur. The code snippet provided is a part of the test suite for the `AppMaster` clas... | codefeedback |
You are tasked with simulating the behavior of DNS resolution for different types of clients. The behavior of two types of clients, as described in the code snippet, needs to be emulated.
For the first type of client (e.g. Google Chrome), the client will query all DNS servers until an answer is found, even if previou... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.