Tutorial by Examples

<?php // Setting parameters $time = time(); $values = [7, $time, $time]; // Prints "At 3:50:31 PM on Apr 19, 2015, there was a disturbance on planet 7." $pattern = "At {1, time} on {1, date}, there was a disturbance on planet {0, number}."; $formatter = new Messa...
import com.ibm.icu.text.MessageFormat import java.util.Locale import scala.collection.JavaConverters._ // Outputs "A common message for all options. Selected: (other)" val formatted = new MessageFormat( "{messageCount, plural, one {{aMessage} (one)} other {{aMessage} (othe...
It's relatively easy to parse the command line by hand if you aren't looking for anything too complex: # Naive error checking abort('Usage: ' + $0 + ' site id ...') unless ARGV.length >= 2 # First item (site) is mandatory site = ARGV.shift ARGV.each do | id | # Do something interestin...
With OptionsParser, it's really easy to set up default values. Just pre-populate the hash you store the options in: options = { :directory => ENV['HOME'] } When you define the parser, it will overwrite the default if a user provide a value: OptionParser.new do |opts| opts.on("-d&...
Detailed instructions on getting identityserver4 set up or installed.
Suppose you had an array: pair = ['Jack','Jill'] And a method that takes two arguments: def print_pair (a, b) puts "#{a} and #{b} are a good couple!" end You might think you could just pass the array: print_pair(pair) # wrong number of arguments (1 for 2) (ArgumentError) Si...
The splat operator removes individual elements of an array and makes them into a list. This is most commonly used to create a method that accepts a variable number of arguments: # First parameter is the subject and the following parameters are their spouses def print_spouses(person, *spouses) s...
Harp doesn’t require any configuration to get started. Install Harp in your terminal using the command: npm install -g harp. $ sudo npm install -g harp $ harp init myproject $ harp server myproject
Creating files Language To create a language file, you must end it with _lang.php. For example, you want to create a language file for French language, then you must save it with french_lang.php. Within this file you can store all your language texts in key, value combination in $lang array as show...
When you have an ajax call, it's extremely difficult to get a log from inside of the callback function. But if you enable the debugging define('WP_DEBUG', true); and then after that add ini_set('log_errors',TRUE); ini_set('error_reporting', E_ALL); ini_set('error_log', dirname(__FILE__) . '/e...
The ValuesAttribute is used to specify a set of values for an individual parameter of a test method with parameters. [Test] public void Sum_Works_Correctly( [Values(1, 2, 3)] int x, [Values(4, 5)] int y) { // Arrange var calculator = new Calculator(...
One of the central difficulties of writing an Android application using Dagger is that many Android framework classes are instantiated by the OS itself, like Activity and Fragment, but Dagger works best if it can create all the injected objects. Instead, you have to perform members injection in a li...
By setting Multi-Release: true in the MANIFEST.MF file, the Jar file becomes a multi-release Jar and the Java runtime (as long as it supports the MRJAR format) will pick the appropriate versions of classes depending on the current major version. The structure of such a Jar is the following: jar ro...
The jar command can be used to create a multi-release Jar containing two versions of the same class compiled for both Java 8 and Java 9, albeit with a warning telling that the classes are identical: C:\Users\manouti>jar --create --file MR.jar -C sampleproject-base demo --release 9 -C sampleproje...
Given the following multi-release Jar: jar root - demo - SampleClass.class - META-INF - versions - 9 - demo - SampleClass.class The following class prints the URL of the SampleClass: package demo; import java.net.URL; public class Main...
First step : PCL part public class RoundedBoxView : BoxView { public static readonly BindableProperty CornerRadiusProperty = BindableProperty.Create("CornerRadius", typeof(double), typeof(RoundedEntry), default(double)); public double CornerRadius { get...
Example: > cat example.txt TODO: complete this NOT this NOT that TODO: Complete that Open the example.txt using vim and type :v/TODO/d in the Ex mode. This will delete all lines that do not contain the TODO pattern.
The following prints all stack frames of the current thread: 1 package test; 2 3 import java.lang.StackWalker.StackFrame; 4 import java.lang.reflect.InvocationTargetException; 5 import java.lang.reflect.Method; 6 import java.util.List; 7 import java.util.stream.Collectors; 8 9 pu...
The following prints the current caller class. Note that in this case, the StackWalker needs to be created with the option RETAIN_CLASS_REFERENCE, so that Class instances are retained in the StackFrame objects. Otherwise an exception would occur. public class StackWalkerExample { public stat...
A couple of other options allow stack traces to include implementation and/or reflection frames. This may be useful for debugging purposes. For instance, we can add the SHOW_REFLECT_FRAMES option to the StackWalker instance upon creation, so that the frames for the reflective methods are printed as ...

Page 1237 of 1336