A generator is a combination of two things - an Iterator and an Observer.
Iterator
An iterator is something when invoked returns an iterable. An iterable is something you can iterate upon. From ES6/ES2015 onwards, all collections (Array, Map, Set, WeakMap, WeakSet) conform to the Iterable contract...
OpenSSL is an open source project that provides a robust, commercial-grade, and full-featured toolkit for the Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols. It is also a general-purpose cryptography library.
The OpenSSL toolkit is licensed under an Apache-style license, wh...
A Stream of items that are in turn streamable can be flattened into a single continuous Stream:
Array of List of Items can be converted into a single List.
List<String> list1 = Arrays.asList("one", "two");
List<String> list2 = Arrays.asList("three"...
To create a Grails application, use the grails create-app command. The following command creates a Grails application, named myapp in the current directory:
grails create-app fancy-app
Running it, is as simple as visiting the, newly created, application directory:
cd fancy-app
and then
grai...
Package names
Package names should be all lower case without underscores or other special characters.
Package names begin with the reversed authority part of the web address of the company of the developer. This part can be followed a by project/program structure dependent package substructure.
...
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...
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...
@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...