Tutorial by Examples

A constructor is a special method in a class that is called when an instance of an object is created. It is a regular MATLAB function that accepts input parameters but it also must follow certain rules. Constructors are not required as MATLAB creates a default one. In practice, however, this is a p...
Unlike other programming languages, in a batch file a variable is substituted by its actual value before the batch script is run. In other words, the substitution is made when the script is read into memory by the command processor, not when the script is later run. This enables the use of variable...
CSS div { height: 200px; width: 200px; background: url(http://lorempixel.com/200/200/nature/1); mask-image: linear-gradient(to right, white, transparent); } HTML <div></div> In the above example there is an element with an image as its background. The mask that is a...
The content mode property of a view tells how its content should be laid out. In the Interface Builder, the various modes can be selected in the Attributes Inspector. Let's use two image views to see how the various modes work. Scale to Fill The image heights and widths are stretched to mat...
Create a new project It can be just a Single View Application. Add the code Create a new Cocoa Touch Class file (File > New > File... > iOS > Cocoa Touch Class). Name it MyCollectionViewCell. This class will hold the outlets for the views that you add to your cell in the storyboard. ...
Using generics to define the type in instanceof Consider the following generic class Example declared with the formal parameter <T>: class Example<T> { public boolean isTypeAString(String s) { return s instanceof T; // Compilation error, cannot use T as class type here ...
The following might have undefined behavior due to incorrect pointer alignment: char *memory_block = calloc(sizeof(uint32_t) + 1, 1); uint32_t *intptr = (uint32_t*)(memory_block + 1); /* possible undefined behavior */ uint32_t mvalue = *intptr; The undefined behavior happens as the pointer...
The following code has undefined behavior: char buffer[6] = "hello"; char *ptr1 = buffer - 1; /* undefined behavior */ char *ptr2 = buffer + 5; /* OK, pointing to the '\0' inside the array */ char *ptr3 = buffer + 6; /* OK, pointing to just beyond */ char *ptr4 = buffer + 7; /* un...
While there are many different control sequences for io:format and io_lib:format, most of the time you'll use only three different ones: ~s, ~p and ~w. ~s The ~s is for strings. It prints strings, binaries and atoms. (Anything else will cause a badarg error.) It doesn't quote or escape anything...
PHP's runtime memory limit is set through the INI directive memory_limit. This setting prevents any single execution of PHP from using up too much memory, exhausting it for other scripts and system software. The memory limit defaults to 128M and can be changed in the php.ini file or at runtime. I...
An extension to PHP called Xdebug is available to assist in profiling PHP applications, as well as runtime debugging. When running the profiler, the output is written to a file in a binary format called "cachegrind". Applications are available on each platform to analyze these files. To...
for /r command can be used to recursively visit all the directories in a directory tree and perform a command. @echo off rem start at the top of the tree to visit and loop though each directory for /r %%a in (.) do ( rem enter the directory pushd %%a echo In directory: cd rem leave...
Go has a built-in logging library known as log with a commonly use method Print and its variants. You can import the library then do some basic printing: package main import "log" func main() { log.Println("Hello, world!") // Prints 'Hello, world!' on a single ...
If you are inside a folder of a git repository it might be nice to show the current branch you are on. In ~/.bashrc or /etc/bashrc add the following (git is required for this to work): function prompt_command { # Check if we are inside a git repository if git status > /dev/null 2>&a...
There are many cases when one has created an NSDate from only an hour and minute format, i.e: 08:12 The downside for this situation is that your NSDate is almost completely "naked" and what you need to do is to create: day, month, year, second and time zone in order to this object to &quo...
If ww have NSDate object, and we want to convert it into NSString. There are different types of Date strings. How we can do that?, It is very simple. Just 3 steps. Create NSDateFormatter Object NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; Set the date format in whi...
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 ...
NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:@"Your String here"]; [attributeString addAttribute:NSStrikethroughStyleAttributeName value:@2 range:NSMakeRange(0, [attributeString length])];
The return method only returns from the lambda, not the outer method. Beware that this is different from Scala and Kotlin! void threeTimes(IntConsumer r) { for (int i = 0; i < 3; i++) { r.accept(i); } } void demo() { threeTimes(i -> { System.out.println(i); return...
Gray Level Co-Occurrence Matrix (Haralick et al. 1973) texture is a powerful image feature for image analysis. The glcm package provides a easy-to-use function to calculate such texutral features for RasterLayer objects in R. library(glcm) library(raster) r <- raster("C:/Program Files/R...

Page 497 of 1336