Tutorial by Examples

NSAttributedString (and its mutable sibling NSMutableAttributedString) allows you to create strings that are complex in their appearance to the user. A common application is to use this to display a string and adding custom kerning / letter-spacing. This would be achieved as follows (where label ...
Method overloading, also known as function overloading, is the ability of a class to have multiple methods with the same name, granted that they differ in either number or type of arguments. Compiler checks method signature for method overloading. Method signature consists of three things - Met...
Method overriding is the ability of subtypes to redefine (override) the behavior of their supertypes. In Java, this translates to subclasses overriding the methods defined in the super class. In Java, all non-primitive variables are actually references, which are akin to pointers to the location of...
Objective-C CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position.x"]; animation.fromValue = @0; animation.toValue = @320; animation.duration = 1; [_label.layer addAnimation:animation forKey:@"basic"]; Swift let animation = CAB...
OBJECTIVE-C CATransition* transition = [CATransition animation]; transition.startProgress = 0; transition.endProgress = 1.0; transition.type = @"flip"; transition.subtype = @"fromLeft"; transition.duration = 0.8; transition.repeatCount = 5; [_label.layer addAnimation:tran...
CGRect boundingRect = CGRectMake(-150, -150, 300, 300); CAKeyframeAnimation *orbit = [CAKeyframeAnimation animation]; orbit.keyPath = @"position"; orbit.path = CFAutorelease(CGPathCreateWithEllipseInRect(boundingRect, NULL)); orbit.duration = 4; orbit.additive = YES; orbit.repeatC...
Objective-C CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position.x"]; animation.values = @[ @0, @10, @-10, @10, @0 ]; animation.keyTimes = @[ @0, @(1 / 6.0), @(3 / 6.0), @(5 / 6.0), @1 ]; animation.duration = 0.4; animation.additive = YES; [_label.lay...
use Data::Dumper; my $data_structure = { foo => 'bar' }; print Dumper $data_structure; Using Data::Dumper is an easy way to look at data structures or variable content at run time. It ships with Perl and you can load it easily. The Dumper function returns the data structure serialized in a...
Sometimes Data::Dumper is not enough. Got a Moose object you want to inspect? Huge numbers of the same structure? Want stuff sorted? Colored? Data::Printer is your friend. use Data::Printer; p $data_structure; Data::Printer writes to STDERR, like warn. That makes it easier to find the outpu...
Step 1 If you already have Django installed, you can skip this step. pip install Django Step 2 Create a new project django-admin startproject hello That will create a folder named hello which will contain the following files: hello/ ├── hello/ │ ├── __init__.py │ ├── settings.py │...
Using reflection, a method of an object can be invoked during runtime. The example shows how to invoke the methods of a String object. import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; String s = "Hello World!"; // method without parameters // i...
var availableName; do { availableName = getRandomName(); } while (isNameUsed(name)); A do while loop is guaranteed to run at least once as it's condition is only checked at the end of an iteration. A traditional while loop may run zero or more times as its condition is checked at the begin...
The docker rmi command is used to remove images: docker rmi <image name> The full image name must be used to remove an image. Unless the image has been tagged to remove the registry name, it needs to be specified. For example: docker rmi registry.example.com/username/myAppImage:1.3.5 I...
Although not strictly required, it is highly recommended to start your project in a "virtual environment." A virtual environment is a container (a directory) that holds a specific version of Python and a set of modules (dependencies), and which does not interfere with the operating system'...
Detailed instructions on getting emacs set up or installed. Official instructions are available on the GNU Emacs website. Debian systems On systems with the Debian package manager (such as Debian, Ubuntu, and Mint) Emacs can be installed via the simple command: sudo apt-get install emacs For ...
Tkinter comes pre-installed with the Python installer binaries for Mac OS X and the Windows platform. So if you install Python from the official binaries for Mac OS X or Windows platform, you are good to go with Tkinter. For Debian versions of Linux you have to install it manually by using the foll...
Often, we need to perform an operation over every element in a variadic template parameter pack. There are many ways to do this, and the solutions get easier to read and write with C++17. Suppose we simply want to print every element in a pack. The simplest solution is to recurse: C++11 void print...
XML is made of basic building blocks, which are: element text attributes comments processing instructions An element has angle brackets: <element/> <element>some content</element> An attribute appears in an opening element tag: <element attribute-name="...
An XML document is a text file that conforms to the XML specification's well-formedness rules. Such a conforming document is said to be well-formed (not to be confused with valid). XML is very strict with well-formedness in comparison to other languages such as HTML. A text file that is not well-for...
The internal keyword makes a class (including nested classes), property, method or field available to every consumer in the same assembly: internal class Foo { internal string SomeProperty {get; set;} } internal class Bar { var myInstance = new Foo(); internal string SomeField ...

Page 120 of 1336