This file contains hidden or 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
/** | |
* If [assumed] is non-null, converts it to a non-null type and executes [block] on the non-null | |
* type as an extension function (like with() in the Standard kotlin library) | |
* | |
* Similar to Swift's "if let = ..." construct. | |
*/ | |
fun <T> if_let(assumed : T?, block : T.() -> Unit) { | |
if (assumed == null) | |
return |
This file contains hidden or 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 getGitCommit() { | |
return 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim() | |
} | |
def getGitTag() { | |
def p = Runtime.getRuntime().exec("git describe HEAD --abbrev=0") | |
if (p.waitFor() != 0) { | |
return "none" // no tag | |
} |
This file contains hidden or 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 Rx = require('rx') | |
var MAX_RETRIES = 4 | |
Rx.Observable.throw(new Error("always fails")) | |
.retryWhen(function (errors) { | |
return Rx.Observable.zip( | |
Rx.Observable.range(1, MAX_RETRIES), errors, function (i, e) { return i }) | |
.flatMap(function (i) { | |
console.log("delay retry by " + i + " second(s)"); | |
return Rx.Observable.timer(i * 1000); |
This file contains hidden or 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
public class ThemeUtils { | |
public static int getResourceIdForAttribute(@AttrRes int attrId, Activity activity) { | |
TypedValue outValue = new TypedValue(); | |
activity.getTheme().resolveAttribute(attrId, outValue, true); | |
return outValue.resourceId; | |
} | |
} |
NewerOlder