Tutorial by Examples: ces

The second value in the curly braces dictates the length of the replacement string. By adjusting the second value to be positive or negative, the alignment of the string can be changed. string.Format("LEFT: string: ->{0,-5}<- int: ->{1,-5}<-", "abc", 123); string....
countMatches method from org.apache.commons.lang3.StringUtils is typically used to count occurences of a substring or character in a String: import org.apache.commons.lang3.StringUtils; String text = "One fish, two fish, red fish, blue fish"; // count occurrences of a substring Str...
Method references allow predefined static or instance methods that adhere to a compatible functional interface to be passed as arguments instead of an anonymous lambda expression. Assume that we have a model: class Person { private final String name; private final String surname; ...
When referring to a worksheet, a range or individual cells, it is important to fully qualify the reference. For example: ThisWorkbook.Worksheets("Sheet1").Range(Cells(1, 2), Cells(2, 3)).Copy Is not fully qualified: The Cells references do not have a workbook and worksheet associated ...
Command: adb devices Result example: List of devices attached emulator-5554 device PhoneRT45Fr54 offline 123.454.67.45 no device First column - device serial number Second column - connection status Android documentation
a reference to seq_name.NEXTVAL is used to get the next value in a sequence. A single statement can only generate a single sequence value. If there are multiple references to NEXTVAL in a statement, they use will use the same generated number. NEXTVAL can be used for INSERTS INSERT INTO Orders (Or...
The foreach package brings the power of parallel processing to R. But before you want to use multi core CPUs you have to assign a multi core cluster. The doSNOW package is one possibility. A simple use of the foreach loop is to calculate the sum of the square root and the square of all numbers from...
Add an accessory view above the keyboard. This is commonly used for adding next/previous buttons, or additional buttons like Done/Submit (especially for the number/phone/decimal pad keyboard types which don't have a built-in return key). Swift let textField = UITextField() // initialized however ...
Under the hood, a matrix is a special kind of vector with two dimensions. Like a vector, a matrix can only have one data class. You can create matrices using the matrix function as shown below. matrix(data = 1:6, nrow = 2, ncol = 3) ## [,1] [,2] [,3] ## [1,] 1 3 5 ## [2,] 2 4...
The base package parallel allows parallel computation through forking, sockets, and random-number generation. Detect the number of cores present on the localhost: parallel::detectCores(all.tests = FALSE, logical = TRUE) Create a cluster of the cores on the localhost: parallelCluster <- para...
For each dimension of an object, the [ operator takes one argument. Vectors have one dimension and take one argument. Matrices and data frames have two dimensions and take two arguments, given as [i, j] where i is the row and j is the column. Indexing starts at 1. ## a sample matrix mat <- matr...
Implementing IErrorHandler for WCF services is a great way to centralize error handling and logging. The implementation shown here should catch any unhandled exception that is thrown as a result of a call to one of your WCF services. Also shown in this example is how to return a custom object, and h...
Inspecting system resource usage is an efficient way to narrow down a problem on a live running application. This example is an equivalent of the traditional ps command for containers. docker top 7786807d8084 To filter of format the output, add ps options on the command line: docker top 7786807...
We will model the process #Load the forecast package library(forecast) #Generate an AR1 process of length n (from Cowpertwait & Meltcalfe) # Set up variables set.seed(1234) n <- 1000 x <- matrix(0,1000,1) w <- rnorm(n) # loop to create x for (t in 2:n) x[t] <- 0.7...
Given a sequence of steps we use repeatedly, it's often handy to store it in a function. Pipes allow for saving such functions in a readable format by starting a sequence with a dot as in: . %>% RHS As an example, suppose we have factor dates and want to extract the year: library(magrittr) ...
This topic specifically talks about UTF-8 and considerations for using it with a database. If you want more information about using databases in PHP then checkout this topic. Storing Data in a MySQL Database: Specify the utf8mb4 character set on all tables and text columns in your database. ...
This example starts Notepad, waits for it to be closed, then gets its exit code. #include <Windows.h> int main() { STARTUPINFOW si = { 0 }; si.cb = sizeof(si); PROCESS_INFORMATION pi = { 0 }; // Create the child process BOOL success = CreateProcessW( L"C:...
Trap expressions don't have to be individual functions or programs, they can be more complex expressions as well. By combining jobs -p and kill, we can kill all spawned child processes of the shell on exit: trap 'jobs -p | xargs kill' EXIT
Given a String and a Character let text = "Hello World" let char: Character = "o" We can count the number of times the Character appears into the String using let sensitiveCount = text.characters.filter { $0 == char }.count // case-sensitive let insensitiveCount = text.low...
Managed resources are resources that the runtime's garbage collector is aware and under control of. There are many classes available in the BCL, for example, such as a SqlConnection that is a wrapper class for an unmanaged resource. These classes already implement the IDisposable interface -- it's u...

Page 8 of 40