Skip to content

Instantly share code, notes, and snippets.

View arekolek's full-sized avatar

Arek Olek arekolek

  • FARA
View GitHub Profile
@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 / 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()
}
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 / 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 / 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:

{"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":"Ουκρανικά","
@arekolek
arekolek / .gitconfig
Created February 3, 2017 11:06
Helpful aliases for Git
[alias]
st = status
aliases = config --get-regexp ^alias\\.
precommit = diff --cached --minimal -w
amend = commit --amend
discard = checkout --
unstage = reset HEAD --
stashes = stash list
save = commit -m
graph = log --graph --branches --remotes --tags --format=format:'%Cgreen%h %Creset• %<(75,trunc)%s (%cN, %cr) %Cred%d' --date-order
// ==UserScript==
// @name No mousewheel-zoom
// @namespace http://github.com/arekolek
// @version 0.1
// @author Arek Olek
// @match http://*/*
// @match https://*/*
// @grant none
// ==/UserScript==
@arekolek
arekolek / adjacency.R
Last active April 29, 2016 11:30
Benchmark BGL functions on list and matrix graph representations
library(plyr)
file = paste(commandArgs(TRUE)[1], '.txt', sep='')
d = read.table(file, col.names=c('n', 'vertices', 'edges', 'edge', 'out_degree', 'adjacent_vertices', 'add_edge', 'remove_edge', 'source', 'target'))
d = ddply(d, ~n, colwise(mean))
d[,c(3:6,8)] = d[,c(3:6,8)]/1000