Tutorial by Examples: di

A bit counter-intuitive to the way most other languages' standard I/O libraries do it, Haskell's isEOF does not require you to perform a read operation before checking for an EOF condition; the runtime will do it for you. import System.IO( isEOF ) eofTest :: Int -> IO () eofTest line = do ...
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest 693bce725149 6 days ago 967 B postgres 9.5 0f3af79d8673 10 weeks ago 265.7 MB postgres ...
While inside a Razor code block, the browser will only recognize HTML code if the code is escaped. Use @: for a Single line: @foreach(int number in Model.Numbers) { @:<h1>Hello, I am a header!</h1> } Use <text> ... </text> for Multi-line: @{ var number = 1; ...
This uses the Dropbox .NET SDK to download a file from the Dropbox API at the remote path to the local file "Test", while tracking progress: var response = await client.Files.DownloadAsync(path); ulong fileSize = response.Response.Size; const int bufferSize = 1024 * 1024; var buffer ...
After the user has approved a request for permission to send notifications, we can send a simple notification that says Hello to the user: new Notification('Hello', { body: 'Hello, world!', icon: 'url to an .ico image' }); This will send a notification like this: Hello Hello, world!
To find a character or another string, you can use std::string::find. It returns the position of the first character of the first match. If no matches were found, the function returns std::string::npos std::string str = "Curiosity killed the cat"; auto it = str.find("cat"); ...
The function std::find, defined in the <algorithm> header, can be used to find an element in a std::vector. std::find uses the operator== to compare elements for equality. It returns an iterator to the first element in the range that compares equal to the value. If the element in question is...
Many IDEs provide support for generating HTML from Javadocs automatically; some build tools (Maven and Gradle, for example) also have plugins that can handle the HTML creation. However, these tools are not required to generate the Javadoc HTML; this can be done using the command line javadoc tool. ...
// Java: String shortest = items.stream() .min(Comparator.comparing(item -> item.length())) .get(); // Kotlin: val shortest = items.minBy { it.length }
// Java: Stream.of("a1", "a2", "a3") .findFirst() .ifPresent(System.out::println); // Kotlin: sequenceOf("a1", "a2", "a3").firstOrNull()?.apply(::println)
// Java: IntStream.range(1, 4).forEach(System.out::println); // Kotlin: (inclusive range) (1..3).forEach(::println)
// Java: Arrays.stream(new int[] {1, 2, 3}) .map(n -> 2 * n + 1) .average() .ifPresent(System.out::println); // 5.0 // Kotlin: arrayOf(1,2,3).map { 2 * it + 1}.average().apply(::println)
// Java: Stream.of("a1", "a2", "a3") .map(s -> s.substring(1)) .mapToInt(Integer::parseInt) .max() .ifPresent(System.out::println); // 3 // Kotlin: sequenceOf("a1", "a2", "a3") .map { it.substring(1) } ...
// Java: IntStream.range(1, 4) .mapToObj(i -> "a" + i) .forEach(System.out::println); // a1 // a2 // a3 // Kotlin: (inclusive range) (1..3).map { "a$it" }.forEach(::println)
// Java: Stream.of(1.0, 2.0, 3.0) .mapToInt(Double::intValue) .mapToObj(i -> "a" + i) .forEach(System.out::println); // a1 // a2 // a3 // Kotlin: sequenceOf(1.0, 2.0, 3.0).map(Double::toInt).map { "a$it" }.forEach(::println)
// Java: Arrays.asList("a1", "a2", "a3") .stream() .findFirst() .ifPresent(System.out::println); // Kotlin: listOf("a1", "a2", "a3").firstOrNull()?.apply(::println) or, create an extension function on String calle...
Once you have a Dockerfile, you can build an image from it using docker build. The basic form of this command is: docker build -t image-name path If your Dockerfile isn't named Dockerfile, you can use the -f flag to give the name of the Dockerfile to build. docker build -t image-name -f Dockerfi...
Template Definition template linux.bonding { subject = {{.Last.Status}}: {{.Eval .Alert.Vars.by_host}} bad bond(s) on {{.Group.host}} body = `{{template "header" .}} <h2>Bond Status</h2> <table> <tr><th>Bond</th><th>Slave&...
This is a continuous collector that uses the hadoop fs -du -s /hbase/* command to get details about the HDFS disk usage. This metric is very useful for tracking space in an OpenTSDB system. #!/bin/bash while true; do while read -r bytes raw_bytes path; do echo "hdfs.du $(date +&...
string s = "Foo"; string paddedLeft = s.PadLeft(5); // paddedLeft = " Foo" (pads with spaces by default) string paddedRight = s.PadRight(6, '+'); // paddedRight = "Foo+++" string noPadded = s.PadLeft(2); // noPadded = "Foo" (original string...

Page 14 of 164