# example data
DT = data.table(Titanic)
Suppose we only want to see second class:
DT[ Class == "2nd" ]
# Class Sex Age Survived N
# 1: 2nd Male Child No 0
# 2: 2nd Female Child No 0
# 3: 2nd Male Adult No 154
# 4: 2nd Female Adult ...
# example data
DT = data.table(Titanic)
Suppose we want to see each class only if a majority survived:
DT[, if (sum(N[Survived=="Yes"]) > sum(N[Survived=="No"]) ) .SD, by=Class]
# Class Sex Age Survived N
# 1: 1st Male Child No 0
# 2: 1st Fema...
Delete all nodes
MATCH (n)
DETACH DELETE n
DETACH doesn't work in older versions(less then 2.3), for previous versions use
MATCH (n)
OPTIONAL MATCH (n)-[r]-()
DELETE n, r
Delete all nodes of a specific label
MATCH (n:Book)
DELETE n
The DISTINCT clause after SELECT eliminates duplicate rows from the result set.
CREATE TABLE `car`
( `car_id` INT UNSIGNED NOT NULL PRIMARY KEY,
`name` VARCHAR(20),
`price` DECIMAL(8,2)
);
INSERT INTO CAR (`car_id`, `name`, `price`) VALUES (1, 'Audi A1', '20000');
INSERT INTO CA...
Here are examples of how to use monotonic predicates instead of impure, non-monotonic constructs in your programs:
dif/2 is meant to be used instead of non-monotonic constructs like (\=)/2
arithmetic constraints (CLP(FD), CLP(Q) and others) are meant to be used instead of moded arithmetic predi...
To interact with WebElements in a webpage, first we need to identify the location of the element.
By is the keyword available in selenium.
You can locate the elements By..
By ID
By Class Name
By TagName
By Name
By Link Text
By Partial Link Text
By CSS Selector
By XPath
Using JavaScript
...
It is deemed best practice to always use Option Explicit in VBA as it forces the developer to declare all their variables before use. This has other benefits too, such as auto-capitalization for declared variable names and IntelliSense.
Option Explicit
Sub OptionExplicit()
Dim a As Integer
...
Option Compare Binary
Binary comparison makes all checks for string equality within a module/class case sensitive. Technically, with this option, string comparisons are performed using sort order of the binary representations of each character.
A < B < E < Z < a < b < e < z
...
Option Base is used to declare the default lower bound of array elements. It is declared at module level and is valid only for the current module.
By default (and thus if no Option Base is specified), the Base is 0. Which means that the first element of any array declared in the module has an index...
Unlike emails, JIDs were defined with Internationalization (i18n) in mind using the
Preparation, Enforcement, and Comparison of Internationalized Strings (PRECIS) framework. PRECIS (defined in RFC 7564), is a framework for comparing strings safely in a variety of contexts. For instance, imagine you...
Adding a footer is not natively possible. Luckily, we can make use of jQuery and CSS to add a footer to the slides of an ioslides presentation rendered with knitr.
First of all we have to include the jQuery plugin. This is done by the line
<script src="https://ajax.googleapis.com/ajax/libs...
Below code is simple java program using selenium.
The journey of the below code is
Open Firefox browser
Open google page
Print title of Google page
Find the search box location
Pass the value as Selenium in the search box
Submit the form
Shutdown the browser
package org.openqa.selenium....
ArrayList is one of the inbuilt data structures in Java. It is a dynamic array (where the size of the data structure not needed to be declared first) for storing elements (Objects).
It extends AbstractList class and implements List interface. An ArrayList can contain duplicate elements where it mai...
This example assumes that your lookup column is named MultiLookupColumnName and that you want to set your multi-lookup field to lookup to the items with IDs 1 and 2.
Using jQuery AJAX
2010
var listName = "YourListName";
var lookupList = "LookupListName";
var idOfItemToUpdate...
The Replace function in SQL is used to update the content of a string. The function call is REPLACE( ) for MySQL, Oracle, and SQL Server. The syntax of the Replace function is:
REPLACE (str, find, repl)
The following example replaces occurrences of South with Southern in Employees table:
FirstN...
Iterate over JSONObject properties
JSONObject obj = new JSONObject("{\"isMarried\":\"true\", \"name\":\"Nikita\", \"age\":\"30\"}");
Iterator<String> keys = obj.keys();//all keys: isMarried, name & age
while (keys.has...
When to use abstract classes: To implement the same or different behaviour among multiple related objects
When to use interfaces: to implement a contract by multiple unrelated objects
Abstract classes create "is a" relations while interfaces provide "has a" capability.
This c...
Disclaimer: In no way does this example advocate the use of singletons. Singletons are to be used with a lot of care.
In PHP there is quite a standard way of implementing a singleton:
public class Singleton {
private $instance;
private function __construct() { };
public function...
To see all the facts involving the le relation from the prelude:
Coq < Search le.
le_n: forall n : nat, n <= n
le_S: forall n m : nat, n <= m -> n <= S m
...
max_l: forall n m : nat, m <= n -> Nat.max n m = n
max_r: forall n m : nat, n <= m -> Nat.max n m = m
...
...