Andy Thomason is a Senior Programmer at Genomics PLC. He has been witing graphics systems, games and compilers since the '70s and specialises in code performance.
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
import androidx.fragment.app.Fragment | |
import androidx.lifecycle.DefaultLifecycleObserver | |
import androidx.lifecycle.LifecycleOwner | |
import kotlin.properties.ReadOnlyProperty | |
import kotlin.reflect.KProperty | |
fun <T> Fragment.viewLifecycleAware(initialise: () -> T): ReadOnlyProperty<Fragment, T> = | |
object : ReadOnlyProperty<Fragment, T>, DefaultLifecycleObserver { | |
private var value: T? = null |
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
import android.util.Log | |
import com.paolo | |
import kotlin.reflect.KClass | |
/* Convenient wrappers over Android Log.* static methods */ | |
/** Wrapper over [Log.i] */ | |
inline fun <reified T> T.logi(message: String, onlyInDebugMode: Boolean = true, enclosingClass: KClass<*>? = null) = |
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
fun loadResource(resource: String): String = | |
try { | |
object {}.javaClass.getResource(resource) | |
.readText(Charsets.UTF_8) | |
} catch (all: Exception) { | |
throw RuntimeException("Failed to load resource=$resource!", all) | |
} |
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
fun String.encodeBase64ToString(): String = String(this.toByteArray().encodeBase64()) | |
fun String.encodeBase64ToByteArray(): ByteArray = this.toByteArray().encodeBase64() | |
fun ByteArray.encodeBase64ToString(): String = String(this.encodeBase64()) | |
fun String.decodeBase64(): String = String(this.toByteArray().decodeBase64()) | |
fun String.decodeBase64ToByteArray(): ByteArray = this.toByteArray().decodeBase64() | |
fun ByteArray.decodeBase64ToString(): String = String(this.decodeBase64()) | |
fun ByteArray.encodeBase64(): ByteArray { | |
val table = (CharRange('A', 'Z') + CharRange('a', 'z') + CharRange('0', '9') + '+' + '/').toCharArray() |
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
// XML generation by code | |
// based on https://www.schibsted.pl/blog/back-end/readable-xml-kotlin-extensions/ | |
fun XmlSerializer.document(docName: String = "UTF-8", | |
xmlStringWriter: StringWriter = StringWriter(), | |
init: XmlSerializer.() -> Unit): String { | |
startDocument(docName, true) | |
xmlStringWriter.buffer.setLength(0) // refreshing string writer due to reuse | |
setOutput(xmlStringWriter) | |
init() | |
endDocument() |
# referecing: # https://www.digitalocean.com/community/tutorials/how-to-install-apache-kafka-on-ubuntu-14-04 # https://chongyaorobin.wordpress.com/2015/07/08/step-by-step-of-install-apache-kafka-on-ubuntu-standalone-mode/
- Add 'kafka' user:
$ sudo useradd kafka -m
- Install Java:
- Book by: Clayton M. Christensen, Cambridge, Massachusetts: Harvard Business School Press, 1997
- Prepared by: B.B. McBreen. See [PDF][1] (more readable but it's not plain text)
- Market progress is separate from technology progress. Customers do not always know what they need.
- Innovation requires resource allocation which is extraordinarily difficult for disruptive technologies.
- Disruptive technology needs a new market. Old customers are less relevant. Disruptive technology is a marketing problem, not a technological one.