instruction_seed stringlengths 0 26.4k | source stringclasses 4
values |
|---|---|
You are tasked with implementing a version control system that supports submodules. A submodule is a separate Git repository embedded within a parent repository. Your goal is to create a class `VersionControl` with the following methods:
1. `add_submodule(subdir: str, url: str, checkout: str)`: This method should add ... | codefeedback |
You are working on a project that involves simulating the execution of MIPS assembly language instructions. You have access to the `geco.mips` module, which provides functionalities for working with MIPS instructions and registers.
Your task is to create a Python function that takes a list of MIPS assembly instruction... | codefeedback |
You are tasked with implementing a function that processes and trains a machine learning model using a given dataset. The function takes in various parameters and performs different operations based on the provided flags. Your task is to complete the function by implementing the missing parts and ensuring that the mode... | codefeedback |
You are tasked with implementing a function that manipulates tilemap objects in a game environment. The function should take a parent game object and an integer as input and create a new tilemap game object with a specific sorting order. Additionally, the function should add a composite collider to the provided collide... | codefeedback |
You are tasked with implementing a simple parser for a custom programming language. The language supports while loops and basic arithmetic expressions. The parser is expected to produce an Abstract Syntax Tree (AST) from the input tokens. The provided code snippet contains assertions that validate the correctness of th... | codefeedback |
You are tasked with implementing a Python function that processes a given dataset using a machine learning classifier. The dataset consists of two arrays, `x` and `t`, where `x` represents the input features and `t` represents the target values. The code snippet provided shows a transformation of the `t` array using a ... | codefeedback |
You are tasked with creating a Python module that manages controllers for a financial data export service. The module should contain classes for different controllers, each responsible for exporting data from a specific trading session to a database. The provided code snippet is a partial example of such a module.
You... | codefeedback |
You are tasked with implementing a scoring system for a game. The game involves rolling five dice and scoring points based on the combination of the rolled dice. The scoring system is based on various combinations such as three of a kind, four of a kind, full house, small straight, large straight, and chance.
Your tas... | codefeedback |
You are tasked with creating a Python function that interacts with a web application using Selenium and Django's LiveServerTestCase. The web application is designed to manage information about animals, and the function needs to test the creation of a new animal entry.
You are provided with a code snippet that sets up ... | codefeedback |
You are tasked with implementing a function that calculates the direction of the sun based on the given timestamp and geographic coordinates. The function should handle both 2D and 3D cases, where the 3D case involves a viewport with latitude and longitude, and the 2D case involves x, y, and z coordinates.
Write a fun... | codefeedback |
You are tasked with creating a script to automate the setup and deployment of a static web application and its associated API using Azure Static Web Apps and Azure Functions. Your script should install the necessary tools and start the application and API locally for development and testing purposes.
Given the provide... | codefeedback |
You are tasked with creating a Python package version checker. Your program should take a user-input version number and compare it to a predefined version number within the package. The version numbers are in the format "YYYY.MM.DD" (Year, Month, Day). Your program should output whether the user-input version is the sa... | codefeedback |
You are tasked with creating a Python script that automates the testing of a command-line interface (CLI) module. The script should be able to execute tests independently or be integrated into a larger test suite. It is important to ensure that the correct version of the module is being tested, especially when the libr... | codefeedback |
You are working on a Django project that involves a model called `BitFieldTestModel`. This model has a field named `flags`, which is a bit field representing various flags. The `flags` field is defined using the `django_bitfield.BitField` class, allowing for bitwise operations on the flags.
The code snippet provided i... | codefeedback |
You are tasked with implementing a function to calculate the final discounted price of a product based on its original price and the discount percentage. The function should take the original price and the discount percentage as input and return the final discounted price. The final discounted price should be formatted... | codefeedback |
You are tasked with creating a regular expression pattern to match and extract specific types of tokens from a given input string. The tokens to be matched include currency amounts, percentages, and ellipses. The currency amounts can be in the format of $12.40 or $100,000. The percentages can be in the format of 82% or... | codefeedback |
You are tasked with creating a program that simulates a simple banking system. The program should be able to handle basic banking operations such as account creation, deposit, withdrawal, and balance inquiry.
Your task is to implement a `Bank` struct and associated methods to support the required banking operations. T... | codefeedback |
You are tasked with implementing a secure authentication mechanism for a web application. The provided code snippet is a part of a Django view that handles the callback from a third-party authentication service. The view expects a GET request with parameters `state` and `code`. It then validates the `state` parameter a... | codefeedback |
You are tasked with creating a Python function to preprocess and load training and validation data for a machine learning model. The training data is stored in a TensorFlow dataset and the validation data is stored in NumPy arrays. Your task is to implement the function `load_data` that takes in the paths to the traini... | codefeedback |
You are tasked with creating a script to generate ISO images for different software distributions. The script should take in various parameters and create an ISO image accordingly.
Write a shell script named `mkisoimages.sh` that takes the following parameters:
- `-b` (optional): Indicates that the ISO image should be... | codefeedback |
You are tasked with implementing a Python function that converts a given input to a boolean value. The function should handle various input types and return the corresponding boolean value based on the input rules.
You are provided with a partial code snippet that includes a `config` function and a `convert_bool` func... | codefeedback |
You are tasked with implementing a data structure to represent 3D objects in a graphics application. The structure should include optional fields for the object's name and rotation. The rotation is represented using a unit quaternion, which is a 4-dimensional vector. Additionally, the structure should support serializa... | codefeedback |
You are tasked with creating a script to automate the waiting process for the availability of specific services on different hosts and ports. The script should utilize environment variables and a custom `wait-for.sh` script to wait for the services to become accessible.
The provided code snippet sets the `MHOST` envir... | codefeedback |
You are tasked with implementing a function that takes a list of integers as input and returns a string representation of the list in reverse order.
Write a function `reverse_list_to_string` that takes a list of integers `input_list` as its parameter and returns a string representation of the list in reverse order. Th... | codefeedback |
You are tasked with creating a unit test for a component in an Angular application. The component, `XmUserLoginWidgetComponent`, is responsible for rendering a user login widget. The test environment is set up using Angular's TestBed and the component is to be tested in isolation. Additionally, a mock service, `MockUse... | codefeedback |
You are tasked with creating a Python function that analyzes a given directory and its subdirectories to count the number of Python files that import specific modules. Your function should take the directory path and the module names as input and return a dictionary with the module names as keys and the count of Python... | codefeedback |
You are tasked with implementing a Python decorator that caches the results of a function to a file. The decorator should check if the cache file exists and is not expired before calling the function. If the cache file exists and is valid, the decorator should return the cached result without calling the function. If t... | codefeedback |
You are tasked with implementing a middleware system for a web framework in Rust. The middleware system should allow for the insertion of middleware functions that can modify the incoming request and outgoing response. The provided code snippet demonstrates the usage of the middleware system, where the `any` variable i... | codefeedback |
You are tasked with implementing a function `do_it(hex_str)` that takes a hexadecimal string as input and returns the corresponding ASCII string after decoding the hexadecimal representation.
The function should perform the following steps:
1. Convert the input hexadecimal string to its binary representation.
2. Decod... | codefeedback |
You are tasked with implementing a simple identity provider system that generates unique user IDs for a given username. The system should assign a unique numerical ID to each username, starting from 1 and incrementing by 1 for each new username. Your task is to create a class `IdentityProvider` with the following metho... | codefeedback |
You are tasked with creating a script to automate the installation of Java Development Kit (JDK) on a Linux system. The script should handle the download, validation, and extraction of the JDK archive. Additionally, it should check if the JDK is already installed and skip the installation if it is. Below is a partial s... | codefeedback |
You are tasked with implementing a function that calculates the total number of parameters in a given neural network model. The parameters include both trainable and non-trainable parameters such as weights, biases, and other model parameters.
You are given a code snippet that represents a function with incomplete imp... | codefeedback |
You are tasked with implementing a custom serialization packer for a networking library in C#. The serialization packer should be able to serialize and deserialize objects to and from a byte array. The packer should support various data types and handle the serialization and deserialization process efficiently.
You ar... | codefeedback |
You are tasked with implementing a MIDI event handling system. MIDI (Musical Instrument Digital Interface) is a technical standard that describes a protocol, digital interface, and connectors that allow a wide variety of electronic musical instruments, computers, and other related devices to connect and communicate wit... | codefeedback |
You are working on a computer vision project and need to write a Python function to find the extreme points of a contour in an image using the OpenCV library. The function should take an input image and return the coordinates of the extreme points of the contour.
Write a Python function called `find_extreme_points` th... | codefeedback |
You are working on a project that involves interacting with a distributed configuration management system. The system uses a combination of Zookeeper and a custom SDK called `huskar_sdk_v2` to manage and retrieve configuration data. Your task is to write a Python function that retrieves a specific configuration value f... | codefeedback |
You are tasked with implementing a Python class that represents a hierarchical structure of namespaces and types. The structure consists of members, each of which can be a namespace or a type. A type can be either a simple type or a namespaced type. A namespaced type is a type that belongs to one or more namespaces.
Y... | codefeedback |
You are tasked with implementing a modal component for a web application. The modal component should be able to display various types of content, such as text, images, forms, or custom components, and provide the ability to close the modal when the user interacts with it.
Your task is to create a JavaScript class for ... | codefeedback |
You are tasked with creating a Python class that manages the installation and versioning of packages for a software project. Your class should be able to handle the addition of new packages, updating package versions, and providing a description of the installed packages. The class should also have the ability to store... | codefeedback |
You are tasked with implementing a key-logging functionality in a C# application. To achieve this, you need to create a delegate for a key-sniffer callback function that will be used to capture key events. The delegate should take in parameters representing the input character, key flags, virtual key, and a reference t... | codefeedback |
You are tasked with creating a Python program that processes a given XML file and extracts specific information from it. The XML file contains data related to various methods and their associated attributes. Your program needs to parse the XML file, extract the relevant information, and perform specific operations base... | codefeedback |
You are tasked with creating a Rust program that processes data from a Mentat database using the `mentat_db` crate. The Mentat database is a powerful, scalable, and efficient database designed for complex data queries. Your program will need to perform specific operations on the data and produce a desired output.
Your... | codefeedback |
You are tasked with implementing a Python decorator that wraps boolean operations for label expressions in a GIS (Geographic Information System) application. The decorator should handle the logical AND, OR, and NOT operations for label expressions used in GIS mapping.
Your task is to complete the implementation of the... | codefeedback |
You are tasked with creating a program that can parse and analyze PHP code to extract specific information. Your program should be able to identify and extract the content within PHP sections, such as sections defined by `<?php ... ?>` tags, and perform a specific operation on the extracted content.
Write a function o... | codefeedback |
You are working on a cryptocurrency investment platform called Krypfolio. The platform allows users to allocate their investments across different cryptocurrencies based on a specified allocation strategy. The code snippet provided is a part of a Python class method that is responsible for checking the validity of an a... | codefeedback |
You are working on a web application framework that includes an admin module for managing various models. The code snippet provided is a part of the framework's routing system, which maps URLs to handler classes and their methods. Your task is to implement a function that retrieves the application routes for the admin ... | codefeedback |
You are tasked with creating a Python script that automates the testing process for a project using the `py.test` framework. The script should run the tests in parallel using 4 processes, disable socket communication, treat runtime warnings as errors, measure test coverage, generate an HTML coverage report, and fail if... | codefeedback |
You are tasked with creating a Python function that utilizes the `phonemizer` library to convert a given text into its phonetic representation. The `phonemizer` library provides a function `phonemize` that takes text as input and returns its phonetic representation based on the specified language and accent.
You need ... | codefeedback |
You are tasked with implementing a submission processing system for a plugin-based API. The provided code snippet is a part of this system and includes a `Log` class for logging API activities and a function `run_submission` to process incoming data. The `run_submission` function checks for the presence of certain fiel... | codefeedback |
You are tasked with implementing a custom mapping function in Swift that can convert a dictionary to a specific data structure. The data structure is defined by a struct with properties that correspond to the keys in the dictionary. Your task is to create a function that takes a dictionary and a struct type as input, a... | codefeedback |
You are tasked with implementing a custom clock interface in Java. The interface should provide methods for retrieving the current time and the elapsed time since system boot.
Your task is to create a class that implements the given interface and provides the required functionality. You should also write a method to c... | codefeedback |
You are given a list of integers representing a rotated version of a sorted array. Your task is to write a function to find the minimum element in this rotated array. The rotated array is formed by splitting the original sorted array into two non-empty subarrays and reversing their order. For example, the original sort... | codefeedback |
You are tasked with creating a function that validates a given URL based on specific criteria. The function should take a URL as input and return a boolean value indicating whether the URL meets the specified requirements.
The URL validation criteria are as follows:
1. The URL must start with either "http://" or "http... | codefeedback |
You are tasked with creating a Python program to simulate a simple game using the BBC micro:bit. The game involves controlling a scrolling action using the micro:bit's accelerometer and button A. The program should display a happy face on the micro:bit's LED matrix and then continuously check for button A presses. When... | codefeedback |
You are tasked with creating a Python function that simulates a simple robotic arm reaching for a target in a 2D environment. The function will take in the initial position of the robotic arm and the target position, and return a sequence of images representing the arm's movement towards the target.
The function signa... | codefeedback |
You are tasked with implementing a class that manages notes for a graphical user interface (GUI) component. The class should provide methods to set a tooltip for the header, label, and note indicator, as well as a method to toggle the visibility of the note indicator. Additionally, the class should ensure that the visi... | codefeedback |
You are tasked with creating a Python decorator that measures the execution time of a given function and prints the elapsed time in milliseconds. The decorator should be implemented using the `async` and `await` keywords to support asynchronous functions. You should also utilize the `asyncio` library for managing async... | codefeedback |
You are tasked with implementing a function to calculate the derivative of a given mathematical function using the finite difference method. The finite difference method is a numerical technique for estimating the derivative of a function at a particular point by evaluating the function at nearby points.
You are give... | codefeedback |
You are tasked with implementing a simplified version of a BitSet data structure in C++. A BitSet is a fixed-size collection of bits, where each bit represents a boolean value (0 for false, 1 for true). The BitSet supports basic operations such as setting a bit, clearing a bit, checking if a bit is set, and performing ... | codefeedback |
You are working on a project that involves training a neural network using TensorFlow. As part of the training process, you need to restore an embedding matrix from a specified path and then initialize the remaining variables before starting the training. Additionally, you are required to create a summary writer for lo... | codefeedback |
You are tasked with exploiting a buffer overflow vulnerability in a simple program to gain control over the instruction pointer and redirect the program flow to execute arbitrary code. The provided code snippet is part of the vulnerable program, and your goal is to craft a payload that will exploit the program and gain... | codefeedback |
You are tasked with creating a C++ program that interacts with various libraries and interfaces to manage the power state of a system. The program will utilize the provided libraries and interfaces to query and set the power state of the system based on certain conditions.
The program should perform the following task... | codefeedback |
You are tasked with implementing a program that can analyze the structure of an HTML file and determine the nesting level of each HTML tag. The nesting level of a tag is defined as the number of ancestor tags it is contained within. For example, a tag directly inside the `<body>` tag would have a nesting level of 1, wh... | codefeedback |
You are tasked with implementing a text transformation function that replaces certain characters in a string based on a given dictionary mapping. The mapping consists of multiple letter definitions, where each key-value pair represents a character and its corresponding replacement string. If the input character matches... | codefeedback |
You are tasked with implementing a function to filter and extract specific items from a Genomic Feature Format (GFF) file based on certain attributes. The GFF file contains information about genomic features such as genes, transcripts, and proteins, and is structured in a tab-delimited format with nine columns represen... | codefeedback |
You are required to implement a function `decodeString` that takes a string `s` as input and returns the decoded string. The input string `s` is encoded in a specific format where some substrings are repeated multiple times.
The encoding rule is: `k[encoded_string]`, where the `encoded_string` inside the square bracke... | codefeedback |
You are tasked with implementing a function that securely stores a user's authentication token in the browser's local storage. The function should take an authentication token as a parameter and store it in the local storage using a secure approach.
Write a function `setToLocalStorage` that takes an object with an `au... | codefeedback |
You are working on an Angular application that manages user roles and permissions. The code snippet provided is a part of the Angular component for the admin interface. Your task is to implement a feature that restricts access to certain sections of the admin interface based on the user's role.
You have the following ... | codefeedback |
You are tasked with implementing a class for managing enemies in a 2D game. The class, `Enemy`, has the following attributes and behaviors:
Attributes:
- `sprites`: A pointer to the texture containing the sprites for the enemies.
- `life`: An integer representing the remaining life of the enemy.
- `score`: An integer ... | codefeedback |
You are tasked with creating a script to parse and validate the configuration parameters for an etcd (distributed key-value store) instance. The etcd configuration is provided as a command-line snippet, and your script should extract and validate the following parameters:
- `data-dir`: The directory path for storing th... | codefeedback |
You are tasked with implementing a function to set the state of specific tasks within a directed acyclic graph (DAG) in an Apache Airflow environment. The function should be able to alter the state of individual tasks and update the overall state of the DAG run. The code snippet provided is a part of a test suite for t... | codefeedback |
You are tasked with implementing a class for managing animated sprites in a 2D game. The class, named `Ship`, is responsible for drawing the sprite on the screen and playing a death animation when the ship is destroyed. The provided code snippet shows two methods of the `Ship` class: `draw` and `playDeathAnimation`.
T... | codefeedback |
You are tasked with implementing a function that processes a series of transactions in a financial system. Each transaction is represented by a reference to the last transaction and the old last transaction, as well as a code section. The function should process these transactions and return the final result.
You are ... | codefeedback |
You are tasked with implementing a C++ template metaprogramming problem related to the manipulation of type traits. Your goal is to create a type trait that determines whether a given type is a specialization of a particular template class.
You are provided with a code snippet that contains the end of a C++ header fil... | codefeedback |
You are tasked with implementing a simplified version of a dynamic array class called `podarray`. The `podarray` class is designed to store elements of a specific type `eT` and provide various operations for accessing and modifying the elements. The class provides the following member functions and constructors:
1. `e... | codefeedback |
You are tasked with implementing a program to find the minimum path sum in a triangle. The triangle is represented as a list of lists, where each inner list represents a row of the triangle. The minimum path sum is the sum of the numbers along a path from the top to the bottom of the triangle, moving only to adjacent n... | codefeedback |
You are tasked with implementing a custom pinned map data structure in Python. A pinned map is a type of hash table that allows for efficient key-value pair storage and retrieval. Your task is to create a Python class `PinnedMap` that mimics the behavior of the given code snippet.
The `PinnedMap` class should have the... | codefeedback |
You are tasked with implementing a neural network architecture for a reinforcement learning agent. The given code snippet is a part of the implementation of the network. The `conv_net_on` function applies convolutional layers to the input state, and the `hidden_layers_on` function creates hidden layers with specific si... | codefeedback |
You are tasked with automating the configuration of network devices using Python and the Netmiko library. You have been provided with an Excel file named "Example4-Device-Details.xlsx" containing details of various network devices. Each row in the Excel file represents a different device and contains the following colu... | codefeedback |
You are tasked with creating a custom error handling system for a Rust application. Your goal is to implement a set of custom error types and associated error messages to handle different kinds of errors that may occur during the application's execution.
You are provided with a code snippet that defines two custom err... | codefeedback |
You are tasked with creating a parser for a simplified version of a Rust code snippet. The code snippet provided is a part of a Rust macro invocation. Your task is to write a function that parses the given input and extracts the imported types and derive macros from the macro invocation.
The input consists of a series... | codefeedback |
You are tasked with creating a preference service class that manages user preferences for a software application. The preference service allows users to set and retrieve preferences, as well as subscribe to preference change events. Your goal is to implement a method for handling preference changes and updating the cor... | codefeedback |
You are tasked with implementing a utility function to convert a given project path from UTF-16 encoding to UTF-8 encoding and vice versa. The provided code snippet contains a C++ function that converts a UTF-16 string to a UTF-8 string and sets the converted path in a project instance. Additionally, there is a functio... | codefeedback |
You are tasked with implementing a shell script that processes a series of commands based on a given code snippet. The code snippet contains a sequence of commands and file references, and your goal is to understand and execute these commands in the correct order.
The code snippet provided is as follows:
```
. ${0%03-... | codefeedback |
You are tasked with implementing a custom comparator function in JavaScript to sort an array of objects based on a specific property. The custom comparator should be concatenated into the array and used to sort the objects based on the specified property.
You are given an array of objects, where each object represents... | codefeedback |
You are tasked with creating a web application that allows users to submit feedback forms. The application uses the ASP.NET Core framework, and you need to implement server-side validation for the input fields. The provided code snippet is a part of the feedback form model and demonstrates the use of data annotations f... | codefeedback |
You are tasked with implementing a custom hook in a React application that manages the state of a subscription to a data stream. The hook should utilize the `useRef`, `useState`, and `useEffect` hooks to achieve this functionality.
Your task is to create a custom React hook called `useDataStream` that takes in a `subj... | codefeedback |
You are tasked with implementing a function that parses a given SVG (Scalable Vector Graphics) code and counts the occurrences of specific attributes within the code. SVG is an XML-based vector image format for two-dimensional graphics with support for interactivity and animation. The function should take the SVG code ... | codefeedback |
You are tasked with implementing a notification system for a software application. The system should allow objects to subscribe to notifications about changes in their properties. To achieve this, you need to create a set of classes and interfaces that enable the notification mechanism.
Your task is to implement the `... | codefeedback |
You are tasked with creating a program that generates a formatted timestamp based on a given date and time input. The program should take a date and time in the format "yyyy-MM-dd HH:mm:ss" and convert it to a formatted timestamp in the format "EEEE, MMMM d, yyyy 'at' h:mm a". For example, the input "2023-09-15 14:30:0... | codefeedback |
You are tasked with implementing a function that generates a random alphanumeric string of a specified length. The function should take an integer `length` as input and return a string of random alphanumeric characters of the given length.
Your task is to implement the `generateRandomString` function, which takes an i... | codefeedback |
You are tasked with testing a React application using Jest and React Testing Library. The application consists of various components, including `GeneralSettings`, `Breadcrumbs`, and `App`. Additionally, the application uses `MemoryRouter` and an `i18n` instance for internationalization.
Your goal is to write a test ca... | codefeedback |
You are tasked with implementing a Python class that handles the formatting and writing of multiple sequence alignments to a file. The class, named `AlignmentWriter`, should have a method `write_and_format` that takes in a sequence alignment object, a file format, and an output file name. The method should write the fo... | codefeedback |
You are tasked with creating a program that can encrypt and decrypt messages using a simple substitution cipher. The substitution cipher works by replacing each letter in the message with a different letter from the alphabet. For example, 'a' might be replaced with 'c', 'b' with 'd', and so on. To encrypt a message, ea... | codefeedback |
You are tasked with creating a script to automate the deployment process for a Dockerized application. The script should handle logging into Docker, setting environment variables, and building the Docker image based on the branch being deployed.
Write a bash script named `deploy.sh` that accomplishes the following tas... | codefeedback |
You are tasked with creating a Python unit test for a function that interacts with AWS S3 using the Chalice framework. The function is responsible for reading and writing objects to an S3 bucket. Additionally, it checks if the objects exist in the bucket. The code snippet provided includes a fixture for mocking AWS cre... | codefeedback |
You are tasked with creating a Python class to manage a playlist for a music player. The playlist should support adding songs, removing songs, shuffling the order of songs, and playing the next song in the playlist. Additionally, the playlist should be able to keep track of the current song that is playing.
Create a P... | codefeedback |
You are tasked with implementing a custom bitfield data structure in Rust. A bitfield is a data structure that compactly stores bits, allowing efficient manipulation and access at the bit level. Your task is to implement the `BitField` struct using the `bitfield` crate, which provides a convenient way to define bitfiel... | codefeedback |
You are tasked with creating a script to automate the migration of SCSS files using the `sass-migrator` tool. The script should traverse through the SCSS files in the `govuk-frontend` package and execute the migration process for each file. The `sass-migrator` command is used to convert SCSS syntax to the newer syntax,... | codefeedback |
You are tasked with implementing a thread-safe logging mechanism for a multi-threaded application. The provided code snippet includes a private static String variable `hostHost` and a ReentrantLock `consoleLogLock` for synchronizing access to the console log. Your goal is to create a class that encapsulates the logging... | codefeedback |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.