instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with creating a Rust program that processes a list of strings and performs various operations on them. Your program should utilize the provided external crates and adhere to the following requirements:
1. Use the `lazy_static` crate to create a lazy-initialized static variable to store a regex pattern f... | codefeedback |
You are tasked with optimizing the performance of a web application's dashboard page. The given code snippet is from a Laravel controller method responsible for rendering the dashboard view. The method retrieves data from the database and passes it to the view for display. However, the current implementation may lead t... | codefeedback |
You are tasked with designing a Python class to manage power zones in a smart home system. The system has a database table named `power` with the following columns: `zone_name` (string), `running` (boolean), and `running_manually` (boolean). The class should have a method to update the status of a power zone in the dat... | codefeedback |
You are tasked with creating a script to automate the mounting of various directories on a Linux system. The script should read a configuration file containing a list of directories and their corresponding UUIDs, and then mount each directory using the specified UUID.
The configuration file will be in the following fo... | codefeedback |
You are tasked with simulating a dice rolling game using C++. The game involves rolling two dice and recording the outcomes. Your task is to complete the code by implementing the `Die` and `Roll` classes, as well as the logic for rolling the dice and storing the results.
The `Die` class should have a method `roll()` t... | codefeedback |
You are tasked with creating a PHP class that manages user data in a database. The class contains methods for adding, editing, and deleting user records. The class uses a session to set flash messages for success or failure of the operations and then redirects the user to a specific page.
Your task is to implement the... | codefeedback |
You are tasked with implementing a class for handling requests related to the FIDO2 CTAP (Client to Authenticator Protocol) standard. The CTAP protocol is used for secure communication between a client device, such as a computer or smartphone, and an authenticator, such as a security key or biometric device. Your goal ... | codefeedback |
You are tasked with creating a React component that displays a phrase and provides a link to show related GIFs. The component should take an `item` object as a prop, which contains the `phrase` and `phraseId` properties. The `phrase` property holds the text of the phrase, and the `phraseId` property holds the unique id... | codefeedback |
You are tasked with creating a script that automates the deployment of a WildFly Swarm application. WildFly Swarm is a framework that allows you to package and run Java EE applications by embedding the WildFly application server within the application. The provided code snippet is a simplified version of a deployment s... | codefeedback |
Vika, a schoolgirl, is preparing to celebrate her birthday at school by bringing N chocolate candies to share with her classmates. However, she encountered a problem when she went to the store to buy the candies a day before her birthday. The store only sells the candies in packs, with each pack containing exactly M ca... | codefeedback |
You are tasked with creating a Python class that manages machine learning models loaded from XML representations. Your class should have the following functionalities:
1. A method to load a machine learning model from an XML string and store it in the class.
2. A method to update the XML representation of the stored m... | codefeedback |
You are tasked with implementing a dynamic 2D upsampling operation using the given code snippet as a reference. The function `dyn_2d_up_operation` takes in several parameters: `x` (input data), `lf_2d` (2D low-frequency data), `k_sz` (kernel size), and an optional parameter `sf` (scaling factor, default value 2). The g... | codefeedback |
You are tasked with implementing a simple event handling system in Python. Your goal is to create a class that allows objects to subscribe to and emit events. The class should have methods to subscribe to an event, unsubscribe from an event, and emit an event to all subscribed handlers.
You need to implement a class `... | codefeedback |
You are tasked with implementing a function that processes a given input and performs specific actions based on the input type. The input can be of type `string`, `number`, or `boolean`. The function should handle each input type differently and return a corresponding result. Additionally, the function should utilize t... | codefeedback |
You are tasked with creating a Python function that processes the results of a machine learning model and visualizes its performance using various metrics. The function takes in a test dataset, applies a decision tree classifier to it, and then generates a classification report, visualizes the data, and plots a confusi... | codefeedback |
You are given a code snippet for a job application system. The code is intended to process job applications and store relevant information. Your task is to implement a function that will parse the given input and extract the relevant data for each job application.
The input consists of a series of job applications, ea... | codefeedback |
You are tasked with creating a script to automate the setup of a wireless access point on a Linux system. The script should take user input for the country code, interface, SSID, and WPA passphrase, and then generate a configuration file for hostapd. Additionally, the script should reboot the system to apply the change... | codefeedback |
You are tasked with creating a program to parse and extract information from HTML code. Specifically, you need to extract the URLs and corresponding link text from anchor tags in the HTML code.
Write a function `extractLinks(html)` that takes a string `html` representing the HTML code as input and returns a dictionary... | codefeedback |
You are tasked with creating a custom plugin for a modeling tool called EDMM (TOSCA-based Environment for Deployment and Management). The EDMM tool provides a framework for modeling and transforming cloud applications. Your custom plugin will need to implement specific functionality to support the transformation proces... | codefeedback |
You are tasked with creating a function to compress images and convert them to base64 format. The function should take an image as input and return the compressed image in base64 format. The compression level should be determined based on the image's size.
You are given the following code snippet as a starting point:
... | codefeedback |
You are tasked with creating a Python decorator that logs the execution time of a function and returns the result along with the execution time. The decorator should be able to handle functions that take in a list of integers and return a list of integers. The decorator should also handle functions that take in a custo... | codefeedback |
You are tasked with implementing a simple routing system for a web server. The server should be able to handle different routes and resources, as well as handle errors and redirects. Your task is to create a class that manages these routes and resources, and to implement the necessary methods to add routes, set a defau... | codefeedback |
You are tasked with creating a C++ unit testing framework for a simple role-playing game. The game consists of characters, commands, enemies, heroes, and the world. Your goal is to implement the necessary unit tests for each component using the Google Test framework.
You have been provided with a code snippet that inc... | codefeedback |
You are tasked with creating a Python program to implement a simple encryption algorithm. The algorithm will take a key and a value as input and produce an encrypted output. The encryption process involves reading the contents of a file specified by the value and applying a simple substitution cipher using the characte... | codefeedback |
You are tasked with implementing a class that generates HTML code for a title table. The class `HF_TitleTable` is a subclass of the `HtmlMaker` class and is responsible for creating HTML code for a title table. The class has a constructor, a destructor, and two member functions for producing titles.
The constructor `H... | codefeedback |
You are given a Python code snippet that manipulates a dictionary called `pessoas`. Your task is to analyze the code and predict the output of each print statement. Additionally, you need to explain the changes made to the `pessoas` dictionary and the final state of the dictionary after the code execution.
```python
p... | codefeedback |
You are tasked with implementing a simple neural network training loop using PyTorch. The given code snippet initializes a neural network model and sets up the training loop. Your task is to complete the training loop by incorporating the necessary steps for training the model on a dataset.
You are provided with the f... | codefeedback |
You are tasked with creating a script to analyze a database of software ports and identify any Python 3 packages that are missing a required hook in their respective Makefiles. The script should iterate through the database, extract the category and port name for each Python 3 package, and then check if the correspondi... | codefeedback |
You are tasked with implementing a custom label metrics evaluation function for a machine learning model. The function should calculate the area under the curve (AUC) for each specified label and return the results in a dictionary format. You are given a code snippet that uses the `CustomLabelMetrics` class from the `m... | codefeedback |
You are tasked with implementing a custom random number generator class in Python. The class should have a method to generate random integers within a specified range using a linear congruential generator algorithm. The linear congruential generator algorithm is defined by the recurrence relation:
Xn+1 = (a * Xn + c) ... | codefeedback |
You are tasked with creating a script to clean up a directory by removing all files except those specified in a whitelist file. The script should identify any unknown files in the directory and prompt the user to confirm deletion.
Your script should take two arguments:
1. The directory path to be cleaned.
2. The whit... | codefeedback |
You are tasked with creating a Python program to control a traffic light system using a Raspberry Pi and the RPi.GPIO library. The traffic light has three colors: red, yellow, and green. The program should continuously prompt the user for input and respond to specific commands to control the traffic light.
The traffic... | codefeedback |
You are tasked with creating a URL routing system for a music streaming web application using Django. The application has endpoints for managing playlists, songs, and user accounts. Your goal is to define the URL patterns for these endpoints based on the provided code snippet.
Given the code snippet, you need to compl... | codefeedback |
You are tasked with implementing a custom stack data structure that supports the standard push, pop, and peek operations, along with an additional operation `getMin` that returns the minimum element in the stack in constant time. Your implementation should have O(1) time complexity for all operations.
You are given th... | codefeedback |
You are tasked with implementing a function that evaluates a Python expression with extreme caution. The function `cautious_eval` takes in a Python expression as a string and an optional size limit for the evaluated expression. The goal is to carefully evaluate the expression, taking into account potential security ris... | codefeedback |
You are tasked with creating a Python function that generates a random symmetric matrix of a given size. A symmetric matrix is a square matrix that is equal to its transpose. Your function should take an integer `n` as input and return a NumPy array representing the symmetric matrix of size `n x n`.
Your task is to im... | codefeedback |
You are working on implementing a neural network training algorithm using a library that provides matrix operations for efficient computation. The code snippet provided is part of the backpropagation process for updating the weights and biases of a neural network.
Your task is to implement a function that performs the... | codefeedback |
You are given a list of strings, where each string represents a word. Your task is to write a function that finds all pairs of words in the list that can be joined together to form a new word. A pair of words can be joined together if the end of the first word is the same as the beginning of the second word. For exampl... | codefeedback |
You are tasked with creating a program that processes a list of GitHub repositories and their corresponding star counts. Your program should read in the repository data and perform specific operations based on the requirements outlined below.
You are given a list of GitHub repositories in the following format:
```
<gh... | codefeedback |
You are tasked with implementing a message processing system that processes message block elements and constructs a message using a StringBuilder. Each message block element is processed by a function `processElement` which takes the element and a context as input and returns a `ProcessingReturnValue`. The context cont... | codefeedback |
You are tasked with implementing a custom `subtract` function for arrays in Swift. The `subtract` function should take two arrays of the same type and return a new array containing the elements from the first array that are not present in the second array. If an element appears multiple times in the first array, it sho... | codefeedback |
You are tasked with implementing a function that simulates the behavior of the `awaitCatcher` function. The `awaitCatcher` function takes a promise as an argument and returns a new promise that resolves to an array containing the resolved value of the original promise (if it resolves) and the error (if it rejects). You... | codefeedback |
You are tasked with implementing a system to manage events in a music streaming application. The application supports various events related to playing songs, managing playlists, handling payments, and controlling the streaming service. Each event is represented by a unique string identifier. Your goal is to design a d... | codefeedback |
You are given a positive integer `n`. Your task is to write a function that calculates the sum of the digits in the thousands and hundreds place of the given number `n`.
Write a function `sumOfThousandsAndHundreds` that takes in a positive integer `n` and returns the sum of the digits in the thousands and hundreds pla... | codefeedback |
You are tasked with implementing a system for managing widgets in a game engine. The game engine uses the ECS (Entity-Component-System) architecture, where entities are objects in the game world, components are the data associated with entities, and systems are responsible for processing entities with specific componen... | codefeedback |
You are tasked with parsing and extracting autofocus information from a Canon camera's metadata. The autofocus information is stored in an array with 'fake' tags, and the values in this record are sequential. Some values have variable sizes based on the number of autofocus points (numafpoints), which can be 1, 5, 7, 9,... | codefeedback |
You are tasked with creating a Python class that acts as a wrapper for a command-line tool. The class should provide a convenient interface for executing the tool and handling its output. Your task is to implement the `AlignAceCommandline` class, which will serve as a wrapper for the AlignAce command-line tool.
The `A... | codefeedback |
You are given a code snippet that appears to be part of a program written in C++ or a similar language. Your task is to understand the logic and purpose of the code and then implement a specific function based on the given code snippet.
The code snippet seems to be part of a larger program that involves handling casca... | codefeedback |
You are tasked with implementing a simple neural network model using Python and TensorFlow. The model should consist of a single layer of Transformer architecture. The Transformer model should be designed to perform a basic classification task on a given dataset. Your task is to complete the implementation of the model... | codefeedback |
You are tasked with implementing a neural network classifier using PyTorch for a computer vision project. The given code snippet shows the beginning of the classifier definition, where a fully connected layer is added to the sequential model. Your task is to complete the classifier by adding additional layers and then ... | codefeedback |
You are tasked with implementing a custom list queue data structure in Rust. The list queue should support the following operations:
1. `enqueue`: Add an element to the end of the queue.
2. `dequeue`: Remove and return the element at the front of the queue.
3. `peek`: Return the element at the front of the queue withou... | codefeedback |
You are tasked with creating a simple iOS app that fetches data from a remote server using Moya for network requests and RxSwift for handling asynchronous operations. Your app needs to display a list of items retrieved from the server in a table view. Each item should have a title and a description.
You have been prov... | codefeedback |
You are tasked with creating a script that retrieves the latest release version of a given GitHub repository. Your script should utilize the `curl` command to fetch the release information from the GitHub API and then extract the latest release version using `grep` and `sed`. Additionally, the script should accept comm... | codefeedback |
You are tasked with implementing a Java class that represents a simple shopping cart. The shopping cart should be able to hold a collection of items, calculate the total cost of the items, and apply a discount if a promotional code is provided.
Your task is to implement the `ShoppingCart` class with the following requ... | codefeedback |
You are working on a web application and need to implement a feature that involves parsing and extracting information from HTML code. Your task is to write a function that extracts the URL and text content from an anchor tag in the given HTML code.
Write a function `extractAnchorTagInfo(htmlCode)` that takes a string ... | codefeedback |
You are tasked with creating a Python class to manage social media user profiles. The class should have the following functionalities:
1. Initialize a user profile with a name, active status, last seen date, and number of followers.
2. Provide methods to update the active status, last seen date, and number of followers... | codefeedback |
You are tasked with implementing a VIPER (View, Interactor, Presenter, Entity, Router) architecture for a mobile application. The VIPER architecture is a design pattern used to separate the concerns of an application into distinct layers, promoting modularity and testability. In this problem, you will focus on the Pres... | codefeedback |
You are tasked with implementing a function to add directory entries to a buffer in a C program. The function `dirbuf_add` takes in parameters representing the directory entry information and adds it to the buffer. Your task is to complete the implementation of the `dirbuf_add` function according to the given specifica... | codefeedback |
You are tasked with creating a file upload feature for a web application using PHP. Your goal is to implement a method that processes the uploaded file and saves it to the server. The web application uses the CodeIgniter framework, and you need to write the method within a controller class.
You are provided with the f... | codefeedback |
You are tasked with implementing a Python function that updates a code snippet in a database using FastAPI and SQLAlchemy. The function takes in a data object representing the snippet data, an authentication token, and returns a response object representing the updated snippet. The function is responsible for handling ... | codefeedback |
You are tasked with implementing a partial key collector data structure in Rust. The `PartialKeyCollector` struct is designed to store partial keys, which can be either string references or integer values. The collector should allow adding and retrieving partial keys, and it should enforce certain constraints on the ke... | codefeedback |
You are tasked with implementing a 2D Gaussian blur operation using the provided code snippet as a starting point. The `GaussianBlur2D` class extends `DefaultBenchmarkableModule` and contains a private field `sigma` of type `Double`. Your goal is to complete the implementation of the Gaussian blur operation by adding t... | codefeedback |
You are tasked with implementing a service management system that allows users to create, update, and delete services within different environments. The system is designed to work with a RESTful API, and you are provided with a partial code snippet for the `delete_service` method of the service management class. Your t... | codefeedback |
You are tasked with implementing a basic AVL tree data structure in Python. An AVL tree is a self-balancing binary search tree, where the heights of the two child subtrees of any node differ by at most one. Your task is to implement the `AVLTree` class with the following methods:
1. `update(self, key_value_pair)`: Thi... | codefeedback |
You are tasked with simulating the movement of a simple human arm in a 3D environment. The arm is represented by a set of joints and links, and its movement is controlled by specifying joint angles. Your goal is to implement a function that calculates the end-effector position of the arm given a set of joint angles and... | codefeedback |
You are tasked with creating a Rust function that interacts with an API to retrieve random clues for a game. The provided code snippet is part of an asynchronous Rust program that makes use of the reqwest library for making HTTP requests. The function `get_random_clues` takes a reference to `self` and a `count` paramet... | codefeedback |
You are tasked with creating a Python script to blind the files in a directory for analysis. The script should be non-destructive, meaning it will create a copy of the files to be blinded and record their identities to a text file. The blinding process involves creating a copy of each file in the directory, renaming th... | codefeedback |
You are given a code snippet for a file header in a programming project. Your task is to write a program that extracts the creation date and the author's name from the header.
The header follows the format:
```
//
// Created by [Author's Name] on [Creation Date].
// Copyright © [Year] [Author's Name]. All rights res... | codefeedback |
You are tasked with implementing a function to process context logs from a given log store using a provided client. The function should retrieve context logs forward, extract pack information, and print relevant details. You are given a code snippet as inspiration, which demonstrates the process of retrieving context l... | codefeedback |
You are tasked with implementing a Python class that calculates the average loss of examples in a mini-batch. The class should inherit from `BaseLoss` and provide a method `calculate_loss` that takes in prediction scores, labels, and additional parameters. The prediction scores are stored in a 2D tensor, where each row... | codefeedback |
You are tasked with implementing a Python function that simulates a simplified version of the `conda_remove` function from the given code snippet. The `conda_remove` function is responsible for deactivating a conda environment and restoring the original system PATH.
You need to create a Python function `simulate_conda... | codefeedback |
You are tasked with implementing a function that can efficiently determine the length of the longest namespace chain in a given C++ code snippet. A namespace chain is a sequence of nested namespaces, and the length of the chain is the number of nested levels. For example, in the code snippet provided, the longest names... | codefeedback |
You are tasked with creating a script to automate the process of applying a custom theme to the dwm window manager and setting a wallpaper. The script should prompt the user to choose a theme from a directory, copy the necessary theme files to the appropriate locations, and then compile the dwm window manager.
Your sc... | codefeedback |
You are tasked with implementing a function to find the upper bound of a given key in a binary search tree. The function `upper_bound` takes in two parameters: `root`, an optional reference to the root node of the binary search tree, and `key`, a reference to the key whose upper bound needs to be found. The function sh... | codefeedback |
You are tasked with implementing a function that executes a command on a network node and prints the command as well as the output of the command. You are given a code snippet that outlines the function signature and usage. Your task is to create the function `exec_cmd` that takes a `node` object, a `cmd` string, and r... | codefeedback |
You are tasked with creating a Python class that simulates a simple banking system. The class should have methods for depositing funds, withdrawing funds, and checking the account balance. Additionally, you need to implement a method for transferring funds from one account to another. To ensure security, the system sho... | codefeedback |
You are tasked with implementing a container management system that can retrieve containers based on their status. The system has a method `_get_containers_with_state` which takes in a list of container names, a boolean flag `select_random`, and variable number of container states. The method retrieves containers with ... | codefeedback |
You are tasked with implementing a class that manages event handling and transport setup for a logging system. The class should provide methods for creating events from messages, setting up the transport, and starting a native client with specific options. Additionally, the class should have a property to indicate the ... | codefeedback |
You are tasked with implementing a module resolution algorithm for a simple JavaScript module system. The module system uses the `export * from 'module'` syntax to re-export all the exports from another module. Your task is to write a function that resolves the exports for a given module, taking into account the re-exp... | codefeedback |
You are tasked with creating a program that processes images from a webcam, detects objects within the images, and applies a grayscale filter to the detected objects. The program reads a file containing class names, creates a detection model, and continuously captures images from the webcam while a specific exit key is... | codefeedback |
You are working as a DevOps engineer for a company that uses Docker extensively for its applications. Your team is responsible for managing and deploying various Docker containers across different environments. One of the challenges you face is ensuring that the containers are launched with the correct configurations a... | codefeedback |
You are tasked with creating a Python function that verifies the existence of resources in a given template against the actual resources in a cloud environment. The function should compare the expected resources from the template with the actual resources in the cloud and raise an assertion error if the counts do not m... | codefeedback |
You are tasked with implementing a Python function that uses the `selectors` module to create a simple TCP echo server. The server should be able to accept incoming connections, read data from the client, and then echo the received data back to the client. The server should also keep track of the number of connections ... | codefeedback |
You are tasked with implementing a function that generates a payload for a 32-bit or 64-bit architecture. The payload will be used to exploit a vulnerability in a program by controlling the offset of the first formatter, providing a dictionary of addresses and values to write, and specifying the number of bytes already... | codefeedback |
You are tasked with implementing a function that processes data from reinforcement learning paths. The function takes in three arguments: `adjusted_rewards`, `env_infos`, and `agent_infos`. The `adjusted_rewards` is a 2D array of shape (batch_size, max_path_length), while `env_infos` and `agent_infos` are dictionaries ... | codefeedback |
You are working on a constrained device that communicates using the CoAP (Constrained Application Protocol) and need to implement a function to handle CoAP options. The CoAP options are encoded in a compact manner, and you need to parse the option details from the received buffer.
The code snippet provided is part of ... | codefeedback |
You are tasked with creating a Python function that parses a given file to extract the license information. The license information is typically found within a file's comments and includes details such as the copyright holder, license type, and any additional notes. Your function should be able to identify and extract ... | codefeedback |
You are tasked with implementing a property validation library in PHP. The library should allow users to define validation rules for various properties of objects. The validation rules should cover common scenarios such as required fields, minimum and maximum values, string length, and custom validation functions.
You... | codefeedback |
You are tasked with creating a command-line interface (CLI) tool for setting up pipelines for Unity projects. The tool should support various options and parameters to customize the pipeline setup based on the user's requirements.
Your task is to implement a function or method that parses the command-line arguments an... | codefeedback |
You are tasked with simulating a simplified workflow engine that processes a series of activities and gateways. The engine is represented by the given code snippet, which includes the creation of a pipeline, runtime, and engine, followed by the execution of the pipeline and subsequent actions. Your goal is to implement... | codefeedback |
You are tasked with analyzing a dataset containing information about different machine learning models' performance on various datasets. The dataset is represented as a pandas DataFrame `df` with the following columns: "m" (model type), "ds" (dataset), and "tech" (technology used).
Your goal is to write a Python funct... | codefeedback |
You are tasked with implementing a custom math library for embedded systems that only support 32-bit floating-point operations. The library should include the functions `cosf32` and `tanf32`, which calculate the cosine and tangent of a given angle in radians, respectively. However, due to the limited resources of the e... | codefeedback |
You are tasked with implementing a script that processes symbolic links in a given directory. Your script should identify all symbolic links and determine their target paths.
Write a Bash script that takes a directory path as an argument and outputs the symbolic links within that directory along with their correspond... | codefeedback |
You are tasked with creating a function that processes a list of scene transition events in a mobile app. Each event is represented by a string containing the event type and the scene name. The function should return a dictionary containing the count of each event type for each scene. If a scene has no events of a cert... | codefeedback |
You are tasked with creating a function that processes a given HTML snippet to extract specific information. The HTML snippet represents a card element displaying a pending "Provide Help" request in a financial system. The snippet contains the amount of the pending request in Nigerian Naira (NGN) and some descriptive t... | codefeedback |
You are tasked with implementing a simple event handling system for a graphical application. The application has a window with a key press function that triggers an action when a key is pressed. Your goal is to create a class that manages the key press events and their associated actions.
You are given a partial code ... | codefeedback |
You are tasked with creating a Python script that generates a configuration file for Supervisor, a process control system. The configuration file should include specific settings and environment variables for running a Python application under Supervisor.
The configuration file should have the following properties:
- ... | codefeedback |
You are tasked with implementing a Python class that performs fuzzy string matching using the Levenshtein distance algorithm. The Levenshtein distance between two strings is the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one string into the other.
You need to ... | codefeedback |
You are tasked with implementing a game scoring system. The game has a concept of frames and a score that increases based on the duration of gameplay. The game has a function `Render()` that is called to update the game display. Your task is to write a function that calculates the score based on the given rules.
You a... | codefeedback |
You are tasked with creating a Python function that retrieves the number of stars for a given GitHub repository and the version of a specified package from the PyPI repository. You will need to use the GitHub API to fetch the number of stars for the repository and the PyPI API to retrieve the version of the package.
C... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.