(This is a request for a good example that shows how to construct a SELECT using CONCAT, then prepare+execute it. Please emphasize the use of @variables versus DECLAREd variables -- it makes a big difference, and it is something that novices (include myself) stumble over.)
# example data
DT = data.table(iris)
DT[, Bin := cut(Sepal.Length, c(4,6,8))]
summary is handy for browsing summary statistics. Besides direct usage like summary(DT), it can also be applied per-group conveniently with split:
lapply(split(DT, by=c("Species", "Bin"), drop=TRU...
# example data
DT = data.table(iris)
DT[, Bin := cut(Sepal.Length, c(4,6,8))]
To apply the same summarizing function to every column by group, we can use lapply and .SD
DT[, lapply(.SD, median), by=.(Species, Bin)]
# Species Bin Sepal.Length Sepal.Width Petal.Length Petal.Width
# 1...
Setup Ruby On Rails on Ubuntu 16.04 Xenial Xerus
All commands should be run in Linux terminal (hotkey: Ctrl + Alt + T)
You need to install Ruby on your local machine in development environment.
The first step is to install some dependencies for Ruby.
sudo apt-get update
sudo apt-get install git...
A function is a block of code that will be called several times during the execution. Instead of writing the same piece of code again and again, one can write this code inside a function and call that function whenever it is needed.
A function :
Must be declared in a class or a module
Returns a...
Configuring your environment
RabbitMQ looks for an set of environment variables in /etc/rabbitmq/rabbitmq-env.conf. If it does not exist, it assumes default values. All values in rabbitmq-env.conf get exported to the environment the RabbitMQ server runs in with a RABBITMQ_ prefix; this prefix is no...
The DATE data type does not handle time zones or changes in daylight savings time.
Either:
use the TIMESTAMP WITH TIME ZONE data type; or
handle the changes in your application logic.
A DATE can be stored as Coordinated Universal Time (UTC) and converted to the current session time zone like...
You can switch it On at the Module/Class Level by placing the directive at the top of the code file.
Option Strict On
You can switch it on at the project level via the menu in Visual Studio
Project > [Project] Properties > Compile Tab > Option Strict > On
You ...
Throughout the topics and examples here we'll see many declarations of variables, functions and so on.
As well as their name, data objects may have attributes. Covered in this topic are declaration statements like
integer, parameter :: single_kind = kind(1.)
which gives the object single_kind...
This example displays a transaction for an image view with only two images.(can use more images as well one after the other for the first and second layer positions after each transaction as a loop)
add a image array to res/values/arrays.xml
<resources>
<array
name=&...
Express is based on Connect, which is what provides the middleware functionality of Express. To understand what connect is, you can see that it provides the basic app structure that you use when you use express
const connect = require('connect')
const app = connect()
app.listen(3000)
This wi...
std::optional<float> divide(float a, float b) {
if (b!=0.f) return a/b;
return {};
}
Here we return either the fraction a/b, but if it is not defined (would be infinity) we instead return the empty optional.
A more complex case:
template<class Range, class Pred>
auto find_if...
You can call an instance method using the . special form:
(.trim " hello ")
;;=> "hello"
You can call instance methods with arguments like this:
(.substring "hello" 0 2)
;;=> "he"
You can call a Clojure function from Java code by looking up the function and invoking it:
IFn times = Clojure.var("clojure.core", "*");
times.invoke(2, 2);
This looks up the * function from the clojure.core namespace and invokes it with the arguments 2 & 2.