Tutorial by Examples: er

Subroutine arguments in Perl are passed by reference, unless they are in the signature. This means that the members of the @_ array inside the sub are just aliases to the actual arguments. In the following example, $text in the main program is left modified after the subroutine call because $_[0] in...
To get started quickly with Express, you can use the Express generator which will create an application skeleton for you. First, install it globally with npm: npm install express-generator -g You may need to put sudo before this command if you get a "permission denied" error. Once th...
Command line You can use cpan to install modules directly from the command line: cpan install DBI This would be followed by possibly many pages of output describing exactly what it is doing to install the module. Depending on the modules being installed, it may pause and ask you questions. Int...
The Fluent NHibernate is a library to help you to map the entities using C# code instead of xml mappings. Fluent NHibernate uses the fluent pattern and it is based on conventions to create the mappings and it gives you the power of the visual studio tools (such as intellisense) to improve the way yo...
IQueryable<Cat> cats = session.Query<Cat>() .Where(c => c.Name == "Max");
Also known as bogosort. import Data.List (permutations) sorted :: Ord a => [a] -> Bool sorted (x:y:xs) = x <= y && sorted (y:xs) sorted _ = True psort :: Ord a => [a] -> [a] psort = head . filter sorted . permutations Extremely inefficient (on today's compu...
A basic QueryOver query is performed against an ISession using the QueryOver<T> method, where T is the type of a mapped entity. IList<Customer> customers = session.QueryOver<Customer>() .Where(c => c.LastName == "Simpson") .List();
This will show you the generated SQL, but will not show you the values contained within the queries. <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="hibernateProperties"> <p...
The @ sign binds a variable to a name during a pattern match. The bound variable can either be the entire matched object or part of the matched object: sealed trait Shape case class Rectangle(height: Int, width: Int) extends Shape case class Circle(radius: Int) extends Shape case object Point ex...
Pattern matching can also be used to check the type of an instance, rather than using isInstanceOf[B]: val anyRef: AnyRef = "" anyRef match { case _: Number => "It is a number" case _: String => "I...
The [ and [[ operators are primitive functions that are generic. This means that any object in R (specifically isTRUE(is.object(x)) --i.e. has an explicit "class" attribute) can have its own specified behaviour when subsetted; i.e. has its own methods for [ and/or [[. For example, this is...
This operator checks whether the object is of a particular class/interface type. instanceof operator is written as: ( Object reference variable ) instanceof (class/interface type) Example: public class Test { public static void main(String args[]){ String name = "Buyya";...
The left hand operand for these operators must be a either a non-final variable or an element of an array. The right hand operand must be assignment compatible with the left hand operand. This means that either the types must be the same, or the right operand type must be convertible to the left o...
The R-Logo is a multilayer raster file (red, green, blue) library(raster) r <- stack("C:/Program Files/R/R-3.2.3/doc/html/logo.jpg") plot(r) The individual layers of the RasterStack object can be adressed by [[. plot(r[[1]])
There is no simple way to obtain attributes from an interface, since classes does not inherit attributes from an interface. Whenever implementing an interface or overriding members in a derived class, you need to re-declare the attributes. So in the example below output would be True in all three c...
The code below implements a very simple complex number type for which the underlying field is automatically promoted, following the language's type promotion rules, under application of the four basic operators (+, -, *, and /) with a member of a different field (be it another complex<T> or so...
To take a photo, first we need to declare required permissions in AndroidManifest.xml. We need two permissions: Camera - to open camera app. If attribute required is set to true you will not be able to install this app if you don't have hardware camera. WRITE_EXTERNAL_STORAGE - This permission i...
You will have to inject $filter: angular .module('filters', []) .filter('percentage', function($filter) { return function (input) { return $filter('number')(input * 100) + ' %'; }; });
By default, a filter has a single parameter: the variable it is applied on. But you can pass more parameter to the function: angular .module('app', []) .controller('MyController', function($scope) { $scope.example = 0.098152; }) .filter('percentage', function($filter) { return...
Consider the case of creating a nested list structure by multiplying: li = [[]] * 3 print(li) # Out: [[], [], []] At first glance we would think we have a list of containing 3 different nested lists. Let's try to append 1 to the first one: li[0].append(1) print(li) # Out: [[1], [1], [1]] ...

Page 150 of 417