Tutorial by Examples

For added safety we can define the type of object that the array contains: NSArray<NSString *> *colors = @[@"Red", @"Green", @"Blue", @"Yellow"]; NSMutableArray<NSString *> *myColors = [NSMutableArray arrayWithArray:colors]; [myColors addObject:...
NSArray *myColors = @[@"Red", @"Green", @"Blue", @"Yellow"]; [myColors enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { NSLog(@"enumerating object %@ at index %lu", obj, idx); }]; By setting the stop parameter to YES you c...
As parameters (8, 16, 32 bits) 8, 16, 32 bits integers are always passed, on the stack, as full width 32 bits values1. No extension, signed or zeroed, is needed. The callee will just use the lower part of the full width values. //C prototype of the callee void __attribute__((cdecl)) foo(char ...
As parameters (float, double) Floats are 32 bits in size, they are passed naturally on the stack. Doubles are 64 bits in size, they are passed, on the stack, respecting the Little Endian convention1, pushing first the upper 32 bits and than the lower ones. //C prototype of callee double foo(dou...
Python provides functions for justifying strings, enabling text padding to make aligning various strings much easier. Below is an example of str.ljust and str.rjust: interstates_lengths = { 5: (1381, 2222), 19: (63, 102), 40: (2555, 4112), 93: (189,305), } for road, length in...
The clear property is directly related to floats. Property Values: none - Default. Allows floating elements on both sides left - No floating elements allowed on the left side right - No floating elements allowed on the right side both - No floating elements allowed on either the left or the r...
This is a very common workflow when using Ansible for provisioning an AWS EC2 instance. This post assumes a basic understand of Ansible and most importantly, assumes you've properly configured it to connect to AWS. As Ansible official documentation insists, we are going to use four roles: 1- ami_f...
Managing AWS resources that scale up and down runs into the limits of the static inventory host file, that's why we need something dynamic. And that's what the dynamic inventories are for. Let's start: Download these ec2.ini and ec2.py files to the your project folder: cd my_ansible_project wget...
There is a maximum capacity an integer can store. And when you go over that limit, it will loop back to the negative side. For int, it is 2147483647 int x = int.MaxValue; //MaxValue is 2147483647 x = unchecked(x + 1); //make operation explicitly unchecked so that the ...
Overflow also happens during the operation. In the following example, x is an int, 1 is an int by default. Therefore addition is an int addition. And the result will be an int. And it will overflow. int x = int.MaxValue; //MaxValue is 2147483647 long y = x + 1; //...
If you are using multiple namespaces that may have same-name classes(such as System.Random and UnityEngine.Random), you can use an alias to specify that Random comes from one or the other without having to use the entire namespace in the call. For instance: using UnityEngine; using System; Ran...
Built in functions can subset rows with columns that meet conditions. df <- data.frame(item = c(1:10), price_Elasticity = c(-0.57667, 0.03205, -0.04904, 0.10342, 0.04029, 0.0742, 0.1669, 0.0313, 0.22204, 0.06158), total...
Create a file named SCALA_PROJECT/build.gradle with these contents: group 'scala_gradle' version '1.0-SNAPSHOT' apply plugin: 'scala' repositories { jcenter() mavenCentral() maven { url "https://repo.typesafe.com/typesafe/maven-releases" } } dep...
Over time, our classes may implement more and more interfaces. When these interfaces have many methods, the total number of methods in our class will become very large. For example, let's suppose that we have two interfaces and a class implementing them: interface Printable { public functio...
To install an APK file, use the following command: adb install path/to/apk/file.apk or if the app is existing and we want to reinstall adb install -r path/to/apk/file.apk To uninstall an application, we have to specify its package adb uninstall application.package.name Use the following...
file is no longer a builtin name in 3.x (open still works). Internal details of file I/O have been moved to the standard library io module, which is also the new home of StringIO: import io assert io.open is open # the builtin is an alias buffer = io.StringIO() buffer.write('hello, ') # returns...
import cv2 image_path= #put your image path here #use imread() function to read image data to variable img. img = cv2.imread(image_path) #display image data in a new window with title 'I am an image display window' cv2.imshow('I am an image display window',img) #wait until user hi...
Java Logging Api has 7 levels. The levels in descending order are: SEVERE (highest value) WARNING INFO CONFIG FINE FINER FINEST (lowest value) The default level is INFO (but this depends on the system and used a virtual machine). Note: There are also levels OFF (can be used to turn log...
The reserved word "void" is an alias of System.Void type, and has two uses: Declare a method that doesn't have a return value: public void DoSomething() { // Do some work, don't return any value to the caller. } A method with a return type of void can still have the return ...
The if statement is used to control the flow of the program. An if statement identifies which statement to run based on the value of a Boolean expression. For a single statement, the braces{} are optional but recommended. int a = 4; if(a % 2 == 0) { Console.WriteLine("a contains an...

Page 435 of 1336