instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with implementing a thread-safe storage preference system using Rust's atomic operations. The `AtomicStoragePreference` struct represents a storage preference value that can be updated atomically. The `StoragePreference` enum represents different storage preferences, and the `upgrade` method allows upgra...
codefeedback
You are tasked with creating a Python function that processes file paths and generates the appropriate command to open the file in the correct application. The function should take in the following parameters: - `server`: An object representing a server connection. - `secret`: A string representing a secret key for aut...
codefeedback
You are tasked with creating a PHP class that interacts with a database table using the CodeIgniter framework. Your goal is to extend the provided `MejaModel` class to include a method that retrieves specific data from the database table. Your task is to extend the `MejaModel` class with a method called `getMejaByStat...
codefeedback
You are tasked with creating a Python package that converts Jinja2 templates to HTML and PDF files. To achieve this, you need to implement a function that takes a Jinja2 template file, processes it with provided context data, and generates both an HTML file and a PDF file from the rendered template. Your task is to cr...
codefeedback
You are tasked with implementing a function to perform cubic interpolation for a given set of control points. Cubic interpolation is a method of constructing a smooth curve that passes through a set of given points. The function should take in four control points and a parameter `t` within the range [0, 1], and return ...
codefeedback
You are tasked with implementing a function to calculate the average waiting time for a set of processes in an operating system. The function should take in a list of processes, each represented by their arrival time and burst time, and return the average waiting time for these processes. The waiting time for a process...
codefeedback
You are tasked with implementing a function that simulates the behavior of a tokenizer for a pre-trained transformer model. The tokenizer takes a sentence as input and tokenizes it according to the rules of the model. The provided code snippet shows a test case for the tokenizer using the "bert-base-cased" model. The s...
codefeedback
You are tasked with implementing a Python class to calculate the weighted average of a set of indicators. The class should be able to accept a list of indicators, each with a key, factor, and name, and calculate the weighted average based on a group factor. The weighted average for each indicator is calculated by multi...
codefeedback
You are working on a data processing project and need to write a Python program to perform some data analysis and output the results to a CSV file. The program should read data from a nested dictionary `content`, perform calculations, and write the results to a CSV file using the `csv` module. The `content` dictionary...
codefeedback
You are tasked with implementing a custom PyTorch module for matching and shifting image features. The provided code snippet is a partial implementation of the `matchshifted` module, which takes two input tensors `left` and `right`, and a shift value, and produces a concatenated tensor of shifted left and right feature...
codefeedback
You are tasked with implementing a custom file output format class in Java for a data processing application. The class, `PythonOutputFormat`, extends the `FileOutputFormat` class and is responsible for managing a `PythonStreamer` object and handling multiple tasks. The `PythonOutputFormat` class has the following att...
codefeedback
You are working on a Django web application that manages university courses. The application has a module for registering different course modules, and the admin interface is used to manage these modules. The code snippet provided is from the admin.py file of the uicCourse app within the UICHCC repository. Your task i...
codefeedback
You are tasked with implementing a custom attribute macro in Rust that validates the length of a string input. The macro should be used to annotate a struct field and enforce a specific length constraint on the string value assigned to that field. Your task is to create a macro `at_arg` that takes two arguments: `posi...
codefeedback
You are tasked with implementing a C++ class that manages texture atlas data for the SFML library. The provided code snippet is the beginning of the implementation of the `SFMLTextureAtlasData` class. Your task is to complete the implementation of this class by adding necessary member variables and methods to manage te...
codefeedback
You are working as a DevOps engineer for a company that utilizes Docker for containerization and PostgreSQL for its database management system. As part of your responsibilities, you need to create a script to automate the backup process for the PostgreSQL database running in a Docker container. The provided code snippe...
codefeedback
You are given a function `double_it` that takes an integer as input and returns double the input value. However, the function seems to be producing unexpected results. Your task is to identify the issue with the given function and fix it to ensure that it correctly doubles the input value. You need to modify the `doub...
codefeedback
You are tasked with implementing a color utility class in a Swift application. The class should provide predefined color values for various shades of green, each represented as a hexadecimal color code and its corresponding RGB values. Your task is to create a Swift structure or enumeration to represent the predefined...
codefeedback
You are tasked with creating a program to manage product data in a warehouse. The program should be able to read and process a CSV file containing product information and perform various operations on the data. Each row in the CSV file represents a product and contains the following columns: "Producto", "Precio", "Obse...
codefeedback
You are tasked with implementing a function to parse and extract information from a given JSON object. The JSON object represents a command packet with various fields. The fields include "command", "devId", "uid", and "t". The "command" field contains a sub-object with "devId", "uid", and "t" fields. The "prefix" field...
codefeedback
You are tasked with creating a Swift function that processes incoming messages from a WebSocket connection. The function should parse the incoming message, extract specific data, and perform a series of operations based on the extracted information. You are given a code snippet that represents the beginning of the mes...
codefeedback
You are tasked with implementing a dropout function for a neural network library in Rust, utilizing the `wasm_bindgen` library for WebAssembly integration. The `handle_dropout` function is intended to take a `Tensor` as input and return a modified `Tensor` after applying the dropout operation. The `Tensor` type represe...
codefeedback
You are tasked with implementing a program that simulates a simple banking system. The program should support the following operations: creating a new bank account, depositing funds into an account, withdrawing funds from an account, and checking the balance of an account. Each account should have a unique account numb...
codefeedback
You are tasked with implementing a session management system for an online MBA (Master of Business Administration) program. The system should allow users to log in, view their course information, and log out. The user's session should be maintained throughout their interaction with the system. You are provided with a ...
codefeedback
You are tasked with implementing a simple dependency injection container in Swift. The container should be able to register dependencies and resolve them when requested. Your task is to create a DependencyContainer class with the following requirements: 1. The container should be able to register dependencies using a ...
codefeedback
You are working on a computer graphics project and need to implement a function to render orthographic projections of 3D objects. The function `render_prt_ortho` takes several parameters and is responsible for rendering the orthographic projections of a 3D object onto a 2D plane. Your task is to complete the implementa...
codefeedback
You are tasked with implementing a Python function that simulates a simple text-based game. The game involves a player navigating through a grid-based world, collecting treasures, and avoiding obstacles. The player's position in the grid is represented by (x, y) coordinates, where (0, 0) is the top-left corner. The gri...
codefeedback
You are tasked with implementing a queue naming strategy interface for a messaging system. The interface, `IQueueNamingStrategy`, defines two methods for generating queue names based on the message type or the message itself. The `GetName` method takes either a `Message` object or a `Type` object as input and returns t...
codefeedback
You are tasked with implementing a program that converts a given logical expression from an OR formulation to an AND formulation. The logical expression is represented as a string containing variables, logical operators (AND, OR), and parentheses. The program should take the input logical expression in OR formulation a...
codefeedback
You are working as a DevOps engineer for a company that is deploying a new application using Docker containers. As part of the deployment process, you need to automate the setup of a MySQL database within a Docker container. The company has provided you with a bash script that pulls the latest version of the MySQL serv...
codefeedback
You are tasked with creating a RESTful API for managing consume types in a financial application. The consume types are represented by the `ConsumeTypeEntity` class, and you need to implement the necessary endpoints using Spring Boot and the Spring Web framework. Your task is to create a Spring Boot controller that ha...
codefeedback
You are tasked with implementing a function to transpose a given matrix. Transposing a matrix involves converting its rows into columns and vice versa. Your task is to write a function `transpose_matrix(matrix)` that takes a 2D matrix as input and returns its transposed form. For example, given the input matrix: ``` m...
codefeedback
You are given a code snippet written in C++ that is intended to output either "YES" or "NO" based on certain conditions. However, the code is incomplete and contains a syntax error. Your task is to identify the error and fix the code to ensure that it behaves as intended. The original code snippet is as follows: ```cp...
codefeedback
You are tasked with creating a Vue component that manages user accounts. The component should render the account information and provide functionality to update and delete user accounts. You are provided with a code snippet that sets up a Vue component test using Jest and Vuex. Your task is to implement the Vue compone...
codefeedback
You are tasked with implementing a class that represents a generator in a custom data processing library. The class should support multiplication operations with other generators. The provided code snippet shows two methods, `mul_generators` and `rmul_generators`, which are used to multiply two generators together. The...
codefeedback
You are tasked with creating a program that analyzes the frequency of words in a given text. Your program should take a string of text as input and output the frequency of each word in the text. For the purpose of this problem, a word is defined as a sequence of alphanumeric characters (letters and digits) separated by...
codefeedback
You are given a set of coordinates representing atoms in a molecular structure. Each line of the input represents an atom and consists of the atom's symbol (one or two characters) followed by its x, y, and z coordinates. Your task is to write a program to calculate the distance between two specified atoms in the molecu...
codefeedback
You are tasked with implementing a custom hashing algorithm for a class in C#. The class has a method that returns a boolean value and an overridden `GetHashCode` method. Your goal is to create a custom hashing algorithm that generates a unique hash code for each instance of the class based on its properties and behavi...
codefeedback
You are given a 2D grid representing a map of a forest. The grid is composed of open squares (.) and trees (#). You are also provided with a toboggan rule engine that specifies the slope or pattern for toboggan movement. The toboggan can move through the grid in a specific pattern, and you need to calculate the number ...
codefeedback
You are tasked with creating a Python function to analyze the distribution of a specific feature within a dataset's metadata. The metadata is stored in a dictionary format, and each key-value pair represents a feature and its corresponding data. Your function should take the metadata dictionary and a feature name as in...
codefeedback
You are tasked with developing a build configuration system for a software project. The build configuration system is responsible for setting various options that control the build process. Each option can be either enabled or disabled, and the final build configuration is determined by the combination of these options...
codefeedback
You are given a binary tree in the form of a string representing its level order traversal. Each node in the tree has an integer value. You need to write a program to find the number of paths in the tree that sum up to a given target value. The input string represents the level order traversal of the binary tree, wher...
codefeedback
You are tasked with implementing a custom modifier system for a SwiftUI-like framework. The provided code snippet defines an extension for the `View` protocol, allowing the creation of custom modifiers. The `modifier` function takes a modifier as input and returns a `ModifiedContent` instance, which combines the origin...
codefeedback
You are tasked with implementing a function that can parse a Django migration file and extract the names of all the models being created. A Django migration file is a Python file that contains a series of operations to apply to the database schema, including creating, altering, or deleting models. Each model creation o...
codefeedback
You are tasked with creating a Python class that represents a user in a web application. The user class should have attributes for the user's name, email, password, and registration date. Additionally, the class should include a method to hash the user's password using the SHA-256 algorithm. You are provided with a cod...
codefeedback
You are tasked with implementing a memory management system for a custom data structure called `IntBlockPool`. The `IntBlockPool` is used to manage a pool of integer buffers and is responsible for allocating and resetting memory blocks. Your task is to implement the `reset` method for the `IntBlockPool` struct, which r...
codefeedback
You are tasked with implementing a Python class for training machine learning models. The class includes functionality for distributed training across multiple GPUs using PyTorch's DistributedDataParallel (DDP) module. Additionally, the class provides an option for verbose output during training. The provided code sni...
codefeedback
You are tasked with implementing a custom layout for a collection view in an iOS app. The layout, called WaterfallLayout, is designed to display items in a waterfall-like arrangement, where each column contains items of varying heights. The provided code snippet is a part of the prepare() method within the WaterfallLay...
codefeedback
You are tasked with implementing a constrained conjugate gradient algorithm for solving a specific optimization problem in the context of a fluid dynamics simulation. The problem involves finding the optimal pressure distribution in a fluid system subject to certain constraints. The given code snippet demonstrates the ...
codefeedback
You are tasked with simulating a granular synthesis process using Python. Granular synthesis is a technique used in electronic music production to create complex sounds by playing back small, overlapping snippets of audio called grains. Your goal is to implement a Python class that models a granular synthesis engine. ...
codefeedback
You are working on a project that involves creating a game environment with traversable nodes. Each node has a coordinate, vector, movement cost, slope status, and a list of adjacent cardinal nodes. Your task is to implement a method that constructs a new traversable node with modified coordinates and the same vector, ...
codefeedback
You are tasked with creating a Swift function that processes attributed text to identify and extract URLs. Your function should take an attributed string as input and return an array of URLs found within the attributed text. Your function signature should be: ```swift func extractURLs(from attributedText: NSAttributed...
codefeedback
You are tasked with creating a Python function that retrieves information about a GitHub repository using the GitHub API. The function should take the repository owner's username and the repository name as input and return the number of stars the repository has received. You are provided with a code snippet that initia...
codefeedback
You are tasked with implementing a caching mechanism for storing statistics related to champion performance in a video game. The provided code snippet is a part of a method that stores the statistics in the cache. The `key` is generated by formatting the class name, patch, and elo, and then the statistics item is store...
codefeedback
You are tasked with implementing a thread tracking system in Rust. The given code snippet is a part of a struct definition that includes fields for thread tracking. The `#[cfg(feature = "track_threads")]` attribute indicates that this code is conditionally compiled based on the presence of a feature named "track_thread...
codefeedback
You are tasked with implementing a file monitoring system in Python. Your task is to create a class that monitors a directory for file changes and updates. The class should have a method to continuously loop and check for file updates at a specified interval. Additionally, it should provide an option for asynchronous p...
codefeedback
You are tasked with creating a Python programming problem related to database migrations in Django. Your task is to create a function that simulates the process of applying database migrations to a Django project. In Django, database migrations are used to manage changes to the database schema over time. Each migratio...
codefeedback
You are tasked with creating a Python function that simulates a simplified version of a message queue system using asyncio. The function should establish a connection to the message queue server, publish a message to a specified topic, and then subscribe to the same topic to receive the published message. You are provi...
codefeedback
You are tasked with creating a script that securely retrieves a GitHub token from a specified file path and uses it to perform a specific action. The GitHub token is stored in a file, and the script needs to read the token from the file and utilize it for authentication purposes. Your task is to write a bash script tha...
codefeedback
You are given a series of sets, each containing distinct integers. Your task is to write a function that takes these sets as input and returns the intersection of all the sets. The intersection of sets is the set of elements that are common to all the sets. For example, given the following sets: ``` {2, 3} {4} {3, 4} ...
codefeedback
You are tasked with creating a Python function that extracts the version number from a given package's `__init__.py` file and appends a version identifier based on the commit count if the version ends with 'a', 'b', or 'rc'. The function should handle various scenarios and provide the final version number. Write a Pyt...
codefeedback
You are tasked with implementing a custom test framework for a C++ project. The framework should be able to handle test cases and provide a clear output of the test results. Your task is to create a class `TestFramework` with the following functionalities: 1. The class should have a method `addTest` that takes a test ...
codefeedback
You are working on a project that involves querying a graph database using the Gremlin query language. The code snippet provided is part of a C# library that interfaces with the graph database. The library contains methods for building and executing Gremlin queries. Your task is to implement a method that filters node...
codefeedback
You are tasked with implementing a Python class that filters and organizes images based on their associated labels. The class, named `ImageDataset`, has the following attributes and methods: Attributes: - `imgs_all`: A list of tuples, where each tuple contains an image and its corresponding label. - `n_class`: An inte...
codefeedback
You are working for a typography company that is developing a font correction tool. The tool is designed to apply specific fixes to fonts for web usage. Your task is to implement a function that applies these fixes to a given font. You are provided with a Python code snippet that demonstrates the usage of the font cor...
codefeedback
You are tasked with creating a Python function that processes a configuration dictionary based on a given module and request configuration. The function should handle different modules and their specific requirements. The configuration dictionary contains various parameters, and the function should modify it based on t...
codefeedback
You are tasked with implementing a class that manages resource bundle information for a refactoring tool. The class should handle the setting of an accessor package and the determination of a resource bundle name based on a given class reference. You are provided with a code snippet that demonstrates part of the funct...
codefeedback
You are working on a program to manage a library's collection of books. The program has a list of authors' names, and you need to sort them alphabetically by their last names. Each author's name is in the format "First Name Last Name". You are required to write a function that takes a list of author names and returns t...
codefeedback
You are tasked with creating a program to manage the delivery details for a logistics company. The program should allow users to input and store information about various deliveries, such as the delivery ID, recipient's name, delivery address, and delivery status. Additionally, the program should provide functionality ...
codefeedback
You are tasked with implementing a function that will parse a given HTML form and extract all the input fields along with their attributes. The function should take the HTML form as input and return a dictionary where the keys are the input field names and the values are dictionaries containing the attributes of each i...
codefeedback
You are tasked with creating a Python class that extends the functionality of a basic word counter. The class should be named `AdvancedWORC` and should inherit from the `BasicWORC` class provided in the `basicworc` module. The `BasicWORC` class has a method `count_words` that takes a string as input and returns the cou...
codefeedback
You are tasked with implementing a method to create an issue using a REST client in a Java application. The provided code snippet demonstrates the setup for this task. The `IssueLoader` class is responsible for creating issues using the `Client` instance, which is initialized with a server and an API key. However, the ...
codefeedback
You are tasked with implementing a function to validate and process coupon data for a coupon management system. The system receives coupon data in the form of an object with various properties. Your task is to create a function that takes this coupon data as input and performs the following tasks: 1. Validates the inpu...
codefeedback
You are working at a company where employees greet each other by performing "salutes". The company's office layout is represented by a one-dimensional hallway, where each position can be occupied by an employee facing either left ("<") or right (">"). When two employees meet, they perform a salute by raising their hand...
codefeedback
You are tasked with creating a program to simulate a traffic light system. The traffic light should cycle through the following states: green, yellow, and red, with specific durations for each state. Your program should use a loop to iterate through the states and simulate the appropriate time delays for each state. Y...
codefeedback
You are tasked with implementing a task runner utility that can execute a series of tasks in a specific order. Each task is represented by an object with properties `id`, `title`, `genFunc`, and `deployFunc`. The `id` is a unique identifier for the task, `title` is a descriptive title for the task, `genFunc` is a funct...
codefeedback
You are given a string `s`. Write a function `longestPalindrome` to find the longest palindromic substring in `s`. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward. For example, "level" and "radar" are palindromes. The function signature is: ```python def...
codefeedback
You are tasked with implementing a Python class that represents a worksheet and provides methods for accessing its data. The class should have the following functionalities: 1. A method `worksheets` that returns a list containing the worksheet itself. 2. A method `get_all_values` that returns the data contained within...
codefeedback
You are tasked with creating a command-line utility that processes template files based on user-defined variables. The utility should accept command-line arguments to specify the source directory, filename prefix, and template variable. Additionally, it should support a debug mode to enable additional logging and debug...
codefeedback
You are tasked with creating a Python function that processes a list of file paths and extracts specific information from each path. The function should take in a list of file paths and return a dictionary containing the index of each path, the folder name, and the file extension. The file paths are generated using th...
codefeedback
You are tasked with implementing a class that represents a collection of observable names. An observable name is a name that can be monitored for changes. Your task is to create a class `ObservableNames` that extends the `collections.namedtuple` class and adds the functionality to monitor changes to the names in the co...
codefeedback
You are working on a project that involves low-level memory manipulation in Swift. You need to understand and utilize pointer conversions to achieve the desired functionality. In Swift, pointers are used to interact with C APIs or perform low-level memory operations. The code snippet provided demonstrates the usage of ...
codefeedback
You are working on a machine learning project and need to implement a log probability calculation function for a statistical model. The function `log_probability` takes two parameters: `input`, which is a tensor representing input data, and `target`, which is a tensor representing target values. The function is a metho...
codefeedback
You are tasked with implementing a function to shuffle an array using the Fisher-Yates shuffle algorithm. The Fisher-Yates shuffle is an algorithm for generating a random permutation of a finite sequence. The algorithm produces an unbiased permutation: every permutation is equally likely. The algorithm effectively puts...
codefeedback
You are tasked with creating a Discord bot that can perform various tasks based on user input. The bot should be able to count the number of messages sent by a specific user within the last 100 messages in a channel, execute a sleep command for a specified duration, and search for a URL based on user input. Your task ...
codefeedback
You are tasked with creating a web application that displays different pages based on the URL path. The application uses the Blade templating engine, and the code snippet provided is from a file named `life.blade.php` located in the `resources/views/pages` directory. The content of the file includes an HTML `<h2>` tag ...
codefeedback
You are tasked with implementing a class method for a Django model that handles bulk actions on a queryset of instances. The method should delete the queryset instances from the database and then perform a specific action on each individual instance. You are given the following code snippet as a starting point: ```py...
codefeedback
You are tasked with creating a Python program that reads data from a file, performs Fast Fourier Transform (FFT) on the data, and then plots the FFT results. The input data is stored in a file named "fft-O0-sample.txt" and is formatted as follows: ``` 0.0 1.0 0.1 2.0 0.2 3.0 ... ``` Each line contains two space-separat...
codefeedback
You are tasked with implementing a simple state machine for a traffic signal system. The system should have three states: "Signal light off", "Red signal", and "Green signal". The traffic signal should transition from "Signal light off" to "Red signal" when a car is detected, and from "Red signal" to "Green signal" aft...
codefeedback
You are tasked with simulating a predator-prey model using the Lotka-Volterra equations. The Lotka-Volterra model describes the dynamics of biological systems in which two species interact, one as a predator and the other as prey. The model is governed by the following differential equations: \[ \frac{dP}{dt} = aP - b...
codefeedback
You are tasked with creating a Rust library for interfacing with a DHT22 temperature and humidity sensor. The provided code snippet is a part of the library implementation and shows the function `attach` being defined. Your task is to complete the implementation of the `attach` function to enable the library to work wi...
codefeedback
You are tasked with implementing a custom comparison function for a class called `FullscreenQuad`. The `FullscreenQuad` class has a member function `bool operator<(const FullscreenQuad& other) const` which is used to compare two `FullscreenQuad` objects. The comparison function should be implemented in such a way that ...
codefeedback
You are working on a build optimization tool for a web development project. The provided code snippet is a part of the build process and includes the `preprocess` function, which is responsible for preprocessing the project's source files before the actual build. The function imports and utilizes various modules such a...
codefeedback
You are tasked with creating a Python class for managing podcasts. The class should have methods for adding new podcasts, updating existing podcasts, and retrieving a list of podcasts based on certain criteria. Your task is to implement the `PodcastManager` class with the specified methods. The `PodcastManager` class ...
codefeedback
You are tasked with creating a Django migration to add a new field to an existing model. The model in question is `User` from the app `email_verification`. The new field to be added is `is_verified`, which will be a boolean field indicating whether the user's email has been verified. Your task is to write the migratio...
codefeedback
You are tasked with implementing a randomizer for two-handed voicings in a music application. Two-handed voicings are a technique used in piano playing where both hands are used to play chords in a harmonically rich and balanced manner. The randomizer should be designed as a module in the application and should be acce...
codefeedback
You are tasked with creating a Rust macro that generates code for creating a contract reference. Contract references are used to dynamically depend on a smart contract. Your task is to implement a macro that takes in the contract name and generates the necessary code for creating a reference to that contract. Your mac...
codefeedback
You are tasked with implementing a custom error handling system for a web application. The system should include a base error class and a specific error class for handling invalid field errors. Your task is to create the `AppError` base class and the `InvalidFieldError` class, ensuring that they handle error messages ...
codefeedback
You are tasked with implementing a Depth-First Search (DFS) algorithm for a graph traversal. The graph is represented using an adjacency list and the DFS algorithm should be implemented as a method within a Python class. You are given a code snippet that initializes some instance variables and calls the `__dfs` method...
codefeedback
You are tasked with implementing a class that interacts with Amazon DynamoDB using the provided `AmazonDynamoDbService` module. Your goal is to create a class called `DynamoDBManager` that encapsulates the functionality to perform basic operations such as adding an item, getting an item, updating an item, and deleting ...
codefeedback
You are tasked with creating a script to automate the generation of a configuration file for a bouncer service. The script should replace a placeholder in a template file with the actual path to the alert pipe and then save the modified content to a new file. You are given a template file named `bouncer_config_templat...
codefeedback