Skip to content

Instantly share code, notes, and snippets.

View NoNews's full-sized avatar

Alexey Bykov NoNews

View GitHub Profile
import argparse
import os
parser = argparse.ArgumentParser("")
parser.add_argument('--target-branch', required=True)
args = parser.parse_args()
command = "git diff {target_branch} --name-status".format(target_branch=args.target_branch)
diffs = os.popen(command).read()
for current_file in diffs.splitlines():
abstract class BaseViewModel : ViewModel() {
protected val defaultErrorHandler: (Throwable) -> Unit by lazy {
{ throwable: Throwable ->
Log.e(javaClass.simpleName, "DefaultErrorHandler", throwable)
Unit
}
}
private val defaultCompleteHandler: () -> Unit by lazy { {} }
Observable.just("Hey")
.subscribeOn(Schedulers.io())
.map(String::length)
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe { doAction() }
.flatMap {
doAction()
Observable.timer(1, TimeUnit.SECONDS)
.subscribeOn(Schedulers.single())
oldSize+(oldSize>>1) 
//4->8->12->18->27->...
...
index = ~index; //~-1 == 0
...
mHashes[index] = hash;
mArray[index<<1] = key; //Xor 0 == 0
mArray[(index<<1)+1] = value; //Xor 0 + 1 == 1
mSize++;
val user2 = User(id = 9986, name = "Diane Nguyen")
val key = Key(user2.name)
map[key] = user
int indexOf(Object key, int hash) {
...
//next available position for our element = 0
//to show, that we don't have this key, will execute ~0, which is equal -1
int index = binarySearchHashes(mHashes, N, hash);
if (index < 0) {
// hash code not found, "put" operation
return index;
val user3 = User(id = 2508, name = "Penny Carson") //hashCode will be 12
val key = Key(user3.name)
map[key] = user
public V put(K key, V value) {
...
index = ~index; //NOT -1 = 0
...
mHashes[index] = hash;
mArray[index<<1] = key; //XOR 1 == 0
mArray[(index<<1)+1] = value; //XOR 1 + 1 == 1
return null //previous value
}
int indexOf(Object key, int hash) {
final int N = mSize;
// Important fast case: if nothing is in here, nothing to look for.
if (N == 0) {
return ~0; // NOT 0 will return -1
}
...
}