Tutorial by Examples

It is easy to get confused in the C preprocessor, and treat it as part of C itself, but that is a mistake because the preprocessor is just a text substitution mechanism. For example, if you write /* WRONG */ #define MAX 100; int arr[MAX]; the code expands to int arr[100;]; which is a synta...
Binaries in elixir are created using the Kernel.SpecialForms construct <<>>. They are a powerful tool which makes Elixir very useful for working with binary protocols and encodings. Binaries and bitstrings are specified using a comma delimited list of integers or variable values, booke...
Lets assume we have this class and we would like to test doSmth method. In this case we want to see if parameter "val" is passed to foo. Object foo is mocked. public class Bar { private final Foo foo; public Bar(final Foo foo) { this.foo = foo; } public ...
You can define central config info's in a separate gradle include file Centralizing dependencies via "dependencies.gradle" file a stand alone properties file Versioning your builds via "version.properties" file or do it with root gradle.properties file the project structu...
Inline display elements, usually such as span or a, will include up to one white-space character before and after them in the document. In order to avoid very long lines in the markup (that are hard to read) and unintentional white-space (which affects formatting), the white-space can be commented o...
build.gradle: dependencies { compile 'com.android.support:appcompat-v7:23.3.0' compile 'com.jakewharton.rxbinding:rxbinding-appcompat-v7:0.4.0' } menu/menu.xml: <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.c...
Since the release of Gradle 2.2, the use of the android-apt plugin is no longer used. The following method of setting up Dagger 2 should be used. For older version of Gradle, use the previous method shown below. For Gradle >= 2.2 dependencies { // apt command comes from the android-apt plu...
First of all you need Uri and temp Folders and request codes : public final int REQUEST_SELECT_PICTURE = 0x01; public final int REQUEST_CODE_TAKE_PICTURE = 0x2; public static String TEMP_PHOTO_FILE_NAME ="photo_"; Uri mImageCaptureUri; File mFileTemp; Then init mFileTemp : public ...
Obfuscation is often considered as a magic solution for code protection, by making your code harder to understand if it ever gets de-compiled by hackers. But if you're thinking that removing the Log.x(..) actually removes the information the hackers need, you'll have a nasty surprise. Removing al...
In some circumstances (for example obtaining a Google API key) you need to find your keystore fingerprint. Gradle has a convenient task that display all the signing information, including keystore fingerprints: ./gradlew signingReport This is a sample output: :app:signingReport Variant: releas...
In addition to cursor movements using the arrow keys, Home, End, Page up, and Page down, emacs defines a number of keystrokes that can move the cursor over smaller or larger pieces of text: By character: Backward character: C-b Forward character: C-f By word Backward word: M-b (i.e. Alt b...
One of the use cases of callback URLs is OAuth. Let us do this with an Instagram Login: If the user enters their credentials and clicks the Login button, Instagram will validate the credentials and return an access_token. We need that access_token in our app. For our app to be able to listen to suc...
X-Macros can be used for code generation, by writing repetitive code: iterate over a list to do some tasks, or to declare a set of constants, objects or functions. Here we use X-macros to declare an enum containing 4 commands and a map of their names as strings Then we can print the string values ...
Enums contains only constants and can be compared directly with ==. So, only reference check is needed, no need to use .equals method. Moreover, if .equals used incorrectly, may raise the NullPointerException while that's not the case with == check. enum Day { GOOD, AVERAGE, WORST; } publi...
The Standard (10.4) states: Member functions can be called from a constructor (or destructor) of an abstract class; the effect of making a virtual call (10.3) to a pure virtual function directly or indirectly for the object being created (or destroyed) from such a constructor (or destructor) is u...
Most, but not all, C++ implementations support the #pragma once directive which ensures the file is only included once within a single compilation. It is not part of any ISO C++ standard. For example: // Foo.h #pragma once class Foo { }; While #pragma once avoids some problems associated w...
Insertion sort is a very simple, stable, in-place sorting algorithm. It performs well on small sequences but it is much less efficient on large lists. At every step, the algorithms considers the i-th element of the given sequence, moving it to the left until it is in the correct position. Graphica...
Installation Volley JCenter Gradle Import //in your project's app level build.gradle compile 'com.android.volley:volley:1.0.0' Create a subclass of Application public class AppController extends Application { public static final String TAG = AppController.class .getSimpleN...
.set-colors(@type) when (@type = error) { @base-color: #d9534f; background: @base-color; color: contrast(@base-color, lighten(@base-color, 25%), darken(@base-color, 25%)); border: 1px solid contrast(@base-color, lighten(@base-color, 25%), darken(@base-color, 25%)); } .set-colors(@type)...
There are two common ways to list all processes on a system. Both list all processes running by all users, though they differ in the format they output (the reason for the differences are historical). ps -ef # lists all processes ps aux # lists all processes in alternative format (BSD) Thi...

Page 652 of 1336