Skip to content

Instantly share code, notes, and snippets.

View arekolek's full-sized avatar

Arek Olek arekolek

  • FARA
View GitHub Profile
{"el":{"gu":"Gujarati","ga":"Ιρλανδικά","gn":"Γουαρανί (Υοπαρά)","gl":"Galician","la":"Latin","tt":"Tatar","tr":"Τουρκικά","lv":"Latvian","tl":"Ταγκάλογκ","th":"Ταϊλανδέζικα","te":"Τελούγκου","ta":"Ταμίλ","yi":"Γίντις","dk":"Ντοθράκι","de":"Γερμανικά","db":"Dutch (Belgium)","da":"Δανέζικα","uz":"Uzbek","el":"Ελληνικά","eo":"Εσπεράντο","en":"Αγγλικά","zc":"Chinese (Cantonese)","eu":"Basque","et":"Estonian","ep":"English (Pirate)","es":"Ισπανικά","zs":"Κινέζικα","ru":"Ρωσικά","ro":"Ρουμανικά","be":"Belarusian","bg":"Bulgarian","ms":"Malay","bn":"Μπενγκάλι","ja":"Ιαπωνικά","or":"Oriya","xl":"Lolcat","ca":"Καταλανικά","xe":"Emoji","xz":"Zombie","cy":"Ουαλικά","cs":"Τσέχικα","pt":"Πορτογαλικά","lt":"Lithuanian","pa":"Παντζαπικά (Γκουρμούκι)","pl":"Πολωνικά","hy":"Armenian","hr":"Croatian","hv":"Υψηλά Βαλυριανά","ht":"Κρεόλ Αϊτής","hu":"Ουγγρικά","hi":"Ινδικά","he":"Εβραϊκά","mb":"Malay (Brunei)","mm":"Malay (Malaysia)","ml":"Malayalam","mn":"Mongolian","mk":"Macedonian","ur":"Urdu","kk":"Kazakh","uk":"Ουκρανικά","
package com.example
import android.arch.lifecycle.ViewModel
import android.arch.lifecycle.ViewModelProvider
import javax.inject.Inject
import javax.inject.Provider
/**
* Lets us use [Inject] annotations on [ViewModel] classes.
@arekolek
arekolek / LiveData.kt
Last active July 15, 2018 14:08
LiveData extension property for use in unit tests
val <T> LiveData<T>.blockingValue: T?
get() {
var value: T? = null
val latch = CountDownLatch(1)
observeForever {
value = it
latch.countDown()
}
if (latch.await(2, TimeUnit.SECONDS)) return value
else throw Exception("LiveData value was not set within 2 seconds")
@arekolek
arekolek / KotlinFunctions.md
Last active February 22, 2019 05:20 — forked from cbeyls/KotlinFunctions.md
Comparison of Kotlin functions: also, apply, let, run, with

Receiver vs. return value:

Returns block result Returns receiver
Receiver available as it let also
Receiver available as this run apply

How to read the table:

@arekolek
arekolek / HasContext.kt
Created April 16, 2020 18:11
Convert dp to px
interface HasContext {
fun getContext(): Context
val Int.dp
get() = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, this.toFloat(), getContext().resources.displayMetrics).toInt()
}
@arekolek
arekolek / decompile.sh
Last active June 27, 2020 14:28
Decompile APK
#!/usr/local/bin/zsh
if [[ -z $1 ]]; then
echo "usage: ./decompile.sh path_to_apk"
exit 0
elif ! [[ -f $1 ]]; then
echo "$1: No such file or directory"
exit 1
fi
@arekolek
arekolek / LiveDataReactiveStreamsActivity.kt
Last active August 27, 2020 04:09
Using LiveDataReactiveStreams to handle lifecycle and threading while computing list diff for recycler view
package com.github.arekolek.diffutil
import android.arch.lifecycle.*
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.util.DiffUtil
import android.support.v7.widget.RecyclerView
import android.util.Log
import android.view.LayoutInflater
import android.view.View
@arekolek
arekolek / Duolingo_Trim_tree.user.js
Last active August 19, 2021 11:23
Duolingo Trim tree (see https://www.duolingo.com/comment/12962386 for discussion)
// ==UserScript==
// @name Duolingo Trim tree
// @namespace 9a84a9d7b3fef7de9d2fd7155dcd794c
// @description Hides all golden skills with a button.
// @author Arek Olek
// @match https://www.duolingo.com/*
// @icon http://arkadiuszolek.student.tcs.uj.edu.pl/greasemonkey/duolingo.png
// @grant GM_getValue
// @grant GM_setValue
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js