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
<?xml version="1.0" encoding="utf-8"?> | |
<!DOCTYPE resources [ | |
<!ENTITY appname "WhereDat"> | |
<!ENTITY author "Oded"> | |
]> | |
<resources> | |
<string name="app_name">&appname;</string> | |
<string name="description">The &appname; app was created by &author;</string> | |
</resources> |
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
String path = "android.resource://" + context.getPackageName() + "/" + R.raw.raw_resource_id; | |
Uri rawUri = Uri.parse(path); |
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.regex.Matcher | |
import java.util.regex.Pattern | |
// ext makes method callable project wide | |
ext.getCurrentFlavor = { -> | |
Gradle gradle = getGradle() | |
String tskReqStr = gradle.getStartParameter().getTaskRequests().toString() | |
Pattern pattern; |
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
use -assumenosideeffects | |
https://www.guardsquare.com/en/proguard/manual/usage | |
http://qiita.com/gfx/items/e412dab7f127b7ae44d8 | |
https://github.com/gfx/ProguardRemovesObjectWait |
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 android.os.Build | |
import android.security.KeyPairGeneratorSpec | |
import android.security.keystore.KeyGenParameterSpec | |
import android.security.keystore.KeyProperties | |
import android.util.Base64 | |
import timber.log.Timber | |
import java.math.BigInteger | |
import java.security.GeneralSecurityException | |
import java.security.KeyPairGenerator | |
import java.security.KeyStore |
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 android.annotation.TargetApi | |
import android.os.Build | |
import android.security.keystore.KeyGenParameterSpec | |
import android.security.keystore.KeyProperties | |
import android.util.Base64 | |
import timber.log.Timber | |
import java.security.GeneralSecurityException | |
import java.security.KeyStore | |
import javax.crypto.Cipher | |
import javax.crypto.KeyGenerator |
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
class EvenOddPickGame(private val randomIntGen : RandomValueGenerator<Integer>) { | |
fun pick(times: Int): List<String> { | |
return ArrayList<String>().apply { | |
for (i in 0 until times) { | |
val rolled = randomIntGen.nextRandom(lowerBound = 1, upperBound = 2) % 2 | |
if (rolled == 0) { | |
add("EVEN") | |
} else { | |
add("ODD") | |
} |
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
/** | |
* This logic demonstrates how to draw all nCr combinations from given set. | |
* The time complexity of this logic is O(n²). | |
* Actual logic invocations are 1/2((n - 2)² + r(n - 2) + 2), where n > 2. | |
* | |
* Imagine selecting 3 different numbers from a set which has 4 different | |
* numbers. Assume that we've given a set as follows: | |
* | |
* let dataSet = {1, 2, 3, 4} | |
* |
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
interface EnumWithKey<T, K> { | |
val T.key: K | |
} | |
/* | |
* The reified type parameter lets you call the function without explicitly | |
* passing the Class-object. | |
*/ | |
inline fun <reified T : Enum<T>, R> EnumWithKey<T, R>.byKey(key: R): T? { | |
return enumValues<T>().find { it.key == key } |
OlderNewer