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 Wtf | |
// Primitives | |
operator fun Int.plus(that: String) = "$this$that" | |
operator fun String.plus(that: Int) = "$this$that" | |
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 be.brol | |
import android.os.Binder | |
import android.os.Bundle | |
import android.support.v4.app.BundleCompat | |
import android.support.v4.app.Fragment | |
/** | |
* Eases the Fragment.newInstance ceremony by marking the fragment's args with this delegate | |
* Just write the property in newInstance and read it like any other property after the fragment has been created |
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
fun idSequence(seed:Int=0) : Sequence<Int>{ | |
return generateSequence(seed,{it + 1}) | |
} | |
class TreeNode<T>(val id: T){ | |
val childNodes = mutableListOf<TreeNode<T>>() | |
fun addChild(node: TreeNode<T>) = childNodes.add(node) | |
fun removeChild(node: TreeNode<T>) = childNodes.remove(node) | |
fun children() = childNodes.asIterable() |
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
/** | |
* An [Observer] for [Event]s, simplifying the pattern of checking if the [Event]'s content has | |
* already been handled. | |
* | |
* [onEventUnhandledContent] is *only* called if the [Event]'s contents has not been handled. | |
*/ | |
class EventObserver<T>(private val onEventUnhandledContent: (T) -> Unit) : Observer<Event<T>> { | |
override fun onChanged(event: Event<T>?) { | |
event?.getContentIfNotHandled()?.let { value -> | |
onEventUnhandledContent(value) |
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 com.alibaba.fastjson.JSON; | |
import com.google.common.collect.Maps; | |
import javax.crypto.Cipher; | |
import javax.crypto.KeyGenerator; | |
import javax.crypto.SecretKey; | |
import javax.crypto.spec.SecretKeySpec; | |
import java.nio.charset.StandardCharsets; | |
import java.util.Base64; |
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
fun RepositoryHandler.enableMirror() { | |
all { | |
if (this is MavenArtifactRepository) { | |
val originalUrl = this.url.toString().removeSuffix("/") | |
urlMappings[originalUrl]?.let { | |
logger.lifecycle("Repository[$url] is mirrored to $it") | |
this.setUrl(it) | |
} | |
} | |
} |