Thread pools on the JVM should usually be divided into the following three categories:
- CPU-bound
- Blocking IO
- Non-blocking IO polling
Each of these categories has a different optimal configuration and usage pattern.
| #!/usr/bin/env bash | |
| # Generate JWT for Github App | |
| # | |
| # Inspired by implementation by Will Haley at: | |
| # http://willhaley.com/blog/generate-jwt-with-bash/ | |
| # From: | |
| # https://stackoverflow.com/questions/46657001/how-do-you-create-an-rs256-jwt-assertion-with-bash-shell-scripting | |
| thisdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| import java.io.IOException; | |
| import okhttp3.HttpUrl; | |
| import okhttp3.Interceptor; | |
| import okhttp3.OkHttpClient; | |
| import okhttp3.Request; | |
| /** An interceptor that allows runtime changes to the URL hostname. */ | |
| public final class HostSelectionInterceptor implements Interceptor { | |
| private volatile String host; |
| import java.util.Arrays; | |
| class NonCapturing { | |
| public static void main(String... args) { | |
| run(new Runnable() { | |
| @Override public void run() { | |
| System.out.println("Hey!"); | |
| } | |
| }); | |
| } |
Centralize the support libraries dependencies in gradle
Working with multi-modules project, it is very useful to centralize the dependencies, especially the support libraries.
A very good way is to separate gradle build files, defining something like:
root
--gradleScript
----dependencies.gradle
| Unless specified otherwise, all of the below tinting applies to both Lollipop and pre-Lollipop using AppCompat v21. To use the support version of these attributes, remove the android namespace. For instance, "android:colorControlNormal" becomes "colorControlNormal". These attributes will be propagated to their corresponding attributes within the android namespace for devices running Lollipop. Any exceptions to this will be noted by including the "android:" prefix. | |
| All Clickable Views: | |
| ----------- | |
| * ripple effect (Lollipop only) -- "colorControlHighlight" | |
| Status Bar: | |
| ------------ | |
| * background (Lollipop only) - "colorPrimaryDark" |
| package your.package; | |
| import android.app.Activity; | |
| import android.os.Bundle; | |
| import android.support.v7.graphics.Palette; | |
| import com.squareup.picasso.Picasso; | |
| import your.package.PaletteTransformation; | |
| import static your.package.PaletteTransformation.PaletteCallback; |
| import android.text.SpannableStringBuilder; | |
| import java.util.ArrayDeque; | |
| import java.util.Deque; | |
| import static android.text.Spanned.SPAN_INCLUSIVE_EXCLUSIVE; | |
| /** A {@link SpannableStringBuilder} wrapper whose API doesn't make me want to stab my eyes out. */ | |
| public class Truss { | |
| private final SpannableStringBuilder builder; | |
| private final Deque<Span> stack; |
| import java.io.UnsupportedEncodingException; | |
| import java.util.Map; | |
| import org.simpleframework.xml.Serializer; | |
| import org.simpleframework.xml.core.Persister; | |
| import com.android.volley.AuthFailureError; | |
| import com.android.volley.NetworkResponse; | |
| import com.android.volley.ParseError; | |
| import com.android.volley.Request; |