Tutorial by Examples: o

OR

In general OR kills optimization. WHERE a = 12 OR b = 78 cannot use INDEX(a,b), and may or may not use INDEX(a), INDEX(b) via "index merge". Index merge is better than nothing, but only barely. WHERE x = 3 OR x = 5 is turned into WHERE x IN (3, 5) which may use an index with x...
A common problem that leads to an inefficient query goes something like this: SELECT ... FROM a JOIN b ON ... WHERE ... GROUP BY a.id First, the JOIN expands the number of rows; then the GROUP BY whittles it back down the the number of rows in a. There may not be any good c...
Create a testing class in the src/test/scala directory, in a file named HelloWorldSpec.scala. Put this inside the file: import org.scalatest.{FlatSpec, Matchers} class HelloWorldSpec extends FlatSpec with Matchers { "Hello World" should "not be an empty String" in { ...
Detailed instructions on getting cloudkit set up or installed.
import { NgModule } from '@angular/core'; @NgModule({ declarations: [], // components your module owns. imports: [], // other modules your module needs. providers: [], // providers available to your module. bootstrap: [] // bootstrap this root component. }) export class MyModule {} ...
// app.module.ts import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { HttpModule } from '@angular/http'; import { MyRootComponent } from './app.component'; @NgModule({ declarations: [MyRootComponent], imports: [BrowserModule, Ht...
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { MyModule } from './app.module'; platformBrowserDynamic().bootstrapModule( MyModule ); In this example, MyModule is the module containing your root component. By bootstrapping MyModule your Angul...
This example has two parts - some boilerplate steps for adding Castle Windsor to your WCF service, and then a simple, concrete example to show how we configure and use Windsor's container. That makes the example a little bit long. If you already understand using a DI container then you likely only ...
Prototype: aggregate(zeroValue, seqOp, combOp) Description: aggregate() lets you take an RDD and generate a single value that is of a different type than what was stored in the original RDD. Parameters: zeroValue: The initialization value, for your result, in the desired format. seqOp: ...
/** * Checks if a resource exists by sending a HEAD-Request. * @param url The url of a resource which has to be checked. * @return true if the response code is 200 OK. */ public static final boolean checkIfResourceExists(URL url) throws IOException { HttpURLConnection conn = (HttpURLCo...
Let's say you're working on an app called MyTasks, and you want to allow inbound URLs to create a new task with a title and a body. The URL you're designing might look something like this: mytasks://create?title=hello&body=world (Of course, the text and body parameters are used to populate our...
Sometimes we need to perform basic operations like hide/show view based on single value, for that single variable we cannot create model or it is not good practice to create model for that. DataBinding supports basic datatypes to perform those oprations. <layout xmlns:android="http://schema...
NIO appeared in Java 1.4 and introduced the concept of "Channels", which are supposed to be faster than regular I/O. Network-wise, the SelectableChannel is the most interesting as it allows to monitor different states of the Channel. It works in a similar manner as the C select() system ca...
It is very common to get a StackOverflowError error while calling recursive function. Scala standard library offers TailCall to avoid stack overflow by using heap objects and continuations to store the local state of the recursion. Two examples from the scaladoc of TailCalls import scala.util.cont...
NSLog is good, but you can also log by appending to a file instead, using code like: NSFileHandle* fh = [NSFileHandle fileHandleForWritingAtPath:path]; if ( !fh ) { [[NSFileManager defaultManager] createFileAtPath:path contents:nil attributes:nil]; fh = [NSFileHandle fileHandleForWriting...
C# allows using pointer variables in a function of code block when it is marked by the unsafe modifier. The unsafe code or the unmanaged code is a code block that uses a pointer variable. A pointer is a variable whose value is the address of another variable i.e., the direct address of the memory l...
You can retrieve the data stored at the located referenced by the pointer variable, using the ToString() method. The following example demonstrates this: using System; namespace UnsafeCodeApplication { class Program { public static void Main() { unsafe { ...
You can pass a pointer variable to a method as parameter. The following example illustrates this: using System; namespace UnsafeCodeApplication { class TestPointer { public unsafe void swap(int* p, int *q) { int temp = *p; *p = *q; *q = temp; ...
In C#, an array name and a pointer to a data type same as the array data, are not the same variable type. For example, int *p and int[] p, are not same type. You can increment the pointer variable p because it is not fixed in memory but an array address is fixed in memory, and you can't increment th...
For compiling unsafe code, you have to specify the /unsafe command-line switch with command-line compiler. For example, to compile a program named prog1.cs containing unsafe code, from command line, give the command: csc /unsafe prog1.cs If you are using Visual Studio IDE then you need to enabl...

Page 586 of 1038