Tutorial by Examples: c

The classpath is a sequence of entries which are directory pathnames, JAR or ZIP file pathnames, or JAR / ZIP wildcard specifications. For a classpath specified on the command line (e.g. -classpath) or as an environment variable, the entries must be separated with ; (semicolon) characters on Wi...
Sometimes, just adding all the JARs from a folder isn't enough, for example when you have native code and need to select a subset of JARs. In this case, you need two main() methods. The first one builds a classloader and then uses this classloader to call the second main(). Here is an example which...
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...
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...
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])];
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...
The package mmand provides functions for the calculation of Mathematical Morphologies for n-dimensional arrays. With a little workaround, these can also be calculated for raster images. library(raster) library(mmand) r <- raster("C:/Program Files/R/R-3.2.3/doc/html/logo.jpg") plot...
If you know the format of the string you are converting (parsing) you should use DateTime.ParseExact Dim dateString As String = "12.07.2003" Dim dateFormat As String = "dd.MM.yyyy" Dim dateValue As Date dateValue = DateTime.ParseExact(dateString, dateFormat, Globalization.C...
Simply use the .ToString overload of a DateTime object to get the format you require: Dim dateValue As DateTime = New DateTime(2001, 03, 06) Dim dateString As String = dateValue.ToString("yyyy-MM-dd") '2001-03-06

Page 308 of 826