Tutorial by Examples: di

String can be formatted to accept a padding parameter that will specify how many character positions the inserted string will use : ${value, padding} NOTE: Positive padding values indicate left padding and negative padding values indicate right padding. Left Padding A left padding of 5 (a...
Gradients are new image types, added in CSS3. As an image, gradients are set with the background-image property, or the background shorthand. There are two types of gradient functions, linear and radial. Each type has a non-repeating variant and a repeating variant: linear-gradient() repeating-...
You define a map using the keyword map, followed by the types of its keys and its values: // Keys are ints, values are ints. var m1 map[int]int // initialized to nil // Keys are strings, values are ints. var m2 map[string]int // initialized to nil Maps are reference types, and once defined ...
slice = append(slice, "hello", "world")
NSArray *myColors = [NSArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; NSLog (@"Number of elements in array = %lu", [myColors count]);
NSMutableArray *myColors; myColors = [NSMutableArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; [myColors addObject: @"Indigo"]; [myColors addObject: @"Violet"]; //Add objects from an NSArray NSArray *myArray = @[@...
You can "overwrite" a parent element's language declaration by introducing any element apart from applet, base, basefont, br, frame, frameset, hr, iframe, meta, param, script (of HTML 4.0) with an own lang attribute: <p lang="en" title="An English paragraph"> ...
Any fold can be run in the opposite direction with the help of the Dual monoid, which flips an existing monoid so that aggregation goes backwards. newtype Dual a = Dual { getDual :: a } instance Monoid m => Monoid (Dual m) where mempty = Dual mempty (Dual x) `mappend` (Dual y) = Dua...
When the following is compiled, it will return a different value depending on which directives are defined. // Compile with /d:A or /d:B to see the difference string SomeFunction() { #if A return "A"; #elif B return "B"; #else return "C"; #endif ...
C11 Reading an object will cause undefined behavior, if the object is1: uninitialized defined with automatic storage duration it's address is never taken The variable a in the below example satisfies all those conditions: void Function( void ) { int a; int b = a; } 1 (Quo...
// Convert string to ArrayBuffer. This step is only necessary if you wish to hash a string, not if you aready got an ArrayBuffer such as an Uint8Array. var input = new TextEncoder('utf-8').encode('Hello world!'); // Calculate the SHA-256 digest crypto.subtle.digest('SHA-256', input) // Wait fo...
In this example, we illustrate string manipulation in MATLAB MEX. We will create a MEX-function that accepts a string as input from MATLAB, copy the data into C-string, modify it and convert it back to mxArray returned to the MATLAB side. The main objective of this example is to show how strings ca...
round Rounds the value to the nearest whole number with x.5 rounding up (but note that -x.5 rounds down). round(3.000) // 3 round(3.001) // 3 round(3.499) // 3 round(3.500) // 4 round(3.999) // 4 round(-3.000) // -3 round(-3.001) // -3 round(-3.499) // -3 round(-3.500) // -4 *** careful...
Most UIKit classes, including UIView, adhere to UIAccessibilityProtocol and return correct values by default. It’s easy to take for granted that a UIView set to hidden is also absent from the accessibility hierarchy and won’t be navigated by VoiceOver. While this default behavior is usually sufficie...
Closures are often used for asynchronous tasks, for example when fetching data from a website. 3.0 func getData(urlString: String, callback: (result: NSData?) -> Void) { // Turn the URL string into an NSURLRequest. guard let url = NSURL(string: urlString) else { return } let re...
docker ps --filter name=myapp_1
URL url = new URL("http://example.com"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); try { BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream())); // read the input stream // in this case, I simply read t...
URL url = new URL("http://example.com"); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); try { BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream())); // use a string builder to bufferize the response body //...
jQuery makes handling jSON responses painless, but a bit more work is required when a given request wishes you to send data in JSON format: $.ajax("/json-consuming-route", { data: JSON.stringify({author: {name: "Bullwinkle J. Moose", ...
If you have several objects of monadic types, we can achieve combinations of the values using a 'for comprehension': for { x <- Option(1) y <- Option("b") z <- List(3, 4) } { // Now we can use the x, y, z variables println(x, y, z) x // the last expre...

Page 15 of 164