Tutorial by Examples: and

Pass an upper limit as an argument to the rand() function. Input: my $upper_limit = 100; my $random = rand($upper_limit); print $random . "\n"; Output: A random floating-point number, like... 45.8733038119139
Cast your random floating-point number as an int. Input: my $range = 10; # create random integer as low as 0 and as high as 9 my $random = int(rand($range)); # max value is up to but not equal to $range print $random . "\n"; Output: A random integer, like... 0 See also t...
// main.cpp : Defines the entry point for the console application. // #include "opencv2/highgui/highgui.hpp" #include <iostream> using namespace cv; using namespace std; int main(int argc, const char** argv) { Mat img = imread("lena30.jpg", CV_LOAD_IMAGE...
Reading the content of an InputStream as a byte array: // Reading from a file try (InputStream in = new FileInputStream("in.dat")) { byte[] content = ByteStreams.toByteArray(in); // do something with content } Copying an InputStream to an OutputStream: // Copying the content f...
To get a list of the processes running in the current terminal, you can use ps : $ sleep 1000 & $ ps -opid,comm PID COMMAND 1000 sh 1001 sleep 1002 ps To kill a running process, use kill with the process ID (PID) indicated by ps: $ kill 1001 $ ps -opid,comm PID COMMAND 1000 sh...
Reading the content of a Reader as a String: // Reading from a file try (Reader reader = new FileReader("in.txt")) { String content = CharStreams.toString(reader); // do something with content } Reading the content of a Reader as a list of line contents: try (Reader reader = n...
Convert from wide form to long form Load data USArrests from datasets. data("USArrests") head(USArrests) Murder Assault UrbanPop Rape Alabama 13.2 236 58 21.2 Alaska 10.0 263 48 44.5 Arizona 8.1 294 80 31.0 Arkansas 8...
Convert from long form to wide form To recover data from the previous example, use dcast like so. DTc <- dcast(DTmu, State + UrbanPop ~ Crime) This gives the data in the original wide form. State UrbanPop Murder Assault Rape 1: Alabama 58 13.2 236 21.2 2:...
Many real-world database tables have many rows with DATETIME OR TIMESTAMP column values spanning a lot of time, including years or even decades. Often it's necessary to use a WHERE clause to retrieve some subset of that timespan. For example, we might want to retrieve rows for the date 1-September-2...
image: jangrewe/gitlab-ci-android before_script: - apt-get --quiet update --yes - apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1 openjdk-8-jdk - echo y | ${ANDROID_HOME}/tools/android --silent update sdk --no-ui --all --filter android-24 - echo y | ${ANDROID_HOME}/too...
Two of the most fundamental higher-order functions included in the standard library are map and filter. These functions are generic and can operate on any iterable. In particular, they are well-suited for computations on arrays. Suppose we have a dataset of schools. Each school teaches a particular...
// PixelAccessTutorial.cpp : Defines the entry point for the console // Environment: Visual studio 2015, Windows 10 // Assumptions: Opecv is installed configured in the visual studio project // Opencv version: OpenCV 3.1 #include "stdafx.h" #include<opencv2/core/core.hpp> #i...
Overview Android Studio's built-in update mechanism can be set to receive updates through any one of these four channels: Canary: Bleeding edge, released about weekly. These are early previews released in order to obtain real-world feedback during development. The canary channel will always have...
You can attach an image in a texture to a framebuffer, so that you can render directly to that texture. glGenFramebuffers (1, &framebuffer); glBindFramebuffer (GL_FRAMEBUFFER, framebuffer); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, ...
Go to the Microsoft link for the OpenXML SDK download. Click the red download button. On the next screen click the box next to OpenXMLSDKToolV25.msi and click next to begin the download. Once the download is complete, launch the OpenXMLSDKToolV25.msi and follow the instructions on the screen. Th...
If you are inserting data into a table with an auto increment column and if you want to get the value of the auto increment column. Say you have a table called my_table: CREATE TABLE my_table ( id serial NOT NULL, -- serial data type is auto incrementing four-byte integer name character varying...
There are two types of Active Patterns that somewhat differ in usage - Complete and Partial. Complete Active Patterns can be used when you are able to enumerate all the outcomes, like "is a number odd or even?" let (|Odd|Even|) number = if number % 2 = 0 then Even else Odd N...
productFlavors { // Define separate dev and prod product flavors. dev { // dev utilizes minSDKVersion = 21 to allow the Android gradle plugin // to pre-dex each module and produce an APK that can be tested on // Android Lollipop without time c...
The %>% operator can also be used to pipe the dplyr output into ggplot. This creates a unified exploratory data analysis (EDA) pipeline that is easily customizable. This method is faster than doing the aggregations internally in ggplot and has the added benefit of avoiding unnecessary intermediat...
Operators that bound tighter (higher precedence) are listed first. OperatorsPrecedence group (≥3.0)PrecedenceAssociativity.∞left?, !, ++, --, [], (), {}(postfix)!, ~, +, -, ++, --(prefix)~> (swift ≤2.3)255left<<, >>BitwiseShiftPrecedence160none*, /, %, &, &*MultiplicationPrec...

Page 105 of 153