Having more than one element with the same ID is a hard to troubleshoot problem. The HTML parser will usually try to render the page in any case. Usually no error occurs. But the pace could end up in a mis-behaving web page.
In this example:
<div id="aDiv">a</div>
<div id...
To ignore a test, simply add the @Ignore annotation to the test and optionally provide a parameter to the annotation with the reason.
@Ignore("Calculator add not implemented yet.")
@Test
public void testPlus() {
assertEquals(5, calculator.add(2,3));
}
Compared to commenting the...
A spring bean can be configured such that it will register only if it has a particular value or a specified property is met. To do so, implement Condition.matches to check the property/value:
public class PropertyCondition implements Condition {
@Override
public boolean matches(ConditionC...
Find meaningful names for computation units.
Use for comprehensions or map to combine computations together.
Let's say you have something like this:
if (userAuthorized.nonEmtpy) {
makeRequest().map {
case Success(respone) =>
someProcessing(..)
if (resendToUser) {
...
By default:
Use val, not var, wherever possible. This allows you to take seamless advantage of a number of functional utilities, including work distribution.
Use recursion and comprehensionss, not loops.
Use immutable collections. This is a corrolary to using val whenever possible.
Focus on da...
This example shows a white Snackbar with custom Undo icon.
Snackbar customBar = Snackbar.make(view , "Text to be displayed", Snackbar.LENGTH_LONG);
customBar.setAction("UNDO", new View.OnClickListener() {
@Override
public void onClick(View view) {
//Put the logic...
Say we have Products and Categorys in a many-to-many relationship:
public class Product
{
public Product()
{
Categories = new HashSet<Category>();
}
public int ProductId { get; set; }
public string ProductName { get; set; }
public virtual ICollection<...
The flatMap operator help you to transform one event to another Observable (or transform an event to zero, one, or more events).
It's a perfect operator when you want to call another method which return an Observable
public Observable<String> perform(int i) {
// ...
}
Observabl...
The Fibonacci numbers are defined inductively as
F0 = 0
F1 = 1
Fn+2 = Fn + Fn+1
The sum of the first n+1 Fibonacci numbers is given by
F0 + F1 + F2 + ... + Fn = Fn+2 - 1.
This summation arises, among other places, in the analysis of Fibonacci heaps, where it's used to provide a lower b...
You can animate complex changes to your collection view using the performBatchUpdates method. Inside the update block, you can specify several modifications to have them animate all at once.
collecitonView.performBatchUpdates({
// Perform updates
}, nil)
Inside the update block, you can pe...
Before starting with the example I'd recommend to create a Singleton with a delegate class member so you could achieve a use case of uploading a file in the background and let the user keep using your app while the files are being uploaded even when the app is the background.
Let's start, first, we...
If all you need is to wrap the value into a promise, you don't need to use the long syntax like here:
//OVERLY VERBOSE
var defer;
defer = $q.defer();
defer.resolve(['one', 'two']);
return defer.promise;
In this case you can just write:
//BETTER
return $q.when(['one', 'two']);
$q.when ...
C-h t runs the function help-with-tutorial, which opens a buffer containing a tutorial on the basic editing functionality of emacs, including moving around in text, and working with files, buffers, and windows.
Another powerful & mature concurrency tool in Haskell is Software Transactional Memory, which allows for multiple threads to write to a single variable of type TVar a in an atomic manner.
TVar a is the main type associated with the STM monad and stands for transactional variable. They're used m...
The Data.Vector module provided by the vector is a high performance library for working with arrays.
Once you've imported Data.Vector, it's easy to start using a Vector:
Prelude> import Data.Vector
Prelude Data.Vector> let a = fromList [2,3,4]
Prelude Data.Vector> a
fromList [2,3,4]...
Vectors can be map'd and fold'd,filter'd andzip`'d:
Prelude Data.Vector> Data.Vector.map (^2) y
fromList [0,1,4,9,16,25,36,49,64,81,100,121] :: Data.Vector.Vector
Reduce to a single value:
Prelude Data.Vector> Data.Vector.foldl (+) 0 y
66
Zip two arrays into an array of pairs:
Prelude Data.Vector> Data.Vector.zip y y
fromList [(0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9),(10,10),(11,11)] :: Data.Vector.Vector
Most of the magic of destructuring uses the splat (*) operator.
ExampleResult / commenta, b = [0,1]a=0, b=1a, *rest = [0,1,2,3]a=0, rest=[1,2,3]a, * = [0,1,2,3]a=0 Equivalent to .first*, z = [0,1,2,3]z=3 Equivalent to .last
By default Code First includes in model
Types defined as a DbSet property in context class.
Reference types included in entity types even if they are defined in
different assembly.
Derived classes even if only the base class is defined as DbSet
property
Here is an example, that we are only...