Vavr List:
List<String> str = List.of("A", "B", "C");
HashSet<String> res = str.foldLeft(
HashSet.empty(),
(set, s) -> set.add(s)
);| #!/usr/bin/env ruby | |
| require 'pathname' | |
| infile = ARGV[0] | |
| fonts_dir = ARGV[1] | |
| unless infile && fonts_dir | |
| puts "Usage: webfonts-to-local.rb <INPUT-CSS> <FONTS-DIR>" | |
| exit(1) |
| # in spec/features_helper.rb | |
| # adapted from https://robots.thoughtbot.com/automatically-wait-for-ajax-with-capybara | |
| # for legacy Rails apps still using Prototype.js | |
| def wait_for_ajax! | |
| Timeout.timeout(Capybara.default_max_wait_time) do | |
| # Error pages etc. may not have Ajax defined | |
| loop until page.evaluate_script("(typeof Ajax === 'undefined') ? 0 : Ajax.activeRequestCount").zero? | |
| end | |
| end |
| from typing import Tuple, List | |
| """A 'bin' of observations in the form (average, error, # of observations)""" | |
| Bin = Tuple[float, float, int] | |
| """Based on http://isi.ssl.berkeley.edu/~tatebe/whitepapers/Combining%20Errors.pdf""" | |
| def combine(a: Bin, b: Bin) -> Bin: | |
| a_avg, a_err, n_a = a | |
| b_avg, b_err, n_b = b | |
| n = n_a + n_b |
Vavr List:
List<String> str = List.of("A", "B", "C");
HashSet<String> res = str.foldLeft(
HashSet.empty(),
(set, s) -> set.add(s)
);| public class Arguments { | |
| // ------------------------------------------------------------ | |
| // Checks | |
| public static <T> T require(T argument, Predicate<T> condition, Supplier<String> msgSupplier) { | |
| return require(argument, () -> condition.test(argument), msgSupplier); | |
| } | |
| public static <T> T requireNot(T argument, Predicate<T> condition, Supplier<String> msgSupplier) { |
| $ ./gradlew check | |
| > Configure project :buildSrc | |
| 2018-01-03 10:41:04.718:INFO::Daemon worker Thread 10: Logging initialized @6632166ms | |
| 2018-01-03 10:41:04.763:INFO:oejs.Server:Daemon worker Thread 10: jetty-9.2.12.v20150709 | |
| OpenSSL::X509::StoreError: setting default path failed: No password supplied for PKCS#12 KeyStore. | |
| set_default_paths at org/jruby/ext/openssl/X509Store.java:165 | |
| SSLContext at uri:classloader:/META-INF/jruby.home/lib/ruby/shared/jopenssl19/openssl/ssl-internal.rb:31 | |
| SSL at uri:classloader:/META-INF/jruby.home/lib/ruby/shared/jopenssl19/openssl/ssl-internal.rb:22 |
| import javafx.application.Application; | |
| import javafx.beans.binding.Bindings; | |
| import javafx.beans.binding.ObjectBinding; | |
| import javafx.beans.property.ReadOnlyObjectProperty; | |
| import javafx.beans.property.ReadOnlyObjectWrapper; | |
| import javafx.collections.FXCollections; | |
| import javafx.collections.ObservableList; | |
| import javafx.scene.Group; | |
| import javafx.scene.Scene; | |
| import javafx.scene.control.TableCell; |
| import javafx.application.Application; | |
| import javafx.beans.property.ReadOnlyObjectWrapper; | |
| import javafx.collections.ListChangeListener; | |
| import javafx.collections.ObservableList; | |
| import javafx.scene.Group; | |
| import javafx.scene.Scene; | |
| import javafx.scene.control.TableColumn; | |
| import javafx.scene.control.TableView; | |
| import javafx.scene.control.skin.TableHeaderRow; | |
| import javafx.stage.Stage; |
A naive regex to match supplementary characters in the range U+10000–U+EFFFF produces nonsensical results:
jshell> Pattern.matches("[\u10000-\uEFFFF]+", "abc")
==> true
Likewise the version using regex escapes rather than character escapes:
jshell> Pattern.matches("[\\u10000-\\uEFFFF]+", "abc")
==> true
| import io.vavr.collection.Array; | |
| import java.net.URI; | |
| import java.util.Objects; | |
| import java.util.function.IntSupplier; | |
| import java.util.stream.Stream; | |
| class Vocab implements Comparable<Vocab> { | |
| private final String prefix; | |
| private final URI uri; |