Skip to content

Instantly share code, notes, and snippets.

View AndrewReitz's full-sized avatar

Andrew Reitz AndrewReitz

View GitHub Profile
@AndrewReitz
AndrewReitz / keybase.md
Created March 18, 2014 01:12
Keybase verification

Keybase proof

I hereby claim:

  • I am pieces029 on github.
  • I am areitz (https://keybase.io/areitz) on keybase.
  • I have a public key whose fingerprint is 6513 2A0E 64C9 3BC1 EDB4 BA62 0221 9C76 97C0 FB6E

To claim this, I am signing this object:

@AndrewReitz
AndrewReitz / CrashlyticsTree.java
Created June 21, 2014 12:51
Crashlytics Tree
public final class CrashlyticsTree extends HollowTree {
private static final Pattern ANONYMOUS_CLASS = Pattern.compile("\\$\\d+$");
private enum LogLevel {
INFO,
ERROR,
WARNING
}
@Override public void i(String message, Object... args) {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked"
}
}
@AndrewReitz
AndrewReitz / gist:01a3e098b95ecb83fda0
Created July 17, 2014 16:10
Linux Upfind + Gradlew
# Find something in a directory above the one you are in
function upfind() {
dir=`pwd`
while [ "$dir" != "/" ]; do
path=`find "$dir" -maxdepth 1 -name $1`
if [ ! -z $path ]; then
echo "$path"
return
fi
dir=`dirname "$dir"`
@AndrewReitz
AndrewReitz / PushTester.groovy
Last active August 29, 2015 14:04
SmartThings Test Pusher
/**
* PushTester
*
* Copyright 2014 Andrew Reitz
*
*/
definition(
name: "PushTester",
namespace: "com.andrewreitz",
author: "Andrew Reitz",
@AndrewReitz
AndrewReitz / randomdots.scala
Last active August 29, 2015 14:06
Random Dots
def randDots:String = {
val nLines = 100
val width = 80
Seq.range(0, nLines*width).map(a=>if(scala.util.Random.nextBoolean())"." else " ").grouped(width).map(_.mkString("")).mkString("\n")
}
while(true){
println(randDots)
Thread.sleep(scala.util.Random.nextInt(5000))
}
@AndrewReitz
AndrewReitz / RxCursor
Created November 22, 2014 14:58
Anbdroid RxCursorLoader
Observable.create(new Observable.OnSubscribe<T>() {
@Override public void call(Subscriber<? super T> subscriber) {
final Cursor cursor = cursorLoader.getCursor();
if (cursor.moveToFirst()) {
while (!cursor.isAfterLast()) {
if (!subscriber.isUnsubscribed()) {
subscriber.onNext(cursor));
cursor.moveToNext();
}
}
@AndrewReitz
AndrewReitz / ಠ__ಠ.java
Last active August 29, 2015 14:10
@ಠ__ಠ
package lol;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;
@AndrewReitz
AndrewReitz / check.gradle
Created February 9, 2015 03:19
Android Checkstyles
// Checkstyle
apply plugin: 'checkstyle'
checkstyle {
showViolations true
configFile = rootProject.file('codequality/checkstyle.xml')
}
def isLibraryPlugin = project.plugins.findPlugin('android-library') != null
def setupCheck = { variant ->
def name = variant.buildType.name
@AndrewReitz
AndrewReitz / consolewarmer.scala
Created February 12, 2015 17:25
Console Warmer
var n = 60
var n2 = 20
while (true) {
n = n + (if (scala.util.Random.nextBoolean()) 1 else -1)
n = n max 0 min 80
n2 = n2 + (if (scala.util.Random.nextBoolean()) 1 else -1)
n2 = n2 max 0 min 80
for (i <- 0 until (n min n2)) print(" ")
if (n2 < n) print("░") else print("█")
for (i <- 0 until (n max n2) - (n min n2)) print(" ")