Skip to content

Instantly share code, notes, and snippets.

Jake Wharton JakeWharton

View GitHub Profile
@JakeWharton
JakeWharton / build.gradle
Last active May 10, 2018
Prevent wildcard versions in your Gradle project. These undermine deterministic and hermetic builds and are generally considered bad practice.
View build.gradle
allprojects {
afterEvaluate { project ->
project.configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.version.contains('+')) {
throw new GradleException("Wildcard dependency forbidden: ${requested.group}:${requested.name}:${requested.version}")
}
}
}
@JakeWharton
JakeWharton / README.md
Last active May 10, 2018
A special activity which facilitates restarting your application process.
View README.md
View keybase.md

Keybase proof

I hereby claim:

  • I am JakeWharton on github.
  • I am jakewharton (https://keybase.io/jakewharton) on keybase.
  • I have a public key whose fingerprint is 90EE 1978 7A7B CF6F D37A 1E91 80C0 8B1C 2910 0955

To claim this, I am signing this object:

@JakeWharton
JakeWharton / AutoGson.java
Last active Mar 7, 2019
A Gson TypeAdapterFactory which allows serialization of @autovalue types. Apache 2 licensed.
View AutoGson.java
import com.google.auto.value.AutoValue;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Marks an {@link AutoValue @AutoValue}-annotated type for proper Gson serialization.
* <p>
@JakeWharton
JakeWharton / .bash_profile
Created Aug 7, 2014
Merge all your branches into a hacking branch.
View .bash_profile
function hackhackhack() {
# Merge all your local branches into a hacking branch.
PREFIX="$(whoami)/"
git co master
git branch -D "${PREFIX}hackhackhack"
git pull --prune
git co -b "${PREFIX}hackhackhack"
for branch in $(git branch | \grep "$PREFIX"); do
git merge --no-edit $branch
done
@JakeWharton
JakeWharton / README.md
Last active May 10, 2018
A workaround for Android "L" Okio packaging problem. Place all of the following in a `libs/` folder.
View README.md
@JakeWharton
JakeWharton / build.gradle
Created Jul 19, 2014
Adding support-annotations jar to a Java module.
View build.gradle
apply plugin: 'java'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
def logger = new com.android.build.gradle.internal.LoggerWrapper(project.logger)
def sdkHandler = new com.android.build.gradle.internal.SdkHandler(project, logger)
for (File file : sdkHandler.sdkLoader.repositories) {
project.repositories.maven {
url = file.toURI()
@JakeWharton
JakeWharton / ForegroundImageView.java
Created Jul 10, 2014
An ImageView which supports a foreground drawable.
View ForegroundImageView.java
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;
public class ForegroundImageView extends ImageView {
private Drawable foreground;
@JakeWharton
JakeWharton / 19.1.0_to_20.0.0.diff
Last active Aug 29, 2015
Public API changes between support-v4 19.1.0 to 20.0.0. Created with https://github.com/JakeWharton/jardiff
View 19.1.0_to_20.0.0.diff
diff -U 0 -N support-v4-19.1.0/android.support.v4.BuildConfig support-v4-20.0.0/android.support.v4.BuildConfig
--- support-v4-19.1.0/android.support.v4.BuildConfig 1969-12-31 16:00:00.000000000 -0800
+++ support-v4-20.0.0/android.support.v4.BuildConfig 2014-06-26 19:59:59.000000000 -0700
@@ -0,0 +1,9 @@
+public final class android.support.v4.BuildConfig {
+ public static final boolean DEBUG;
+ public static final java.lang.String PACKAGE_NAME;
+ public static final java.lang.String BUILD_TYPE;
+ public static final java.lang.String FLAVOR;
+ public static final int VERSION_CODE;
@JakeWharton
JakeWharton / README.md
Created Jun 12, 2014
Map Java 8 streams to RxJava Observables.
View README.md

Output

Greeting: Hey
Greeting: Hi
Greeting: Hello

[60, 61, 62, 63, 64, 65, 66, 67, 68, 69]
[70, 71, 72, 73, 74, 75, 76, 77, 78, 79]
[80, 81, 82, 83, 84, 85, 86, 87, 88, 89]
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.