instruction_seed
stringlengths
29
40.5k
source
stringclasses
6 values
How can I construct a C++ program that generates pseudo-random numbers between 0 and 10? I want to ensure that the results are random by properly seeding the random number generator. Can you provide a code example?
glaive
You are tasked with setting up a C++ project using CMake and need to define the dependencies, include paths, and preprocessor definitions for the project. You are also required to link the project with other targets. Write a CMakeLists.txt file for the project based on the given requirements.
glaive
I need to write a program in OCaml that will take in a boolean condition and return a value based on that condition. The program should be able to handle nested if-else statements and also include the ability to execute a block of code if the condition is true. The program should also be able to print a message if the ...
glaive
You are working on a project that requires you to check for certain type sizes and structs in a C/C++ program. You need to write functions to search for libraries and check for the existence of specific functions in those libraries. Additionally, you need to test for the presence of certain header files and symbols in ...
glaive
You are tasked with implementing a MemoryInputStream class in Rust that extends the functionality of the InputStream and Seekable traits. The MemoryInputStream should have a method to create a new instance, as well as a method to add bytes to the stream. Additionally, there should be a method to create a new MemoryInpu...
glaive
I'm facing an issue where I need to update a table with values from another table, but the problem is that I have thousands of rows to update and PHPMyAdmin can't handle that load. Unfortunately, I don't have direct access to the server. Can someone guide me on how to achieve this? Here is the structure of my tables: ...
glaive
I am working on a project that requires implementing a State Monad in Haskell. I need to create a function that takes a list of State Monad operations and executes them sequentially. The function should take a list of operations as input and return a new State Monad that represents the combined effect of running each o...
glaive
You are tasked with creating a module in Elm that contains SVG icons for popular social media platforms. The module should include icons for "noredink", "facebook", "twitter", "clever", "cleverC", "googleClassroom", and "googleG". Each icon should be defined as a separate function that returns an SVG element. Your tas...
glaive
You are tasked with creating a module in Emacs Lisp that will allow VM to use emacs-w3m for displaying HTML emails. The module should be able to handle the inlining of HTML mails in the VM presentation buffer. The module should also include the ability to toggle the display of all images in the presentation buffer, wit...
glaive
You are tasked with implementing a `cau_seq` data type representing a Cauchy sequence. A Cauchy sequence is a sequence of numbers in which the terms become arbitrarily close to each other as the sequence progresses. The `cau_seq` type should support basic operations such as addition, multiplication, comparison, and abs...
glaive
I am working on a project that involves creating a module in Julia using MPI, Dates, and Formatting libraries. I need to define a new mutable struct called `NULLOM_DATA` with specific fields and implement functions to initialize, run, and finalize the module. The `init` function should initialize the struct with given ...
glaive
You are tasked with implementing a utility function in Go to generate a random encryption key using the Google Cloud Key Management Service (KMS) API. The function should take in a context and return a randomly generated encryption key.
glaive
You are tasked with creating a responsive navigation bar for a website using HTML and CSS. The navigation bar should have the following features: - A fixed position at the top of the page - A brand logo on the left and navigation links on the right - Responsive design for different screen sizes, with specific adjustmen...
glaive
You are tasked with creating a program that simulates the execution of activity diagrams using the MIT licensed R6RS scheme language. The program should be able to handle the following components of activity diagrams: - Variables - Activity nodes - Activity edges - Control flows - Initial nodes - Final nodes - Fork nod...
glaive
You are tasked with creating a programming solution that involves implementing a BatchUpdate feature for a resource model in a CMDB (Configuration Management Database) system. The BatchUpdateRequest message is used to request updates for multiple data entries, and the BatchUpdateResponse message is used to handle the r...
glaive
You are tasked with creating a Makefile to build a C++ project using CMake. The project consists of a single source file called main.cpp. Your Makefile should include rules to build an object file, preprocess the source file, generate assembly for the file, and clean the project. Additionally, you need to include a rul...
glaive
You are tasked with creating a Gulp task to minify JavaScript files using gulp-uglify. Your task is to write a gulpfile.js that defines a Gulp task called 'uglify' which takes all JavaScript files from the 'src' directory, minifies them using gulp-uglify, and then saves the minified files in the 'dist' directory. Addit...
glaive
I am creating a game using a game development platform and I need to define an object in the game. The object should have specific properties such as its name, path, visibility, and physical characteristics like density, restitution, friction, etc. I also need to specify its event list and parent. Can someone provide m...
glaive
You are tasked with creating a program that allows users to search for a specific employee in a database and display their information. The program should include a form with a label prompting the user to enter the desired employee's name, a DBGrid to display the employee information, and an edit box for the user to in...
glaive
You are tasked with creating a simple thread pool management object in Ruby. The thread pool should maintain a minimum of `min` and maximum of `max` threads in the pool. The block that is passed to the thread pool object is the work that will be performed in each thread. The thread pool should have the ability to add w...
glaive
How can I obtain the underlying `syscall.Handle` for a `*net.UDPConn` on Windows? I need this handle to set the `IP_MULTICAST_TTL` via `syscall.SetsockoptInt`. The code I currently have to do this works on Linux but fails on Windows with the error "dup: not supported by windows". How can I get this handle on Windows? I...
glaive
I am trying to implement a function that involves capturing continuation marks and working with composable continuations. However, I am encountering issues with caching and updating continuation attachments. It seems like the caching strategy may not be working as expected, leading to incorrect results. I need to ensur...
glaive
I need to write a program that calculates the average of two numbers, a and b, using the following formula: average = (3.5a + 7.5b) / 11.0 The program should take input for the values of a and b, and then output the average with 5 decimal places.
glaive
I am trying to create a function in Common Lisp that composes any number of one-argument functions. The compose function takes in a variable number of arguments, where each argument is a one-argument function. The goal is to return a new function that applies each function in reverse order to the input. For example, if...
glaive
You are tasked with creating a Ruby program that calculates the intersection point of a ray and a plane in 3D space. The program should take in the following parameters: - `rayVector`: A vector representing the direction of the ray - `rayPoint`: A vector representing a point on the ray - `planeNormal`: A vector represe...
glaive
I have a vector in R and I want to count the number of times a specific element is repeated in that vector. Can someone provide a solution for this?
glaive
You are required to implement a CUDA kernel for 2D gradient pooling. The kernel should calculate the gradient of the input with respect to the output of the pooling operation. The pooling process can be either average pooling or max pooling. The input, output, and gradients are stored in arrays on the device. The probl...
glaive
You are tasked with creating a program to provision an Autonomous Database instance (ADW or ATP) on the Oracle Cloud. The program should allow the user to specify the configuration of the instance including compartment, display name, database name, workload type, deployment type, database version, OCPU count, storage c...
glaive
You are working with a dataset containing information about families in different municipalities. You need to visualize this data on a map, using a specific map file. Additionally, you are required to calculate the average family size for each municipality and overlay this information on the map. Create R code to: - I...
glaive
You are tasked with creating a program that implements certain constants and masks related to the X Window System protocol. The X Window System is a windowing system for bitmap displays, common on Unix-like operating systems. Your program should include the necessary constants and masks to perform various operations re...
glaive
I am working on a project that involves handling BigWig files in Julia. I need to create a module that can read, write, and manipulate BigWig files. The module should be able to import BufferedStreams, GenomicFeatures, Libz, and other necessary packages. Additionally, it should include specific files such as header.jl,...
glaive
You are tasked with creating a web page that will automatically print after a 2-second delay when the page is loaded. Your web page should include the necessary HTML, CSS, and JavaScript code to achieve this functionality. The page should display the content of a variable called "data" in the <body> section. The "data"...
glaive
You are tasked with implementing a hierarchical Bayesian model using the brms package in R. The data consists of a response variable Y, a population-level design matrix X, and group-level predictor values Z_1_1. The model also includes grouping indicators J_1 and is specified to have a number of population-level effect...
glaive
Could someone please help me understand the purpose of the 'send()' method in the following code snippet? I am having trouble comprehending its functionality. The code is written in Ruby 1.8.7 with Rails 1.2.3. Please note that upgrading is not an option in this case, as it is a client's environment. Here is the code s...
glaive
I am trying to create a function in F# that takes an array of strings and shuffles it in place. I want to be able to use this function to shuffle an array of strings for a game I am developing. Can someone provide me with the F# code to achieve this?
glaive
I am trying to solve an advection-diffusion problem in 1D using the CLIMA package in Julia. I have a code snippet for a Pseudo1D struct and some helper functions, and I need to implement the `do_output` function for writing output files in VTK format. The `run` function is also provided, and it uses an ODE solver to so...
glaive
You are tasked with creating a simple web application using Flask that allows users to input a mathematical expression and get the result displayed on the screen. The application should have a login system in place to restrict access to authenticated users only. Create a Flask app with the following requirements: 1. U...
glaive
Why does TensorFlow 2 have much slower performance than TensorFlow 1? When benchmarking performance, TensorFlow 1 runs anywhere from 47% to 276% faster. I am looking for an explanation for this significant slowdown at the graph or hardware level. I've noticed this issue even when disabling Eager Execution. The system s...
glaive
Can you provide a SQL query that retrieves the names of employees and their corresponding department names for those who joined after the year 2014?
glaive
You are tasked with creating a system to check the reset outputs of rstmgr cascade properly. The hierarchy of resets is as follows: por > lc > sys > specific peripherals. You need to implement a series of assertions that will ensure that higher level resets always cause the lower level ones to assert. The cascade relat...
glaive
You are tasked with creating a smart contract interface for a lottery system in Solidity. The interface should include two functions: `mint` and `burn`. The `mint` function should take in the address of the recipient and the amount to mint, while the `burn` function should take in the address of the sender and the amou...
glaive
How can I design a CSS template with three different divs and assign different colors to them?
glaive
I want to write my first assembly program. I have done some programs on papers but it's my first time with the compiler. I am using ideone. My program is very simple, Translate "A = 5 - A" to Assembly. ``` NEG A ADD A, 5 ``` Now I want to run this program and check it. How do I do it with the compiler? Please help me...
glaive
You are tasked with implementing a function that takes a string as input and returns the width of the string. The width of the string is defined as the number of characters it contains. For example, the string "hello" has a width of 5. Your function should be able to handle any input string and accurately determine it...
glaive
You are asked to write a bootloader program in assembly language that will load a kernel from disk and set up the VESA display mode. The bootloader should also read the available drives, retrieve information about the system's memory map using the e820 interrupt, and detect the CPU's capabilities. Additionally, the boo...
glaive
You are tasked with implementing a program that processes data based on certain conditions. The program should check the role of a given input and update it based on the conditions provided. If the role is 'INPUT' or 'REJECTED', then the program should further evaluate the name and update the role accordingly. If the n...
glaive
I am trying to insert data into a graph using SPARQL with specific conditions and bindings. I want to insert information about a person, their account, and their membership to a specific organization. The person's information includes their first name, last name, UUID, and a link to their online account. The account's ...
glaive
I am trying to implement a test bench for a FIFO axis in VHDL using the Xilinx Vivado simulator. However, when I run the simulation, I encounter an error and the simulation quits with a force quit command. I have tried using the "onbreak" and "onerror" commands to handle any errors, but the issue still persists. Can so...
glaive
You are tasked with creating a data class in Kotlin for a mobile application that represents game data. The data class should have the following fields: - gameId: a unique identifier for the game (String) - title: the title of the game (String) - logoUri: the URI for the game's logo image (String) Additionally, the da...
glaive
I need help creating a code that can calculate absolute probabilities for a given set of data. Can anyone assist me?
glaive
You are tasked with creating a CMake function to download dependencies for a custom V8 build. The function should download release and debug binaries as well as header files, and verify their integrity using SHA1 checksums. If the dependencies are not present or their checksums do not match with the CDN, the function s...
glaive
You are tasked with creating an XML file for a specific language using a given framework and technology. The XML file should include the necessary models, facets, generators, dependencies, and language versions. The file should also specify the location of source roots and classes generated for the specified language. ...
glaive
I am working on a RESTful API using the rs.openapi framework and I need to implement a new resource operation for my petstore API. The operation I need to implement is to update a pet's information by its ID. The function signature should look like this: update-pet-by-id (pet-id name status). The function should take i...
glaive
You are tasked with creating a class in C++ that interacts with CUDA for GPU programming. The class should have the following functionalities: 1. Constructor that takes in a className as a parameter. 2. Method to set the current CUDA device. 3. Method to allocate memory on the GPU. 4. Method to transfer data between th...
glaive
You are tasked with writing a CMake script to remove specific files and directories within a given directory path. The script should be able to remove the "oroca_ros_tutorials_generate_messages_eus" directory and its contents, as well as the files "/home/bonobono/catkin_ws/devel/share/roseus/ros/oroca_ros_tutorials/msg...
glaive
You are tasked with creating a PHP widget that generates a masked text input using the Yii framework. The widget should force users to enter properly formatted data, such as phone numbers or social security numbers. The widget should support custom mask definitions and aliases, and should be implemented based on the jQ...
glaive
You are tasked with creating a script to automate the implementation process of a hardware design. The script should be able to start, end, and handle any failures that may occur during the steps of initializing, optimizing, placing, and routing the design. The script should also handle any errors that may occur during...
glaive
You need to create a module in Verilog that wraps a Xilinx int multiplier IP with flow control to add back pressure. The module should have the following features: - It should have an interface `XilinxIntMul` with the following methods: - `req`: Takes in two 64-bit numbers `a` and `b`, a sign `XilinxIntMulSign`, and ...
glaive
How can I handle this HackerRank challenge in Python? Challenge: Create the following function: ```def dominant_character(string: str) -> str:``` Given a string of length N, find the dominant character. A dominant character is a character that appears more than ⌊ N/2 ⌋ times. However, this time we need to optimize f...
glaive
You are tasked with implementing a state machine editor using VHDL. The state machine editor should have the following inputs: clock, reset, ready, counter, and data_end. The output should be the state of the state machine. The state machine has three states: CTRL, DATA, and IDLE. The state transitions are dependent o...
glaive
You are tasked with creating a program using Microsoft Azure SDK for .NET in C# that generates library code for a specific resource type in the consumption/resource-manager. Your program should take input from the user for the resource type and then use the Azure SDK to generate the library code for that resource type....
glaive
How do I set a default parameter value in routing in Rails 3? I have a route that looks like this: ```ruby match ':slug/:id/:direction' => 'quiz#show', :as => :quiz_details, :direction => "next" ``` I want to set the default value of `direction` to "next". Can someone help me with this?
glaive
How can I convert a JSON Object to CSV using JavaScript?
glaive
You are tasked with creating a Zig program that imports two test files, "semver/semver_test.zig" and "dirhash/dirhash_test.zig". Your program should be able to handle these imports and perform any necessary testing or operations on the imported files.
glaive
I am working on a C++ project and I need to use Boost libraries. I want to create a function that will allow me to easily include and link these Boost libraries in my project. Can someone provide a solution for creating a CMake function that takes in a target and a list of Boost libraries, and then includes and links t...
glaive
You are tasked with creating a PlayAppWithDependencies class that extends the PlayApp class and takes a VersionNumber as a parameter. The PlayApp class is responsible for managing a Play application, while the PlayAppWithDependencies class should add the functionality of managing dependencies for the Play application. ...
glaive
You are tasked with creating a function called `GENERATE` that will generate specification templates based on the given input. The function should have the following method signatures: 1. `(GENERATE (FORM LIST) &KEY APPEND)`: This method should generate each exported symbol's template. If the spec file already exists a...
glaive
I am trying to find and include Qt5 libraries and headers in my project. I want to specify a list of Qt5 modules to be looked for and added, and if not defined, all modules should be looked for and added to the project. I also need to set some variables like QT5_FOUND, QT_LIBRARIES, QT_QMAKE_EXECUTABLE, QT_RCC_EXECUTAB...
glaive
You are tasked with implementing a Lua client library for the redis key-value storage system. Your task is to create a function that takes a command and its parameters and sends a request to the Redis server. Create a function `send_request` that takes in the following parameters: - `client`: The Redis client object -...
glaive
I want to load a YAML file into a Hash in my Ruby program. How can I achieve this?
glaive
You are working on a computer graphics project and need to write a shader program that takes in a depth texture, a color texture, and various uniform parameters to process the data and output a final color. The given code snippet represents a part of the shader program that is responsible for calculating the final colo...
glaive
You are tasked with creating an XSLT stylesheet to transform an input XML document into a specific output format. The input XML document contains information about an HTTP request, including the request URI and URL. Your goal is to extract specific elements from the input XML and construct a new XML document with the t...
glaive
You are working on a web application using Java and Spring framework. You need to create a modal dialog box that displays a message and a button to close the modal. Additionally, you need to include a hidden input field with a user ID and a JavaScript function that redirects to a specific URL when the button is clicked...
glaive
You are tasked with creating a Go program that simulates a provision job for a service instance. The program should include the following components: - A struct named ProvisionJob with the following fields: - serviceInstance: a pointer to a ServiceInstance struct from the apb package - clusterConfig: a ClusterConf...
glaive
You are tasked with creating a Ruby on Rails application to manage product stock levels. The application should include a background job that increases the stock of a product by a specified amount. The job should be enqueued to run on the default queue. Write a Ruby on Rails class `StockIncreaseJob` that contains a me...
glaive
I am working on a project that involves classifying the sentiment of news articles. Can anyone help me with creating an algorithm using natural language processing to accomplish this task?
glaive
You are tasked with implementing a C++ struct that represents a cached power. The struct should have three public attributes: - f: a 64-bit unsigned integer representing the value of the cached power - e: an integer representing the exponent of the cached power - k: an integer representing a cached binary exponent You...
glaive
You are tasked with creating a program that tests a 'packed' scheme for a given value of N. The 'packed' scheme is an algorithm that involves packing data into a specific format for efficient storage and retrieval. Your program should take a parameter log_n, which represents the exponent of 2 (N = 2^log_n), and then ru...
glaive
I am working on a project that involves simulating neural networks using Julia programming language. I need to create a program that includes the "hodgkinhuxley.jl", "prinzneuron.jl", and "simplesynapse.jl" files to model the behavior of neurons and synapses. The program should be able to simulate the electrical activi...
glaive
You are tasked with implementing a program that handles the file format description for carbon sort index file in Java. The program should define a struct called ColumnSortInfo with two fields: sort_index, which is a list of binary values representing the surrogate values sorted by the original value order, and sort_in...
glaive
I am working on a project that requires the integration of various libraries and tools, such as CUDA, Eigen, BLAS, NNPACK, DNNL, Protobuf, JSON, and OpenCV. I need to set up the CMakeLists.txt file to handle the inclusion and usage of these dependencies. The project should be able to dynamically enable or disable these...
glaive
You are tasked with generating the mean, variance, standard error of mean, and coefficient of variation for diary data for a specific UCC (Universal Classification Code). This requires processing diary survey microdata to calculate these statistical measures for the given UCC. The diary data is stored in a directory ...
glaive
What are the advantages of PyPy over other Python interpreters such as CPython, Jython, and IronPython? Does it offer increased speed, cross-platform compatibility (including mobile platforms), or the ability to use c-extensions without the Global Interpreter Lock (GIL)? Or is it more of an experimental project to expl...
glaive
You are given a matrix stored in a 2D vector, where each element represents a value in the matrix. You need to implement a function to calculate the Jaccard weights of the non-zero elements in the matrix. The Jaccard weight is calculated based on the volume of intersections (*weight_i) and the cumulated volume of neigh...
glaive
You are tasked with writing a program to analyze data from a sensor. The sensor provides readings for X, Y, TStamp, Pres., and EndPts. The data is in the following format: X, Y, TStamp, Pres., EndPts DataSize: 139 14000 14336 0 52 0 14000 14336 10 58 0 14000 14336 30 63 0 ... Your task is to write a program that reads...
glaive
How can I create an application in Java for playing tic-tac-toe?
glaive
You are tasked with developing a method to retrieve a meta domain based on the environment. The method should take an environment parameter and return the corresponding meta domain based on the environment. If the meta domain for the environment is not found, the method should return the default meta server URL. You ar...
glaive
I need to create a C++ program that takes a user input and prints "hi" to the console. The program should prompt the user to enter a string and then display "hi" followed by the entered string. It should use the standard input and output streams for user input and console output.
glaive
You are tasked with creating a data structure and message protocol for logging frames and referee box commands in a soccer game. The data structure should include a message for each frame containing SSL_DetectionFrame and a string for referee box command. The protocol should allow for multiple log frames to be stored a...
glaive
You are working on a project that requires you to delete all .resx files in the "Properties" folder and then copy new .resx files from a different location into the same "Properties" folder. You need to write a script or program to automate this process. Assume that you are working in a Windows environment and can use ...
glaive
You are tasked with implementing a simulation of a simple wireless network using the ns-2 network simulator. The network consists of 3 nodes, each of which is capable of sending and receiving messages to and from other nodes in the network. The nodes are initially positioned at different coordinates in a 700x200 grid. ...
glaive
You are tasked with creating a class in a programming language of your choice that contains a nested class. The nested class should have a method that prints the value of a variable from the outer class. It should be possible to access the variable from the nested class using the outer class's reference.
glaive
You are tasked with creating a program that connects to a MySQL database and executes a specific query. The program should be able to handle the necessary include files and library dependencies, and should be compiled using the cc compiler. Your program should be named testdbc and should be able to connect to the MySQL...
glaive
I have an instruction `MOV EAX,[0xFFFFFFFF]` encoded in 64-bit mode as `67A1FFFFFFFF`. The Intel instruction reference manual states that addressing in 64-bit mode uses existing 32-bit ModR/M and SIB encodings, and the ModR/M and SIB sizes remain 8 bits or 32 bits and are sign-extended to 64 bits. However, I'm not sure...
glaive
I am trying to dynamically create Django model classes using the `type()` function. I want to be able to programmatically determine the number and names of the attributes that make up the class. However, I am facing the challenge of defining the `__module__` attribute for the Django model, which is necessary for dynami...
glaive
You are tasked with creating a batch script that will perform the following tasks: 1. Create a directory structure for various platforms within a specified path. 2. Copy a specific file to each of the created directories. Write a batch script that takes a single argument as the path and performs the above tasks.
glaive
You are tasked with creating a batch file that checks for the existence of a node.exe file in the current directory. If the file exists, the batch file should execute a specific command using node.exe and pass in the path to a cmd.js file located in a different directory. If the node.exe file does not exist, the batch ...
glaive
You are tasked with querying an RDF dataset to retrieve information about environmental ontology terms. You need to create a query that selects the label, definition, exact synonym, broad synonym, narrow synonym, related synonym, subset type, and URI for each environmental ontology term. Additionally, you need to filte...
glaive
I'm currently using R for machine learning and following the standard machine learning methodology, I would like to split my data into three sets: training, validation, and test. There are available resources on how to split into two data sets, but I'm not sure how to do this for three sets. How can I randomly split my...
glaive
I am trying to create a server using the Go programming language that will handle GraphQL requests. I want to be able to update the server's schema dynamically based on changes in the file system and have the ability to use GraphiQL for testing and debugging. Can someone provide a way to implement this in Go?
glaive