Attributes are name-value pairs associated with an element.
They are represented by values in single or double quotes inside the opening element tag, or the empty element tag if it is an empty element.
<document>
<anElement foo="bar" abc='xyz'><!-- some content -->&l...
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...
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...
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...
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...
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...
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] ...
Free version of SSH protocol implementation, OpenSSH is available in all the Linux distributions. It consists of the server and client packages.
Installation
On Debian-based Linux, you can install openssh using
# apt-get install openssh-server openssh-client
On RHEL/CentOS you need to use yum:...
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 works similarly to the * operator but it applies to keyword parameters.
def options(required_key:, optional_key: nil, **other_options)
other_options
end
options(required_key: 'Done!', foo: 'Foo!', bar: 'Bar!')
#> { :foo => "Foo!", :bar => "Bar!" ...
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])
...
Using iris dataset:
import sklearn.datasets
iris_dataset = sklearn.datasets.load_iris()
X, y = iris_dataset['data'], iris_dataset['target']
Data is split into train and test sets. To do this we use the train_test_split utility function to split both X and y (data and target vectors) randomly w...
Finding patterns in data often proceeds in a chain of data-processing steps, e.g., feature selection, normalization, and classification. In sklearn, a pipeline of stages is used for this.
For example, the following code shows a pipeline consisting of two stages. The first scales the features, and t...
For ease of testing, sklearn provides some built-in datasets in sklearn.datasets module. For example, let's load Fisher's iris dataset:
import sklearn.datasets
iris_dataset = sklearn.datasets.load_iris()
iris_dataset.keys()
['target_names', 'data', 'target', 'DESCR', 'feature_names']
You can ...
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...