Tutorial by Examples: e

# example data set.seed(1) n = 1e7 ng = 1e4 DT = data.table( g1 = sample(ng, n, replace=TRUE), g2 = sample(ng, n, replace=TRUE), v = rnorm(n) ) Matching on one column After the first run of a subsetting operation with == or %in%... system.time( DT[ g1 %in% 1:100] )...
Consider an array of work items. The time needed for an each work item to complete varies greatly. In order to balance the work distribution between blocks it may be prudent for each block to fetch the next item only when previous one is complete. This is in contrast to a-priori assigning items to...
Tuples support the following build-in functions Comparison If elements are of the same type, python performs the comparison and returns the result. If elements are different types, it checks whether they are numbers. If numbers, perform comparison. If either element is a number, then the other...
Introduction The PHPUnit Manual describes mocking as such: The practice of replacing an object with a test double that verifies expectations, for instance asserting that a method has been called, is referred to as mocking. So instead of stubbing out code, an observer is created that not onl...
// application/controllers/Company_controller.php <?php if(!defined('BASEPATH')) exit('No direct script access allowed'); class Company_controller extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('companies_mo...
If a void* value is converted to a pointer to object type, T*, but is not properly aligned for T, the resulting pointer value is unspecified. Example: // Suppose that alignof(int) is 4 int x = 42; void* p1 = &x; // Do some pointer arithmetic... void* p2 = static_cast<char*>(p1) + 2; ...
Batch file command line arguments are parameter values submitted when starting the batch. They should be enclosed in quotes if they contain spaces. In a running batch file, the arguments are used for various purposes, i.e. redirection to :labels, setting variables, or running commands. The argument...
When more than 9 arguments are supplied, the shift [/n] command can be used, where /n means start at the nth argument, n is between zero and eight. Looping through arguments: :args set /a "i+=1" set arg!i!=%~1 call echo arg!i! = %%arg!i!%% shift goto :args Note, in the above exam...
Bottom sheets slide up from the bottom of the screen to reveal more content. They were added to the Android Support Library in v25.1.0 version and supports above all the versions. Make sure the following dependency is added to your app's build.gradle file under dependencies: compile 'com.android...
Assuming you have Eclipse IDE for Java Developers installed, start Eclipse, click "Help" -> "Install New Software..." Select "--All Available Sites--" at "Work with:", and navigate to "Eclipse Plugin Development Tools". Select "Eclipse Pl...
Automatic Linebreaks Table content is line wrapped automatically if it is too wide. In the following example, text is added to the second column, which causes oth the text itself and the column header of the first column to be wrapped. | this is a really wide column header | another header | | -...
io-streams is Stream-based library that focuses on the Stream abstraction but for IO. It exposes two types: InputStream: a read-only smart handle OutputStream: a write-only smart handle We can create a stream with makeInputStream :: IO (Maybe a) -> IO (InputStream a). Reading from ...
Let's create an Enumerator for Fibonacci numbers. fibonacci = Enumerator.new do |yielder| a = b = 1 loop do yielder << a a, b = b, a + b end end We can now use any Enumerable method with fibonacci: fibonacci.take 10 # => [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
If an iteration method such as each is called without a block, an Enumerator should be returned. This can be done using the enum_for method: def each return enum_for :each unless block_given? yield :x yield :y yield :z end This enables the programmer to compose Enumerable operati...
Use rewind to restart the enumerator. ℕ = Enumerator.new do |yielder| x = 0 loop do yielder << x x += 1 end end ℕ.next # => 0 ℕ.next # => 1 ℕ.next # => 2 ℕ.rewind ℕ.next # => 0
When multiple variables are defined at the beginning of the batch, a short definition form may be used by employing a replacement string. @echo off set "vars=_A=good,_B=,_E=bad,_F=,_G=ugly,_C=,_H=,_I=,_J=,_K=,_L=,_D=6 set "%vars:,=" & set "%" for /f %%l in ('set _'...
There are two approaches for influencing when a memory cleanup is performed. They are influencing how often the automatic process is performed and the other is manually triggering a cleanup. The garbage collector can be manipulated by tuning the collection thresholds which affect the frequency at w...
If you want to clear your current Activity stack and launch a new Activity (for example, logging out of the app and launching a log in Activity), there appears to be two approaches. 1. Target (API >= 16) Calling finishAffinity() from an Activity 2. Target (11 <= API < 16) Intent intent ...
A few pre-requisites in the build.gradle for vectors to work all the way down to API 7 for VectorDrawables and API 13 for AnimatedVectorDrawables (with some caveats currently): //Build Tools has to be 24+ buildToolsVersion '24.0.0' defaultConfig { vectorDrawables.useSupportLibrary = true ...
Get the current date and time. public class Program { static void Main() { // create empty pipeline PowerShell ps = PowerShell.Create(); // add command ps.AddCommand("Get-Date"); // run command(s) Console.WriteLine(&quot...

Page 603 of 1191