This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function weightedMedian(values, weights) { | |
| var midpoint = 0.5 * sum(weights); | |
| var cumulativeWeight = 0; | |
| var belowMidpointIndex = 0; | |
| var sortedValues = []; | |
| var sortedWeights = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| for (( ; ; )) | |
| do | |
| sleep 10 && echo "$(date): $(wget -q -S -O - http://localhost:8079/actuator/health 2>&1 | grep HTTP)" | |
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div id="app"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| factorials | |
| .zipWith(Source(0 to 100))((num, idx) ⇒ s"$idx! = $num") | |
| .throttle(1, 1.second) | |
| .runForeach(println) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val o = Observable.interval(200 millis).take(5) | |
| o.subscribe(n => println("n = " + n)) | |
| Observable.just(1, 2, 3, 4).reduce(_ + _) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class HelloWorld { | |
| public static void main(String[] args) { | |
| Flowable.just("Hello world").subscribe(System.out::println); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { Observable, Subject, ReplaySubject, from, of, range } = require('rxjs'); | |
| const { map, filter, switchMap } = require('rxjs/operators'); | |
| range(1, 200) | |
| .pipe(filter(x => x % 2 === 1), map(x => x + x)) | |
| .subscribe(x => console.log(x)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from rx import Observable | |
| Observable.of("Alpha", "Beta", "Gamma", "Delta", "Epsilon") \ | |
| .map(lambda s: len(s) >= 5) \ | |
| .subscribe(on_next=lambda value: print("Received {0}".format(value)), | |
| on_completed=lambda: print("Done!"), | |
| on_error=lambda error: print("Error Occurred: {0}".format(error)))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val list = listOf("Alpha", "Beta", "Gamma", "Delta", "Epsilon") | |
| list.toObservable() // extension function for Iterables | |
| .filter { it.length >= 5 } | |
| .subscribeBy( // named arguments for lambda Subscribers | |
| onNext = { println(it) }, | |
| onError = { it.printStackTrace() }, | |
| onComplete = { println("Done!") } | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it, _ := iterable.New([]interface{}{1, 2, 3, 4, errors.New("bang"), 5}) | |
| source := observable.From(it) | |
| sub := source.Subscribe(watcher) |
NewerOlder