/**
* Operate on a stream of inputs in parallel returning the list of results.
*
* @see <a href="http://stackoverflow.com/a/35638609/1286667">Parallel operations on Kotlin collections?</a>
*/
fun <T, R> Iterable<T>.parallelMap(
numThreads: Int = Runtime.getRuntime().availableProcessors(),
exec: ExecutorService = Executors.newFixedThreadPool(numThreads),
transform: (T) -> R): List {
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
package timber.log | |
import com.toxicbakery.logging.Arbor | |
import com.toxicbakery.logging.Branch | |
class Tree(private val branch: Branch) { | |
fun d( | |
throwable: Throwable | |
) = branch.d(throwable) |
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 java.util.concurrent.atomic.AtomicInteger | |
class CircularArray<T> : Iterable<T>, Cloneable { | |
/** | |
* Creates a new instance of the array with the given size. | |
*/ | |
constructor(bufferSize: Int) { | |
this.arr = arrayOfNulls(bufferSize) | |
this.tail = -1 |
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
# Run ADB commands against all devices in parallel. Remove `&` from line 9 to run sequentially. | |
# http://stackoverflow.com/a/17882578/1286667 | |
adb devices | while read line | |
do | |
if [ ! "$line" = "" ] && [ `echo $line | awk '{print $2}'` = "device" ] | |
then | |
device=`echo $line | awk '{print $1}'` | |
echo "$device $@ ..." | |
adb -s $device $@ & | |
fi |
Octane
36277
Kraken
882.1ms +/- 0.8%
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
{"id":"9ef2a17d-bd70-328d-7ab4-ff404f411a27","name":"Pizzahut","timestamp":1433037789301,"requests":[{"collectionId":"9ef2a17d-bd70-328d-7ab4-ff404f411a27","id":"2b852493-f523-f119-b22e-66189f55d09c","name":"getHtmlOrder","description":"","url":"https://quikorder.pizzahut.com/phorders3/service.php","method":"POST","headers":"","data":[{"key":"accountID","value":"phimc2api","type":"text"},{"key":"accountPW","value":"fs112358","type":"text"},{"key":"version","value":"2.0","type":"text"},{"key":"appsource","value":"Android","type":"text"},{"key":"appversion","value":"2.1.2","type":"text"},{"key":"request","value":"HTMLOrder","type":"text"},{"key":"data","value":"{\"sessionToken\":\"zDmPoTjzLOd8E8YYLxsFy0MPwQE7LKo19FmFxyZDQFSRRzfRd1LE48xCCj5k3PwC\",\"unitID\":\"029704\",\"occasion\":\"C\",\"location_index\":-1,\"action\":\"start\"}","type":"text"}],"dataMode":"urlencoded","timestamp":0,"version":2,"time":1433811561494},{"collectionId":"9ef2a17d-bd70-328d-7ab4-ff404f411a27","id":"5fc79717-503b-c4eb-f50c-c954bd8231 |
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
// Comparison of data management | |
// Given a simple object | |
class MyObject { | |
String name; | |
int value; | |
} | |
// Create an instance with some values | |
MyObject myObjectInstance = new MyObject(); |