This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* PushTester | |
* | |
* Copyright 2014 Andrew Reitz | |
* | |
*/ | |
definition( | |
name: "PushTester", | |
namespace: "com.andrewreitz", | |
author: "Andrew Reitz", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.LinkedHashMap; | |
import java.util.Map; | |
import rx.Observer; | |
import rx.Subscription; | |
import rx.subjects.PublishSubject; | |
abstract class Repository<K, V> { | |
private final Cache<K, V> cache; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(" ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
char z = Character.class.getDeclaredMethods()[0].toString().charAt(6) | |
char x = javax.sql.RowSet.class.getName().charAt(5) | |
Object o = ClassLoader.getSystemClassLoader() | |
.loadClass( | |
javax.crypto.Cipher.class.getName().split(String.format("\\%s", x))[0].substring(0, 4) + | |
x + | |
java.lang.annotation.Annotation.class.getName().split(String.format("\\%s", x))[1] + | |
x + | |
Character.toUpperCase(java.sql.Connection.class.getName().split(String.format("\\%s", x))[1].charAt(0)) + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Adds extra tasks to improve android usage | |
project.android.applicationVariants.all { | |
it.buildType*.name.each { buildType -> | |
def adb = new File(project.android.sdkDirectory as File, '/platform-tools/adb') | |
def buildTypeString = buildType.capitalize() | |
task "run$buildTypeString"(type: Exec, dependsOn: "install$buildTypeString", group: 'run') { | |
description = "Builds and runs the $buildTypeString of the application." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Create a string representation of an object. This will include all fields that are not | |
* transient or static. The returned string will be in the form of `full_class_name{fieldName='value'}` | |
* This will also include all super types values as well in the string. | |
* | |
* @param object The object to get a string representation from. | |
* @return String representation of the object. | |
*/ | |
public static String toString(Object object) { | |
Class<?> aClass = object.getClass(); |