instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with implementing a program that can efficiently count the occurrences of a given word in a large text file. Your program should be able to handle very large files and provide accurate results in a timely manner. Your program should take as input a file path and a target word, and it should output the c...
codefeedback
You are working on a cryptocurrency project that involves note encryption and decryption. The code snippet provided is a part of the Zcash cryptocurrency library and includes declarations for `NoteEncryption` and `NoteDecryption` classes. Your task is to implement a function to generate a random 256-bit unsigned intege...
codefeedback
You are tasked with implementing a rate limiter module for a web application. The rate limiter should restrict the number of requests a client can make within a specified time window. To achieve this, you need to create a rate limiter module that enforces a maximum request limit per client within a given time frame. Y...
codefeedback
You are tasked with creating a utility function that combines the functionality of two existing utility functions for working with images in a web application. The existing utility functions are `getCanvas` and `loadImage`, both of which are imported from the `~utils/dom` module. Your task is to create a new utility f...
codefeedback
You are tasked with creating a Python function that processes a list of package repositories and returns the name of the repository with the highest priority. Each repository is represented as a string in the format "name-priority", where "name" is the repository name and "priority" is a numerical value indicating its ...
codefeedback
You are tasked with implementing a data augmentation pipeline for a computer vision model using the provided code snippet as a reference. The code snippet is part of a class constructor that initializes the data augmentation pipeline for a model. Your task is to create a function that applies the specified data transfo...
codefeedback
You are tasked with implementing a function that checks whether a given string contains a valid HTML closing tag. A valid closing tag must start with "</" followed by a tag name and end with ">". The tag name should consist of only lowercase letters and may contain hyphens. Additionally, the tag name should match the o...
codefeedback
You are tasked with implementing a validation system for a scheduling application. The application allows users to define scheduling rules using a cron expression, and depending on the type of trigger selected, additional validation rules need to be applied. Your task is to create a validation system that enforces the...
codefeedback
You are tasked with implementing a plugin system for a web server application. The server has the ability to load plugins, and each plugin can define its own routes for handling various requests. The code snippet provided shows the process of creating routes for different components of the server, such as user manageme...
codefeedback
You are working on a script to set up symbolic links for various configuration files in a user's home directory. The script should create symbolic links for the `.clang-format`, `.gdbinit`, `.gitconfig`, and `.bashrc` files from a specified directory (`$DIR`) to the user's home directory. If a symbolic link already exi...
codefeedback
You are tasked with implementing a function that simulates the behavior of a selection mechanism in a software application. The function should take in an array of items and a boolean flag indicating whether the selection should be toggled or set to a specific state. The function should then update the selection state ...
codefeedback
You are working on a project that involves processing and exporting layers from a PSD (Photoshop Document) file. The code snippet provided is a part of a shell script that performs some operations related to exporting layers from a PSD file using a tool called `psd-exporter`. The script echoes the results of a test, ex...
codefeedback
You are tasked with creating a Python program that manages a list of people's names. The program should allow users to add, remove, and display the names in the list. Additionally, it should provide the functionality to search for a specific name in the list. Your task is to implement the following functions: 1. `add...
codefeedback
You are tasked with implementing a shader system for a 3D game engine. The provided code snippet is a part of a method that iterates through a list of pairs, where each pair consists of a building and a corresponding 3D model. The method sets shader inputs for each model based on the properties of the associated buildi...
codefeedback
You are tasked with implementing a simple key-value store in Python using a dictionary. The key-value store should support setting default values for keys that have not been explicitly set. Your task is to create a class `KeyValueStore` with the following requirements: 1. The class should have a class variable `DEFAUL...
codefeedback
You are tasked with implementing a function that processes an input image according to a series of conditions. The function takes an image as input and performs the following operations: 1. If the image has more than 3 channels, only the first 3 channels are retained. 2. If a scaling factor other than 1.0 is provided,...
codefeedback
You are tasked with implementing a custom routing system for a web application framework. The provided code snippet is a part of a Python web framework and defines a class `StaticFiles` that handles static file serving. The `get` method of this class is responsible for serving static files based on the provided URL par...
codefeedback
You are tasked with implementing a Python function that performs matrix multiplication using a custom linear operator. The linear operator is defined by a given set of weights and a domain, and the matrix multiplication involves a set of input vectors and corresponding coefficients. The function takes in the following...
codefeedback
You are tasked with implementing a neural network layer using PyTorch. The layer involves several operations including matrix multiplication, transposition, activation functions, and softmax. Your goal is to write a Python function that takes an input tensor `x` and performs the necessary operations to produce an outpu...
codefeedback
You are tasked with creating a script to automate the installation and setup of a Buildkite agent on a Linux system. The Buildkite agent is a small, reliable, and cross-platform build runner that makes it easy to run automated builds on your own infrastructure. Your script should perform the following tasks: 1. Update...
codefeedback
You are tasked with implementing a function that processes a list of app descriptors and performs various operations based on the type of each descriptor. The function should handle the addition of new native applications, check for the existence of native applications, and commit a specific action to a cauldron. You a...
codefeedback
You are tasked with implementing a Python decorator that modifies the behavior of a given function. The decorator should wrap the output of the function in a fixed-width format before returning it. The fixed-width format should ensure that the output is limited to 80 characters per line. Your task is to complete the i...
codefeedback
You are tasked with creating a Python module that simulates a simple banking system. The module should include classes for a Bank, Account, and Transaction. The Bank class should be responsible for managing accounts and processing transactions, the Account class should represent a bank account with a balance and owner ...
codefeedback
You are tasked with implementing a function that checks if a given input is of a specific type. The function should take in two parameters: the input value and a type flag. If the type flag is set to true, the function should only check if the input is of the specified type. If the type flag is set to false, the functi...
codefeedback
You are tasked with implementing a generic class in TypeScript that represents a global object with a specific type for its properties. The class should allow adding, retrieving, and deleting properties, as well as providing a method to check if a property exists. You are given the following code snippet as a starting...
codefeedback
You are tasked with creating a Python script to automate the installation and initialization process of a Frappe application using the `frappe-bench` tool. The script should perform the following steps: 1. Install the `frappe-bench` package using `pip3`. 2. Check the successful installation of `frappe-bench` by displa...
codefeedback
You are working on a data acquisition system that communicates with a device using a custom protocol. The provided code snippet is a part of a Python class method that interacts with the device to read and process data. The method is responsible for sending a command to the device, reading the response, and then proces...
codefeedback
You are tasked with implementing a utility function for managing deep learning model state dictionaries. The function should handle three specific operations: building a model from a configuration, loading a state dictionary onto a model of the same size, and fixing the state dictionary of a model trained with differen...
codefeedback
You are tasked with implementing a Python function that processes a list of file paths and returns a dictionary containing the count of files with unique extensions. The function should ignore case sensitivity when comparing file extensions. The function signature is: ```python def count_unique_extensions(file_paths: ...
codefeedback
You are tasked with implementing a function to calculate the total number of internal sectors in a given 2D grid. An internal sector is defined as a contiguous area of the grid that is completely surrounded by filled cells. The grid is represented as a 2D array of characters, where 'X' represents a filled cell and '.' ...
codefeedback
You are tasked with creating a Swift data structure to manage migration callbacks for a software development kit (SDK). The SDK has various events and properties associated with it, and you need to design a suitable data structure to handle these callbacks. Your task is to create a Swift struct or class that can store...
codefeedback
You are tasked with creating a script to automate the process of updating a GitHub repository. Your script should perform the following steps: 1. Print a message indicating that the GitHub repository is being updated. 2. Change the working directory to a subdirectory named "public". 3. Add all changes in the "public" d...
codefeedback
You are tasked with implementing a simple game using Rust. The game involves flags, game moves, kinds, and stats. You are provided with a code snippet that imports modules from the `game` crate. Your task is to create a function that processes game moves and updates the game state accordingly. You are given the follow...
codefeedback
You are tasked with implementing a class method that processes a video file and generates screenshots based on specified quantiles. Additionally, the method should support uploading the generated screenshots to an image hosting service and a PTP image hosting service, if specified. You are given a Python class method ...
codefeedback
You are given a list of data points `X` and a reference distribution `reference_distribution`. Your task is to calculate the Mahalanobis distance for each data point in `X` with respect to the reference distribution. The Mahalanobis distance is a measure of the distance between a point and a distribution. It is a mult...
codefeedback
You are tasked with implementing a function to prepare a log record header in a logging system. The function `prepare_lrh` takes in five parameters: `csn` (commit sequence number), `checkpoint_csn` (checkpoint commit sequence number), `tsn` (transaction sequence number), and `rec_type` (record type). The function is re...
codefeedback
You are tasked with creating a Python script to process a given text using the spaCy library. Your script should perform the following tasks: 1. Install the necessary dependencies using conda and pip. 2. Download the English language model and the large English language model for spaCy. 3. Execute a bash script to down...
codefeedback
You are working on a project that involves processing a series of satellite images using Google Earth Engine (GEE). The code snippet provided is a part of the image processing pipeline. Your task is to complete the pipeline by implementing the missing functionality for exporting the processed images to Google Drive. Y...
codefeedback
You are tasked with creating a Python script to automate the process of cracking passwords using the Hashcat tool. Hashcat is a popular password cracking tool that uses the power of GPUs to crack passwords through brute force, rule-based, and dictionary attacks. Your script will need to interact with Hashcat, manage di...
codefeedback
You are tasked with creating a class that represents a website user's visit history. The class should track the time of the user's last visit and provide methods to update and retrieve this information. You are provided with a code snippet that includes a private member variable `$timeLastVisit` of type `DateTime`. Yo...
codefeedback
You are tasked with creating a command-line interface for a chatbot. The chatbot has a set of predefined commands stored in a dictionary called `cmds`. The code snippet provided is a part of the command processing logic. The snippet is written in Python and uses the `html` module for escaping HTML characters. The snip...
codefeedback
You are tasked with creating a script to automate the execution of a series of commands for processing network packet capture files using a program called "asterix". The script should update tests by running the "asterix" program with various options and input files, and then redirect the output to specific files. The...
codefeedback
You are tasked with creating a reinforcement learning algorithm to train an agent to navigate a grid environment. The environment is represented by a grid with `nx` cells, and the agent can move between cells by taking actions. The agent's policy is represented by a function `policy(s)` that takes the current state `s`...
codefeedback
You are tasked with implementing a Python function that performs encryption using a given cipher algorithm. The function should handle different encryption modes and initialization vectors (IVs) based on the input parameters. The function should encrypt a given message using the provided key and return the resulting ci...
codefeedback
You are tasked with implementing a function that processes a series of protocol buffer messages. The function should handle the merging of sub-messages and building partial messages based on the given code snippet. The code snippet provided is a part of a larger program that processes protocol buffer messages. It show...
codefeedback
You are tasked with implementing a note-taking application using Python. Your goal is to create a class `NoteRepository` that allows users to create and manage notes within different notebooks. The `NoteRepository` class should have a static method `create` that enables users to create a new note within a specified not...
codefeedback
You are tasked with understanding and optimizing a build process for a software project. The build process is currently using a combination of CMake and Ninja to compile and install the software. Your goal is to identify potential improvements to the build process and suggest modifications to the given code snippet. T...
codefeedback
You are tasked with implementing a simplified version of the Fragment management system in an Android application. The application has a main activity that can display different fragments based on user interactions. The code snippet provided is a part of the logic responsible for managing the display of the "Settings" ...
codefeedback
You are tasked with creating a Python function that simulates a data preprocessing pipeline for a machine learning project. The pipeline consists of several steps, including loading data, dropping redundant columns, reshaping the data, encoding categorical columns, and performing data sampling. Additionally, the code s...
codefeedback
You are tasked with creating a program to manage a custom voice model for a speech synthesis service. The custom voice model contains words and their translations, and it has a limit of 20,000 entries. Your program should allow users to update the metadata of the voice model, including the name, description, and the wo...
codefeedback
You are tasked with creating a program that analyzes a given source code file to count the occurrences of specific license-related comments. In this problem, you are to focus on counting the occurrences of the phrases "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE" and "GNU General Public License" within the comm...
codefeedback
You are tasked with implementing a function that calculates the total area of a series of rectangles on a 2D plane. Each rectangle is represented by its top-left and bottom-right coordinates. The total area is the sum of the individual areas of the rectangles, excluding any overlapping regions. You need to write a fun...
codefeedback
You are tasked with implementing a function to calculate the MD5 hash of a given input string. The MD5 (Message Digest Algorithm 5) is a widely used cryptographic hash function that produces a 128-bit (16-byte) hash value. The hash is typically represented as a 32-character hexadecimal number. The function should take ...
codefeedback
You are tasked with creating a custom control in WPF (Windows Presentation Foundation) that displays a list of items in a specific format. The control should be named `CustomListBox` and should inherit from the `ListBox` class. The `CustomListBox` should have the following features: 1. Each item in the list should be d...
codefeedback
You are tasked with implementing a clustering algorithm using the ROCK (RObust Clustering using linKs) method. The ROCK algorithm is a density-based clustering algorithm that can identify clusters of arbitrary shapes and sizes in a dataset. The algorithm is implemented using the following code snippet: ```python sampl...
codefeedback
You are tasked with implementing a function to encode two ASCII digits into a single Unicode character. The function should take two ASCII digits as input and return the corresponding Unicode character after performing a specific calculation. You are given the following code snippet as a starting point: ```cpp namespa...
codefeedback
You are tasked with implementing a Python function that builds a nearest neighbor search tree based on the dimensionality of the input data. The function should create a KDTree for low-dimensional data (3 or fewer dimensions) and a BallTree for high-dimensional data (more than 3 dimensions). The choice of distance metr...
codefeedback
You are tasked with implementing a custom window procedure for a property page in a Windows application. The custom window procedure should handle specific messages and perform appropriate actions based on the message type. You are given the following code snippet as a starting point: ```cpp return CPropertyPage::Wind...
codefeedback
You are tasked with implementing a function to calculate the Discrete Cosine Transform (DCT) of a given image using the Fast Fourier Transform (FFT) library. The input image is represented as a 2D array of real numbers, and the DCT is to be computed along both dimensions. The code snippet provided is a part of a larger...
codefeedback
You are given a 6x6 grid representing a chessboard. Each cell of the grid is denoted by its row and column indices, both ranging from 0 to 5. The grid is represented as a 2D array with 6 rows and 6 columns. Your task is to write a function that, given the row and column indices of a cell on the chessboard, returns the...
codefeedback
You are tasked with creating a script to automate the process of assigning roles to users in a web application's authentication system. The script will interact with the authentication server's API using the `curl` command and process the JSON responses using `jq`. Your task is to complete the script by adding the nec...
codefeedback
You are tasked with implementing a function that parses and processes SVG icon data to extract specific information. The SVG icon data is represented as a React component, and the function should extract the display name and the number of paths in the icon. Write a function `parseSVGIcon` that takes the SVG icon data ...
codefeedback
You are tasked with implementing a custom asynchronous file reader in C#. Your task is to create a class `CustomFileReader` that provides a method `ReadFileAsync` to read the contents of a file asynchronously and return the content as a string. The `CustomFileReader` class should utilize the `System.IO` namespace for f...
codefeedback
You are tasked with implementing a user management system for a web application. The system should allow for the creation, retrieval, updating, and deletion of user records. The user records should include fields for the user's name, email, and role. Additionally, the system should enforce the following role-based acce...
codefeedback
You are tasked with implementing a class that manages the initialization and closing of Kafka consumer instances for processing messages from different topic partitions. The class should provide methods for initializing the consumer and closing the consumer connection. The `Initialize` method should return a dictionary...
codefeedback
You are tasked with creating a program that simulates a simple banking system. The program should allow users to create accounts, deposit and withdraw funds, and check their balance. Each account should have a unique account number, and the program should support multiple accounts. Your task is to implement the `Bank`...
codefeedback
You are tasked with implementing a function that constructs a child realm map based on the given component declaration. A child realm map is a data structure that maps child monikers to their respective realms. Each realm is associated with a child component and contains information about the component's execution envi...
codefeedback
You are tasked with creating a word cloud generator using Python. A word cloud is a visual representation of text data, where the size of each word indicates its frequency or importance within the text. Your task is to implement a function that takes a string of text as input and generates a word cloud based on the fre...
codefeedback
You are tasked with implementing a function to manipulate the visibility of a view in an Android application. The function should take in an integer array representing the visibility states of multiple views and return the number of views that are set to `ViewStates.Gone`. The function signature is: ```java public int...
codefeedback
You are tasked with creating a simple CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) image generator using PHP. Your task is to write a PHP script that generates a random 6-character alphanumeric string, places it on a JPEG image, and then displays the image as a CAPTCHA. Your PHP...
codefeedback
You are tasked with creating a script that will organize and execute a series of startup scripts based on specific criteria. The startup scripts are named in a specific format: `start_<name>.sh`. Your script should be able to identify and execute these startup scripts based on the following rules: 1. If the script name...
codefeedback
You are tasked with implementing a function that converts an integer to a string without using any built-in conversion functions or libraries. Your function should take an integer as input and return a string representation of that integer. You should not use any external libraries or functions that directly convert in...
codefeedback
You are given a list of tuples, where each tuple represents a test case for a license plate validation system. Each tuple contains the following elements: 1. A string representing a license plate number. 2. An integer representing the expected result of the validation test. 3. A tuple of tuples, where each inner tuple ...
codefeedback
You are working on a project that involves linear algebra computations using Python's NumPy library. As part of this project, you need to create a function that performs a specific matrix operation. The operation involves replacing a specific column of a given matrix with a given vector and then calculating the determi...
codefeedback
You are tasked with implementing a simple caching mechanism for an Apollo Client in a web application. The provided code snippet includes a function `getClient` that is responsible for retrieving the Apollo Client instance from the window object using a predefined key `APOLLO_KEY`. Your task is to extend this code to i...
codefeedback
You are tasked with implementing a class that manages the configuration and staging of sandbox environments for a software deployment system. The class should provide methods for configuring a node, performing a preflight check, generating a unique key, configuring a sandbox, and staging the configured sandbox. You ne...
codefeedback
You are given a singly linked list and a positive integer `k`. Your task is to rotate the linked list to the right by `k` places. This means that the last `k` nodes of the linked list will be moved to the front, and the rest of the elements will move to the right. For example, if the linked list is `1 -> 2 -> 3 -> 4 -...
codefeedback
You are tasked with implementing a function that converts a given number of seconds into a human-readable format. The function should take an integer value representing the number of seconds and return a string with the humanized value. The humanized value should be in the form of weeks, days, hours, minutes, and secon...
codefeedback
You are tasked with creating a Python class that simulates a smart home device adapter for controlling various smart home devices. The adapter class should be able to register new devices and provide a method to control these devices. You are provided with a code snippet that shows a dictionary `moes_adapters` contain...
codefeedback
You are tasked with developing a program to analyze a given text and extract specific information from it. The text contains a series of rules and guidelines for a system called CONTA. Each rule is numbered and followed by a statement. Your program needs to extract the rule numbers and the corresponding statements from...
codefeedback
You are tasked with creating a Rust program that processes images using the `imagefmt` crate and accepts command-line arguments using the `docopt` crate. Your program should read an input image file, convert it to grayscale, and save the grayscale image to a specified output file. Your program should accept the follow...
codefeedback
You are tasked with creating a Python function that processes data from multiple files and generates a summary report. The function should read data from a set of files, perform calculations, and produce a report based on the processed data. You are given a code snippet that iterates through unique run IDs and reads d...
codefeedback
You are tasked with implementing a priority queue data structure in C++. The priority queue should support the following operations: 1. `del_pdq`: Delete the highest priority element from the priority queue. 2. `snd_pdq`: Insert an element into the priority queue with a specified priority. 3. `psnd_pdq`: Insert an ele...
codefeedback
You are given a list `head_medica` containing a single string element. The string consists of comma-separated medical class codes, where each code is in the format "Class-{number}-{code}". The number and code are separated by a hyphen. The task is to write a function `count_medical_codes` to count the occurrences of ea...
codefeedback
You are working as a DevOps engineer for a company managing a large number of virtual machines (VMs) in a vSphere environment. Your task is to automate the process of powering on VMs that are currently in a powered-off state using Ansible. You have been provided with a JSON file, `vmfact.json`, containing information ...
codefeedback
You are working on a project that involves computing tree decompositions for a graph-based model. The code snippet provided is part of a test suite for the tree decomposition computation module. The `tree_decomp` is computed using the `compute_tree_decomposition()` method of `td_comp`, and then it is asserted that the ...
codefeedback
You are tasked with creating a Java program that manages the scheduling of appointments for a medical clinic. The program should utilize the Java Time API for handling date and time operations, and it should integrate with the Spring Framework for dependency injection and transaction management. Your task is to implem...
codefeedback
You are tasked with creating a script to automate the deployment of a software application. The script should handle the copying of the application executable to a parent directory based on certain conditions. Your script should check if a directory named "Release" exists. If it does, the script should copy the file "...
codefeedback
You are tasked with implementing a hash map data structure with a remove method. The hash map is represented as a linear probing hash table, and the remove method should take a hash value and a closure to determine equality. The closure will be used to compare keys and values in the hash map. Your task is to implement...
codefeedback
You are tasked with creating a Python class that simulates a simple 1D wave propagation using the Clawpack library. The code snippet provided is a part of a larger program that sets up the solver for the simulation. Your task is to complete the implementation of the simulation class by adding methods to initialize the ...
codefeedback
You are tasked with creating a Bash script that processes a given directory and its subdirectories to find all files with a specific file extension. Your script should then calculate the total size of all these files and print the result in a human-readable format. Your Bash script should accept two command-line argum...
codefeedback
You are tasked with creating a Python function that processes a given text file and extracts the license information from it. The text file contains a software license agreement in the form of comments, similar to the code snippet provided. Your function should read the file, extract the license information, and return...
codefeedback
You are tasked with implementing a Java program to process a collection of words and count the frequency of each word. Your program should read a text file containing words separated by spaces and output the count of each unique word in the file. Additionally, the program should ignore punctuation and be case-insensiti...
codefeedback
You are working on a Python project for managing data related to livestock farming. The project has a package named `ganaderia` which contains several modules for different aspects of livestock management. The given code snippet is from a file named `__init__.py` within the `ganaderia` package. It is importing three mo...
codefeedback
You are tasked with implementing a function that creates and runs a set of subprocesses based on a given configuration. The configuration specifies the details of the subprocesses to be created and run. Each subprocess is expected to perform a specific task based on the configuration provided. You are given the follow...
codefeedback
You are tasked with creating a Python class that generates a graph using the Kivy library. The class should have a method called `build` which initializes and returns a Kivy layout containing a graph with a sinusoidal plot. Your task is to complete the `build` method by creating the necessary Kivy widgets and adding a...
codefeedback
You are tasked with creating a Java program that processes a given source code to extract specific model content declarations. The program should utilize regular expressions to identify and extract the model content declarations from the source code. You are provided with a code snippet that includes the declaration o...
codefeedback
You are tasked with implementing a blockchain data structure in Python. A blockchain consists of a series of blocks, each containing a list of transactions and a reference to the previous block. Each block also has a hash size and a challenge level associated with it. The hash size represents the size of the hash used ...
codefeedback
You are tasked with creating a script to automate the process of uploading files to Dropbox using a custom uploader script. The script should create a specific subfolder in Dropbox and then upload files to that subfolder. You are given a code snippet that partially demonstrates this process. The code snippet provided ...
codefeedback
You are tasked with implementing a synchronous wrapper for asynchronous methods in C#. The goal is to create a method that can call an asynchronous method and return its result synchronously. You need to ensure that the synchronous wrapper does not block the calling thread and handles any exceptions thrown by the async...
codefeedback