Tutorial by Examples

This guide assumes you already have Ruby installed. If you're using Ruby < 1.9 you'll have to manually install RubyGems as it won't be included natively. To install a ruby gem, enter the command: gem install [gemname] If you are working on a project with a list of gem dependencies, then the...
To generate true random values that can be used for cryptography std::random_device has to be used as generator. #include <iostream> #include <random> int main() { std::random_device crypto_random_generator; std::uniform_int_distribution<int> int_distribution(0,9); ...
A pseudo-random number generator generates values that can be guessed based on previously generated values. In other words: it is deterministic. Do not use a pseudo-random number generator in situations where a true random number is required. #include <iostream> #include <random> in...
The random number generator can (and should) be used for multiple distributions. #include <iostream> #include <random> int main() { std::default_random_engine pseudo_random_generator; std::uniform_int_distribution<int> int_distribution(0, 9); std::uniform_real_dis...
If you have a type definition file (d.ts) for the module, you can use an import statement. import _ = require('lodash'); If you don't have a definition file for the module, TypeScript will throw an error on compilation because it cannot find the module you are trying to import. In this case, yo...
//Swift let barButtonItem = UIBarButtonItem(title: "Greetings!", style: .Plain, target: self, action: #selector(barButtonTapped)) self.navigationItem.rightBarButtonItem = barButtonItem //Objective-C UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Greeti...
Using code UILabel.lineBreakMode: NSLineBreakMode Swift label.lineBreakMode = .ByTruncatingTail .ByWordWrapping .ByCharWrapping .ByClipping .ByTruncatingHead .ByTruncatingTail .ByTruncatingMiddle Swift 3 label.lineBreakMode = .byTruncatingTail .byWordWrapping .byCharWrapping...
[a-b] where a and b are digits in the range 0 to 9 [3-7] will match a single digit in the range 3 to 7. Matching multiple digits \d\d will match 2 consecutive digits \d+ will match 1 or more consecutive digits \d* will match 0 or more consecutive digits \d{3} will ma...
Define a new type Person using namedtuple like this: Person = namedtuple('Person', ['age', 'height', 'name']) The second argument is the list of attributes that the tuple will have. You can list these attributes also as either space or comma separated string: Person = namedtuple('Person', 'age,...
By default, Interface Builder doesn't accept the CGColor datatype, so to allow adding a CGColor using user defined attributes in interface builder; one may want to use an extension like this: Swift Extension : extension CALayer { func borderUIColor() -> UIColor? { return borderCol...
Exceptions are errors which occur when a program is executing. Consider the Java program below which divides two integers. class Division { public static void main(String[] args) { int a, b, result; Scanner input = new Scanner(System.in); System.out.println(&qu...
NSSet *set = [NSSet set]; NSArray *array = [NSArray array]; NSArray *fromSet = [set allObjects]; NSSet *fromArray = [NSSet setWithArray:array];
IMPORTANT: This delegate method is only called in the foreground. Swift func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) { } Objective-C - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotifi...
Function DisableShift() 'This function disable the shift at startup. This action causes 'the Autoexec macro and Startup properties to always be executed. On Error GoTo errDisableShift Dim db As DAO.Database Dim prop As DAO.Property Const conPropNotFound = 3270 Set db = C...
Function EnableShift() 'This function enables the SHIFT key at startup. This action causes 'the Autoexec macro and the Startup properties to be bypassed 'if the user holds down the SHIFT key when the user opens the database. On Error GoTo errEnableShift Dim db As DAO.Database Dim p...
Tuples can be compared based on their elements. As an example, an enumerable whose elements are of type Tuple can be sorted based on comparisons operators defined on a specified element: List<Tuple<int, string>> list = new List<Tuple<int, string>>(); list.Add(new Tuple<...
References behaves similarly, but not entirely like const pointers. A reference is defined by suffixing an ampersand & to a type name. int i = 10; int &refi = i; Here, refi is a reference bound to i. References abstracts the semantics of pointers, acting like an alias to the underlying...
Any quality Android application will keep track of what it's doing through application logs. These logs allow easy debugging help for the developer to diagnose what's going on with the application. Full Android Documentation can be found here, but a summary follows: Basic Logging The Log class...
The strchr and strrchr functions find a character in a string, that is in a NUL-terminated character array. strchr return a pointer to the first occurrence and strrchr to the last one. #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char toSe...
To use the IronPython command line, open ipy.exe or ipy64.exe. Both files are located in the path that was selected during installation. By default they will be located at C:\Program Files\IronPython 2.7\. Then start writing your statements directly in the IronPython command line. For example: pr...

Page 189 of 1336