Tutorial by Examples

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...
Do not overcomplicate simple tasks. Most of the time you will need only: algebraic datatypes structural recursion monad-like api (map, flatMap, fold) There is plenty of complicated stuff in Scala, such as: Cake pattern or Reader Monad for Dependency Injection. Passing arbitrary values as...
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...
HTML5 is not based on SGML, and therefore does not require a reference to a DTD. HTML 5 Doctype declaration: <!DOCTYPE html> Case Insensitivity Per the W3.org HTML 5 DOCTYPE Spec: A DOCTYPE must consist of the following components, in this order: A string that is an ASCII case-inse...
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...
The blob.slice() method is used to create a new Blob object containing the data in the specified range of bytes of the source Blob. This method is usable with File instances too, since File extends Blob. Here we slice a file in a specific amount of blobs. This is useful especially in cases where yo...
For signing to work you need a default GPG key configured. You can turn it on or off as follows: npm config set sign-git-tag <true or false>
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&lt...
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...
There is no format specifier to print boolean type using NSLog. One way to print boolean value is to convert it to a string. BOOL boolValue = YES; NSLog(@"Bool value %@", boolValue ? @"YES" : @"NO"); Output: 2016-07-30 22:53:18.269 Test[4445:64129] Bool value YES ...
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.
Pressing C-h a will run the emacs function apropos-command which makes emacs prompt for words (or a regexp) to search for. It will then show a buffer containing a list of names and descriptions related to that topic, including key bindings for each of the functions available via keystrokes. Pressin...
C-h k runs the function describe-key, which looks up the function mapped to the key strokes provided, and presents a description of the function which will be run when these keys are pressed. C-h c runs the function describe-key-briefly, which only displays the function name mapped to given key seq...
C-h f runs the function describe-function, which displays information on the usage and purpose of a given function. This is especially useful for functions that do not have a mapped key binding that can be used for documentation lookup via C-h k.
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...

Page 645 of 1336