Tutorial by Examples: c

Spark uses lazy evaluation; that means it will not do any work, unless it really has to. That approach allows us to avoid unnecessary memory usage, thus making us able to work with big data. A transformation is lazy evaluated and the actual work happens, when an action occurs. Example: In [1]: li...
You want to combine arrays into one. For example, you have fruits = ['Broccoli', 'Carrots'] spices = ['Thyme', 'Cinnamon'] and you want to combine them into ingredients = ['Broccoli', 'Carrots', 'Thyme', 'Cinnamon'] Method 1 - using .concat ingredients = fruits.concat spices Method 2 -...
Block strings can be used to hold formatted or indentation-sensitive text (or, if you just don't feel like escaping quotes and apostrophes). The indentation level that begins the block is maintained throughout, so you can keep it all aligned with the body of your code. html = """ ...
Complete the Installation and setup part to connect your app to Firebase. This will create the project in Firebase. Add the dependency for Firebase Realtime Database to your module-level build.gradle file: compile 'com.google.firebase:firebase-database:10.2.1' Configure Firebase ...
While the if ()... else statement allows to define only one (default) behaviour which occurs when the condition within the if () is not met, chaining two or more if () ... else statements allow to define a couple more behaviours before going to the last else branch acting as a "default", i...
In .NET, the GC allocates objects when there are no references left to them. Therefore, while an object can still be reached from code (there is a strong reference to it), the GC will not allocate this object. This can become a problem if there are a lot of large objects. A weak reference is a ref...
Plenty has been written about Python's GIL. It can sometimes cause confusion when dealing with multi-threaded (not to be confused with multiprocess) applications. Here's an example: import math from threading import Thread def calc_fact(num): math.factorial(num) num = 600000 t = Threa...
In most object oriented languages, allocating memory for an object and initializing it is an atomic operation: // Both allocates memory and calls the constructor MyClass object = new MyClass(); In Objective-C, these are separate operations. The class methods alloc (and its historic sibling allo...
Use the following piece of code to set the badge number from within your application (suppose someNumber has been declared before): Objective-C [UIApplication sharedApplication].applicationIconBadgeNumber = someNumber; Swift UIApplication.shared.applicationIconBadgeNumber = someNumber In order ...
import React, { Component } from 'react' import { View, Text, AppRegistry } from 'react-native' class Example extends Component { render () { return ( <View> <Text> I'm a basic Component </Text> </View> ) } } AppRegistry.registe...
These components will have changing States. import React, { Component } from 'react' import { View, Text, AppRegistry } from 'react-native' class Example extends Component { constructor (props) { super(props) this.state = { name: "Sriraman" } } render ...
As the name implies, Stateless Components do not have any local state. They are also known as Dumb Components. Without any local state, these components do not need lifecycle methods or much of the boilerplate that comes with a stateful component. Class syntax is not required, you can simply do con...
[Header( "My variables" )] public string MyString; [HideInInspector] public string MyHiddenString; [Multiline( 5 )] public string MyMultilineString; [TextArea( 2, 8 )] public string MyTextArea; [Space( 15 )] public int MyInt; [Range( 2.5f, 12.5f )] public float MyFlo...
[DisallowMultipleComponent] [RequireComponent( typeof( Rigidbody ) )] public class AttributesExample : MonoBehaviour { [...] } [DisallowMultipleComponent] The DisallowMultipleComponent attribute prevents users adding multiple instances of this component to one GameObject. [Requi...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Draw two rectangles on the canvas</title> <style> canvas{ border:1px solid gray; } </style> <script async...
We can change the tasks execution order with the dependsOn method. task A << { println 'Hello from A' } task B(dependsOn: A) << { println "Hello from B" } Adding `dependsOn: causes: task B depends on task A Gradle to execute A task everytime before the B ta...
project('projectA') { task A(dependsOn: ':projectB:B') << { println 'Hello from A' } } project('projectB') { task B << { println 'Hello from B' } } To refer to a task in another project, you prefix the name of the task with the path of the pr...
task A << { println 'Hello from A' } task B << { println 'Hello from B' } B.dependsOn A It is an alternative way to define the dependency instead of using the task name. And the output is the same: > gradle -q B Hello from A Hello from B
You can add multiple dependencies. task A << { println 'Hello from A' } task B << { println 'Hello from B' } task C << { println 'Hello from C' } task D << { println 'Hello from D' } Now you can define a set of dependencies: B.dependsOn A...
You can add multiple dependencies. task A << { println 'Hello from A' } task B(dependsOn: A) << { println 'Hello from B' } task C << { println 'Hello from C' } task D(dependsOn: ['B', 'C'] << { println 'Hello from D' } The output is: >...

Page 478 of 826