Tutorial by Examples: f

This example fills text with a specified image. Important! The specified image must be fully loaded before calling this function or the drawing will fail. Use image.onload to be sure the image is fully loaded. function drawImageInsideText(canvas,x,y,img,text,font){ var c=canvas.cloneNode();...
// Add observer let observer = NSNotificationCenter.defaultCenter().addObserverForName("nameOfTheNotification", object: nil, queue: nil) { (notification) in // Do operations with the notification in this block } // Remove observer NSNotificationCenter.defaultCenter().removeObser...
4.0 Since bash 4.0, a new operator ;& was introduced which provides fall through mechanism. #!/bin/bash var=1 case $var in 1) echo "Antartica" ;& 2) echo "Brazil" ;& 3) echo "Cat" ;& esac Outputs: Antartica Brazil Cat ...
4.0 Since Bash 4.0, another operator ;;& was introduced which also provides fall through only if the patterns in subsequent case statement(s), if any, match. #!/bin/bash var=abc case $var in a*) echo "Antartica" ;;& xyz) echo "Brazil" ;;& *b*) ...
Run go test as normal, yet with the coverprofile flag. Then use go tool to view the results as HTML. go test -coverprofile=c.out go tool cover -html=c.out
Calculating the factorial of a number is a classic example of a recursive function. Missing the Base Condition: #include <stdio.h> int factorial(int n) { return n * factorial(n - 1); } int main() { printf("Factorial %d = %d\n", 3, factorial(3)); return 0;...
To add a Swipe To Refresh layout with a RecyclerView add the following to your Activity/Fragment layout file: <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/refresh_layout" android:layout_width="match_parent" android:layout_height="match_pa...
While Runnable provides a means to wrap code to be executed in a different thread, it has a limitation in that it cannot return a result from the execution. The only way to get some return value from the execution of a Runnable is to assign the result to a variable accessible in a scope outside of t...
To make a jar, you need one or more class files. This should have a main method if it is to be run by a double click. For this example, we will use: import javax.swing.*; import java.awt.Container; public class HelloWorld { public static void main(String[] args) { JFrame f = ne...
Starting with the Support Library version 22.2.1, it's possible to show and hide a FloatingActionButton from scrolling behavior using a FloatingActionButton.Behavior sublclass that takes advantage of the show() and hide() methods. Note that this only works with a CoordinatorLayout in conjunction wi...
A keyword denoting one of the two possible values of type bool. bool ok = true; if (!f()) { ok = false; goto end; }
A floating point type. Has the narrowest range out of the three floating point types in C++. float area(float radius) { const float pi = 3.14159f; return pi*radius*radius; }

for

Introduces a for loop or, in C++11 and later, a range-based for loop. // print 10 asterisks for (int i = 0; i < 10; i++) { putchar('*'); }
This is a mistake that causes real confusion for Java beginners, at least the first time that they do it. Instead of writing this: if (feeling == HAPPY) System.out.println("Smile"); else System.out.println("Frown"); they accidentally write this: if (feeling == HAP...
const url = 'http://api.stackexchange.com/2.2/questions?site=stackoverflow&tagged=javascript'; const questionList = document.createElement('ul'); document.body.appendChild(questionList); const responseData = fetch(url).then(response => response.json()); responseData.then(({item...
You can define the signing configuration to sign the apk in the build.gradle file. You can define: storeFile : the keystore file storePassword: the keystore password keyAlias: a key alias name keyPassword: A key alias password You have to define the signingConfigs block to create a signin...
You can define the signing configuration in an external file as a signing.properties in the root directory of your project. For example you can define these keys (you can use your favorite names): STORE_FILE=myStoreFileLocation STORE_PASSWORD=myStorePassword KEY_ALIAS=myKeyAlias KEY_PASSWOR...
You can store the signing information setting environment variables. These values can be accessed with System.getenv("<VAR-NAME>") In your build.gradle you can define: signingConfigs { release { storeFile file(System.getenv("KEYSTORE")) storePasswo...
We use the null function to check if a given Map is empty: > Map.null $ Map.fromList [("Alex", 31), ("Bob", 22)] False > Map.null $ Map.empty True
There are many querying operations on maps. member :: Ord k => k -> Map k a -> Bool yields True if the key of type k is in Map k a: > Map.member "Alex" $ Map.singleton "Alex" 31 True > Map.member "Jenny" $ Map.empty False notMember is similar: &g...

Page 243 of 457