Skip to content

Instantly share code, notes, and snippets.

Arek Olek arekolek

Block or report user

Report or block arekolek

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ViewModelFactory.kt
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 Jul 15, 2018
LiveData extension property for use in unit tests
View LiveData.kt
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 Sep 26, 2019
Using LiveDataReactiveStreams to handle lifecycle and threading while computing list diff for recycler view
View LiveDataReactiveStreamsActivity.kt
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 Feb 22, 2019 — forked from cbeyls/KotlinFunctions.md
Comparison of Kotlin functions: also, apply, let, run, with
View KotlinFunctions.md

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:

View duolingo-language-strings.json
{"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 Feb 3, 2017
Helpful aliases for Git
View .gitconfig
[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
View No_mousewheel_zoom.user.js
// ==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 Apr 29, 2016
Benchmark BGL functions on list and matrix graph representations
View adjacency.R
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
View Duolingo_Trim_tree.user.js
// ==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
@arekolek
arekolek / Duolingo_weak_words_counter.user.js
Created Apr 14, 2015
Control the number of weak words in your vocabulary on Duolingo by displaying a counter at the top of the page.
View Duolingo_weak_words_counter.user.js
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// Version 2, December 2004
//
//Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
//
//Everyone is permitted to copy and distribute verbatim or modified
//copies of this license document, and changing it is allowed as long
//as the name is changed.
//
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
You can’t perform that action at this time.