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...
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...
Unnamed class types may also be used when creating type aliases, i.e. via typedef and using:
C++11
using vec2d = struct {
float x;
float y;
};
typedef struct {
float x;
float y;
} vec2d;
vec2d pt;
pt.x = 4.f;
pt.y = 3.f;
mutable modifier in this context is used to indicate that a data field of a const object may be modified without affecting the externally-visible state of the object.
If you are thinking about caching a result of expensive computation, you should probably use this keyword.
If you have a lock (for ...
By default, the implicit operator() of a lambda is const. This disallows performing non-const operations on the lambda. In order to allow modifying members, a lambda may be marked mutable, which makes the implicit operator() non-const:
int a = 0;
auto bad_counter = [a] {
return a++; // er...