Skip to content

Instantly share code, notes, and snippets.

View Jswizzy's full-sized avatar

Justin Smith Jswizzy

View GitHub Profile
@rishabhkohli
rishabhkohli / !!ViewLifecycleAware.kt
Last active December 29, 2021 17:41 — forked from jamiesanson/ViewLifecycleLazy.kt
A Kotlin delegated property implementation which automatically clears itself at appropriate times in the View Lifecycle of a Fragment.
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
@andy-thomason
andy-thomason / Genomics_A_Programmers_Guide.md
Created May 14, 2019 13:32
Genomics a programmers introduction

Genomics - A programmer's guide.

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.

https://www.genomicsplc.com

@paolop
paolop / LogExtensions.kt
Last active November 20, 2023 09:55
Android logging utilities.
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) =
@bastman
bastman / loadResource.kt
Created January 31, 2018 12:57
Kotlin function to load content of a packaged resource
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)
}
@hector6872
hector6872 / Base64.kt
Last active May 31, 2021 12:41
Base64.kt for Kotlin
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()
@Audhil
Audhil / AppExtensionFuncs.kt
Last active January 27, 2024 09:48
XML generation with Kotlin extension functions
// 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()
@dscape
dscape / The-Innovators-Dilemma-Summary.md
Created February 22, 2011 21:02
Notes on The Innovator’s Dilemma: When New Technologies Cause Great Firms to Fail

Notes on The Innovator’s Dilemma: When New Technologies Cause Great Firms to Fail

  • 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)

Summary

  1. Market progress is separate from technology progress. Customers do not always know what they need.
  2. Innovation requires resource allocation which is extraordinarily difficult for disruptive technologies.
  3. Disruptive technology needs a new market. Old customers are less relevant. Disruptive technology is a marketing problem, not a technological one.