The .split() method splits a string into an array of substrings. By default .split() will break the string into substrings on spaces (" "), which is equivalent to calling .split(" ").
The parameter passed to .split() specifies the character, or the regular expression, to use for...
JavaScript does not technically support private members as a language feature.
Privacy - described by Douglas Crockford - gets emulated instead via closures
(preserved function scope) that will be generated each with every instantiation call
of a constructor function.
The Queue example demonstra...
Memoization consists of caching function results to avoid computing the same result multiple times. This is useful when working with functions that perform costly computations.
We can use a simple factorial function as an example:
let factorial index =
let rec innerLoop i acc =
match...
Most browsers, when configured to block cookies, will also block localStorage. Attempts to use it will result in an exception. Do not forget to manage these cases.
var video = document.querySelector('video')
try {
video.volume = localStorage.getItem('volume')
} catch (error) {
alert('If...
It is sometimes useful to verify that your work on Developer edition hasn't introduced a dependency on any features restricted to Enterprise edition.
You can do this using the sys.dm_db_persisted_sku_features system view, like so:
SELECT * FROM sys.dm_db_persisted_sku_features
Against the datab...
data(AirPassengers)
class(AirPassengers)
1 "ts"
In the spirit of Exploratory Data Analysis (EDA) a good first step is to look at a plot of your time-series data:
plot(AirPassengers) # plot the raw data
abline(reg=lm(AirPassengers~time(AirPassengers))) # fit a trend line
For...
from datetime import datetime
import pandas_datareader.data as wb
stocklist = ['AAPL','GOOG','FB','AMZN','COP']
start = datetime(2016,6,8)
end = datetime(2016,6,11)
p = wb.DataReader(stocklist, 'yahoo',start,end)
p - is a pandas panel, with which we can do funny things:
let's see what...
You can iterate on the object returned by groupby(). The iterator contains (Category, DataFrame) tuples.
# Same example data as in the previous example.
import numpy as np
import pandas as pd
np.random.seed(0)
df = pd.DataFrame({'Age': np.random.randint(20, 70, 100),
'Sex':...
@org.junit.Test
public void should_$name$() {
$END$
}
Make sure to check the Shorted FQ names box when creating this template.
When you type "should" (the abbreviation),
this will add the necessary import org.junit.Test; statement at the top of the file, and this code:
@Test...
Consider the utility class pattern:
a class with only static methods and no fields.
It's recommended to prevent instantiation of such classes by adding a private a constructor.
This live template example makes it easy to add a private constructor to an existing class, using the name of the enclos...
Atoms are constants that represent a name of some thing. The value of an atom is it's name. An atom name starts with a colon.
:atom # that's how we define an atom
An atom's name is unique. Two atoms with the same names always are equal.
iex(1)> a = :atom
:atom
iex(2)> b = :atom
:at...
Imagine a goroutine with a two step process, where the main thread needs to do some work between each step:
func main() {
ch := make(chan struct{})
go func() {
// Wait for main thread's signal to begin step one
<-ch
// Perform work
time.Sle...
Unlike a named class or struct, unnamed classes and structs must be instantiated where they are defined, and cannot have constructors or destructors.
struct {
int foo;
double bar;
} foobar;
foobar.foo = 5;
foobar.bar = 4.0;
class {
int baz;
public:
int buzz;
...
As a non-standard extension to C++, common compilers allow the use of classes as anonymous members.
struct Example {
struct {
int inner_b;
};
int outer_b;
//The anonymous struct's members are accessed as if members of the parent struct
Example() : inner...