List doesn't support "random access", which means it takes more work to get, say, the fifth element from the list than the first element, and as a result there's no List.get nth list function. One has to go all the way from the beginning (1 -> 2 -> 3 -> 4 -> 5).
If you need ra...
Arrays can have more than one dimension. The following example creates a two-dimensional array of ten rows and ten columns:
int[,] arr = new int[10, 10];
An array of three dimensions:
int[,,] arr = new int[10, 10, 10];
You can also initialize the array upon declaration:
int[,] arr = new int...
A comment is marked by an apostrophe ('), and ignored when the code executes. Comments help explain your code to future readers, including yourself.
Since all lines starting with a comment are ignored, they can also be used to prevent code from executing (while you debug or refactor). Placing an ap...
Sub RemComments()
Rem Comments start with "Rem" (VBA will change any alternate casing to "Rem")
Rem is an abbreviation of Remark, and similar to DOS syntax
Rem Is a legacy approach to adding comments, and apostrophes should be preferred
Rem Comments CANNOT appear af...
Usually authentication&authorization processes are performed by built-in cookie and token supports in .net MVC. But if you decide to do it yourself with Session you can use below logic for both page requests and ajax requests.
public class SessionControl : ActionFilterAttribute
{
public o...
This is an example of how to use the generic type TFood inside Eat method on the class Animal
public interface IFood
{
void EatenBy(Animal animal);
}
public class Grass: IFood
{
public void EatenBy(Animal animal)
{
Console.WriteLine("Grass was eaten by: {0}",...
arr = np.arange(7)
print(arr)
# Out: array([0, 1, 2, 3, 4, 5, 6])
Comparison with a scalar returns a boolean array:
arr > 4
# Out: array([False, False, False, False, False, True, True], dtype=bool)
This array can be used in indexing to select only the numbers greater than 4:
arr[arr&...
The numpy.reshape (same as numpy.ndarray.reshape) method returns an array of the same total size, but in a new shape:
print(np.arange(10).reshape((2, 5)))
# [[0 1 2 3 4]
# [5 6 7 8 9]]
It returns a new array, and doesn't operate in place:
a = np.arange(12)
a.reshape((3, 4))
print(a)
# ...
Along with classic way of route definition MVC WEB API 2 and then MVC 5 frameworks introduced Attribute routing:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// This...
Currying, according to Wikipedia,
is the technique of translating the evaluation of a function that
takes multiple arguments into evaluating a sequence of functions.
Concretely, in terms of scala types, in the context of a function that take two arguments, (has arity 2) it is the conversion o...
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...
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...