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
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 } |
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 UserRepository : JpaRepository<User, Long>, UserRepositoryExtension | |
interface UserRepositoryExtension { | |
/* | |
* Here we get exception as following: | |
* | |
* Caused by: java.lang.IllegalArgumentException: Failed to create query for method | |
* public abstract User UserRepositoryExtension.getByRoleCriteria(java.lang.String,java.util.Set)! | |
* At least 2 parameter(s) provided but only 1 parameter(s) present in query. | |
* |
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 Animal { } | |
class Reptile extends Animal { } | |
class Bird extends Animal { } | |
interface MobileLife { | |
// Every classes derived from this interface should implement common features on it. | |
void move(double displacement); | |
double getDistance(); |
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 Animal { } | |
class Reptile extends Animal { } | |
class Bird extends Animal { } | |
mixin MobileLife { | |
// We don't need to implement _move on every classes using this mixin, since mixin can include state. | |
var _distance = 0.0; | |
void _move(double displacement) { |
OlderNewer