Tutorial by Examples: er

Example for adding a document: $document = [ 'name' => 'John', 'active' => true, 'info' => ['genre' => 'male', 'age' => 30] ]; $bulk = new \MongoDB\Driver\BulkWrite; $_id1 = $bulk->insert($document); $result = $manager->executeBulkWrite('database_name.collect...
Navigation Drawers are used to navigate to top-level destinations in an app. Make sure that you have added design support library in your build.gradle file under dependencies: dependencies { // ... compile 'com.android.support:design:25.3.1' } Next, add the DrawerLayout and Navigati...
Using range-base loops, you can loop over a sub-part of a given container or other range by generating a proxy object that qualifies for range-based for loops. template<class Iterator, class Sentinel=Iterator> struct range_t { Iterator b; Sentinel e; Iterator begin() const { return ...
First create a resource pool besides the default one CREATE RESOURCE POOL [PoolAdhoc] WITH(min_cpu_percent=0, max_cpu_percent=50, min_memory_percent=0, max_memory_percent=50) GO Create the worload group for the pool CREATE WORKLOAD GROUP [AdhocMedium] WITH(importa...
Sometimes specific instances of data should be used. Recreation is not desired and referencing static data would have a code smell. It is possible to specify a XmlAdapter instance the Unmarshaller should use, which allows the user to use XmlAdapters with no zero-arg constructor and/or pass data to ...
Using the Employees Table, below is an example to return the Id, FName and LName columns in (ascending) LName order: SELECT Id, FName, LName FROM Employees ORDER BY LName Returns: IdFNameLName2JohnJohnson1JamesSmith4JohnathonSmith3MichaelWilliams To sort in descending order add the DESC keywo...
Multiple fields can be specified for the ORDER BY clause, in either ASCending or DESCending order. For example, using the http://stackoverflow.com/documentation/sql/280/example-databases/1207/item-sales-table#t=201607211314066434211 table, we can return a query that sorts by SaleDate in ascending o...
1 - Include the CoreLocation.framework in your project; this is accomplished by clicking on: root directory -> build phases -> Link Binary With Libraries Click on the (+) button, look for CoreLocation.framework and click add. 2- Modify the info.plist file to ask for permission to use user...
Repeated Timer event Swift class ViewController: UIViewController { var timer = NSTimer() override func viewDidLoad() { NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: Selector(self.timerMethod()), userInfo: nil, repeats: true) } func tim...
All parameters specified after the first asterisk in the function signature are keyword-only. def f(*a, b): pass f(1, 2, 3) # TypeError: f() missing 1 required keyword-only argument: 'b' In Python 3 it's possible to put a single asterisk in the function signature to ensure that the rema...
Usually grep prints only matching lines. In the example below seq 9 generates a list of numbers from 1 to 9, one per line, and grep prints a single matching line: seq 9 | grep 5 # 5 The -C n option (or --context=n in long form) prints n lines before and after each matching line, in addition to ...
import std.stdio; bool isPrime(int number) { foreach(i; 2..number) { if (number % i == 0) { return false; } } return true; } void main() { writeln(2.isPrime); writeln(3.isPrime); writeln(4.isPrime); 5.isPrime.writeln; } ...
Notice, that in order to change file prmissions, your device need to be rooted, su binary doesn't come with factory shipped devices! Convention: adb shell su -c "chmod <numeric-permisson> <file>" Numeric permission constructed from user, group and world sections. For exa...
Dim openListType = GetType(List(Of )) Dim typeParameters = {GetType(String)} Dim stringListType = openListType.MakeGenericType(typeParameters) Dim instance = DirectCast(Activator.CreateInstance(stringListType), List(Of String)) instance.Add("Hello")
Timing There are two trigger action time modifiers : BEFORE trigger activates before executing the request, AFTER trigger fire after change. Triggering event There are three events that triggers can be attached to: INSERT UPDATE DELETE Before Insert trigger example DELIMITER $$ ...
add permission in your manifest file <uses-permission android:name="android.permission.BLUETOOTH" /> In your Fragment(or Activity) Add the receiver method private BroadcastReceiver mBluetoothStatusChangedReceiver = new BroadcastReceiver() { @Override public void o...
The Java Native Interface (JNI) allows you to call native functions from Java code, and vice versa. This example shows how to load and call a native function via JNI, it does not go into accessing Java methods and fields from native code using JNI functions. Suppose you have a native library named ...
You can add a "Browse Our Other Apps" button in your app, listing all your(publisher) applications in the Google Play Store app. String urlApp = "market://search?q=pub:Google+Inc."; String urlWeb = "http://play.google.com/store/search?q=pub:Google+Inc."; try { I...
The internet is packed with tips for performance improvement of Java programs. Perhaps the number one tip is awareness. That means: Identify possible performance problems and bottlenecks. Use analyzing and testing tools. Know good practices and bad practices. The first point should be done d...
1. What is MVC? The Model View Controller (MVC) Pattern is a design pattern most commonly used for creating user interfaces. The major advantage of MVC is that it separates: the internal representation of the application state (the Model), how the information is presented to the user (the View...

Page 177 of 417