Broadcast variables are read only shared objects which can be created with SparkContext.broadcast method:
val broadcastVariable = sc.broadcast(Array(1, 2, 3))
and read using value method:
val someRDD = sc.parallelize(Array(1, 2, 3, 4))
someRDD.map(
i => broadcastVariable.value.apply(...
Accumulators are write-only variables which can be created with SparkContext.accumulator:
val accumulator = sc.accumulator(0, name = "My accumulator") // name is optional
modified with +=:
val someRDD = sc.parallelize(Array(1, 2, 3, 4))
someRDD.foreach(element => accumulator += el...
fs.access() determines whether a path exists and what permissions a user has to the file or directory at that path. fs.access doesn't return a result rather, if it doesn't return an error, the path exists and the user has the desired permissions.
The permission modes are available as a property on ...
The nodemon package makes it possible to automatically reload your program when you modify any file in the source code.
Installing nodemon globally
npm install -g nodemon (or npm i -g nodemon)
Installing nodemon locally
In case you don't want to install it globally
npm install --save-dev nodemo...
Once Pandas has been installed, you can check if it is is working properly by creating a dataset of randomly distributed values and plotting its histogram.
import pandas as pd # This is always assumed but is included here as an introduction.
import numpy as np
import matplotlib.pyplot as plt
...
A macro can produce different outputs against different input patterns:
/// The `sum` macro may be invoked in two ways:
///
/// sum!(iterator)
/// sum!(1234, iterator)
///
macro_rules! sum {
($iter:expr) => { // This branch handles the `sum!(iterator)` case
$iter.f...
Fortran 2003 introduced intrinsic modules which provide access to special named constants, derived types and module procedures. There are now five standard intrinsic modules:
ISO_C_Binding; supporting C interoperability;
ISO_Fortran_env; detailing the Fortran environment;
IEEE_Exceptions, IEEE_...
INSERT INTO will append to the table or partition, keeping the existing data intact.
INSERT INTO table yourTargetTable SELECT * FROM yourSourceTable;
If a table is partitioned then we can insert into that particular partition in static fashion as shown below.
INSERT INTO TABLE yourTarge...
The <label> element is used to reference a form action element.
In the scope of User Interface it's used to ease the target / selection of elements like Type radio or checkbox.
<label> as wrapper
It can enclose the desired action element
<label>
<input type="checkb...
Given a sequence of steps we use repeatedly, it's often handy to store it in a function. Pipes allow for saving such functions in a readable format by starting a sequence
with a dot as in:
. %>% RHS
As an example, suppose we have factor dates and want to extract the year:
library(magrittr) ...
If you need to match characters that are a part of the regular expression syntax you can mark all or part of the pattern as a regex literal.
\Q marks the beginning of the regex literal.
\E marks the end of the regex literal.
// the following throws a PatternSyntaxException because of the un-close...
The following code will print the arguments to the program, and
the code will attempt to convert each argument into a number (to a
long):
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <limits.h>
int main(int argc, char* argv[]) {
for (int ...
There is a limit to the depth of possible recursion, which depends on the Python implementation. When the limit is reached, a RuntimeError exception is raised:
def cursing(depth):
try:
cursing(depth + 1) # actually, re-cursing
except RuntimeError as RE:
print('I recursed {} times!'....
To share files or to host simple websites(http and javascript) in your local network, you can use Python's builtin SimpleHTTPServer module. Python should be in your Path variable. Go to the folder where your files are and type:
For python 2:
$ python -m SimpleHTTPServer <portnumber>
For p...
Defining a member block inside a resource creates a route that can act on an individual member of that resource-based route:
resources :posts do
member do
get 'preview'
end
end
This generates the following member route:
get '/posts/:id/preview', to: 'posts#preview'
# preview_post_p...
The specifier override has a special meaning in C++11 onwards, if appended at the end of function signature. This signifies that a function is
Overriding the function present in base class &
The Base class function is virtual
There is no run time significance of this specifier as is mainl...
With virtual member functions:
#include <iostream>
struct X {
virtual void f() { std::cout << "X::f()\n"; }
};
struct Y : X {
// Specifying virtual again here is optional
// because it can be inferred from X::f().
virtual void f() { std::cout <<...