Tutorial by Examples: c

Example for deleting all documents where name is equal to "Peter": $bulk = new \MongoDB\Driver\BulkWrite; $filter = ['name' => 'Peter']; $bulk->delete($filter); $result = $manager->executeBulkWrite('database_name.collection_name', $bulk);
Comments are used to explain code when the basic code itself isn't clear. Python ignores comments, and so will not execute code in there, or raise syntax errors for plain english sentences. Single-line comments begin with the hash character (#) and are terminated by the end of line. Single lin...
Transact-SQL supports two forms of comment writing. Comments are ignored by the database engine, and are meant for people to read. Comments are preceded by -- and are ignored until a new line is encountered: -- This is a comment SELECT * FROM MyTable -- This is another comment WHERE Id = 1; ...
Introduction Unity has a few 'specially named' folders that allows for a variety of uses. One of these folders is called 'Resources' The 'Resources' folder is one of only TWO ways of loading assets at runtime in Unity (The other being AssetBundles (Unity Docs) The 'Resources' folder can reside an...
Given a local directory with the following contents: └── dir1 ├── subdir1 └── subdir2 We want to create the same subdir1, subdir2 under a new directory dir2, which does not exist yet. import os os.makedirs("./dir2/subdir1") os.makedirs("./dir2/subdir2") R...
select * from sys.dm_resource_governor_workload_groups select * from sys.dm_resource_governor_resource_pools
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...
Given the following XML document: <documentation> <tags> <tag name="Java"> <topic name="Regular expressions"> <example>Matching groups</example> <example>Escaping metacharacter...
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...
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...
ARC can be disabled for individual files by adding the -fno-objc-arc compiler flag for each file. Conversely it can be added in Targets ▸ Build Phases ▸ Compile Sources
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 ...
In this example, a private static instance of the class is declared at its beginning. The value of a static field is shared between instances, so if a new instance of this class gets created the if will find a reference to the first Singleton object, destroying the new instance (or its game object)...
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")
It is possible to easily catch the exception without any try catch block. public class ListTest { private final List<Object> list = new ArrayList<>(); @Test(expected = IndexOutOfBoundsException.class) public void testIndexOutOfBoundsException() { list.get(0); } } ...

Page 348 of 826