Skip to content

Instantly share code, notes, and snippets.

View ToxicBakery's full-sized avatar
🙄
No one uses this..

Ian Thomas ToxicBakery

🙄
No one uses this..
  • Las Vegas, NV
View GitHub Profile
@ToxicBakery
ToxicBakery / logging.kt
Created February 7, 2019 14:17
A drop in kotlin file allowing for simple migration from JVM Timber to JVM Arbor. This adds the otherwise missing formatted arguments
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)
@ToxicBakery
ToxicBakery / CircularArray.kt
Last active February 27, 2024 00:46
Simple circular/ring buffer style implementation backed by an array for kotlin with test coverage
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
@ToxicBakery
ToxicBakery / parallel-map-extension-function.md
Last active February 21, 2017 06:22
Kotlin parallel map extension function.
/**
 * 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) -&gt; R): List {
# 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%
{"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
@ToxicBakery
ToxicBakery / gist:3a9025b75aeaa2f1b10f
Last active August 29, 2015 14:02
Couchbase (Java) vs Couchbase Mobile (Android)
// Comparison of data management
// Given a simple object
class MyObject {
String name;
int value;
}
// Create an instance with some values
MyObject myObjectInstance = new MyObject();