Skip to content

Instantly share code, notes, and snippets.

@fabiankessler
fabiankessler / RestApiClient.java
Created October 26, 2015 23:04
RestApiClient thread safe
/**
* Thread safe.
*/
public class RestApiClient {
/**
* Creation of these Client instances is expensive, and according to its Javadoc, they
* should be shared.
*/
private static ConcurrentMap<String, Client> hostMap = new ConcurrentHashMap<>();
@fabiankessler
fabiankessler / LocaleUtility.java
Last active January 3, 2017 07:54 — forked from phil-brown/LocaleUtility.java
Utility for getting the Script String using a Locale. This is useful, for example, in Android, where this is not part of the Locale Object. To use this, simply call `LocaleUtility.getScript(Locale.getDefault());` to get the script for the current users' Locale.
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
/*
* Source https://gist.github.com/phil-brown/8056700