Tutorial by Examples: c

Introduction Play has several plugins for different IDE-s. The eclipse plugin allows to transform a Play application into a working eclipse project with the command activator eclipse. Eclipse plugin may be set per project or globally per sbt user. It depends on team work, which approach should be u...
C++11 The alignas keyword can be used to force a variable, class data member, declaration or definition of a class, or declaration or definition of an enum, to have a particular alignment, if supported. It comes in two forms: alignas(x), where x is a constant expression, gives the entity the ali...
When creating the project You should check "Include Unit Tests" in the project creation dialog. After creating the project If you missed checking that item while creating your project, you could always add test files later. To do so: 1- Go to your project settings in Xcode 2- Go to ...
To get started with unit testing, which will be done in the tests file and will be testing the View Controller and Storyboard, we should introduce these two files to the test file. Defining the View Controller Swift var viewController : ViewController! Introducing the Storyboard and initializi...
To stop the Handler from execution remove the callback attached to it using the runnable running inside it: Runnable my_runnable = new Runnable() { @Override public void run() { // your code here } }; public Handler handler = new Handler(); // use 'new Handler(Looper.get...
In order to call a function through a function pointer, the function pointer's type must exactly match the function's type. Otherwise, the behaviour is undefined. Example: int f(); void (*p)() = reinterpret_cast<void(*)()>(f); p(); // undefined
To build up an expression like _ => _.Field == "VALUE" at runtime. Given a predicate _ => _.Field and a string value "VALUE", create an expression that tests whether or not the predicate is true. The expression is suitable for: IQueryable<T>, IEnumerable<T>...
Configuring the connection programmatically: var config = new ClientConfiguration { Servers = new List<Uri> { new Uri("http://localhost:8091/pools") }, BucketConfigs = new Dictionary<string, BucketConfiguration> ...
OOP - Object Oriented Programming is a vastly used programming paradigm in these days. In OOP, we model real world problems using Objects and there behaviors, in order to solve them, programmatically. There are four main OOP Concepts Inheritance Polymorphism Abstraction Encapsulation These...
To get versionName and versionCode of current build of your application you should query Android's package manager. try { // Reference to Android's package manager PackageManager packageManager = this.getPackageManager(); // Getting package info of this application PackageInfo...
foreach is unusual among the collections iterators in that it does not return a result. Instead it applies a function to each element that has only side effects. For example: scala> val x = List(1,2,3) x: List[Int] = List(1, 2, 3) scala> x.foreach { println } 1 2 3 The function sup...
In Object Oriented Design, objects receive messages and reply to them. In Ruby, sending a message is calling a method and result of that method is the reply. In Ruby message passing is dynamic. When a message arrives rather than knowing exactly how to reply to it Ruby uses a predefined set of rules...
class Example def example_method :example end def subexample_method :example end def not_missed_method :example end def method_missing name return :example if name == :missing_example_method return :example if name == :missing_subexample_method ...
Ruby moves up on ancestors chain of an object. This chain can contain both modules and classes. Same rules about moving up the chain apply to modules as well. class Example end module Prepended def initialize *args return super :default if args.empty? super end end module Fi...
The Continue operator works in For, ForEach, While and Do loops. It skips the current iteration of the loop, jumping to the top of the innermost loop. $i =0 while ($i -lt 20) { $i++ if ($i -eq 7) { continue } Write-Host $I } The above will output 1 to 20 to the console but miss...
This can be used in various chat applications, rss feeds, and social apps where you need to have latest feeds with timestamps: Objective-C - (NSString *)getHistoricTimeText:(NSDate *)since { NSString *str; NSTimeInterval interval = [[NSDate date] timeIntervalSinceDate:since]; if(in...
Using a file Swift let data = NSData(contentsOfFile: filePath) //assuming filePath is a valid path Objective-C NSData *data = [NSData dataWithContentsOfFile:filePath]; //assuming filePath is a valid path Using a String object Swift let data = (string as NSString).dataUsingEncoding(NSUTF8S...
To String Swift let string = String(NSString(data: data, encoding: NSUTF8StringEncoding)) //assuming data is a valid NSData object Objective-C NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; //assuming data is a valid NSData object [string release]; T...

Page 432 of 826