Skip to content

Instantly share code, notes, and snippets.

View lmller's full-sized avatar
🎲
This is the darkest timeline.

Lovis lmller

🎲
This is the darkest timeline.
View GitHub Profile
@lmller
lmller / 00-ktor-fruits-example
Last active November 23, 2018 08:42
ktor fruit example
Gists for a blog post on blog.codecentric.de
[
{
"name": "Homer",
"imgUrl": "http://www.bento.de/upload/images/imager/upload/aimages/821052/homer-simpson_eff89a5985a475378cd3170917df5aaf.jpg"
},
{
"name": "Bart",
"imgUrl":"https://vignette.wikia.nocookie.net/de.simpsons/images/6/65/Bart_Simpson.png"
},
{
[
{
"lastName": "Jonas",
"firstName": "Justus"
},
{
"lastName": "Shaw",
"firstName": "Peter"
},
{
@lmller
lmller / kotlinkapterror.md
Last active March 23, 2018 05:23
the usual “something with kotlin doesn’t work” check list:
  • Kotlin Plugin up to date?
  • Gradle Plugin up to date?
  • Kotlin version up to date?
  • only use kapt for annotation processing (don't mix Android Studio's annotationProcessor, apt and kapt, or any other processor)
  • use kapt3 by using apply plugin: 'kotlin-kapt'
  • don’t use kapt { generateStubs true } } at all, it will not work with kapt3
  • using databinding? then databinding compiler version needs to be the same as gradle plugin version ( kapt "com.android.databinding:compiler:$version")

Additionally, I stick to org.jetbrains.kotlin:kotlin-stdlib and don’t use the jre7 version

@lmller
lmller / method_references.kt
Created June 23, 2017 13:23 — forked from ditn/method_references.kt
Useful to explain the differences of the three approaches.
fun printString(string: String) = println(string)
/**
* Prints successfully
*/
Observable.just("Test string")
.doOnNext{ printString(it) }
.subscribe()
//me playing around for https://kotlinlang.slack.com/archives/C0922A726/p1494235351616257
fun main(args: Array<String>) {
UnBundler.unbundlers.add(object: UnBundler(canHandle = Test::class) {
override fun unbundle(b: Bundle): Any {
println("it works!")
return Test()
}
val Int.dp: Int
get() = resources.dpToPx(this)
fun Resources.dpToPx(dp: Int) = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp.toFloat(), displayMetrics).toInt()
@lmller
lmller / git remove merged branches
Last active March 14, 2017 09:08
Git things I use
//remove local branches, that are already megred on remote
git branch --merged | grep -v "\*" | grep -v master | xargs -n 1 git branch -d
@lmller
lmller / pipe
Created October 20, 2016 10:33
infix fun<T, R> T.pipe(rhs: (T) -> R) = rhs(this)
@lmller
lmller / SuggestionsCorrector for Samsung
Last active August 29, 2017 14:59
Samsung Devices ignore TYPE_TEXT_FLAG_NO_SUGGESTIONS, so TYPE_TEXT_VARIATION_VISIBLE_PASSWORD is the only thing that works for them.
public class SuggestionsCorrector {
public static final String SAMSUNG = "samsung";
public EditText correctSuggestions(EditText editText) {
if(Build.BRAND.equalsIgnoreCase(SAMSUNG)) {
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
}
return editText;