# 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...
A quick note before actually installing RabbitMQ: Ubuntu 14.04's Erlang packages have issues if you are using SSL with RabbitMQ, so you'll need to install a newer version than what the Ubuntu package maintainers provide, so use the binaries at https://www.erlang-solutions.com/resources/download.html...
Monotonic predicates can be debugged by applying declarative reasoning.
In pure Prolog, a programming mistake can lead to one or all of the following phenomena:
the predicate incorrectly succeeds in a case where it should fail
the predicate incorrectly fails in a case where it should succeed
t...
It is sometimes argued that, for the sake of efficiency, we must accept the use of non-monotonic constructs in real-world Prolog programs.
There is no evidence for this. Recent research indicates that the pure monotonic subset of Prolog may not only be sufficient to express most real-world programs...
//Example 1
int[] array = { 1, 5, 2, 10, 7 };
// Select squares of all odd numbers in the array sorted in descending order
IEnumerable<int> query = from x in array
where x % 2 == 1
orderby x descending
select x ...
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
...
set can also be invoked with just one argument. When called with just one argument, it returns the contents of that argument.
% set x 235
235
% set x
235
List<Integer> nums = Arrays.asList(1, 2, 3);
List<String> strings = nums.stream()
.map(Object::toString)
.collect(Collectors.toList());
That is:
Create a stream from the list
Map each element using Object::toString
Collect the String values into a List using Collectors...
The chan-signal crate provides a solution to handle OS signal using channels, altough this crate is experimental and should be used carefully.
Example taken from BurntSushi/chan-signal.
#[macro_use]
extern crate chan;
extern crate chan_signal;
use chan_signal::Signal;
fn main() {
// S...
The nix crate provides an UNIX Rust API to handle signals, however it requires using unsafe rust so you should be careful.
use nix::sys::signal;
extern fn handle_sigint(_:i32) {
// Be careful here...
}
fn main() {
let sig_action = signal::SigAction::new(handle_sigint,
...
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...
Sometimes one has to work with pages that are not using jQuery while most developers are used to have jQuery handy.
In such situations one can use Chrome Developer Tools console (F12) to manually add jQuery on a loaded page by running following:
var j = document.createElement('script');
j.onload ...
In VB.NET, every variable must be declared before it is used (If Option Explicit is set to On). There are two ways of declaring variables:
Inside a Function or a Sub:
Dim w 'Declares a variable named w of type Object (invalid if Option Strict is On)
Dim x As String 'Declares a variable named ...
Dim flags = BindingFlags.Static Or BindingFlags.Public Or BindingFlags.Instance
Dim members = GetType(String).GetMembers(flags)
For Each member In members
Console.WriteLine($"{member.Name}, ({member.MemberType})")
Next