Tutorial by Examples: c

switch statements are useful when you want to have your program do many different things according to the value of a particular test variable. An example usage of switch statement is like this: int a = 1; switch (a) { case 1: puts("a is 1"); break; case 2: puts("...
A common issue that users of Eclipse encounter is related to the default system JVM. A typical situation is a 64 bit Windows which has both 32 and 64 bit versions of Java installed, and a 32 bit Eclipse. If the 64 bit version of Java is the system default, when Eclipse is launched an error dialog i...
To open a new window, add the following code somewhere where you can keep a reference to the new window (I.E., the app delegate). Swift let storyboard:NSStoryboard = NSStoryboard(name: "Main", bundle: nil) guard let controller:NSWindowController = storyboard.instantiateControllerWithIde...
To print the directory stack, use the command pushd without any parameters: @echo off cd C:\example\ pushd one pushd ..\two pushd ..\.. pushd echo Current Directory: %cd% echo: popd pushd three pushd echo Current Directory: %cd% Output: C:\example\two ...
private final OkHttpClient client = new OkHttpClient(); public void run() throws Exception { Request request = new Request.Builder() .url(yourUrl) .build(); Response response = client.newCall(request).execute(); if (!response.isSuccessful()) throw new IOExcept...
private final OkHttpClient client = new OkHttpClient(); public void run() throws Exception { Request request = new Request.Builder() .url(yourUrl) .build(); client.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOExcepti...
If the type on which the static constructor is declared is generic, the static constructor will be called once for each unique combination of generic arguments. class Animal<T> { static Animal() { Console.WriteLine(typeof(T).FullName); } public static void Yawn...
If a static constructor throws an exception, it is never retried. The type is unusable for the lifetime of the AppDomain. Any further usages of the type will raise a TypeInitializationException wrapped around the original exception. public class Animal { static Animal() { Consol...
It is unlikely for a developer to not come across a deprecated API during a development process. A deprecated program element is one that programmers are discouraged from using, typically because it is dangerous, or because a better alternative exists. Compilers and analyzers (like LINT) warn when a...
This is a huge topic, but it is also the most important "performance" issue. The main lesson for a novice is to learn of "composite" indexes. Here's a quick example: INDEX(last_name, first_name) is excellent for these: WHERE last_name = '...' WHERE first_name = '...' AND ...
innodb_buffer_pool_size should be about 70% of available RAM.
x IN ( SELECT ... ) turn into a JOIN When possible, avoid OR. Do not 'hide' an indexed column in a function, such as WHERE DATE(x) = ...; reformulate as WHERE x = ... You can generally avoid WHERE LCASE(name1) = LCASE(name2) by having a suitable collation. Do no use OFFSET for "paginatio...
You can find the Chef documentation at https://docs.chef.io/.
You can change the url of an existing remote by the command git remote set-url remote-name url
Example below shows how to create a BroadcastReceiver which is able to receive BOOT_COMPLETED events. This way, you are able to start a Service or start an Activity as soon device was powered up. Also, you can use BOOT_COMPLETED events to restore your alarms since they are destroyed when device is ...
For the sake of this example, let us assume that we have a server for handling the POST requests that we will be making from our Android app: // User input data. String email = "[email protected]"; String password = "123"; // Our server URL for handling POST requests. String UR...
For a Django project with requirements and deployment tools under source control. This example builds upon concepts from the Two Scoops of Django. They have published a template: repository/ docs/ .gitignore project/ apps/ blog/ migrations/ ...
Casting: The Basics Casting is used to transform data from long to wide format. Starting with a long data set: DT = data.table(ID = rep(letters[1:3],3), Age = rep(20:22,3), Test = rep(c("OB_A","OB_B","OB_C"), each = 3), Result = 1:9) We can cast our data using the...
The FETCH clause was introduced in Oracle 12c R1: SELECT val FROM mytable ORDER BY val DESC FETCH FIRST 5 ROWS ONLY; An example without FETCH that works also in earlier versions: SELECT * FROM ( SELECT val FROM mytable ORDER BY val DESC ) WHERE ROWNUM <= 5;
Defined in header <numeric> template<class InputIterator, class T> T accumulate(InputIterator first, InputIterator last, T init); // (1) template<class InputIterator, class T, class BinaryOperation> T accumulate(InputIterator first, InputIterator last, T init, BinaryOperation...

Page 360 of 826