Tutorial by Examples: and

The following example listens to window.onerror event and uses an image beacon technique to send the information through the GET parameters of an URL. var hasLoggedOnce = false; // Some browsers (at least Firefox) don't report line and column numbers // when event is handled through window.addE...
# Generates 5 random numbers from a uniform distribution [0, 1) np.random.rand(5) # Out: array([ 0.4071833 , 0.069167 , 0.69742877, 0.45354268, 0.7220556 ])
# Creates a 5x5 random integer array ranging from 10 (inclusive) to 20 (inclusive) np.random.randint(10, 20, (5, 5)) ''' Out: array([[12, 14, 17, 16, 18], [18, 11, 16, 17, 17], [18, 11, 15, 19, 18], [19, 14, 13, 10, 13], [15, 10, 12, 13, 18]]...
letters = list('abcde') Select three letters randomly (with replacement - same item can be chosen multiple times): np.random.choice(letters, 3) ''' Out: array(['e', 'e', 'd'], dtype='<U1') ''' Sampling without replacement: np.random.choice(letters, 3, replace=False) ''' Out...
Draw samples from a normal (gaussian) distribution # Generate 5 random numbers from a standard normal distribution # (mean = 0, standard deviation = 1) np.random.randn(5) # Out: array([-0.84423086, 0.70564081, -0.39878617, -0.82719653, -0.4157447 ]) # This result can also be achieved with t...
Drush status drush status This will give you an overview of your Drupal site. Version, URI, database location, file paths, default theme etc. If you use this command and you do not see this information, it means you are in a wrong folder and Drush does not know which Drupal site you are referrin...
If your class doesn't implement a specific overloaded operator for the argument types provided, it should return NotImplemented (note that this is a special constant, not the same as NotImplementedError). This will allow Python to fall back to trying other methods to make the operation work: When...
Use the HTML or <audio> element to embed video/audio content in a document. The video/audio element contains one or more video/audio sources. To specify a source, use either the src attribute or the <source> element; the browser will choose the most suitable one. Audio tag example: &...
Code that uses generics has many benefits over non-generic code. Below are the main benefits Stronger type checks at compile time A Java compiler applies strong type checking to generic code and issues errors if the code violates type safety. Fixing compile-time errors is easier than fixing runt...
import pandas as pd import numpy as np np.random.seed(0) tuples = list(zip(*[['bar', 'bar', 'foo', 'foo', 'qux', 'qux'], ['one', 'two', 'one', 'two','one', 'two']])) idx = pd.MultiIndex.from_tuples(tuples, names=['first', 'second']) df = pd.DataFrame(np.random.randn(6, ...
data.table offers a wide range of possibilities to reshape your data both efficiently and easily For instance, while reshaping from long to wide you can both pass several variables into the value.var and into the fun.aggregate parameters at the same time library(data.table) #v>=1.9.6 DT <- ...
The * operator can be used to unpack variables and arrays so that they can be passed as individual arguments to a method. This can be used to wrap a single object in an Array if it is not already: def wrap_in_array(value) [*value] end wrap_in_array(1) #> [1] wrap_in_array([1, 2, 3]) ...
Different operations with data are done using special classes. Most of the classes belong to one of the following groups: classification algorithms (derived from sklearn.base.ClassifierMixin) to solve classification problems regression algorithms (derived from sklearn.base.RegressorMixin) to so...
await operator and async keyword come together: The asynchronous method in which await is used must be modified by the async keyword. The opposite is not always true: you can mark a method as async without using await in its body. What await actually does is to suspend execution of the code ...
1) BASIC SIMPLE WAY Database-driven applications often need data pre-seeded into the system for testing and demo purposes. To make such data, first create the seeder class ProductTableSeeder use Faker\Factory as Faker; use App\Product; class ProductTableSeeder extends DatabaseSeeder { pub...
You can download Mercurial from the project's website, and there are graphical utilities for Windows, Linux and OSX if you'd prefer that to a command line interface. Most Unix package managers include Mercurial, for example on Debian/Ubuntu: $ apt-get install mercurial You can verify Mercurial i...
Normal types, like String, are not nullable. To make them able to hold null values, you have to explicitly denote that by putting a ? behind them: String? var string : String = "Hello World!" var nullableString: String? = null string = nullableString // Compiler error: Can't...
When working with regular expressions one modifier for PCRE is g for global match. In R matching and replacement functions have two version: first match and global match: sub(pattern,replacement,text) will replace the first occurrence of pattern by replacement in text gsub(pattern,replace...
interface ITable { // an indexer can be declared in an interface object this[int x, int y] { get; set; } } class DataTable : ITable { private object[,] cells = new object[10, 10]; /// <summary> /// implementation of the indexer declared in the interface //...
Overload resolution occurs after name lookup. This means that a better-matching function will not be selected by overload resolution if it loses name lookup: void f(int x); struct S { void f(double x); void g() { f(42); } // calls S::f because global f is not visible here, ...

Page 29 of 153