This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { {} } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
oldSize+(oldSize>>1) | |
//4->8->12->18->27->... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
index = ~index; //~-1 == 0 | |
... | |
mHashes[index] = hash; | |
mArray[index<<1] = key; //Xor 0 == 0 | |
mArray[(index<<1)+1] = value; //Xor 0 + 1 == 1 | |
mSize++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val user2 = User(id = 9986, name = "Diane Nguyen") | |
val key = Key(user2.name) | |
map[key] = user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val user3 = User(id = 2508, name = "Penny Carson") //hashCode will be 12 | |
val key = Key(user3.name) | |
map[key] = user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
... | |
} |
NewerOlder