instruction_seed
stringlengths
29
40.5k
source
stringclasses
6 values
You are tasked with creating a Moose role in Perl that will keep track of the history of an object and the number of changes made to it. The role should have the following attributes and methods: 1. Attribute 'history': - Type: ArrayRef[HashRef] - Access: read-write - Description: Array of hashrefs that descr...
glaive
You are tasked with creating a Python class that preprocesses observations from an environment using running standardization and min-max normalization. The class should have the following functionalities: - The class should be able to normalize observations from the environment using a running standardization method, ...
glaive
I am working on a C++ project using CMake to manage the build process. I want to ensure that if the CMAKE_BUILD_TYPE variable is not set, it defaults to "Debug". Additionally, if the CMAKE_GENERATOR matches "Visual Studio", I want to set the CMAKE_CONFIGURATION_TYPES to only include the value of ${CMAKE_BUILD_TYPE}. Ho...
glaive
You are working on a project in Racket and need to implement a dynamic module loading and reloading feature. You want to be able to load, reload, and use modules within your program using the @racketmodname[racket/rerequire] and @racketmodname[racket/enter] libraries. Write a Racket program that demonstrates how to us...
glaive
You are required to implement a register block for controlling floating-point context in an embedded system. The register block should include the following registers: 1. FPCCR (Floating-point context control register) - This register is located at address 0x00 and is used for controlling the floating-point context. 2...
glaive
I am trying to write a script to clean up some files and directories using CMake. I have a list of files and directories that I want to remove, but when I run the script, it doesn't seem to be working properly. Can someone help me write a CMake script that will remove the specified files and directories?
glaive
What is the purpose of creating a thread safe singleton class in Java?
glaive
I need to construct a query to retrieve information about organizations that have assigned awards to individuals. The query should return the organization, the property, and the object related to the organization. The organization should be of type foaf:Organization and the award should be of type core:AwardReceipt. Ca...
glaive
I am trying to create a macro for adding a Latino library in CMake, but I am having trouble getting the macro to work as expected. I want to be able to define the properties for the Latino library, including the version, product name, and additional headers. Can someone help me create a macro that sets the Windows vers...
glaive
You are tasked with creating a data structure in the form of a tree using the given programming language. The tree should be defined as an inductive data type and should have two possible forms: either a node with a list of sub-trees and a boolean value, or a leaf with a single value. Additionally, you need to define a...
glaive
You are tasked with implementing a custom loss function in PyTorch for an image classification model. The loss function, called ILloss, has specific requirements and calculations that need to be implemented in the forward method. The ILloss function takes in the number of classes, feature dimensions, and two lambda par...
glaive
How can I plot hourly data with NaN values in matplotlib in such a way that I can see gaps where there is no logger data for a day or more, but also join the data points where there is data? My data consists of various columns, with the first column being a date (`date_log`) and the rest containing different sample poi...
glaive
You are tasked with creating a protocol buffer message definition for a `SourceContext` that represents information about the source of a protobuf element, like the file in which it is defined. The message should include a field for the path-qualified name of the .proto file that contained the associated protobuf eleme...
glaive
You are tasked with creating a Python script that activates a virtual environment and sets up the necessary environment variables. The script should be able to activate the virtual environment, update the PATH variable, and modify the command prompt to reflect the active virtual environment. Additionally, the script sh...
glaive
Can you please provide a Java program that calculates the sum of divisors for a given number?
glaive
How can I share Jupyter notebooks with non-programmers in a read-only format? I am currently using a Jupyter server on our internal server, which is accessible via VPN and password protected. Although I am the only one creating notebooks, I would like my other team members to have visibility to some of these notebooks....
glaive
I am developing a TypeScript project and I want to set up ESLint with the @typescript-eslint plugin to ensure that my code follows best practices and is consistent. I want to configure ESLint to use the @typescript-eslint/parser, and I also want to extend the recommended rules from the @typescript-eslint plugin as well...
glaive
I am using Golang and the Gin framework to get claims from a JWT sent from a client. But I can't compare the extracted roles with a string. When I try to get the value, it returns `[test-app]` but actually I want the value as `"test-app"`. How can I get the value from json claims and use it to compare/validate with a s...
glaive
You are tasked with creating a SQL view that displays specific employee information from a database table. The view should include columns such as EmployeeID, FullName, UCDMailID, HomeDepartment, HireDate, EmployeeStatus, PayRate, and others. Additionally, the view should filter the data based on the current date and c...
glaive
You are asked to implement a program that utilizes the `roaring` crate to manipulate RoaringBitmaps. Your task is to create a function that removes a range of elements from a given RoaringBitmap. The function should take two arguments, `start` and `end`, and remove all elements within the range `[start, end)` from the ...
glaive
Can you provide a function that can verify if a given binary string represents a valid integer?
glaive
I am working on a Django web application and I need to create a new URL endpoint that will display a list of all users in the system. I want to use class-based views for this purpose. Can someone provide me with the code to define the URL pattern and the corresponding view to achieve this in Django?
glaive
You are tasked with creating a Racket interface for the libgit2 git library. The interface should allow users to perform core Git methods using the libgit2 library. Your task is to implement a set of functions in Racket that provide a seamless interface for interacting with the libgit2 library. The interface should be ...
glaive
You are tasked with creating a dropdown filter component using the Marionette framework. The dropdown filter should display a list of items, with the ability to scroll through the list and add new items dynamically. Additionally, the dropdown should include tooltips for each item. The class `ItemDropdown` should be use...
glaive
I need to create a function that takes a string as input and returns the SHA512 hash of the input string as a base64 encoded string. I want to use the System.Security.Cryptography library in C# to accomplish this. Can someone provide a C# code implementation to achieve this?
glaive
Can you compare the performance of Bubble Sort and Insertion Sort for a given array? Can you also explain how these sorting algorithms work?
glaive
You are tasked with creating a program that reads a CSV file and loads its data into a table. The CSV file contains the following columns: n_nationkey (int32), n_name (string), n_regionkey (int32), and n_comment (string). The delimiter used in the CSV file is '|', and there is no header present. Your task is to write a...
glaive
You are tasked with creating a new game sprite using GameMaker Studio. The sprite should be named "spr_player_death" and have dimensions of 64x64 pixels. The sprite should have 13 frames of animation, with each frame representing a different stage of the player's death animation. Additionally, the sprite should have a ...
glaive
How can I create an advanced artificial neural network (ANN) using the Keras Sequential model to predict bitcoin prices through Time Series Forecasting? Can you also explain how to apply regularization methods to avoid overfitting, normalize the data, and split it into training and test sets? Additionally, I would like...
glaive
You are tasked with creating a function in Flutter that checks for a win state in a game. The function should take in a list of Bouncer objects, each representing a cell in the game. Each Bouncer object has a method getColor() that returns the color of the cell and a method getBorderColor() that returns the border colo...
glaive
You are tasked with creating a controller module for an admin interface that manages mailing lists in a web application. The module should provide the following functionalities: 1. List all available mailing lists 2. Enable adding new mailing lists 3. Enable deleting existing mailing lists The module should also handle...
glaive
I'm trying to develop a multi-threaded Java program that can transform a dynamically assigned string into upper case and reverse the string. I want to make sure that the program is thread-safe and follows best coding practices. Additionally, I want the program to handle any exceptions gracefully. Can someone provide me...
glaive
You are tasked with implementing a program that calculates the negative binomial cumulative distribution function (CDF) for various input types. The negative binomial distribution is a discrete probability distribution that models the number of failures in a sequence of independent and identically distributed Bernoulli...
glaive
You are tasked with writing a SPARQL query to retrieve the nationalities of politicians born in Poland who do not have Polish nationality, and then count the number of such individuals for each distinct nationality. The query should also ensure that the politician's label is in Polish.
glaive
You are tasked with creating a Rust program that utilizes the `wasm_bindgen` library to define a struct `SvgPreserveAspectRatio` with the following properties: - `align`: a getter and setter method for the `align` field, which returns or sets a `u16` value - `meetOrSlice`: a getter and setter method for the `meetOrSlic...
glaive
What is a simple way to implement a calculator in JavaScript?
glaive
You are tasked with creating a stand-alone version of the UnsteadyAero module. The UnsteadyAero_DriverCode tests this module, initializing input data for the driver program and running a simulation based on that data. The driver file can be provided as a command line argument when running the Driver exe. If no driver f...
glaive
You are tasked with creating a React component that displays a skeleton loading state for a card with specific actions, tokens, and details. The component should include the following: - SkeletonCardActions: A component that displays a skeleton loading state for card actions, with a height of 48px. - SkeletonCardTokens...
glaive
You are tasked with implementing a neural network using CUDA C++. The neural network consists of multiple layers, each with its own set of neurons and weights. Your goal is to write the CUDA C++ code for the execution of the first, second, third, and fourth layers of the neural network based on the provided code snippe...
glaive
You are tasked with creating a program that will animate sprites on a screen using the Amiga LDOS sample code. Your program should include setting up palettes, installing an interrupt handler, converting chunky to planar graphics, and utilizing the blitter to wait for operations to complete. Additionally, the program s...
glaive
You are tasked with creating a web page that displays a list of courses with their details and provides the functionality to search for a course by its title and add, edit, or delete courses. The web page should have a form for searching by title and a button to add a new course. The list of courses should be displayed...
glaive
You are tasked with creating a genetic algorithm to solve the 8 Queens Puzzle. The 8 Queens Puzzle is the problem of placing eight chess queens on an 8×8 chessboard so that no two queens threaten each other. Thus, a solution requires that no two queens share the same row, column, or diagonal. You need to implement a ge...
glaive
You are tasked with creating a program that can parse a specific type of configuration file entry and store the values in a structured format. The configuration file entry is in a specific format, and the program needs to extract the data and store it in a defined structure. The configuration file entry has the follow...
glaive
You are required to create a program that generates groups by expression based on the age of individuals. The program should take the weight and height of each individual as input and then group them into two categories: "tween" and "teen" based on their age. If the age is less than 13, the individual should be grouped...
glaive
You are tasked with writing a SPARQL query to retrieve information about datasets from a given graph URL. The query should select all distinct datasets that are of type "Dataset" and retrieve their identifier, organization ID and name, title, issue date, modification date, and distribution information. The distribution...
glaive
Hey folks, I have encountered a problem while working with an unmanaged dll that I created. In my C# code, I am using PInvoke to call one of the functions from this dll. However, I need to be able to terminate the thread that is running this function under certain conditions. Can anyone guide me on how to achieve this...
glaive
You are tasked with implementing a set of functions for handling probabilities in a given programming language. The functions should be able to determine whether a random event meets a specified probability or not. The following functions need to be implemented: - meetsProbability(probability: float) -> bool: This func...
glaive
Write a function that takes in a text string and a font family, and returns the minimum and maximum intrinsic width of the text. The function should use the given density and resource loader. The minimum intrinsic width should be calculated based on the length of the text and the font size, and the maximum intrinsic wi...
glaive
I need to create a CMake function that can add a Boost library to my project. The function should take in the name of the Boost library, the source files for the library, and any additional options such as linking, defining, CXX flags and include directories. The function should then create a static library for the Boo...
glaive
I am trying to implement a function in R that calculates the Topographic Wetness Index (TWI) for a given raster dataset. The TWI is a measure of the potential for saturation excess overland flow, and is calculated using the formula TWI = ln(a / tan(b)), where 'a' is the specific catchment area and 'b' is the slope. I w...
glaive
You are tasked with creating a Java class for a relationship edge in a graph database. The relationship edge should have the following properties: - It should be annotated with `@GremlinEdge` and have a partition key field named "country". - It should have two properties annotated with `@GremlinEdgeVertex` representing...
glaive
You are tasked with creating a class that represents a list of attributes for XML elements. The class should have the following functionality: - Ability to add a new attribute to the list - Ability to remove an attribute from the list - Ability to retrieve a specific attribute from the list - Ability to check if a spec...
glaive
You are working on a CMake project and need to find the LibHIREDIS headers and libraries to include in your build. You are tasked with writing the CMake code to find and include these components. You should create a CMakeLists.txt file to achieve this.
glaive
You are tasked with creating a Makefile for a Python project that includes various targets for managing dependencies, formatting, linting, testing, and Docker management. The Makefile should include targets for installing Poetry, managing pre-commit hooks, code formatting using pyupgrade, isort, and black, linting usin...
glaive
Can you provide a Python implementation for the following pseudocode? Pseudocode: if A > B: print("A is greater than B") else: print("B is greater than A")
glaive
You are tasked with creating a makefile for a project called "mn-dual-hostif-gpio" using the settings provided in the code snippet below. The makefile should include the necessary settings for the TERASIC DE2-115 MN Dual Host Interface GPIO design. Additionally, you need to ensure that the makefile retains the copyrigh...
glaive
You need to create a script that runs the Chinese Factored parser on one or more files which are already word segmented, with one sentence per line, printing trees and dependencies in a simple format. The input and output should be in GB18030 encoding. The script should take the form of a csh file and use Java, specifi...
glaive
You are tasked with creating a program that lists the parameters, geometry information, and location of a given element in Autodesk Revit. The program should be able to display the instance parameters, type parameters, geometry information, and location of the element. The parameters should be listed in a readable form...
glaive
You are tasked with creating a Java unit test for an indexing filter that adds a "raw_content" field to a NutchDocument object. The filter should be able to extract the "raw_content" value from a Parse object and add it to the NutchDocument. You need to write the test method testIndexingFilterAdds_raw_content_Field() i...
glaive
I have a dataset with both character and numeric variables, and I need to format the missing values in a specific way. For numeric variables, I want to display a period for missing values and 'X' for all other values. For character variables, I want to display a period for missing values and 'X' for all other values. H...
glaive
I am trying to branch to a specific address in ARM assembly without modifying the LR register. I want to achieve this using GCC inline asm. I have tried the following code: ```c #define JMP(addr) \ __asm__("b %0" \ : /*output*/ \ : /*input*/ \ "r" (addr) \ ); ``` How...
glaive
You are tasked with creating a PowerShell module with DSC Resources to configure a TFS Server. The module should have a version number, a unique GUID, an author, a company or vendor, a copyright statement, a description of the functionality provided by the module, the minimum version of the Windows PowerShell engine re...
glaive
What is the most efficient kmeans clustering package in R that I can use for a large dataset? I have a dataset with over 100 columns and around 10^6 rows. Currently, I am using kmeans function in R with the following parameters: <pre><code>kmeans(dataframe, centers = 100, nstart = 20, iter.ma...
glaive
How can I update the address of a record named 'John' in the "employees" table using a query?
glaive
Is there a way to design a program in Ruby that can convert a given number into its binary representation?
glaive
You have been tasked with writing a program that calculates the length of a given string. The program should be able to handle strings in different languages, including Cyrillic and Chinese characters. Additionally, the program should gracefully handle null values. Write a function or method that takes a string as inp...
glaive
You are tasked with creating a PowerShell script that modifies the Windows registry to change the description, owner, or organization of the operating system based on the input provided. The script should handle the scenarios where the input is provided for either the owner, organization, or description, and it should ...
glaive
You are tasked with creating a ray tracer for spheres using Haskell. The ray tracer should be able to generate an image with 8 spheres, each with their own specified properties such as position, radius, and surface type. The ray tracer should also include convenient vector operations, type declarations, and a main rout...
glaive
You are tasked with creating a message filter in Elm that takes in a string and processes it to generate a new string that will be passed back to JavaScript. The filter should remove any stop words and misspelled words from the input string. Stop words are common words that are filtered out of search queries by search ...
glaive
I'm using Simple Form here, but this is an issue with normal Rails forms, too. When using shallow routes, form_for needs different arguments depending on what context it's used. For example, for editing (http://localhost:3000/notes/2/edit), _form.html.erb needs to have simple_form_for(@note). But for creating a new not...
glaive
You are tasked with creating a web server using the Gauche-makiki framework. The server should listen on a specified port and display a homepage with information about the server, including the timestamp it started, the port it's running on, and the host. Additionally, the server should have a page to browse the source...
glaive
I am trying to implement a program in Java that involves reading a treebank file and a fragment file, and then performing various operations on the data. One of the operations involves filling a hash table with fragments present in the input file and mapping each fragment to its log-frequency. Additionally, I need to r...
glaive
I am currently working with Keras weight initializers and I came across a problem. I saw the official documentation which introduces different initializers like this: ```python model.add(Dense(64, kernel_initializer='random_normal')) ``` However, I was not able to find information about the default weight initializer...
glaive
You are tasked with creating a module in Elm called PersonalBestList that will display a user's personal bests in a formatted list. The personal bests are retrieved from a Signal called loadPBsIn, and the data is of type PersonalBests.PBs. The module should generate and display the personal bests in a visually appealin...
glaive
You are tasked with creating a Python module that will serve as a broker for handling loads in a logistics system. The module needs to include the following core classes and functions: - `Broker`: This class should handle the communication and coordination between the various components of the logistics system. It shou...
glaive
Is there a way to merge two sorted lists in C++ and obtain a single sorted list as output?
glaive
You are tasked with implementing a date and time picker in Elm using the DateTimePicker module. You need to create a custom date and time picker with the following requirements: - The date picker should display a calendar with the ability to navigate between months and years. - The time picker should allow users to sel...
glaive
I am working on a project that requires me to simulate a digital design using a simulation tool. I need to create a testbench for my design and run a simulation to verify its functionality. I also need to generate waveform and structure views for analysis. Can someone provide me with a complete code snippet to achieve ...
glaive
You are tasked with creating a Scala model and a Play JSON formatter for a notification request to update a relationship. The model should include the following fields: - full_name: a string representing the full name of the person - email: an EmailAddress object from the uk.gov.hmrc.emailaddress package - role: a stri...
glaive
You are tasked with creating a program that will parse a JSON object and extract specific information from it. The JSON object will contain information about a folder, including its ID, name, children, filter type, folder name, and whether it is the default view. Your program should be able to extract and display the f...
glaive
How can I order a collection in descending order instead of ascending order in this code snippet? ```html <pre><code>&lt;%= render :partial =&gt; 'event', :collection =&gt; @events.sort_by(&amp;:event_at)%&gt; </code></pre> ```
glaive
I am trying to upload multiple images from a file selection window using Rails 4 and CarrierWave. I have a `post_controller` and `post_attachments` model. Can someone provide an example of how to do this? Is there a simple approach?
glaive
You are tasked with creating a program that calculates the probability of a quantum state. The amplitude of the state is given by the function `amplitude[x_,y_]` and `amplitude2[x_,y_]`. The probability of the state is given by the function `probability[x, y]`, which calculates the absolute value squared of the amplitu...
glaive
You are working on a project that requires deleting specific files and directories using CMake. Your task is to create a CMake script that removes the following files and directories: - "CMakeFiles/bnet_plugin.dir/bnet_plugin.cpp.o" - "libbnet_plugin.pdb" - "libbnet_plugin.a" Additionally, you need to include per-langu...
glaive
I am trying to create a Docker image using the Alpine 3.2 library and I need to incorporate several additional files and scripts into the image. I am encountering issues with the ADD and RUN commands in the Dockerfile, and I need help in resolving these issues. I want to ensure that the additional files and scripts are...
glaive
I am trying to create a class in PHP, but I keep getting a "Fatal error: Cannot declare class Tx_Extbase_MVC_Exception_InvalidActionName" message. I have checked and there is no other class with the same name in my code. What could be causing this issue and how can I resolve it?
glaive
Can anyone provide a MongoDB query to retrieve all documents in a collection where a specific field contains an array with a size greater than one?
glaive
I am working on a programming project and I need to create a function called "foo" that takes an integer as input and returns the square of the input. Can someone provide me with a code solution in [insert programming language] to implement this function?
glaive
You are tasked with creating a C# behavior class that applies a specific window style to a WPF window. The behavior should remove the maximize and minimize buttons from the window, and hide the window icon. The behavior should be attached to the window using the `Behavior` class from the `System.Windows.Interactivity` ...
glaive
You are required to implement a program that generates and runs benchmark states using the NVBench framework. The program should be able to handle various types of input parameters and generate states accordingly. The program should be able to: - Generate benchmark states with no input parameters - Generate benchmark ...
glaive
I need to write a bash script that takes a string as input and writes it to a file specified by the third argument. The script should echo "hello-a" to the specified file. The script should be executed from the command line and should handle any errors that may occur.
glaive
Can you provide an explanation of the differences between synchronous and asynchronous AJAX requests in web development?
glaive
You are tasked with creating a Dockerfile for a Node.js application that will serve a static website. The Dockerfile should copy the built files from the local "build" directory to the container, install yarn, add the serve package globally, expose port 8080, and set the entrypoint to serve the static files on port 808...
glaive
You have been tasked with creating a MySQL view that selects specific columns from a table and applies certain conditions. The view should display the user, event name, total count, total latency, and average latency from the table "performance_schema.events_stages_summary_by_user_by_event_name" where the sum of timer ...
glaive
You are tasked with implementing a module for a Read-Write (RWire) interface in the Prelude package. The RWire interface has two methods: wset(element_type datain) for writing data and wget() that returns a Maybe element_type for reading data. You need to create a module that implements this interface for a specific el...
glaive
Can you provide a Python code snippet to generate random passwords of a specified length?
glaive
I need to write a program that generates a unique md5 hash and a digital signature for a given input. The program should also record the timestamp when the hash and signature were created. Can someone provide a solution in [insert programming language] using the appropriate libraries or modules to accomplish this task?
glaive
I am trying to organize my CMake project into different folders to keep it more organized. However, the built-in `add_subdirectory` function does not allow me to group targets in specific folders. I need a way to add targets to specific folders when using the `add_subdirectory` function in CMake. Can anyone provide a s...
glaive
You are required to create a C++ class that inherits from two other classes, `test_aafl` and `test_delta`. The new class should implement several virtual functions and perform specific operations related to memory allocation, data setup, data initialization, data compression, and data decompression. The class should al...
glaive
You need to implement a CUDA kernel for element-wise multiplication of two arrays, with the option to apply different operations to each element. The function signature is as follows: ```cpp template<typename dType> __global__ void _mul(int n, dType alpha, dType *a, dType beta, dType *b, dType *z) ``` Where: - `n` is...
glaive