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...
Install
npm is bundled with Node.js, so if you install Node.js you'll automatically have npm installed too. You can choose between a Current and a LTS version
Windows
For Microsoft Windows you can download a MSI installer from https://nodejs.org/en/download/.
OS X
For Apple OS X you can downloa...
.htaccess can be used to set a custom error pages that matches the theme of your website instead of seeing a white error page with black techno-babble when users end up on at a page with an error server response code. The error page can be any browser parseable file, including (But not limited to)...
A variable of a reference type can hold either a valid reference to an instance or a null reference. The null reference is the default value of reference type variables, as well as nullable value types.
null is the keyword that represents a null reference.
As an expression, it can be used to assig...
drush dl drupal --drupal-project-rename=example
cd example
drush site-install standard --db-url='mysql://[db_user]:[db_pass]@localhost/[db_name]' --site-name=Example
In the condition of the for and while loops, it's also permitted to declare an object. This object will be considered to be in scope until the end of the loop, and will persist through each iteration of the loop:
for (int i = 0; i < 5; ++i) {
do_something(i);
}
// i is no longer in scope...
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...
The following method computes the Nth Fibonacci number using recursion.
public int fib(final int n) {
if (n > 2) {
return fib(n - 2) + fib(n - 1);
}
return 1;
}
The method implements a base case (n <= 2) and a recursive case (n>2). This illustrates the use of re...
Overload resolution partitions the cost of passing an argument to a parameter into one of four different categorizes, called "sequences". Each sequence may include zero, one or several conversions
Standard conversion sequence
void f(int a); f(42);
User defined conversion seque...
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...
While
The most trivial loop type. Only drawback is there is no intrinsic clue to know where you are in the loop.
/// loop while the condition satisfies
while(condition)
{
/// do something
}
Do
Similar to while, but the condition is evaluated at the end of the loop instead of the beginn...
A factory function is simply a function that returns an object.
Factory functions do not require the use of the new keyword, but can still be used to initialize an object, like a constructor.
Often, factory functions are used as API wrappers, like in the cases of jQuery and moment.js, so users do ...
Files and directories (another name for folders) are at the heart of Linux, so being able to create, view, move, and delete them from the command line is very important and quite powerful. These file manipulation commands allow you to perform the same tasks that a graphical file explorer would perfo...
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:
&...
By recursion
let rec sumTotal list =
match list with
| [] -> 0 // empty list -> return 0
| head :: tail -> head + sumTotal tail
The above example says: "Look at the list, is it empty? return 0. Otherwise it is a non-empty list. So it could be [1], [1; 2], [1; 2; 3] ...