Tutorial by Examples: c

Autoboxing can come at a substantial memory overhead. For example: Map<Integer, Integer> square = new HashMap<Integer, Integer>(); for(int i = 256; i < 1024; i++) { square.put(i, i * i); // Autoboxing of large integers } will typically consume substantial amount of memory (...
To change password of current user just type: sudo passwd It will ask you to enter your current password: [sudo] password for <user>: And then you will be asked to enter new password: Enter new UNIX password: And finally you will be asked to re-enter your password: Retype new UNIX...
Swift //Swift let viewController = UIViewController() let navigationController = UINavigationController(rootViewController: viewController) //Objective-C UIViewController *viewController = [[UIViewController alloc] init]; UINavigationController *navigationController = [[UINavigationControlle...
//Swift let fooViewController = UIViewController() navigationController?.pushViewController(fooViewController, animated: true) //Objective-C UIViewController *fooViewController = [[UIViewController alloc] init]; [navigationController pushViewController:fooViewController animated:YES];
As we know that we should use synchronized keyword to make execution of a method or block exclusive. But few of us may not be aware of one more important aspect of using synchronized and volatile keyword: apart from making a unit of code atomic, it also provides read / write barrier. What is this re...
Typically, when using UIControl or UIButton, we add a selector as a callback action for when an event occurs on a button or control, such as the user pressing the button or touching the control. For example, we would do the following: import UIKit class ViewController: UIViewController { @...
Go to editor (from tool window) Esc Switching focus to corresponding tool window Windows: Alt + <tool window number> OS X / macOS: Cmd + <tool window number> For example switching focus to the project window Windows: Alt + 1 OS X / macOS: Cmd + 1 Recent files popup Windows: Ctrl...
It is common within applications to need to have code like this : a = a + 1 or a = a * 2 There is an effective shortcut for these in place operations : a += 1 # and a *= 2 Any mathematic operator can be used before the '=' character to make an inplace operation : -= decrement the va...
YAML is a text based format allowing to store structured data in a hierarchy. YAML is designed to be human and machine readable with a minimum of overhead. The YAML specification can be found at yaml.org. There is also a reference card Comments start with # and go till newline, comments must be sep...
If you've got multiple implementations of the same interface, Spring can autowire them all into a collection object. I'm going to use an example using a Validator pattern1 Foo Class: public class Foo { private String name; private String emailAddress; private String errorMessage;...
All of the Bitwise operators (except ~) have their own in place versions a = 0b001 a &= 0b010 # a = 0b000 a = 0b001 a |= 0b010 # a = 0b011 a = 0b001 a <<= 2 # a = 0b100 a = 0b100 a >>= 2 # a = 0b001 a = 0b101 a ^= 0b011 # a = 0b110
If you have both Python 3 and Python 2 installed, you can specify which version of Python you would like pip to use. This is useful when packages only support Python 2 or 3 or when you wish to test with both. If you want to install packages for Python 2, run either: pip install [package] or: p...
#;(define (commented-out-function x) (print (string-append "This entire " "s-expression is commented out!")))
Linux has a command for almost any tasks and most of them are intuitive and easily interpreted. Getting Help in Linux CommandUsabilityman <name>Read the manual page of <name>.man <section> <name>Read the manual page of <name>, related to the given section.man -k <e...
Linux uses some conventions for present and parent directories. This can be a little confusing for beginners. Whenever you are in a terminal in Linux, you will be in what is called the current working directory. Often your command prompt will display either the full working directory, or just the l...
private static void explicitTaskParallism() { Thread.CurrentThread.Name = "Main"; // Create a task and supply a user delegate by using a lambda expression. Task taskA = new Task(() => Console.WriteLine($"Hello from task {nameof(taskA)}.")...
private static void Main(string[] args) { var a = new A(); var b = new B(); //implicit task parallelism Parallel.Invoke( () => a.DoSomeWork(), () => b.DoSomeOtherWork() ); }
This example assumes that you have experience in creating Rails applications. To create an API-only app in Rails 5, run rails new name-of-app --api Add active_model_serializers in Gemfile gem 'active_model_serializers' install bundle in terminal bundle install Set the ActiveModelSeriali...
Corner radius for all 4 edges: UIBezierPath* rectanglePath = [UIBezierPath bezierPathWithRoundedRect: CGRectMake(x,y,width,height) cornerRadius: 11]; [UIColor.grayColor setFill]; [rectanglePath fill]; Corner radius for top-left edge: UIBezierPath* rectanglePath = [UIBezierPath bezierPat...
For a simple circle: UIBezierPath* ovalPath = [UIBezierPath bezierPathWithOvalInRect: CGRectMake(0,0,50,50)]; [UIColor.grayColor setFill]; [ovalPath fill]; Swift: let ovalPath = UIBezierPath(ovalInRect: CGRect(x: 0, y: 0, width: 50, height: 50)) UIColor.grayColor().setFill() ovalPath.fill...

Page 256 of 826