Skip to content

Instantly share code, notes, and snippets.

Avatar

Jared Burrows jaredsburrows

View GitHub Profile
@jaredsburrows
jaredsburrows / FinalTest.java
Created Dec 31, 2018
Playing around with finalize()
View FinalTest.java
public class FinalTest {
private static int count = 0;
public static void main(String[] args) throws Exception {
System.gc();
System.out.println("Start");
for (int i = 0; i < 100_000; i++) {
new OtherClass(i);
}
View Retry.kt
@Retention(AnnotationRetention.RUNTIME)
annotation class Retry(
val retryCount: Int = -1
)
View .travis.yml
language: android
env:
global:
- ADB_INSTALL_TIMEOUT=8
jdk:
- oraclejdk8
before_install:
View quality.gradle
apply {
plugin("com.android.application")
plugin("jacoco")
plugin("com.github.kt3k.coveralls")
plugin("io.gitlab.arturbosch.detekt")
}
// Creates tasks based on the application build variant (productFlavor + buildType = variant)
android.applicationVariants.all { variant ->
def variantName = variant.name.capitalize()
@jaredsburrows
jaredsburrows / BstPreOrder.java
Created Jan 28, 2018
Unit test with System.out
View BstPreOrder.java
import api.TreeNode;
public final class BstPreOrder {
public static void printPreOrder(TreeNode<Integer> node) {
if (node == null) {
return;
}
System.out.print(node.value + " ");
printPreOrder(node.left);
@jaredsburrows
jaredsburrows / jacoco.gradle
Created Dec 21, 2017
Jacoco for multi-module projects
View jacoco.gradle
apply {
plugin("jacoco")
}
def include = [""]
def exclude = [
// Android
"**/R.class",
"**/R\$*.class",
"**/Manifest*.*",
@jaredsburrows
jaredsburrows / nullability.gradle
Last active Oct 25, 2018
Generate "package-info.java" for existing Java packages for Kotlin. Adapted from http://stancalau.ro/java_package-info_generator_gradle/.
View nullability.gradle
// Adapted from http://stancalau.ro/java_package-info_generator_gradle/
def generatedPackageInfoDir = "$buildDir/generated/package-info"
// Handle Android projects
if (project.plugins.hasPlugin("android")) {
android.sourceSets.main.java.srcDirs generatedPackageInfoDir
}
// Handle Java projects
if (project.plugins.hasPlugin("java")) {
@jaredsburrows
jaredsburrows / gist:ef4cbbf8a8a7d8b3ea9f1560daec93c0
Created Sep 12, 2017
Mockito 2 + LinkedIn Dexmaker + Multidex
View gist:ef4cbbf8a8a7d8b3ea9f1560daec93c0
androidTestCompile(extra["junit"])
androidTestCompile(extra["truth"])
androidTestCompile(extra["mockitoKotlin"] as String) { exclude(group = "net.bytebuddy") } // DexMaker has it"s own MockMaker
androidTestCompile(extra["mockitoCore"] as String) { exclude(group = "net.bytebuddy") } // DexMaker has it"s own MockMaker
androidTestCompile(extra["dexmakerMockito"] as String) { exclude(group = "net.bytebuddy") } // DexMaker has it"s own MockMaker
androidTestCompile(extra["runner"])
androidTestCompile(extra["espressoCore"])
androidTestCompile(extra["espressoIntents"])
androidTestCompile(extra["espressoContrib"] as String) { exclude(group = "com.android.support") }
androidTestCompile(extra["mockwebserver"])
View NullOnEmptyConverterFactory.java
import android.support.annotation.Nullable;
import okhttp3.ResponseBody;
import retrofit2.Converter;
import retrofit2.Retrofit;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
/**
* https://github.com/square/retrofit/issues/1554#issuecomment-178633697
@jaredsburrows
jaredsburrows / RetrofitError.java
Created Aug 18, 2017
RetrofitError from Retrofit 1
View RetrofitError.java
/*
* Copyright (C) 2012 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
You can’t perform that action at this time.