Enable and configure the experimental Gradle plugin to improve AndroidStudio's NDK support. Check that you fulfill the following requirements:
Gradle 2.10 (for this example)
Android NDK r10 or later
Android SDK with build tools v19.0.0 or later
Configure MyApp/build.gradle file
Edit the dep...
Iterate over JSONObject properties
JSONObject obj = new JSONObject("{\"isMarried\":\"true\", \"name\":\"Nikita\", \"age\":\"30\"}");
Iterator<String> keys = obj.keys();//all keys: isMarried, name & age
while (keys.has...
You can use method chaining while working with JSONObject and JSONArray.
JSONObject example
JSONObject obj = new JSONObject();//Initialize an empty JSON object
//Before: {}
obj.put("name","Nikita").put("age","30").put("isMarried","true"...
cycle is an infinite iterator.
>>> import itertools as it
>>> it.cycle('ABCD')
A B C D A B C D A B C D ...
Therefore, take care to give boundaries when using this to avoid an infinite loop. Example:
>>> # Iterate over each element in cycle for a fixed range
>&g...
When to use abstract classes: To implement the same or different behaviour among multiple related objects
When to use interfaces: to implement a contract by multiple unrelated objects
Abstract classes create "is a" relations while interfaces provide "has a" capability.
This c...
sudo apt-add-repository ppa:brightbox/ruby-ng
Hit Enter to confirm
sudo apt-get update
Then you can install your ruby version of choice (the ppa supports ruby2.0 ruby2.1 ruby2.2 ruby2.3 and legacy versions ruby1.8 ruby1.9.1) Don't forget to include the respective -dev package for your version. Ot...
Create Or Replace Function Generateguid
Return Char Is
V_Guid Char(40);
Begin
Select Substr(Sys_Guid(),1,8)||'-'||Substr(Sys_Guid(),9,4)||'-'
||Substr(Sys_Guid(),13,4)||'-'||Substr(Sys_Guid(),17,4)||'-'
||Substr(Sys_Guid(),21) Into V_Guid...
Disclaimer: In no way does this example advocate the use of singletons. Singletons are to be used with a lot of care.
In PHP there is quite a standard way of implementing a singleton:
public class Singleton {
private $instance;
private function __construct() { };
public function...
With implicit keys:
key: value
another key:
- some
- more
- values
[1, 2, 3]: last value, which has a flow style key
With implicit and explicit keys:
? key
: value
another key:
- some
- more
- values
? [1, 2, 3]
: last value, which has a flow style key
key, another ...
To see all the facts involving the le relation from the prelude:
Coq < Search le.
le_n: forall n : nat, n <= n
le_S: forall n m : nat, n <= m -> n <= S m
...
max_l: forall n m : nat, m <= n -> Nat.max n m = n
max_r: forall n m : nat, n <= m -> Nat.max n m = m
...
...
Search for all facts involving a pattern in an hypothesis or conclusion:
Coq < Search (_ + O).
plus_n_O: forall n : nat, n = n + 0
The _ character serves as a wildcard, it can be used multiple times:
Coq < Search (S _ <= _).
le_S_n: forall n m : nat, S n <= S m -> n <= m
le...
Session Types are a way to tell the compiler about the protocol you want to use to communicate between threads - not protocol as in HTTP or FTP, but the pattern of information flow between threads. This is useful since the compiler will now stop you from accidentally breaking your protocol and causi...
Let's say your launch activity is called MainActivity, in your app com.example.myapp.
In the manifest:
<activity
android:name=".MainActivity"
>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
...
Bridge pattern decouples abstraction from implementation so that both can vary independently. It has been achieved with composition rather than inheritance.
Bridge UML diagram from wikipedia:
You have four components in this pattern.
Abstraction: It defines an interface
RefinedAbstraction: It ...
SELECT SYSDATE();
This function returns the current date and time as a value in 'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS format, depending on whether the function is used in a string or numeric context. It returns the date and time in the current time zone.
SELECT NOW();
This function is a...
The dimension attribute on an object specifies that that object is an array. There are, in Fortran 2008, five array natures:1
explicit shape
assumed shape
assumed size
deferred shape
implied shape
Take the three rank-1 arrays2
integer a, b, c
dimension(5) a ! Explicit shape (default ...