Tutorial by Examples

Behavior Driven Development (BDD) testing style revolves around "given", "when" and "then" stages in tests. However, classical Mockito uses "when" word for "given" phase, and does not include other natural language constructions that can encompass B...
// static: is callable on a class even when no instance of the class has been created public static void MyMethod() // virtual: can be called or overridden in an inherited class public virtual void MyMethod() // internal: access is limited within the current assembly internal void MyMetho...
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...
Selection sort selects the minimum element, repeatedly, until the list is empty. import Data.List (minimum, delete) ssort :: Ord t => [t] -> [t] ssort [] = [] ssort xs = let { x = minimum xs } in x : ssort (delete x xs)
with clause is used to combine matching clauses. It looks like we combine anonymous functions or handle function with multiple bodies (matching clauses). Consider the case: we create a user, insert it into DB, then create greet email and then send it to the user. Without the with clause we might ...
Query: SELECT * FROM Customers ORDER BY CustomerID LIMIT 3; Result: CustomerID CustomerName ContactName Address City PostalCode Country 1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Ge...
In this example our project name is "helloworld" which was created with stack new helloworld simple First we have to build the project with stack build and then we can run it with stack exec helloworld-exe
Circe provides compile-time derived codecs for en/decode json into case classes. A simple example looks like this: import io.circe._ import io.circe.generic.auto._ import io.circe.parser._ import io.circe.syntax._ case class User(id: Long, name: String) val user = User(1, "John Doe&qu...
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...
Attributes: normal Default attribute of fonts. small-caps Sets every letter to uppercase, but makes the lowercase letters(from original text) smaller in size than the letters that originally uppercase. CSS: .smallcaps{ font-variant: small-caps; } HTML: <p class="smallcaps&quot...
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...
The first thing we need to do it add EventBus to our module's gradle file: dependencies { ... compile 'org.greenrobot:eventbus:3.0.0' ... } Now we need to create a model for our event. It can contain anything we want to pass along. For now we'll just make an empty class. public ...
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...
ng-include allows you to delegate the control of one part of the page to a specific controller. You may want to do this because the complexity of that component is becoming such that you want to encapsulate all the logic in a dedicated controller. An example is: <div ng-include src=&q...
def foo(li=[]): li.append(1) print(li) foo([2]) # Out: [2, 1] foo([3]) # Out: [3, 1] This code behaves as expected, but what if we don't pass an argument? foo() # Out: [1] As expected... foo() # Out: [1, 1] Not as expected... This is because default arguments of function...
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]] ...
In Highcharts, there is an array containing the default colors for the chart's series. When all colors are used, new colors are pulled from the start again. Defaults colors for version 4.x and 5.x are: colors: [ '#7cb5ec', '#434348', '#90ed7d', '#f7a35c', '#8085e9', ...
BrandVersions SupportedInternet Explorer6.0 +Firefox2.0 +Chrome1.0 +Safari4.0 +Opera9.0 +iOS (Safari)3.0 +Android Browser2.0 + Highcharts supports jQuery version 1.6+ for legacy browsers, and 2.0+ for modern browsers.
iex> [1, 2, 3] -- [1, 3] [2] -- removes the first occurrence of an item on the left list for each item on the right.

Page 472 of 1336