Tutorial by Examples: ad

7 Object spreading is just syntactic sugar for Object.assign({}, obj1, ..., objn); It is done with the ... operator: let obj = { a: 1 }; let obj2 = { ...obj, b: 2, c: 3 }; console.log(obj2); // { a: 1, b: 2, c: 3 }; As Object.assign it does shallow merging, not deep merging. let obj3 = ...
URL url = new URL("http://example.com"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); try { BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream())); // use a string builder to bufferize the response body //...
If you have several objects of monadic types, we can achieve combinations of the values using a 'for comprehension': for { x <- Option(1) y <- Option("b") z <- List(3, 4) } { // Now we can use the x, y, z variables println(x, y, z) x // the last expre...
Let's take an example of adding a value to a range (as it could be done in a loop for example): 3+1:5 Gives: [1] 4 5 6 7 8 This is because the range operator : has higher precedence than addition operator +. What happens during evaluation is as follows: 3+1:5 3+c(1, 2, 3, 4, 5) expansio...
The <!DOCTYPE> declaration should always be included at the top of the HTML document, before the <html> tag. 5 See HTML 5 Doctype for details on the HTML 5 Doctype. <!DOCTYPE html> 4.01 See HTML 4.01 Doctypes for details on how these types differ from each other. Stri...
First we need to install composer. Steps to install composer Install Composer. curl -sS https://getcomposer.org/installer | php Now change directory: sudo mv composer.phar /usr/local/bin/composer Check composer working composer Now Composer installed. There two ways to install Yii2 adv...
Even just reading the value of a pointer that was freed (i.e. without trying to dereference the pointer) is undefined behavior(UB), e.g. char *p = malloc(5); free(p); if (p == NULL) /* NOTE: even without dereferencing, this may have UB */ { } Quoting ISO/IEC 9899:2011, section 6.2.4 §2: ...
Functions can take inputs in form of variables that can be used and assigned inside their own scope. The following function takes two numeric values and returns their sum: function addition (argument1, argument2){ return argument1 + argument2; } console.log(addition(2, 3)); // -> 5 ...
A custom component that takes the type of a component as input and creates an instance of that component type inside itself. When the input is updated, the previously added dynamic component is removed and the new one added instead. @Component({ selector: 'dcl-wrapper', template: `<div #...
A data.table is an enhanced version of the data.frame class from base R. As such, its class() attribute is the vector "data.table" "data.frame" and functions that work on a data.frame will also work with a data.table. There are many ways to create, load or coerce to a data.table....
To develop an application for iOS, you should start with an application called Xcode. There are other alternative tools you can use, but Xcode is Apple's official tool. Note, however, that it only runs on macOS. The latest official version is Xcode 8.3.3 with Xcode 9 (currently in beta) due to be re...
There are two ways to connect to a MySQL/MariaDB server, depending on your infrastructure. Standard (TCP/IP) connection $dsn = 'mysql:dbname=demo;host=server;port=3306;charset=utf8'; $connection = new \PDO($dsn, $username, $password); // throw exceptions, when SQL error is caused $connection-...
When working with multi-module projects, it is helpful to centralize dependencies in a single location rather than having them spread across many build files, especially for common libraries such as the Android support libraries and the Firebase libraries. One recommended way is to separate the Gra...
In Haskell, it often makes sense not to bother with file handles at all, but simply read or write an entire file straight from disk to memory†, and do all the partitioning/processing of the text with the pure string data structure. This avoids mixing IO and program logic, which can greatly help avoi...
Example for reading file data_file.csv such as: File: index,header1,header2,header3 1,str_data,12,1.4 3,str_data,22,42.33 4,str_data,2,3.44 2,str_data,43,43.34 7, str_data, 25, 23.32 Code: pd.read_csv('data_file.csv') Output: index header1 header2 header3 0 1 str_dat...
Assuming python and python3 are both installed, it is possible to create a virtual environment for Python 3 even if python3 is not the default Python: virtualenv -p python3 foo or virtualenv --python=python3 foo or python3 -m venv foo or pyvenv foo Actually you can create virtual ...
Requirements: Installed Java JDK or JRE (version 7 or higher for Gradle 3.x version) Installation steps: Download Gradle distribution from the official web site Unpack the ZIP Add the GRADLE_HOME environment variable. This variable should point to the unpacked files from the previous step. Ad...
Swift let mapView = MKMapView(frame: CGRect(x: 0, y: 0, width: 320, height: 500)) It's recommended to store the mapView as a property of the containing ViewController since you might want to access it in more complex implementations. Objective C self.map = [[MKMapView alloc]initWithFrame:CGRec...
Just like all programming language, Matlab is designed to read and write in a large variety of formats. The native library supports a large number of Text,Image,Video,Audio,Data formats with more formats included in each version update - check here to see the full list of supported file formats and ...
You can use a column's number (where the leftmost column is '1') to indicate which column to base the sort on, instead of describing the column by its name. Pro: If you think it's likely you might change column names later, doing so won't break this code. Con: This will generally reduce readabilit...

Page 10 of 114